provided interface now sets its own unique id.
[utils] / trunk / system / general / src / main / java / org / wamblee / system / core / DefaultScope.java
index 5a09f942cb3c591779fb3bb18e10e61b2e2794c7..18f26cc8d0a1e8ddaa75a3b88affd2c81422bf5b 100644 (file)
@@ -21,11 +21,11 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
+import java.util.UUID;
 
 public class DefaultScope implements Scope {
 
        private List<Scope> _parents;
-       private int _count;
        private Map<String, Object> _properties;
        private Map<String, Object> _runtimes;
        private Map<String, ProvidedInterfaceImplementation> _provided;
@@ -42,7 +42,6 @@ public class DefaultScope implements Scope {
        public DefaultScope(ProvidedInterface[] aExternallyProvided,
                        List<Scope> aParent) {
                _parents = new ArrayList<Scope>(aParent);
-               _count = 0;
                _properties = new HashMap<String, Object>();
                _runtimes = new HashMap<String, Object>();
                _provided = new HashMap<String, ProvidedInterfaceImplementation>();
@@ -82,10 +81,8 @@ public class DefaultScope implements Scope {
        @Override
        synchronized public void publishInterface(ProvidedInterface aInterface,
                        Object aImplementation) {
-               String id = "" + _count++;
-               _provided.put(id, new ProvidedInterfaceImplementation(aInterface,
+               _provided.put(aInterface.getUniqueId(), new ProvidedInterfaceImplementation(aInterface,
                                aImplementation));
-               aInterface.setUniqueId(id);
        }
 
        @Override