removed the unique id from the provided interface. Now using object
[utils] / system / general / src / main / java / org / wamblee / system / core / DefaultScope.java
index 18f26cc8d0a1e8ddaa75a3b88affd2c81422bf5b..7290a790365eda04712f5ffe5ecd74cc692a2fb4 100644 (file)
@@ -28,7 +28,7 @@ public class DefaultScope implements Scope {
        private List<Scope> _parents;
        private Map<String, Object> _properties;
        private Map<String, Object> _runtimes;
-       private Map<String, ProvidedInterfaceImplementation> _provided;
+       private Map<ProvidedInterface, ProvidedInterfaceImplementation> _provided;
        private ProvidedInterface[] _externallyProvided;
 
        public DefaultScope(ProvidedInterface[] aExternallyProvided) {
@@ -44,7 +44,7 @@ public class DefaultScope implements Scope {
                _parents = new ArrayList<Scope>(aParent);
                _properties = new HashMap<String, Object>();
                _runtimes = new HashMap<String, Object>();
-               _provided = new HashMap<String, ProvidedInterfaceImplementation>();
+               _provided = new HashMap<ProvidedInterface, ProvidedInterfaceImplementation>();
                _externallyProvided = aExternallyProvided;
        }
 
@@ -81,7 +81,7 @@ public class DefaultScope implements Scope {
        @Override
        synchronized public void publishInterface(ProvidedInterface aInterface,
                        Object aImplementation) {
-               _provided.put(aInterface.getUniqueId(), new ProvidedInterfaceImplementation(aInterface,
+               _provided.put(aInterface, new ProvidedInterfaceImplementation(aInterface,
                                aImplementation));
        }
 
@@ -90,13 +90,8 @@ public class DefaultScope implements Scope {
                        Class<T> aType) {
                if ( aInterface == null ) { 
                        return null; 
-               }
-               String id = aInterface.getUniqueId(); 
-               if ( id == null ) { 
-                       // optional interface that was not published.
-                       return null;
-               }
-               ProvidedInterfaceImplementation provided = _provided.get(id);
+               } 
+               ProvidedInterfaceImplementation provided = _provided.get(aInterface);
                if (provided == null) {
                        for (Scope parent : _parents) {
                                T impl = parent.getInterfaceImplementation(aInterface, aType);