HibernateUserAdministrationTest now based on the component mechanism.
[utils] / system / general / src / main / java / org / wamblee / system / core / DefaultScope.java
index b57f51f64f01a04d743f626fc6e90fd00fae4c39..51949ca1570df5dd755a905edb1a4e5049a92a71 100644 (file)
@@ -17,14 +17,15 @@ package org.wamblee.system.core;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+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;
@@ -41,10 +42,9 @@ public class DefaultScope implements Scope {
        public DefaultScope(ProvidedInterface[] aExternallyProvided,
                        List<Scope> aParent) {
                _parents = new ArrayList<Scope>(aParent);
-               _count = 0;
-               _properties = new TreeMap<String, Object>();
-               _runtimes = new TreeMap<String, Object>();
-               _provided = new TreeMap<String, ProvidedInterfaceImplementation>();
+               _properties = new HashMap<String, Object>();
+               _runtimes = new HashMap<String, Object>();
+               _provided = new HashMap<String, ProvidedInterfaceImplementation>();
                _externallyProvided = aExternallyProvided;
        }
 
@@ -65,18 +65,23 @@ public class DefaultScope implements Scope {
 
        @Override
        public void addRuntime(Component aComponent, Object aRuntime) {
-               _runtimes.put(aComponent.getQualifiedName(), aRuntime);
+               _runtimes.put(aComponent.getName(), aRuntime);
        }
 
        @Override
        public Object getRuntime(Component aComponent) {
-               return _runtimes.get(aComponent.getQualifiedName());
+               return _runtimes.get(aComponent.getName());
+       }
+       
+       @Override
+       public Object getRuntime(String aName) {
+           return _runtimes.get(aName);
        }
 
        @Override
        synchronized public void publishInterface(ProvidedInterface aInterface,
                        Object aImplementation) {
-               String id = "" + _count++;
+               String id = UUID.randomUUID().toString();
                _provided.put(id, new ProvidedInterfaceImplementation(aInterface,
                                aImplementation));
                aInterface.setUniqueId(id);