rename subsystem to component.
authorerik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Mon, 31 Mar 2008 16:53:44 +0000 (16:53 +0000)
committererik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Mon, 31 Mar 2008 16:53:44 +0000 (16:53 +0000)
24 files changed:
trunk/system/general/src/main/java/org/wamblee/system/AbstractComponent.java [moved from trunk/system/general/src/main/java/org/wamblee/system/AbstractSubSystem.java with 72% similarity]
trunk/system/general/src/main/java/org/wamblee/system/AbstractInterfaceDescriptor.java [moved from trunk/system/general/src/main/java/org/wamblee/system/AbstractServiceDescriptor.java with 79% similarity]
trunk/system/general/src/main/java/org/wamblee/system/Component.java [moved from trunk/system/general/src/main/java/org/wamblee/system/SubSystem.java with 79% similarity]
trunk/system/general/src/main/java/org/wamblee/system/CompositeSystem.java
trunk/system/general/src/main/java/org/wamblee/system/DefaultProvidedInterfaceDescriptor.java [new file with mode: 0644]
trunk/system/general/src/main/java/org/wamblee/system/DefaultProvidedServiceDescriptor.java [deleted file]
trunk/system/general/src/main/java/org/wamblee/system/DefaultRequiredInterfaceDescriptor.java [moved from trunk/system/general/src/main/java/org/wamblee/system/DefaultRequiredServiceDescriptor.java with 69% similarity]
trunk/system/general/src/main/java/org/wamblee/system/DefaultService.java
trunk/system/general/src/main/java/org/wamblee/system/DefaultServiceRegistry.java
trunk/system/general/src/main/java/org/wamblee/system/InterfaceDescriptor.java [moved from trunk/system/general/src/main/java/org/wamblee/system/ServiceDescriptor.java with 94% similarity]
trunk/system/general/src/main/java/org/wamblee/system/ProvidedInterfaceDescriptor.java [new file with mode: 0644]
trunk/system/general/src/main/java/org/wamblee/system/ProvidedServiceDescriptor.java [deleted file]
trunk/system/general/src/main/java/org/wamblee/system/RequiredInterfaceDescriptor.java [new file with mode: 0644]
trunk/system/general/src/main/java/org/wamblee/system/RequiredServiceDescriptor.java [deleted file]
trunk/system/general/src/main/java/org/wamblee/system/Service.java
trunk/system/general/src/main/java/org/wamblee/system/ServiceRegistry.java
trunk/system/general/src/main/java/org/wamblee/system/SystemAssembler.java
trunk/system/general/src/test/java/org/wamblee/system/Application.java
trunk/system/general/src/test/java/org/wamblee/system/DefaultInterfaceDescriptorTest.java [new file with mode: 0644]
trunk/system/general/src/test/java/org/wamblee/system/DefaultServiceDescriptorTest.java [deleted file]
trunk/system/general/src/test/java/org/wamblee/system/Environment.java
trunk/system/general/src/test/java/org/wamblee/system/SystemAssemblerTest.java
trunk/system/spring/src/main/java/org/wamblee/system/spring/SpringSystem.java
trunk/system/spring/src/test/java/org/wamblee/system/spring/SpringSystemTest.java

similarity index 72%
rename from trunk/system/general/src/main/java/org/wamblee/system/AbstractSubSystem.java
rename to trunk/system/general/src/main/java/org/wamblee/system/AbstractComponent.java
index 6e9cebbd0966fa5b1814c735d67e0cca36a49334..5c96b5491f650288dce681a15337b389f71490d8 100644 (file)
@@ -13,15 +13,15 @@ import org.apache.commons.logging.LogFactory;
 /**
  * Abstract subsystem class making it easy to implement new subsystems.
  */
-public abstract class AbstractSubSystem implements SubSystem {
+public abstract class AbstractComponent implements Component {
 
-       private static final Log LOG = LogFactory.getLog(AbstractSubSystem.class);
+       private static final Log LOG = LogFactory.getLog(AbstractComponent.class);
 
        private String _name;
        private ServiceRegistry _registry; 
-       private List<ServiceDescriptor> _provided;
-       private List<ServiceDescriptor> _required;
-       private Map<ServiceDescriptor, Service> _running;
+       private List<InterfaceDescriptor> _provided;
+       private List<InterfaceDescriptor> _required;
+       private Map<InterfaceDescriptor, Service> _running;
        
        /**
         * Constructs the subsystem.
@@ -35,15 +35,15 @@ public abstract class AbstractSubSystem implements SubSystem {
         * @param aRequired
         *            Required services.
         */
-       protected AbstractSubSystem(String aName, ServiceRegistry aRegistry, ServiceDescriptor[] aProvided,
-                       ServiceDescriptor[] aRequired) {
+       protected AbstractComponent(String aName, ServiceRegistry aRegistry, InterfaceDescriptor[] aProvided,
+                       InterfaceDescriptor[] aRequired) {
                _name = aName;
                _registry = aRegistry; 
-               _provided = new ArrayList<ServiceDescriptor>();
+               _provided = new ArrayList<InterfaceDescriptor>();
                _provided.addAll(Arrays.asList(aProvided));
-               _required = new ArrayList<ServiceDescriptor>();
+               _required = new ArrayList<InterfaceDescriptor>();
                _required.addAll(Arrays.asList(aRequired));
-               _running = new HashMap<ServiceDescriptor, Service>();
+               _running = new HashMap<InterfaceDescriptor, Service>();
        }
 
        @Override
@@ -56,13 +56,13 @@ public abstract class AbstractSubSystem implements SubSystem {
        }
 
        @Override
-       public final ProvidedServiceDescriptor[] getProvidedServices() {
-               return _provided.toArray(new ProvidedServiceDescriptor[0]);
+       public final ProvidedInterfaceDescriptor[] getProvidedServices() {
+               return _provided.toArray(new ProvidedInterfaceDescriptor[0]);
        }
 
        @Override
-       public final RequiredServiceDescriptor[] getRequiredServices() {
-               return _required.toArray(new RequiredServiceDescriptor[0]);
+       public final RequiredInterfaceDescriptor[] getRequiredServices() {
+               return _required.toArray(new RequiredInterfaceDescriptor[0]);
        }
 
        @Override
@@ -93,7 +93,7 @@ public abstract class AbstractSubSystem implements SubSystem {
         *            Service.
         */
        protected final void addService(String aContext,
-                       ProvidedServiceDescriptor aDescriptor, Object aService) {
+                       ProvidedInterfaceDescriptor aDescriptor, Object aService) {
                LOG.info(aContext + ": service '" + aService + "' started.");
                Service svc = getRegistry().register(aDescriptor, aService);
                _running.put(svc.getDescriptor(), svc);
similarity index 79%
rename from trunk/system/general/src/main/java/org/wamblee/system/AbstractServiceDescriptor.java
rename to trunk/system/general/src/main/java/org/wamblee/system/AbstractInterfaceDescriptor.java
index f31e49760d399e97f559796d3fe66c5b05d8ebe0..361cd2ece5e788e63b6c82cfaa0636a024f117b1 100644 (file)
@@ -7,7 +7,7 @@ import java.util.Arrays;
  *
  * @author Erik Brakkee
  */
-public abstract class AbstractServiceDescriptor implements ServiceDescriptor {
+public abstract class AbstractInterfaceDescriptor implements InterfaceDescriptor {
        
        private String _name; 
        private Class[] _interfaces; 
@@ -16,12 +16,12 @@ public abstract class AbstractServiceDescriptor implements ServiceDescriptor {
         * Constructs the descriptor. 
         * @param aInterface Type of service. 
         */
-       public AbstractServiceDescriptor(String aName, Class aInterface) {
+       public AbstractInterfaceDescriptor(String aName, Class aInterface) {
                _name = aName; 
                _interfaces = new Class[] { aInterface };  
        }
        
-       public AbstractServiceDescriptor(String aName, Class[] aInterfaces) {
+       public AbstractInterfaceDescriptor(String aName, Class[] aInterfaces) {
                _name = aName; 
                _interfaces = Arrays.copyOf(aInterfaces, aInterfaces.length);  
        }
@@ -38,10 +38,10 @@ public abstract class AbstractServiceDescriptor implements ServiceDescriptor {
        
        @Override
        public boolean equals(Object obj) {
-               if ( !(obj instanceof AbstractServiceDescriptor)) { 
+               if ( !(obj instanceof AbstractInterfaceDescriptor)) { 
                        return false; 
                }
-               AbstractServiceDescriptor descr = (AbstractServiceDescriptor)obj;
+               AbstractInterfaceDescriptor descr = (AbstractInterfaceDescriptor)obj;
                if ( _interfaces.length != descr._interfaces.length ) { 
                        return false; 
                }
similarity index 79%
rename from trunk/system/general/src/main/java/org/wamblee/system/SubSystem.java
rename to trunk/system/general/src/main/java/org/wamblee/system/Component.java
index 4e79ed76830f6eb1e625b1dfd0ec5e662d0330e2..6a31e01d61748002d63a435ac0da55f56ca66733 100644 (file)
@@ -1,12 +1,12 @@
 package org.wamblee.system;
 
 /**
- * A sub system represents a part of a system that required a 
- * number of services and provides a number of services. 
+ * A component represents a part of a system that requires a 
+ * number of interfaces and provides a number of interfaces. 
  *
  * @author Erik Brakkee
  */
-public interface SubSystem {
+public interface Component {
        
        /**
         * Gets the name of the subsystem.
@@ -18,13 +18,13 @@ public interface SubSystem {
         * Gets a description of the provided interfaces. 
         * @return Provided interfaces. 
         */
-       ProvidedServiceDescriptor[] getProvidedServices();
+       ProvidedInterfaceDescriptor[] getProvidedServices();
        
        /**
         * Gets a description of the required interfaces. 
         * @return Required interfaces. 
         */
-       RequiredServiceDescriptor[] getRequiredServices();
+       RequiredInterfaceDescriptor[] getRequiredServices();
 
        
        /**
index db94f738c7051b397f30ae380afbf1d22a085e9e..24547a9373078878880130b8463646312e87c682 100644 (file)
@@ -14,11 +14,11 @@ import sun.util.LocaleServiceProviderPool.LocalizedObjectGetter;
  *
  * @author Erik Brakkee
  */
-public class CompositeSystem extends AbstractSubSystem {
+public class CompositeSystem extends AbstractComponent {
 
        private static final Log LOG = LogFactory.getLog(CompositeSystem.class);
 
-       private SubSystem[] _systems;
+       private Component[] _systems;
 
        /**
         * Construcst the composite system. 
@@ -28,8 +28,8 @@ public class CompositeSystem extends AbstractSubSystem {
         * @param aProvided Provided services of the system. 
         * @param aRequired Required services by the system. 
         */
-       public CompositeSystem(String aName, ServiceRegistry aRegistry, SubSystem[] aSystems,
-                       ServiceDescriptor[] aProvided, ServiceDescriptor[] aRequired) {
+       public CompositeSystem(String aName, ServiceRegistry aRegistry, Component[] aSystems,
+                       InterfaceDescriptor[] aProvided, InterfaceDescriptor[] aRequired) {
                super(aName, aRegistry, aProvided, aRequired);
                _systems = aSystems;
                validate();
@@ -42,24 +42,24 @@ public class CompositeSystem extends AbstractSubSystem {
         * Also logs a warning in case of superfluous requirements.  
         */
        private void validate() {
-               List<ServiceDescriptor> provided = new ArrayList<ServiceDescriptor>();
-               for (SubSystem system : _systems) {
+               List<InterfaceDescriptor> provided = new ArrayList<InterfaceDescriptor>();
+               for (Component system : _systems) {
                        provided.addAll(Arrays.asList(system.getProvidedServices()));
                }
 
-               List<ServiceDescriptor> required = new ArrayList<ServiceDescriptor>();
-               for (SubSystem system : _systems) {
+               List<InterfaceDescriptor> required = new ArrayList<InterfaceDescriptor>();
+               for (Component system : _systems) {
                        required.addAll(Arrays.asList(system.getRequiredServices()));
                }
 
-               for (ServiceDescriptor service : getProvidedServices()) {
+               for (InterfaceDescriptor service : getProvidedServices()) {
                        if (!(provided.contains(service))) {
                                throw new SystemAssemblyException(getName() + ": Service '" + service
                                                + "' is not provided by any of the subsystems");
                        }
                }
 
-               for (ServiceDescriptor service : getRequiredServices()) {
+               for (InterfaceDescriptor service : getRequiredServices()) {
                        if (!(required.contains(service))) {
                                info("Service '"
                                                + service
@@ -67,27 +67,27 @@ public class CompositeSystem extends AbstractSubSystem {
                        }
                }
 
-               List<ServiceDescriptor> reallyRequired = new ArrayList<ServiceDescriptor>(
+               List<InterfaceDescriptor> reallyRequired = new ArrayList<InterfaceDescriptor>(
                                required);
-               for (ServiceDescriptor service : provided) {
+               for (InterfaceDescriptor service : provided) {
                        reallyRequired.remove(service); 
                }
-               for (ServiceDescriptor service: getRequiredServices()) { 
+               for (InterfaceDescriptor service: getRequiredServices()) { 
                        reallyRequired.remove(service); 
                }
-               for (ServiceDescriptor service: reallyRequired) { 
+               for (InterfaceDescriptor service: reallyRequired) { 
                        throw new SystemAssemblyException(getName() + ": " + "Service '" + service + "' is not provided internally and is not indicated as required for this sub system");
                }
        }
 
        @Override
        protected void doStart(String aContext, Service[] aRequiredServices) {
-               List<ProvidedServiceDescriptor> descriptors = new ArrayList<ProvidedServiceDescriptor>();
+               List<ProvidedInterfaceDescriptor> descriptors = new ArrayList<ProvidedInterfaceDescriptor>();
                for (Service service : aRequiredServices) {
                        descriptors.add(service.getDescriptor());
                }
                SystemAssembler assembler = new SystemAssembler(aContext + "." + getName(), _systems,
-                               descriptors.toArray(new ProvidedServiceDescriptor[0]));
+                               descriptors.toArray(new ProvidedInterfaceDescriptor[0]));
                assembler.start(getRegistry(), aRequiredServices);
        }
        
diff --git a/trunk/system/general/src/main/java/org/wamblee/system/DefaultProvidedInterfaceDescriptor.java b/trunk/system/general/src/main/java/org/wamblee/system/DefaultProvidedInterfaceDescriptor.java
new file mode 100644 (file)
index 0000000..97e62da
--- /dev/null
@@ -0,0 +1,19 @@
+package org.wamblee.system;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+
+public class DefaultProvidedInterfaceDescriptor extends AbstractInterfaceDescriptor implements
+               ProvidedInterfaceDescriptor {
+
+       public DefaultProvidedInterfaceDescriptor(String aName, Class aInterface) { 
+               super(aName, aInterface);
+       }
+       
+       public DefaultProvidedInterfaceDescriptor(String aName, Class[] aInterface) { 
+               super(aName, aInterface);
+       }
+       
+}
diff --git a/trunk/system/general/src/main/java/org/wamblee/system/DefaultProvidedServiceDescriptor.java b/trunk/system/general/src/main/java/org/wamblee/system/DefaultProvidedServiceDescriptor.java
deleted file mode 100644 (file)
index c270cb8..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.wamblee.system;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-
-public class DefaultProvidedServiceDescriptor extends AbstractServiceDescriptor implements
-               ProvidedServiceDescriptor {
-
-       public DefaultProvidedServiceDescriptor(String aName, Class aInterface) { 
-               super(aName, aInterface);
-       }
-       
-       public DefaultProvidedServiceDescriptor(String aName, Class[] aInterface) { 
-               super(aName, aInterface);
-       }
-       
-}
similarity index 69%
rename from trunk/system/general/src/main/java/org/wamblee/system/DefaultRequiredServiceDescriptor.java
rename to trunk/system/general/src/main/java/org/wamblee/system/DefaultRequiredInterfaceDescriptor.java
index ad63cb4a001f931472b1fc0d399e6808a4e66b30..fbee3155870ce16d16d52a16e78c48bf573ca0ba 100644 (file)
@@ -1,18 +1,18 @@
 package org.wamblee.system;
 
-public class DefaultRequiredServiceDescriptor extends AbstractServiceDescriptor
-               implements RequiredServiceDescriptor {
+public class DefaultRequiredInterfaceDescriptor extends AbstractInterfaceDescriptor
+               implements RequiredInterfaceDescriptor {
 
-       public DefaultRequiredServiceDescriptor(String aName, Class aInterface) {
+       public DefaultRequiredInterfaceDescriptor(String aName, Class aInterface) {
                super(aName, aInterface);
        }
 
-       public DefaultRequiredServiceDescriptor(String aName, Class[] aInterfaces) {
+       public DefaultRequiredInterfaceDescriptor(String aName, Class[] aInterfaces) {
                super(aName, aInterfaces);
        }
 
        @Override
-       public boolean implementedBy(ProvidedServiceDescriptor aDescriptor) {
+       public boolean implementedBy(ProvidedInterfaceDescriptor aDescriptor) {
                Class[] provided = aDescriptor.getInterfaceTypes();
                for (Class required : getInterfaceTypes()) {
                        if ( !serviceProvided(required, provided)) { 
index 9e2e53f18b51245ea027ce083731eb172d351df9..dc266223d4699724895f1e7d2778d39ac66c2bf0 100644 (file)
@@ -8,7 +8,7 @@ package org.wamblee.system;
 public class DefaultService implements Service {
 
        private String _id;
-       private ProvidedServiceDescriptor _descriptor;
+       private ProvidedInterfaceDescriptor _descriptor;
        private Object _service;
 
        /**
@@ -19,7 +19,7 @@ public class DefaultService implements Service {
         * @param aService
         *            Service.
         */
-       public DefaultService(String aId, ProvidedServiceDescriptor aDescriptor,
+       public DefaultService(String aId, ProvidedInterfaceDescriptor aDescriptor,
                        Object aService) {
                _id = aId;
                _descriptor = aDescriptor;
@@ -32,7 +32,7 @@ public class DefaultService implements Service {
        }
 
        @Override
-       public ProvidedServiceDescriptor getDescriptor() {
+       public ProvidedInterfaceDescriptor getDescriptor() {
                return _descriptor;
        }
 
index 464c6be59786a5e886ad37208406542342d0d02d..ae3f8b3240e8ac5652339e724b5f001538c7ec40 100644 (file)
@@ -15,7 +15,7 @@ public class DefaultServiceRegistry implements ServiceRegistry {
        }
 
        @Override
-       public synchronized Service register(ProvidedServiceDescriptor aDescriptor,
+       public synchronized Service register(ProvidedInterfaceDescriptor aDescriptor,
                        Object aService) {
                _count++;
                String id = "" + _count;
similarity index 94%
rename from trunk/system/general/src/main/java/org/wamblee/system/ServiceDescriptor.java
rename to trunk/system/general/src/main/java/org/wamblee/system/InterfaceDescriptor.java
index 81032ac649e95ebd4651c629db948d195229e383..987a85954ad3562c4a8bf1170de6fdd8957b92bf 100644 (file)
@@ -12,7 +12,7 @@ package org.wamblee.system;
  *
  * @author Erik Brakkee
  */
-public interface ServiceDescriptor {
+public interface InterfaceDescriptor {
        
        /**
         * Symbolic name for the service as used by the subsystem.  
diff --git a/trunk/system/general/src/main/java/org/wamblee/system/ProvidedInterfaceDescriptor.java b/trunk/system/general/src/main/java/org/wamblee/system/ProvidedInterfaceDescriptor.java
new file mode 100644 (file)
index 0000000..1af949c
--- /dev/null
@@ -0,0 +1,7 @@
+package org.wamblee.system;
+
+import java.util.Collection;
+
+public interface ProvidedInterfaceDescriptor extends InterfaceDescriptor {
+    // Empty
+}
diff --git a/trunk/system/general/src/main/java/org/wamblee/system/ProvidedServiceDescriptor.java b/trunk/system/general/src/main/java/org/wamblee/system/ProvidedServiceDescriptor.java
deleted file mode 100644 (file)
index 94eb43d..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-package org.wamblee.system;
-
-import java.util.Collection;
-
-public interface ProvidedServiceDescriptor extends ServiceDescriptor {
-    // Empty
-}
diff --git a/trunk/system/general/src/main/java/org/wamblee/system/RequiredInterfaceDescriptor.java b/trunk/system/general/src/main/java/org/wamblee/system/RequiredInterfaceDescriptor.java
new file mode 100644 (file)
index 0000000..1a1237b
--- /dev/null
@@ -0,0 +1,6 @@
+package org.wamblee.system;
+
+public interface RequiredInterfaceDescriptor extends InterfaceDescriptor {
+
+       boolean implementedBy(ProvidedInterfaceDescriptor aDescriptor);
+}
diff --git a/trunk/system/general/src/main/java/org/wamblee/system/RequiredServiceDescriptor.java b/trunk/system/general/src/main/java/org/wamblee/system/RequiredServiceDescriptor.java
deleted file mode 100644 (file)
index 1c79923..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-package org.wamblee.system;
-
-public interface RequiredServiceDescriptor extends ServiceDescriptor {
-
-       boolean implementedBy(ProvidedServiceDescriptor aDescriptor);
-}
index 1721f401bee11e4adb5b684a35245d3bebb4bf28..63988f08943ca5a89f2604cad363a9f3e713b8f3 100644 (file)
@@ -17,7 +17,7 @@ public interface Service {
         * Gets the descriptor of the service. 
         * @return Descriptor. 
         */
-       ProvidedServiceDescriptor getDescriptor(); 
+       ProvidedInterfaceDescriptor getDescriptor(); 
        
        /**
         * Returns a reference to the running service. 
index 9fda9eef6a6e96d34168af5a5025ec4e4fbe919c..17294bbb3bf00124e9a7573464b87f3d0615f88a 100644 (file)
@@ -2,7 +2,7 @@ package org.wamblee.system;
 
 public interface ServiceRegistry {
 
-       Service register(ProvidedServiceDescriptor aDescriptor, Object aService);
+       Service register(ProvidedInterfaceDescriptor aDescriptor, Object aService);
        
        void remove(Service aService); 
        
index 7b45f8b1d7b047389a2fc12b34e420624fa6a5e2..561e3f9569ebcf39db1770a5bcda7ee517075e16 100644 (file)
@@ -22,30 +22,30 @@ public class SystemAssembler {
 
        private static final String ROOT_CONTEXT_NAME = "root";
        private String _context;
-       private SubSystem[] _systems;
+       private Component[] _systems;
 
-       public static RequiredServiceDescriptor[] filterRequiredServices(
-                       ProvidedServiceDescriptor aProvided,
-                       Collection<RequiredServiceDescriptor> aDescriptors) {
-               List<RequiredServiceDescriptor> required = new ArrayList<RequiredServiceDescriptor>();
-               for (RequiredServiceDescriptor descriptor : aDescriptors) {
+       public static RequiredInterfaceDescriptor[] filterRequiredServices(
+                       ProvidedInterfaceDescriptor aProvided,
+                       Collection<RequiredInterfaceDescriptor> aDescriptors) {
+               List<RequiredInterfaceDescriptor> required = new ArrayList<RequiredInterfaceDescriptor>();
+               for (RequiredInterfaceDescriptor descriptor : aDescriptors) {
                        if (descriptor.implementedBy(aProvided)) {
                                required.add(descriptor);
                        }
                }
-               return required.toArray(new RequiredServiceDescriptor[0]);
+               return required.toArray(new RequiredInterfaceDescriptor[0]);
        }
 
-       public static ProvidedServiceDescriptor[] filterProvidedServices(
-                       RequiredServiceDescriptor aRequired,
-                       Collection<ProvidedServiceDescriptor> aProvided) {
-               List<ProvidedServiceDescriptor> provided = new ArrayList<ProvidedServiceDescriptor>();
-               for (ProvidedServiceDescriptor descriptor : aProvided) {
+       public static ProvidedInterfaceDescriptor[] filterProvidedServices(
+                       RequiredInterfaceDescriptor aRequired,
+                       Collection<ProvidedInterfaceDescriptor> aProvided) {
+               List<ProvidedInterfaceDescriptor> provided = new ArrayList<ProvidedInterfaceDescriptor>();
+               for (ProvidedInterfaceDescriptor descriptor : aProvided) {
                        if (aRequired.implementedBy(descriptor)) {
                                provided.add(descriptor);
                        }
                }
-               return provided.toArray(new ProvidedServiceDescriptor[0]);
+               return provided.toArray(new ProvidedInterfaceDescriptor[0]);
        }
 
        /**
@@ -57,8 +57,8 @@ public class SystemAssembler {
         *            Available services from other systems outside of the systems
         *            that this assembler manages.
         */
-       public SystemAssembler(SubSystem[] aSystems,
-                       ProvidedServiceDescriptor[] aAvailableServices) {
+       public SystemAssembler(Component[] aSystems,
+                       ProvidedInterfaceDescriptor[] aAvailableServices) {
                this(ROOT_CONTEXT_NAME, aSystems, aAvailableServices);
        }
 
@@ -73,8 +73,8 @@ public class SystemAssembler {
         *            Available services from other systems outside of the systems
         *            that this assembler manages.
         */
-       public SystemAssembler(String aContext, SubSystem[] aSystems,
-                       ProvidedServiceDescriptor[] aAvailableServices) {
+       public SystemAssembler(String aContext, Component[] aSystems,
+                       ProvidedInterfaceDescriptor[] aAvailableServices) {
                _context = aContext;
                _systems = aSystems;
                validate(aAvailableServices);
@@ -84,20 +84,20 @@ public class SystemAssembler {
         * Determines if the systems are ordered appropriately so that all
         * dependencies are met.
         */
-       private void validate(ProvidedServiceDescriptor[] aDescriptors)
+       private void validate(ProvidedInterfaceDescriptor[] aDescriptors)
                        throws SystemAssemblyException {
 
-               List<ProvidedServiceDescriptor> allProvided = new ArrayList<ProvidedServiceDescriptor>();
-               for (ProvidedServiceDescriptor descriptor : aDescriptors) {
+               List<ProvidedInterfaceDescriptor> allProvided = new ArrayList<ProvidedInterfaceDescriptor>();
+               for (ProvidedInterfaceDescriptor descriptor : aDescriptors) {
                        allProvided.add(descriptor);
                }
-               for (SubSystem system : _systems) {
+               for (Component system : _systems) {
                        // Check if all required services are already provided by earlier
                        // systems.
-                       RequiredServiceDescriptor[] required = system.getRequiredServices();
+                       RequiredInterfaceDescriptor[] required = system.getRequiredServices();
 
-                       for (RequiredServiceDescriptor descriptor : required) {
-                               ProvidedServiceDescriptor[] filtered = filterProvidedServices(
+                       for (RequiredInterfaceDescriptor descriptor : required) {
+                               ProvidedInterfaceDescriptor[] filtered = filterProvidedServices(
                                                descriptor, allProvided);
 
                                if (filtered.length == 0) {
@@ -120,7 +120,7 @@ public class SystemAssembler {
                        }
 
                        // add all provided services
-                       ProvidedServiceDescriptor[] provided = system.getProvidedServices();
+                       ProvidedInterfaceDescriptor[] provided = system.getProvidedServices();
                        allProvided.addAll(Arrays.asList(provided));
                }
        }
@@ -136,20 +136,20 @@ public class SystemAssembler {
         */
        public void start(ServiceRegistry aRegistry, Service[] aRequiredServices) {
                LOG.info("Starting '" + _context + "'");
-               Map<ProvidedServiceDescriptor, Service> allProvided = new HashMap<ProvidedServiceDescriptor, Service>();
+               Map<ProvidedInterfaceDescriptor, Service> allProvided = new HashMap<ProvidedInterfaceDescriptor, Service>();
 
                for (Service service : aRequiredServices) {
                        allProvided.put(service.getDescriptor(), service);
                }
-               for (SubSystem system : _systems) {
+               for (Component system : _systems) {
                        
                        // Compose a list of the required services required for the subsystem.
                        
-                       RequiredServiceDescriptor[] descriptors = system
+                       RequiredInterfaceDescriptor[] descriptors = system
                                        .getRequiredServices();
                        List<Service> services = new ArrayList<Service>();
-                       for (RequiredServiceDescriptor descriptor : descriptors) {
-                               ProvidedServiceDescriptor[] provided = filterProvidedServices(
+                       for (RequiredInterfaceDescriptor descriptor : descriptors) {
+                               ProvidedInterfaceDescriptor[] provided = filterProvidedServices(
                                                descriptor, allProvided.keySet());
                                services.add(allProvided.get(provided[0]));
                        }
index 07b1e34cbc7939d6e30ce44b9acc8d7fcebfc40c..47c92af88405a1edae2990ff5c4c350e4c826078 100644 (file)
@@ -2,15 +2,15 @@ package org.wamblee.system;
 
 import javax.sql.DataSource;
 
-public class Application extends AbstractSubSystem {
-       private static final ServiceDescriptor[] REQUIRED = 
-               new ServiceDescriptor[] { 
-                       new DefaultRequiredServiceDescriptor("datasource", DataSource.class), 
-                       new DefaultRequiredServiceDescriptor("integer", Integer.class)
+public class Application extends AbstractComponent {
+       private static final InterfaceDescriptor[] REQUIRED = 
+               new InterfaceDescriptor[] { 
+                       new DefaultRequiredInterfaceDescriptor("datasource", DataSource.class), 
+                       new DefaultRequiredInterfaceDescriptor("integer", Integer.class)
        };
        
        public Application(ServiceRegistry aRegistry) {
-               super("application", aRegistry, new ServiceDescriptor[0], REQUIRED); 
+               super("application", aRegistry, new InterfaceDescriptor[0], REQUIRED); 
        }
 
        @Override
diff --git a/trunk/system/general/src/test/java/org/wamblee/system/DefaultInterfaceDescriptorTest.java b/trunk/system/general/src/test/java/org/wamblee/system/DefaultInterfaceDescriptorTest.java
new file mode 100644 (file)
index 0000000..dd3451d
--- /dev/null
@@ -0,0 +1,66 @@
+package org.wamblee.system;
+
+import java.io.Serializable;
+
+import junit.framework.TestCase;
+
+public class DefaultInterfaceDescriptorTest extends TestCase {
+
+       public void testOneRequiredOneProvidedMatch() { 
+               ProvidedInterfaceDescriptor provided = new DefaultProvidedInterfaceDescriptor("name", String.class);
+               RequiredInterfaceDescriptor required = new DefaultRequiredInterfaceDescriptor("name", String.class);
+               assertTrue(required.implementedBy(provided));
+       }
+       
+       public void testOneRequiredOneProvidedMatchSubClass() { 
+               ProvidedInterfaceDescriptor provided = new DefaultProvidedInterfaceDescriptor("name", Integer.class);
+               RequiredInterfaceDescriptor required = new DefaultRequiredInterfaceDescriptor("name", Number.class);
+               assertTrue(required.implementedBy(provided));
+       }
+       
+       public void testOneRequiredOneProvidedNoMatch() { 
+               ProvidedInterfaceDescriptor provided = new DefaultProvidedInterfaceDescriptor("name", String.class);
+               RequiredInterfaceDescriptor required = new DefaultRequiredInterfaceDescriptor("name", Number.class);
+               assertFalse(required.implementedBy(provided));
+       }
+       
+       public void testOneRequiredMultipleProvidedMatch() { 
+               ProvidedInterfaceDescriptor provided = new DefaultProvidedInterfaceDescriptor("name", 
+                               new Class[] { String.class, Integer.class} );
+               RequiredInterfaceDescriptor required = new DefaultRequiredInterfaceDescriptor("name", String.class);
+               assertTrue(required.implementedBy(provided));
+       }
+       
+       private static class MyMultiple implements Runnable, Serializable { 
+               @Override
+               public void run() {
+                       // Empty        
+               }
+       }
+       
+       public void testMultipleRequiredOneProvidedMatch() { 
+               ProvidedInterfaceDescriptor provided = new DefaultProvidedInterfaceDescriptor("name", 
+                               MyMultiple.class );
+               RequiredInterfaceDescriptor required = new DefaultRequiredInterfaceDescriptor("name", 
+                               new Class[] {Runnable.class, Serializable.class} );
+               assertTrue(required.implementedBy(provided));
+       }
+       
+       public void testMultipleRequiredOneProvidedNoMatch() { 
+               ProvidedInterfaceDescriptor provided = new DefaultProvidedInterfaceDescriptor("name", 
+                               MyMultiple.class );
+               RequiredInterfaceDescriptor required = new DefaultRequiredInterfaceDescriptor("name", 
+                               new Class[] { String.class, Runnable.class} );
+               assertFalse(required.implementedBy(provided));
+       }
+       
+       public void testMultipleRequiredMultipleProvidedMatch() { 
+               ProvidedInterfaceDescriptor provided = new DefaultProvidedInterfaceDescriptor("name", 
+                               new Class[] { Runnable.class, Serializable.class, String.class}  );
+               RequiredInterfaceDescriptor required = new DefaultRequiredInterfaceDescriptor("name", 
+                               new Class[] {Runnable.class, Serializable.class} );
+               assertTrue(required.implementedBy(provided));
+       }
+       
+       
+}
diff --git a/trunk/system/general/src/test/java/org/wamblee/system/DefaultServiceDescriptorTest.java b/trunk/system/general/src/test/java/org/wamblee/system/DefaultServiceDescriptorTest.java
deleted file mode 100644 (file)
index b222d28..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-package org.wamblee.system;
-
-import java.io.Serializable;
-
-import junit.framework.TestCase;
-
-public class DefaultServiceDescriptorTest extends TestCase {
-
-       public void testOneRequiredOneProvidedMatch() { 
-               ProvidedServiceDescriptor provided = new DefaultProvidedServiceDescriptor("name", String.class);
-               RequiredServiceDescriptor required = new DefaultRequiredServiceDescriptor("name", String.class);
-               assertTrue(required.implementedBy(provided));
-       }
-       
-       public void testOneRequiredOneProvidedMatchSubClass() { 
-               ProvidedServiceDescriptor provided = new DefaultProvidedServiceDescriptor("name", Integer.class);
-               RequiredServiceDescriptor required = new DefaultRequiredServiceDescriptor("name", Number.class);
-               assertTrue(required.implementedBy(provided));
-       }
-       
-       public void testOneRequiredOneProvidedNoMatch() { 
-               ProvidedServiceDescriptor provided = new DefaultProvidedServiceDescriptor("name", String.class);
-               RequiredServiceDescriptor required = new DefaultRequiredServiceDescriptor("name", Number.class);
-               assertFalse(required.implementedBy(provided));
-       }
-       
-       public void testOneRequiredMultipleProvidedMatch() { 
-               ProvidedServiceDescriptor provided = new DefaultProvidedServiceDescriptor("name", 
-                               new Class[] { String.class, Integer.class} );
-               RequiredServiceDescriptor required = new DefaultRequiredServiceDescriptor("name", String.class);
-               assertTrue(required.implementedBy(provided));
-       }
-       
-       private static class MyMultiple implements Runnable, Serializable { 
-               @Override
-               public void run() {
-                       // Empty        
-               }
-       }
-       
-       public void testMultipleRequiredOneProvidedMatch() { 
-               ProvidedServiceDescriptor provided = new DefaultProvidedServiceDescriptor("name", 
-                               MyMultiple.class );
-               RequiredServiceDescriptor required = new DefaultRequiredServiceDescriptor("name", 
-                               new Class[] {Runnable.class, Serializable.class} );
-               assertTrue(required.implementedBy(provided));
-       }
-       
-       public void testMultipleRequiredOneProvidedNoMatch() { 
-               ProvidedServiceDescriptor provided = new DefaultProvidedServiceDescriptor("name", 
-                               MyMultiple.class );
-               RequiredServiceDescriptor required = new DefaultRequiredServiceDescriptor("name", 
-                               new Class[] { String.class, Runnable.class} );
-               assertFalse(required.implementedBy(provided));
-       }
-       
-       public void testMultipleRequiredMultipleProvidedMatch() { 
-               ProvidedServiceDescriptor provided = new DefaultProvidedServiceDescriptor("name", 
-                               new Class[] { Runnable.class, Serializable.class, String.class}  );
-               RequiredServiceDescriptor required = new DefaultRequiredServiceDescriptor("name", 
-                               new Class[] {Runnable.class, Serializable.class} );
-               assertTrue(required.implementedBy(provided));
-       }
-       
-       
-}
index 56118ccbb7fb325d1c96616bc017800b9bff4549..76d3a3c1bfbb9bf0d736eeab4a1b7b103084b07d 100644 (file)
@@ -3,16 +3,16 @@ package org.wamblee.system;
 import javax.sql.DataSource;
 
 
-public class Environment extends AbstractSubSystem {
+public class Environment extends AbstractComponent {
        
-       private static final ProvidedServiceDescriptor[] PROVIDED = 
-               new ProvidedServiceDescriptor[] { 
-                       new DefaultProvidedServiceDescriptor("datasource", DataSource.class), 
-                       new DefaultProvidedServiceDescriptor("integer", Integer.class)
+       private static final ProvidedInterfaceDescriptor[] PROVIDED = 
+               new ProvidedInterfaceDescriptor[] { 
+                       new DefaultProvidedInterfaceDescriptor("datasource", DataSource.class), 
+                       new DefaultProvidedInterfaceDescriptor("integer", Integer.class)
        };
        
        public Environment(ServiceRegistry aRegistry) { 
-               super("environment", aRegistry, PROVIDED, new ServiceDescriptor[0]);
+               super("environment", aRegistry, PROVIDED, new InterfaceDescriptor[0]);
        }
        
        @Override
index 2dba056e63197879c35e4e9e30a96c70b0516843..885cff39739a748fbd1e015c4f45f66b461128db 100644 (file)
@@ -26,46 +26,46 @@ public class SystemAssemblerTest extends TestCase {
        }
 
        public void testFilterProvided() {
-               RequiredServiceDescriptor req1 = new DefaultRequiredServiceDescriptor(
+               RequiredInterfaceDescriptor req1 = new DefaultRequiredInterfaceDescriptor(
                                "name", Runnable.class);
-               RequiredServiceDescriptor req2 = new DefaultRequiredServiceDescriptor(
+               RequiredInterfaceDescriptor req2 = new DefaultRequiredInterfaceDescriptor(
                                "name", Serializable.class);
-               ProvidedServiceDescriptor prov1 = new DefaultProvidedServiceDescriptor(
+               ProvidedInterfaceDescriptor prov1 = new DefaultProvidedInterfaceDescriptor(
                                "name", Runnable.class);
-               ProvidedServiceDescriptor prov2 = new DefaultProvidedServiceDescriptor(
+               ProvidedInterfaceDescriptor prov2 = new DefaultProvidedInterfaceDescriptor(
                                "name", Serializable.class);
-               ProvidedServiceDescriptor prov3 = new DefaultProvidedServiceDescriptor(
+               ProvidedInterfaceDescriptor prov3 = new DefaultProvidedInterfaceDescriptor(
                                "name", MyMultiple.class);
 
-               AssertionUtils.assertEquals(new RequiredServiceDescriptor[] { req1 },
+               AssertionUtils.assertEquals(new RequiredInterfaceDescriptor[] { req1 },
                                SystemAssembler.filterRequiredServices(prov1, Arrays
-                                               .asList(new RequiredServiceDescriptor[] { req1 })));
-               AssertionUtils.assertEquals(new RequiredServiceDescriptor[] { req1 },
+                                               .asList(new RequiredInterfaceDescriptor[] { req1 })));
+               AssertionUtils.assertEquals(new RequiredInterfaceDescriptor[] { req1 },
                                SystemAssembler
                                                .filterRequiredServices(prov1, Arrays
-                                                               .asList(new RequiredServiceDescriptor[] { req1,
+                                                               .asList(new RequiredInterfaceDescriptor[] { req1,
                                                                                req2 })));
-               AssertionUtils.assertEquals(new RequiredServiceDescriptor[] { req1,
+               AssertionUtils.assertEquals(new RequiredInterfaceDescriptor[] { req1,
                                req2 }, SystemAssembler.filterRequiredServices(prov3, Arrays
-                               .asList(new RequiredServiceDescriptor[] { req1, req2 })));
+                               .asList(new RequiredInterfaceDescriptor[] { req1, req2 })));
 
-               AssertionUtils.assertEquals(new ProvidedServiceDescriptor[] { prov1 },
+               AssertionUtils.assertEquals(new ProvidedInterfaceDescriptor[] { prov1 },
                                SystemAssembler.filterProvidedServices(req1, Arrays
-                                               .asList(new ProvidedServiceDescriptor[] { prov1 })));
-               AssertionUtils.assertEquals(new ProvidedServiceDescriptor[] { prov1 },
+                                               .asList(new ProvidedInterfaceDescriptor[] { prov1 })));
+               AssertionUtils.assertEquals(new ProvidedInterfaceDescriptor[] { prov1 },
                                SystemAssembler.filterProvidedServices(req1,
-                                               Arrays.asList(new ProvidedServiceDescriptor[] { prov1,
+                                               Arrays.asList(new ProvidedInterfaceDescriptor[] { prov1,
                                                                prov2 })));
-               AssertionUtils.assertEquals(new ProvidedServiceDescriptor[] { prov1,
+               AssertionUtils.assertEquals(new ProvidedInterfaceDescriptor[] { prov1,
                                prov3 }, SystemAssembler.filterProvidedServices(req1, Arrays
-                               .asList(new ProvidedServiceDescriptor[] { prov1, prov3 })));
+                               .asList(new ProvidedInterfaceDescriptor[] { prov1, prov3 })));
        }
 
        public void testEnvironmentApplication() {
-               SubSystem environment = new Environment(_registry);
-               SubSystem application = new Application(_registry);
-               SystemAssembler assembler = new SystemAssembler(new SubSystem[] {
-                               environment, application }, new ProvidedServiceDescriptor[0]);
+               Component environment = new Environment(_registry);
+               Component application = new Application(_registry);
+               SystemAssembler assembler = new SystemAssembler(new Component[] {
+                               environment, application }, new ProvidedInterfaceDescriptor[0]);
                assembler.start(_registry, new Service[0]);
                Service[] envServices = environment.getRunningServices();
                assertEquals(2, envServices.length);
@@ -82,11 +82,11 @@ public class SystemAssemblerTest extends TestCase {
 
        public void testApplicationEnvironment() {
                try {
-                       SubSystem environment = new Environment(_registry);
-                       SubSystem application = new Application(_registry);
-                       SystemAssembler assembler = new SystemAssembler(new SubSystem[] {
+                       Component environment = new Environment(_registry);
+                       Component application = new Application(_registry);
+                       SystemAssembler assembler = new SystemAssembler(new Component[] {
                                        application, environment },
-                                       new ProvidedServiceDescriptor[0]);
+                                       new ProvidedInterfaceDescriptor[0]);
                        assembler.start(_registry, new Service[0]);
                } catch (SystemAssemblyException e) {
                        // e.printStackTrace();
@@ -96,29 +96,29 @@ public class SystemAssemblerTest extends TestCase {
        }
 
        public void testComposite() {
-               SubSystem environment = new Environment(_registry);
-               SubSystem application = new Application(_registry);
+               Component environment = new Environment(_registry);
+               Component application = new Application(_registry);
                CompositeSystem system = new CompositeSystem("all", _registry,
-                               new SubSystem[] { environment, application },
-                               new ServiceDescriptor[0], new ServiceDescriptor[0]);
+                               new Component[] { environment, application },
+                               new InterfaceDescriptor[0], new InterfaceDescriptor[0]);
                system.start("root", new Service[0]);
-               ServiceDescriptor[] required = system.getRequiredServices();
+               InterfaceDescriptor[] required = system.getRequiredServices();
                assertEquals(0, required.length);
-               ServiceDescriptor[] provided = system.getProvidedServices();
+               InterfaceDescriptor[] provided = system.getProvidedServices();
                assertEquals(0, provided.length);
        }
 
        public void testCompositeWithWrongProvidedInfo() {
                try {
-                       SubSystem environment = new Environment(_registry);
-                       SubSystem application = new Application(_registry);
+                       Component environment = new Environment(_registry);
+                       Component application = new Application(_registry);
                        CompositeSystem system = new CompositeSystem(
                                        "all",
                                        _registry,
-                                       new SubSystem[] { environment, application },
-                                       new ServiceDescriptor[] { new DefaultProvidedServiceDescriptor(
+                                       new Component[] { environment, application },
+                                       new InterfaceDescriptor[] { new DefaultProvidedInterfaceDescriptor(
                                                        "string", String.class) },
-                                       new DefaultRequiredServiceDescriptor[0]);
+                                       new DefaultRequiredInterfaceDescriptor[0]);
                } catch (SystemAssemblyException e) {
                        return;
                }
@@ -126,26 +126,26 @@ public class SystemAssemblerTest extends TestCase {
        }
 
        public void testCompositeWithSuperfluousRequiredInfo() {
-               SubSystem environment = new Environment(_registry);
-               SubSystem application = new Application(_registry);
+               Component environment = new Environment(_registry);
+               Component application = new Application(_registry);
                CompositeSystem system = new CompositeSystem("all", _registry,
-                               new SubSystem[] { environment, application },
-                               new ServiceDescriptor[0],
-                               new ServiceDescriptor[] { new DefaultRequiredServiceDescriptor(
+                               new Component[] { environment, application },
+                               new InterfaceDescriptor[0],
+                               new InterfaceDescriptor[] { new DefaultRequiredInterfaceDescriptor(
                                                "string", String.class) });
                system.start("root", new Service[0]);
-               ServiceDescriptor[] required = system.getRequiredServices();
+               InterfaceDescriptor[] required = system.getRequiredServices();
                assertEquals(1, required.length);
-               ServiceDescriptor[] provided = system.getProvidedServices();
+               InterfaceDescriptor[] provided = system.getProvidedServices();
                assertEquals(0, provided.length);
        }
 
        public void testCompositeWithExternalDependencesNotProvided() {
                try {
-                       SubSystem environment = new Environment(_registry);
-                       SubSystem application = new Application(_registry);
+                       Component environment = new Environment(_registry);
+                       Component application = new Application(_registry);
                        CompositeSystem system = new CompositeSystem("all", _registry,
-                                       new SubSystem[] { application }, new ServiceDescriptor[0],
+                                       new Component[] { application }, new InterfaceDescriptor[0],
                                        application.getRequiredServices());
                        system.start("root", new Service[0]);
                } catch (SystemAssemblyException e) {
@@ -157,33 +157,35 @@ public class SystemAssemblerTest extends TestCase {
 
        public void testCompositeWithExternalDependencesProvided() {
 
-               SubSystem environment = new Environment(_registry);
-               SubSystem application = new Application(_registry);
+               Component environment = new Environment(_registry);
+               Component application = new Application(_registry);
                CompositeSystem system = new CompositeSystem("all", _registry,
-                               new SubSystem[] { application }, new ServiceDescriptor[0],
+                               new Component[] { application }, new InterfaceDescriptor[0],
                                application.getRequiredServices());
                Service[] envServices = environment.start("env", new Service[0]);
                system.start("root", envServices);
-               ServiceDescriptor[] required = system.getRequiredServices();
+               InterfaceDescriptor[] required = system.getRequiredServices();
                assertEquals(2, required.length);
-               ServiceDescriptor[] provided = system.getProvidedServices();
+               InterfaceDescriptor[] provided = system.getProvidedServices();
                assertEquals(0, provided.length);
 
        }
 
        public void testAmbiguousInterfaces() {
                try {
-                       SubSystem environment1 = new Environment(_registry);
-                       SubSystem environment2 = new Environment(_registry);
-                       SubSystem application = new Application(_registry);
-                       SystemAssembler assembler = new SystemAssembler(new SubSystem[] {
+                       Component environment1 = new Environment(_registry);
+                       Component environment2 = new Environment(_registry);
+                       Component application = new Application(_registry);
+                       SystemAssembler assembler = new SystemAssembler(new Component[] {
                                        environment1, environment2, application },
-                                       new ProvidedServiceDescriptor[0]);
+                                       new ProvidedInterfaceDescriptor[0]);
                        assembler.start(_registry, new Service[0]);
+                       
                } catch (SystemAssemblyException e) {
                        return;
                }
                fail();
        }
 
+       
 }
index 5b7bfce62391a534fc5fc7a9f549910a4e512612..7a8b513ee7b318129f1b643c89a9096d3d7e30fa 100644 (file)
@@ -10,12 +10,12 @@ import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 import org.springframework.context.support.GenericApplicationContext;
-import org.wamblee.system.AbstractSubSystem;
+import org.wamblee.system.AbstractComponent;
 import org.wamblee.system.CompositeSystem;
-import org.wamblee.system.ProvidedServiceDescriptor;
-import org.wamblee.system.RequiredServiceDescriptor;
+import org.wamblee.system.ProvidedInterfaceDescriptor;
+import org.wamblee.system.RequiredInterfaceDescriptor;
 import org.wamblee.system.Service;
-import org.wamblee.system.ServiceDescriptor;
+import org.wamblee.system.InterfaceDescriptor;
 import org.wamblee.system.ServiceRegistry;
 import org.wamblee.system.SystemAssembler;
 import org.wamblee.system.SystemAssemblyException;
@@ -25,7 +25,7 @@ import org.wamblee.system.SystemAssemblyException;
  *
  * @author Erik Brakkee
  */
-public class SpringSystem extends AbstractSubSystem {
+public class SpringSystem extends AbstractComponent {
 
        /**
         * Singleton access to the service registry. Required while starting up.
@@ -33,8 +33,8 @@ public class SpringSystem extends AbstractSubSystem {
        static ThreadLocal<ServiceRegistry> REGISTRY = new ThreadLocal<ServiceRegistry>();
 
        private String[] _configFiles;
-       private Map<String, ProvidedServiceDescriptor> _provided;
-       private Map<RequiredServiceDescriptor, String> _required;
+       private Map<String, ProvidedInterfaceDescriptor> _provided;
+       private Map<RequiredInterfaceDescriptor, String> _required;
        /**
         * Parent application context containing required services.
         */
@@ -62,10 +62,10 @@ public class SpringSystem extends AbstractSubSystem {
         *            service.
         */
        public SpringSystem(String aName, ServiceRegistry aRegistry, String[] aConfigFiles,
-                       Map<String, ProvidedServiceDescriptor> aProvided,
-                       Map<RequiredServiceDescriptor, String> aRequired) {
-               super(aName, aRegistry, aProvided.values().toArray(new ServiceDescriptor[0]),
-                               aRequired.keySet().toArray(new ServiceDescriptor[0]));
+                       Map<String, ProvidedInterfaceDescriptor> aProvided,
+                       Map<RequiredInterfaceDescriptor, String> aRequired) {
+               super(aName, aRegistry, aProvided.values().toArray(new InterfaceDescriptor[0]),
+                               aRequired.keySet().toArray(new InterfaceDescriptor[0]));
                _configFiles = aConfigFiles;
                _provided = aProvided;
                _required = aRequired;
@@ -121,10 +121,10 @@ public class SpringSystem extends AbstractSubSystem {
                
                for (Service svc: aRequiredServices) { 
                        String id = svc.getId();
-                       ProvidedServiceDescriptor descriptor = svc.getDescriptor();
-                       RequiredServiceDescriptor[] requiredServices = SystemAssembler.filterRequiredServices(descriptor,
+                       ProvidedInterfaceDescriptor descriptor = svc.getDescriptor();
+                       RequiredInterfaceDescriptor[] requiredServices = SystemAssembler.filterRequiredServices(descriptor,
                                        _required.keySet()); 
-                       for (RequiredServiceDescriptor required: requiredServices) { 
+                       for (RequiredInterfaceDescriptor required: requiredServices) { 
                                String beanName = _required.get(required);
                                ConstructorArgumentValues cargs = new ConstructorArgumentValues();
                                cargs.addGenericArgumentValue(id); 
index e12e0113a46e2d9a2b42e7f1b9ca3929d3cc64f2..1543b7ab8cd39067b6d9a9aa64450c9a733a8669 100644 (file)
@@ -5,14 +5,14 @@ import java.util.Map;
 
 import junit.framework.TestCase;
 
-import org.wamblee.system.AbstractServiceDescriptor;
-import org.wamblee.system.DefaultProvidedServiceDescriptor;
-import org.wamblee.system.DefaultRequiredServiceDescriptor;
+import org.wamblee.system.AbstractInterfaceDescriptor;
+import org.wamblee.system.DefaultProvidedInterfaceDescriptor;
+import org.wamblee.system.DefaultRequiredInterfaceDescriptor;
 import org.wamblee.system.DefaultServiceRegistry;
-import org.wamblee.system.ProvidedServiceDescriptor;
-import org.wamblee.system.RequiredServiceDescriptor;
+import org.wamblee.system.ProvidedInterfaceDescriptor;
+import org.wamblee.system.RequiredInterfaceDescriptor;
 import org.wamblee.system.Service;
-import org.wamblee.system.ServiceDescriptor;
+import org.wamblee.system.InterfaceDescriptor;
 import org.wamblee.system.ServiceRegistry;
 import org.wamblee.system.SystemAssemblyException;
 
@@ -32,8 +32,8 @@ public class SpringSystemTest extends TestCase {
        public void testBlackboxSystem() {
                SpringSystem system = new SpringSystem("system", _registry,
                                new String[] { HELLO_SERVICE_SPRING_XML },
-                               new HashMap<String, ProvidedServiceDescriptor>(),
-                               new HashMap<RequiredServiceDescriptor, String>());
+                               new HashMap<String, ProvidedInterfaceDescriptor>(),
+                               new HashMap<RequiredInterfaceDescriptor, String>());
                system.start("Hello", new Service[0]);
                Service[] services = system.getRunningServices();
                assertEquals(0, services.length);
@@ -42,13 +42,13 @@ public class SpringSystemTest extends TestCase {
        }
 
        public void testOneProvidedService() {
-               Map<String, ProvidedServiceDescriptor> provided = new HashMap<String, ProvidedServiceDescriptor>();
-               provided.put("helloService", new DefaultProvidedServiceDescriptor(
+               Map<String, ProvidedInterfaceDescriptor> provided = new HashMap<String, ProvidedInterfaceDescriptor>();
+               provided.put("helloService", new DefaultProvidedInterfaceDescriptor(
                                "hello", HelloService.class));
 
                SpringSystem system = new SpringSystem("system", _registry,
                                new String[] { HELLO_SERVICE_SPRING_XML }, provided,
-                               new HashMap<RequiredServiceDescriptor, String>());
+                               new HashMap<RequiredInterfaceDescriptor, String>());
                system.start("Hello", new Service[0]);
                Service[] services = system.getRunningServices();
                assertEquals(1, services.length);
@@ -62,8 +62,8 @@ public class SpringSystemTest extends TestCase {
                try {
                        SpringSystem system = new SpringSystem("system", _registry,
                                        new String[] { HELLO_SERVICE_SPRING_WITH_REQS_XML },
-                                       new HashMap<String, ProvidedServiceDescriptor>(),
-                                       new HashMap<RequiredServiceDescriptor, String>());
+                                       new HashMap<String, ProvidedInterfaceDescriptor>(),
+                                       new HashMap<RequiredInterfaceDescriptor, String>());
                        system.start("Bla", new Service[0]);
                } catch (SystemAssemblyException e) {
                        //e.printStackTrace();
@@ -73,25 +73,25 @@ public class SpringSystemTest extends TestCase {
        }
 
        public void testWithRequirement() {
-               Map<RequiredServiceDescriptor, String> required = new HashMap<RequiredServiceDescriptor, String>();
-               required.put(new DefaultRequiredServiceDescriptor("hello", HelloService.class),
+               Map<RequiredInterfaceDescriptor, String> required = new HashMap<RequiredInterfaceDescriptor, String>();
+               required.put(new DefaultRequiredInterfaceDescriptor("hello", HelloService.class),
                                "helloService");
                SpringSystem system = new SpringSystem("system", _registry,
                                new String[] { HELLO_SERVICE_SPRING_WITH_REQS_XML },
-                               new HashMap<String, ProvidedServiceDescriptor>(), required);
+                               new HashMap<String, ProvidedInterfaceDescriptor>(), required);
                
                HelloService helloObject = new HelloService("ladida"); 
-               Service helloService = _registry.register(new DefaultProvidedServiceDescriptor("hello", HelloService.class), helloObject);
+               Service helloService = _registry.register(new DefaultProvidedInterfaceDescriptor("hello", HelloService.class), helloObject);
                system.start("Bla", new Service[] { helloService } );
                system.stop();
        }
        
        public void testWithRequirementAndProvidedService() {
-               Map<RequiredServiceDescriptor, String> required = new HashMap<RequiredServiceDescriptor, String>();
-               required.put(new DefaultRequiredServiceDescriptor("hello", HelloService.class),
+               Map<RequiredInterfaceDescriptor, String> required = new HashMap<RequiredInterfaceDescriptor, String>();
+               required.put(new DefaultRequiredInterfaceDescriptor("hello", HelloService.class),
                                "helloService");
-               Map<String,ProvidedServiceDescriptor> provided = new HashMap<String, ProvidedServiceDescriptor>();
-               provided.put("blaService", new DefaultProvidedServiceDescriptor("bla",
+               Map<String,ProvidedInterfaceDescriptor> provided = new HashMap<String, ProvidedInterfaceDescriptor>();
+               provided.put("blaService", new DefaultProvidedInterfaceDescriptor("bla",
                                BlaService.class));
 
                SpringSystem system = new SpringSystem("system", _registry,
@@ -99,7 +99,7 @@ public class SpringSystemTest extends TestCase {
                                provided, required);
                
                HelloService helloObject = new HelloService("ladida"); 
-               Service helloService = _registry.register(new DefaultProvidedServiceDescriptor("hello", HelloService.class), helloObject);
+               Service helloService = _registry.register(new DefaultProvidedInterfaceDescriptor("hello", HelloService.class), helloObject);
                Service[] services = system.start("Bla", new Service[] { helloService } );
                assertEquals(1, services.length);