X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=system%2Fgeneral%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fsystem%2Fcore%2FDefaultScope.java;h=50c6cc3b2ad6ebd682b0f57336963e019b34c1be;hb=e1975449f1bf16ccb441632d68e440f3e3704a79;hp=18f26cc8d0a1e8ddaa75a3b88affd2c81422bf5b;hpb=8c773ebc6af18d4c0c0c973551f582856644f4d3;p=utils diff --git a/system/general/src/main/java/org/wamblee/system/core/DefaultScope.java b/system/general/src/main/java/org/wamblee/system/core/DefaultScope.java index 18f26cc8..50c6cc3b 100644 --- a/system/general/src/main/java/org/wamblee/system/core/DefaultScope.java +++ b/system/general/src/main/java/org/wamblee/system/core/DefaultScope.java @@ -17,19 +17,22 @@ package org.wamblee.system.core; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; 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 _parents; private Map _properties; private Map _runtimes; - private Map _provided; - private ProvidedInterface[] _externallyProvided; + private Map _provided; + private List _externallyProvided; + + public DefaultScope(ListaExternallyProvided) { + this(aExternallyProvided.toArray(new ProvidedInterface[0])); + } public DefaultScope(ProvidedInterface[] aExternallyProvided) { this(aExternallyProvided, new ArrayList()); @@ -44,13 +47,14 @@ public class DefaultScope implements Scope { _parents = new ArrayList(aParent); _properties = new HashMap(); _runtimes = new HashMap(); - _provided = new HashMap(); - _externallyProvided = aExternallyProvided; + _provided = new HashMap(); + _externallyProvided = new ArrayList(); + _externallyProvided.addAll(Arrays.asList(aExternallyProvided)); } @Override - public ProvidedInterface[] getProvidedInterfaces() { - return _externallyProvided; + public List getProvidedInterfaces() { + return Collections.unmodifiableList(_externallyProvided); } @Override @@ -81,7 +85,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 +94,8 @@ public class DefaultScope implements Scope { Class 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);