(no commit message)
authorerik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Fri, 4 Apr 2008 19:09:48 +0000 (19:09 +0000)
committererik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Fri, 4 Apr 2008 19:09:48 +0000 (19:09 +0000)
18 files changed:
trunk/system/general/src/main/java/org/wamblee/system/AbstractComponent.java
trunk/system/general/src/main/java/org/wamblee/system/Component.java
trunk/system/general/src/main/java/org/wamblee/system/Container.java
trunk/system/general/src/main/java/org/wamblee/system/DefaultProvidedInterfaceDescriptor.java
trunk/system/general/src/main/java/org/wamblee/system/DefaultRequiredInterfaceDescriptor.java
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/ProvidedInterface.java [moved from trunk/system/general/src/main/java/org/wamblee/system/ProvidedInterfaceDescriptor.java with 88% similarity]
trunk/system/general/src/main/java/org/wamblee/system/RequiredInterface.java [moved from trunk/system/general/src/main/java/org/wamblee/system/RequiredInterfaceDescriptor.java with 67% similarity]
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
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/SpringComponent.java
trunk/system/spring/src/test/java/org/wamblee/system/spring/SpringComponentTest.java

index 885cad6e1056980a5b2c769b2b9866ce8d7842fc..a78b46f1152720a10fd94b62da686a2a42776eb7 100644 (file)
@@ -21,9 +21,9 @@ public abstract class AbstractComponent implements Component {
        private Status _status; 
        private String _name;
        private ServiceRegistry _registry; 
-       private List<ProvidedInterfaceDescriptor> _provided;
-       private List<RequiredInterfaceDescriptor> _required;
-       private Map<ProvidedInterfaceDescriptor, Service> _running;
+       private List<ProvidedInterface> _provided;
+       private List<RequiredInterface> _required;
+       private Map<ProvidedInterface, Service> _running;
        
        /**
         * Constructs the subsystem.
@@ -37,16 +37,16 @@ public abstract class AbstractComponent implements Component {
         * @param aRequired
         *            Required services.
         */
-       protected AbstractComponent(String aName, ServiceRegistry aRegistry, ProvidedInterfaceDescriptor[] aProvided,
-                       RequiredInterfaceDescriptor[] aRequired) {
+       protected AbstractComponent(String aName, ServiceRegistry aRegistry, ProvidedInterface[] aProvided,
+                       RequiredInterface[] aRequired) {
                _status = Status.NOT_STARTED;
                _name = aName;
                _registry = aRegistry; 
-               _provided = new ArrayList<ProvidedInterfaceDescriptor>();
+               _provided = new ArrayList<ProvidedInterface>();
                _provided.addAll(Arrays.asList(aProvided));
-               _required = new ArrayList<RequiredInterfaceDescriptor>();
+               _required = new ArrayList<RequiredInterface>();
                _required.addAll(Arrays.asList(aRequired));
-               _running = new HashMap<ProvidedInterfaceDescriptor, Service>();
+               _running = new HashMap<ProvidedInterface, Service>();
        }
        
        @Override
@@ -64,13 +64,13 @@ public abstract class AbstractComponent implements Component {
        }
 
        @Override
-       public final ProvidedInterfaceDescriptor[] getProvidedServices() {
-               return _provided.toArray(new ProvidedInterfaceDescriptor[0]);
+       public final ProvidedInterface[] getProvidedServices() {
+               return _provided.toArray(new ProvidedInterface[0]);
        }
 
        @Override
-       public final RequiredInterfaceDescriptor[] getRequiredServices() {
-               return _required.toArray(new RequiredInterfaceDescriptor[0]);
+       public final RequiredInterface[] getRequiredServices() {
+               return _required.toArray(new RequiredInterface[0]);
        }
 
        @Override
@@ -102,7 +102,7 @@ public abstract class AbstractComponent implements Component {
         *            Service.
         */
        protected final void addService(String aContext,
-                       ProvidedInterfaceDescriptor aDescriptor, Object aService) {
+                       ProvidedInterface aDescriptor, Object aService) {
                LOG.info(aContext + ": service '" + aService + "' started.");
                Service svc = getRegistry().register(aDescriptor, aService);
                _running.put(svc.getDescriptor(), svc);
index afbed94cd677fb04e8e049cddd25d3e53132b756..e72dd7f0b37978da6452701d0f32f282fe894ccd 100644 (file)
@@ -28,13 +28,13 @@ public interface Component {
         * Gets a description of the provided interfaces. 
         * @return Provided interfaces. 
         */
-       ProvidedInterfaceDescriptor[] getProvidedServices();
+       ProvidedInterface[] getProvidedServices();
        
        /**
         * Gets a description of the required interfaces. 
         * @return Required interfaces. 
         */
-       RequiredInterfaceDescriptor[] getRequiredServices();
+       RequiredInterface[] getRequiredServices();
 
        
        /**
index ee3a053595db2d7a7444d091db19947b0cd4c527..a23a7373aba0b9635ec9ad4e7c9b5d802d753281 100644 (file)
@@ -29,7 +29,7 @@ public class Container extends AbstractComponent {
         * @param aRequired Required services by the system. 
         */
        public Container(String aName, ServiceRegistry aRegistry, Component[] aSystems,
-                       ProvidedInterfaceDescriptor[] aProvided, RequiredInterfaceDescriptor[] aRequired) {
+                       ProvidedInterface[] aProvided, RequiredInterface[] aRequired) {
                super(aName, aRegistry, aProvided, aRequired);
                _systems = aSystems;
                validate();
@@ -42,24 +42,24 @@ public class Container extends AbstractComponent {
         * Also logs a warning in case of superfluous requirements.  
         */
        private void validate() {
-               List<ProvidedInterfaceDescriptor> provided = new ArrayList<ProvidedInterfaceDescriptor>();
+               List<ProvidedInterface> provided = new ArrayList<ProvidedInterface>();
                for (Component system : _systems) {
                        provided.addAll(Arrays.asList(system.getProvidedServices()));
                }
 
-               List<RequiredInterfaceDescriptor> required = new ArrayList<RequiredInterfaceDescriptor>();
+               List<RequiredInterface> required = new ArrayList<RequiredInterface>();
                for (Component system : _systems) {
                        required.addAll(Arrays.asList(system.getRequiredServices()));
                }
 
-               for (ProvidedInterfaceDescriptor service : getProvidedServices()) {
+               for (ProvidedInterface service : getProvidedServices()) {
                        if (!(provided.contains(service))) {
                                throw new SystemAssemblyException(getName() + ": Service '" + service
                                                + "' is not provided by any of the subsystems");
                        }
                }
 
-               for (RequiredInterfaceDescriptor service : getRequiredServices()) {
+               for (RequiredInterface service : getRequiredServices()) {
                        if (!(required.contains(service))) {
                                info("Service '"
                                                + service
@@ -67,16 +67,16 @@ public class Container extends AbstractComponent {
                        }
                }
 
-               List<RequiredInterfaceDescriptor> reallyRequired = new ArrayList<RequiredInterfaceDescriptor>(
+               List<RequiredInterface> reallyRequired = new ArrayList<RequiredInterface>(
                                required);
-               for (ProvidedInterfaceDescriptor service : provided) {
+               for (ProvidedInterface service : provided) {
                        reallyRequired.remove(service); 
                }
-               for (RequiredInterfaceDescriptor service: getRequiredServices()) { 
+               for (RequiredInterface service: getRequiredServices()) { 
                        reallyRequired.remove(service); 
                }
                String missingRequired = "";
-               for (RequiredInterfaceDescriptor service: reallyRequired) {
+               for (RequiredInterface service: reallyRequired) {
                        missingRequired += service + "\n";
                }
                if ( missingRequired.length() > 0 ) { 
@@ -86,12 +86,12 @@ public class Container extends AbstractComponent {
 
        @Override
        protected void doStart(String aContext, Service[] aRequiredServices) {
-               List<ProvidedInterfaceDescriptor> descriptors = new ArrayList<ProvidedInterfaceDescriptor>();
+               List<ProvidedInterface> descriptors = new ArrayList<ProvidedInterface>();
                for (Service service : aRequiredServices) {
                        descriptors.add(service.getDescriptor());
                }
                SystemAssembler assembler = new SystemAssembler(aContext + "." + getName(), _systems,
-                               descriptors.toArray(new ProvidedInterfaceDescriptor[0]));
+                               descriptors.toArray(new ProvidedInterface[0]));
                assembler.start(getRegistry(), aRequiredServices);
        }
        
index 31eb64bb06097d841153ff18c3c9b6cec612f783..2b51c60afc39cbfce5cb43d504714f1d4f2f82a3 100644 (file)
@@ -7,7 +7,7 @@ import java.util.Arrays;
  *
  * @author Erik Brakkee
  */
-public class DefaultProvidedInterfaceDescriptor implements ProvidedInterfaceDescriptor {
+public class DefaultProvidedInterfaceDescriptor implements ProvidedInterface {
        
        private String _name; 
        private Class[] _interfaces; 
index 08411f90ad260ec7c1ba9a8604fb244a46273d79..9e434c08d49c276a6d599f84cfbd162aa5036d04 100644 (file)
@@ -1,7 +1,7 @@
 package org.wamblee.system;
 
 public class DefaultRequiredInterfaceDescriptor extends DefaultProvidedInterfaceDescriptor
-               implements RequiredInterfaceDescriptor {
+               implements RequiredInterface {
 
        public DefaultRequiredInterfaceDescriptor(String aName, Class aInterface) {
                super(aName, aInterface);
@@ -12,7 +12,7 @@ public class DefaultRequiredInterfaceDescriptor extends DefaultProvidedInterface
        }
 
        @Override
-       public boolean implementedBy(ProvidedInterfaceDescriptor aDescriptor) {
+       public boolean implementedBy(ProvidedInterface aDescriptor) {
                Class[] provided = aDescriptor.getInterfaceTypes();
                for (Class required : getInterfaceTypes()) {
                        if ( !serviceProvided(required, provided)) { 
index dc266223d4699724895f1e7d2778d39ac66c2bf0..a8a2692e89233c32b7078936a824cc70dda59e5c 100644 (file)
@@ -8,7 +8,7 @@ package org.wamblee.system;
 public class DefaultService implements Service {
 
        private String _id;
-       private ProvidedInterfaceDescriptor _descriptor;
+       private ProvidedInterface _descriptor;
        private Object _service;
 
        /**
@@ -19,7 +19,7 @@ public class DefaultService implements Service {
         * @param aService
         *            Service.
         */
-       public DefaultService(String aId, ProvidedInterfaceDescriptor aDescriptor,
+       public DefaultService(String aId, ProvidedInterface aDescriptor,
                        Object aService) {
                _id = aId;
                _descriptor = aDescriptor;
@@ -32,7 +32,7 @@ public class DefaultService implements Service {
        }
 
        @Override
-       public ProvidedInterfaceDescriptor getDescriptor() {
+       public ProvidedInterface getDescriptor() {
                return _descriptor;
        }
 
index ae3f8b3240e8ac5652339e724b5f001538c7ec40..27d576e5a971a8c13bdb6c5185a1731f76c31566 100644 (file)
@@ -15,7 +15,7 @@ public class DefaultServiceRegistry implements ServiceRegistry {
        }
 
        @Override
-       public synchronized Service register(ProvidedInterfaceDescriptor aDescriptor,
+       public synchronized Service register(ProvidedInterface aDescriptor,
                        Object aService) {
                _count++;
                String id = "" + _count;
similarity index 88%
rename from trunk/system/general/src/main/java/org/wamblee/system/ProvidedInterfaceDescriptor.java
rename to trunk/system/general/src/main/java/org/wamblee/system/ProvidedInterface.java
index 9afe375219dd4d12d12d3bdcc1098d4d20d4bf29..11b566460b068e3f8ed0d9aff597b85103458a02 100644 (file)
@@ -7,7 +7,7 @@ import java.util.Collection;
  *  
  * @author Erik Brakkee
  */
-public interface ProvidedInterfaceDescriptor {
+public interface ProvidedInterface {
     
        /**
         * Symbolic name for the service as used by the subsystem.  
similarity index 67%
rename from trunk/system/general/src/main/java/org/wamblee/system/RequiredInterfaceDescriptor.java
rename to trunk/system/general/src/main/java/org/wamblee/system/RequiredInterface.java
index 9e86767a95c987465f092d259a9272b40a99e1f8..fd6074031e2b16f8374536a6bcd233889d312b36 100644 (file)
@@ -1,6 +1,6 @@
 package org.wamblee.system;
 
-public interface RequiredInterfaceDescriptor {
+public interface RequiredInterface {
 
        /**
         * Name for the interface. 
@@ -12,5 +12,5 @@ public interface RequiredInterfaceDescriptor {
         * @param aInterface Provided interface. 
         * @return
         */
-       boolean implementedBy(ProvidedInterfaceDescriptor aInterface);
+       boolean implementedBy(ProvidedInterface aInterface);
 }
index 63988f08943ca5a89f2604cad363a9f3e713b8f3..8624c0ccf85037f1e8c62c014135c8034f4ad4aa 100644 (file)
@@ -17,7 +17,7 @@ public interface Service {
         * Gets the descriptor of the service. 
         * @return Descriptor. 
         */
-       ProvidedInterfaceDescriptor getDescriptor(); 
+       ProvidedInterface getDescriptor(); 
        
        /**
         * Returns a reference to the running service. 
index 17294bbb3bf00124e9a7573464b87f3d0615f88a..7fe35063b591f1517e524c7ea65381969397c5ce 100644 (file)
@@ -2,7 +2,7 @@ package org.wamblee.system;
 
 public interface ServiceRegistry {
 
-       Service register(ProvidedInterfaceDescriptor aDescriptor, Object aService);
+       Service register(ProvidedInterface aDescriptor, Object aService);
        
        void remove(Service aService); 
        
index 561e3f9569ebcf39db1770a5bcda7ee517075e16..5cdb3890cc5a3b810345f0dc114b424d143af7e6 100644 (file)
@@ -24,28 +24,28 @@ public class SystemAssembler {
        private String _context;
        private Component[] _systems;
 
-       public static RequiredInterfaceDescriptor[] filterRequiredServices(
-                       ProvidedInterfaceDescriptor aProvided,
-                       Collection<RequiredInterfaceDescriptor> aDescriptors) {
-               List<RequiredInterfaceDescriptor> required = new ArrayList<RequiredInterfaceDescriptor>();
-               for (RequiredInterfaceDescriptor descriptor : aDescriptors) {
+       public static RequiredInterface[] filterRequiredServices(
+                       ProvidedInterface aProvided,
+                       Collection<RequiredInterface> aDescriptors) {
+               List<RequiredInterface> required = new ArrayList<RequiredInterface>();
+               for (RequiredInterface descriptor : aDescriptors) {
                        if (descriptor.implementedBy(aProvided)) {
                                required.add(descriptor);
                        }
                }
-               return required.toArray(new RequiredInterfaceDescriptor[0]);
+               return required.toArray(new RequiredInterface[0]);
        }
 
-       public static ProvidedInterfaceDescriptor[] filterProvidedServices(
-                       RequiredInterfaceDescriptor aRequired,
-                       Collection<ProvidedInterfaceDescriptor> aProvided) {
-               List<ProvidedInterfaceDescriptor> provided = new ArrayList<ProvidedInterfaceDescriptor>();
-               for (ProvidedInterfaceDescriptor descriptor : aProvided) {
+       public static ProvidedInterface[] filterProvidedServices(
+                       RequiredInterface aRequired,
+                       Collection<ProvidedInterface> aProvided) {
+               List<ProvidedInterface> provided = new ArrayList<ProvidedInterface>();
+               for (ProvidedInterface descriptor : aProvided) {
                        if (aRequired.implementedBy(descriptor)) {
                                provided.add(descriptor);
                        }
                }
-               return provided.toArray(new ProvidedInterfaceDescriptor[0]);
+               return provided.toArray(new ProvidedInterface[0]);
        }
 
        /**
@@ -58,7 +58,7 @@ public class SystemAssembler {
         *            that this assembler manages.
         */
        public SystemAssembler(Component[] aSystems,
-                       ProvidedInterfaceDescriptor[] aAvailableServices) {
+                       ProvidedInterface[] aAvailableServices) {
                this(ROOT_CONTEXT_NAME, aSystems, aAvailableServices);
        }
 
@@ -74,7 +74,7 @@ public class SystemAssembler {
         *            that this assembler manages.
         */
        public SystemAssembler(String aContext, Component[] aSystems,
-                       ProvidedInterfaceDescriptor[] aAvailableServices) {
+                       ProvidedInterface[] 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(ProvidedInterfaceDescriptor[] aDescriptors)
+       private void validate(ProvidedInterface[] aDescriptors)
                        throws SystemAssemblyException {
 
-               List<ProvidedInterfaceDescriptor> allProvided = new ArrayList<ProvidedInterfaceDescriptor>();
-               for (ProvidedInterfaceDescriptor descriptor : aDescriptors) {
+               List<ProvidedInterface> allProvided = new ArrayList<ProvidedInterface>();
+               for (ProvidedInterface descriptor : aDescriptors) {
                        allProvided.add(descriptor);
                }
                for (Component system : _systems) {
                        // Check if all required services are already provided by earlier
                        // systems.
-                       RequiredInterfaceDescriptor[] required = system.getRequiredServices();
+                       RequiredInterface[] required = system.getRequiredServices();
 
-                       for (RequiredInterfaceDescriptor descriptor : required) {
-                               ProvidedInterfaceDescriptor[] filtered = filterProvidedServices(
+                       for (RequiredInterface descriptor : required) {
+                               ProvidedInterface[] filtered = filterProvidedServices(
                                                descriptor, allProvided);
 
                                if (filtered.length == 0) {
@@ -120,7 +120,7 @@ public class SystemAssembler {
                        }
 
                        // add all provided services
-                       ProvidedInterfaceDescriptor[] provided = system.getProvidedServices();
+                       ProvidedInterface[] provided = system.getProvidedServices();
                        allProvided.addAll(Arrays.asList(provided));
                }
        }
@@ -136,7 +136,7 @@ public class SystemAssembler {
         */
        public void start(ServiceRegistry aRegistry, Service[] aRequiredServices) {
                LOG.info("Starting '" + _context + "'");
-               Map<ProvidedInterfaceDescriptor, Service> allProvided = new HashMap<ProvidedInterfaceDescriptor, Service>();
+               Map<ProvidedInterface, Service> allProvided = new HashMap<ProvidedInterface, Service>();
 
                for (Service service : aRequiredServices) {
                        allProvided.put(service.getDescriptor(), service);
@@ -145,11 +145,11 @@ public class SystemAssembler {
                        
                        // Compose a list of the required services required for the subsystem.
                        
-                       RequiredInterfaceDescriptor[] descriptors = system
+                       RequiredInterface[] descriptors = system
                                        .getRequiredServices();
                        List<Service> services = new ArrayList<Service>();
-                       for (RequiredInterfaceDescriptor descriptor : descriptors) {
-                               ProvidedInterfaceDescriptor[] provided = filterProvidedServices(
+                       for (RequiredInterface descriptor : descriptors) {
+                               ProvidedInterface[] provided = filterProvidedServices(
                                                descriptor, allProvided.keySet());
                                services.add(allProvided.get(provided[0]));
                        }
index 0ebf001841e0a588ef42397ab87a78eb0dc01b72..3825c98962614eaae400c3c68ea1db230b981638 100644 (file)
@@ -3,14 +3,14 @@ package org.wamblee.system;
 import javax.sql.DataSource;
 
 public class Application extends AbstractComponent {
-       private static final RequiredInterfaceDescriptor[] REQUIRED = 
-               new RequiredInterfaceDescriptor[] { 
+       private static final RequiredInterface[] REQUIRED = 
+               new RequiredInterface[] { 
                        new DefaultRequiredInterfaceDescriptor("datasource", DataSource.class), 
                        new DefaultRequiredInterfaceDescriptor("integer", Integer.class)
        };
        
        public Application(ServiceRegistry aRegistry) {
-               super("application", aRegistry, new ProvidedInterfaceDescriptor[0], REQUIRED); 
+               super("application", aRegistry, new ProvidedInterface[0], REQUIRED); 
        }
 
        @Override
index dd3451dbc1cf0ed8427e630d58eccacca0e53257..f74557be5c56eeca368e3e7d72215ac9efb73514 100644 (file)
@@ -7,27 +7,27 @@ 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);
+               ProvidedInterface provided = new DefaultProvidedInterfaceDescriptor("name", String.class);
+               RequiredInterface 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);
+               ProvidedInterface provided = new DefaultProvidedInterfaceDescriptor("name", Integer.class);
+               RequiredInterface 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);
+               ProvidedInterface provided = new DefaultProvidedInterfaceDescriptor("name", String.class);
+               RequiredInterface required = new DefaultRequiredInterfaceDescriptor("name", Number.class);
                assertFalse(required.implementedBy(provided));
        }
        
        public void testOneRequiredMultipleProvidedMatch() { 
-               ProvidedInterfaceDescriptor provided = new DefaultProvidedInterfaceDescriptor("name", 
+               ProvidedInterface provided = new DefaultProvidedInterfaceDescriptor("name", 
                                new Class[] { String.class, Integer.class} );
-               RequiredInterfaceDescriptor required = new DefaultRequiredInterfaceDescriptor("name", String.class);
+               RequiredInterface required = new DefaultRequiredInterfaceDescriptor("name", String.class);
                assertTrue(required.implementedBy(provided));
        }
        
@@ -39,25 +39,25 @@ public class DefaultInterfaceDescriptorTest extends TestCase {
        }
        
        public void testMultipleRequiredOneProvidedMatch() { 
-               ProvidedInterfaceDescriptor provided = new DefaultProvidedInterfaceDescriptor("name", 
+               ProvidedInterface provided = new DefaultProvidedInterfaceDescriptor("name", 
                                MyMultiple.class );
-               RequiredInterfaceDescriptor required = new DefaultRequiredInterfaceDescriptor("name", 
+               RequiredInterface required = new DefaultRequiredInterfaceDescriptor("name", 
                                new Class[] {Runnable.class, Serializable.class} );
                assertTrue(required.implementedBy(provided));
        }
        
        public void testMultipleRequiredOneProvidedNoMatch() { 
-               ProvidedInterfaceDescriptor provided = new DefaultProvidedInterfaceDescriptor("name", 
+               ProvidedInterface provided = new DefaultProvidedInterfaceDescriptor("name", 
                                MyMultiple.class );
-               RequiredInterfaceDescriptor required = new DefaultRequiredInterfaceDescriptor("name", 
+               RequiredInterface required = new DefaultRequiredInterfaceDescriptor("name", 
                                new Class[] { String.class, Runnable.class} );
                assertFalse(required.implementedBy(provided));
        }
        
        public void testMultipleRequiredMultipleProvidedMatch() { 
-               ProvidedInterfaceDescriptor provided = new DefaultProvidedInterfaceDescriptor("name", 
+               ProvidedInterface provided = new DefaultProvidedInterfaceDescriptor("name", 
                                new Class[] { Runnable.class, Serializable.class, String.class}  );
-               RequiredInterfaceDescriptor required = new DefaultRequiredInterfaceDescriptor("name", 
+               RequiredInterface required = new DefaultRequiredInterfaceDescriptor("name", 
                                new Class[] {Runnable.class, Serializable.class} );
                assertTrue(required.implementedBy(provided));
        }
index ebc432657c88c227197f1ec0fd46d92964adc64e..e2bd2b8053731fc0b603d1e297a9116f69fa9b61 100644 (file)
@@ -5,14 +5,14 @@ import javax.sql.DataSource;
 
 public class Environment extends AbstractComponent {
        
-       private static final ProvidedInterfaceDescriptor[] PROVIDED = 
-               new ProvidedInterfaceDescriptor[] { 
+       private static final ProvidedInterface[] PROVIDED = 
+               new ProvidedInterface[] { 
                        new DefaultProvidedInterfaceDescriptor("datasource", DataSource.class), 
                        new DefaultProvidedInterfaceDescriptor("integer", Integer.class)
        };
        
        public Environment(ServiceRegistry aRegistry) { 
-               super("environment", aRegistry, PROVIDED, new RequiredInterfaceDescriptor[0]);
+               super("environment", aRegistry, PROVIDED, new RequiredInterface[0]);
        }
        
        @Override
index edd4bc2c0a9577def246f3401442415635bc6c08..c372bf045b13c236f7923c25f6afd4525ee02dae 100644 (file)
@@ -27,47 +27,47 @@ public class SystemAssemblerTest extends TestCase {
        }
 
        public void testFilterProvided() {
-               RequiredInterfaceDescriptor req1 = new DefaultRequiredInterfaceDescriptor(
+               RequiredInterface req1 = new DefaultRequiredInterfaceDescriptor(
                                "name", Runnable.class);
-               RequiredInterfaceDescriptor req2 = new DefaultRequiredInterfaceDescriptor(
+               RequiredInterface req2 = new DefaultRequiredInterfaceDescriptor(
                                "name", Serializable.class);
-               ProvidedInterfaceDescriptor prov1 = new DefaultProvidedInterfaceDescriptor(
+               ProvidedInterface prov1 = new DefaultProvidedInterfaceDescriptor(
                                "name", Runnable.class);
-               ProvidedInterfaceDescriptor prov2 = new DefaultProvidedInterfaceDescriptor(
+               ProvidedInterface prov2 = new DefaultProvidedInterfaceDescriptor(
                                "name", Serializable.class);
-               ProvidedInterfaceDescriptor prov3 = new DefaultProvidedInterfaceDescriptor(
+               ProvidedInterface prov3 = new DefaultProvidedInterfaceDescriptor(
                                "name", MyMultiple.class);
 
-               AssertionUtils.assertEquals(new RequiredInterfaceDescriptor[] { req1 },
+               AssertionUtils.assertEquals(new RequiredInterface[] { req1 },
                                SystemAssembler.filterRequiredServices(prov1, Arrays
-                                               .asList(new RequiredInterfaceDescriptor[] { req1 })));
-               AssertionUtils.assertEquals(new RequiredInterfaceDescriptor[] { req1 },
+                                               .asList(new RequiredInterface[] { req1 })));
+               AssertionUtils.assertEquals(new RequiredInterface[] { req1 },
                                SystemAssembler.filterRequiredServices(prov1,
-                                               Arrays.asList(new RequiredInterfaceDescriptor[] { req1,
+                                               Arrays.asList(new RequiredInterface[] { req1,
                                                                req2 })));
-               AssertionUtils.assertEquals(new RequiredInterfaceDescriptor[] { req1,
+               AssertionUtils.assertEquals(new RequiredInterface[] { req1,
                                req2 }, SystemAssembler.filterRequiredServices(prov3, Arrays
-                               .asList(new RequiredInterfaceDescriptor[] { req1, req2 })));
+                               .asList(new RequiredInterface[] { req1, req2 })));
 
                AssertionUtils.assertEquals(
-                               new ProvidedInterfaceDescriptor[] { prov1 },
+                               new ProvidedInterface[] { prov1 },
                                SystemAssembler.filterProvidedServices(req1, Arrays
-                                               .asList(new ProvidedInterfaceDescriptor[] { prov1 })));
+                                               .asList(new ProvidedInterface[] { prov1 })));
                AssertionUtils.assertEquals(
-                               new ProvidedInterfaceDescriptor[] { prov1 }, SystemAssembler
+                               new ProvidedInterface[] { prov1 }, SystemAssembler
                                                .filterProvidedServices(req1, Arrays
-                                                               .asList(new ProvidedInterfaceDescriptor[] {
+                                                               .asList(new ProvidedInterface[] {
                                                                                prov1, prov2 })));
-               AssertionUtils.assertEquals(new ProvidedInterfaceDescriptor[] { prov1,
+               AssertionUtils.assertEquals(new ProvidedInterface[] { prov1,
                                prov3 }, SystemAssembler.filterProvidedServices(req1, Arrays
-                               .asList(new ProvidedInterfaceDescriptor[] { prov1, prov3 })));
+                               .asList(new ProvidedInterface[] { prov1, prov3 })));
        }
 
        public void testEnvironmentApplication() {
                Component environment = new Environment(_registry);
                Component application = new Application(_registry);
                SystemAssembler assembler = new SystemAssembler(new Component[] {
-                               environment, application }, new ProvidedInterfaceDescriptor[0]);
+                               environment, application }, new ProvidedInterface[0]);
                assembler.start(_registry, new Service[0]);
                Service[] envServices = environment.getRunningServices();
                assertEquals(2, envServices.length);
@@ -88,7 +88,7 @@ public class SystemAssemblerTest extends TestCase {
                        Component application = new Application(_registry);
                        SystemAssembler assembler = new SystemAssembler(new Component[] {
                                        application, environment },
-                                       new ProvidedInterfaceDescriptor[0]);
+                                       new ProvidedInterface[0]);
                        assembler.start(_registry, new Service[0]);
                } catch (SystemAssemblyException e) {
                        // e.printStackTrace();
@@ -103,13 +103,13 @@ public class SystemAssemblerTest extends TestCase {
                assertEquals(Status.NOT_STARTED, environment.getStatus());
                assertEquals(Status.NOT_STARTED, application.getStatus());
                Container system = new Container("all", _registry, new Component[] {
-                               environment, application }, new ProvidedInterfaceDescriptor[0],
-                               new RequiredInterfaceDescriptor[0]);
+                               environment, application }, new ProvidedInterface[0],
+                               new RequiredInterface[0]);
                assertEquals(Status.NOT_STARTED, system.getStatus());
                system.start("root", new Service[0]);
-               RequiredInterfaceDescriptor[] required = system.getRequiredServices();
+               RequiredInterface[] required = system.getRequiredServices();
                assertEquals(0, required.length);
-               ProvidedInterfaceDescriptor[] provided = system.getProvidedServices();
+               ProvidedInterface[] provided = system.getProvidedServices();
                assertEquals(0, provided.length);
                assertEquals(Status.RUNNING, environment.getStatus());
                assertEquals(Status.RUNNING, application.getStatus());
@@ -129,7 +129,7 @@ public class SystemAssemblerTest extends TestCase {
                                        "all",
                                        _registry,
                                        new Component[] { environment, application },
-                                       new ProvidedInterfaceDescriptor[] { new DefaultProvidedInterfaceDescriptor(
+                                       new ProvidedInterface[] { new DefaultProvidedInterfaceDescriptor(
                                                        "string", String.class) },
                                        new DefaultRequiredInterfaceDescriptor[0]);
                } catch (SystemAssemblyException e) {
@@ -145,13 +145,13 @@ public class SystemAssemblerTest extends TestCase {
                                "all",
                                _registry,
                                new Component[] { environment, application },
-                               new ProvidedInterfaceDescriptor[0],
-                               new RequiredInterfaceDescriptor[] { new DefaultRequiredInterfaceDescriptor(
+                               new ProvidedInterface[0],
+                               new RequiredInterface[] { new DefaultRequiredInterfaceDescriptor(
                                                "string", String.class) });
                system.start("root", new Service[0]);
-               RequiredInterfaceDescriptor[] required = system.getRequiredServices();
+               RequiredInterface[] required = system.getRequiredServices();
                assertEquals(1, required.length);
-               ProvidedInterfaceDescriptor[] provided = system.getProvidedServices();
+               ProvidedInterface[] provided = system.getProvidedServices();
                assertEquals(0, provided.length);
        }
 
@@ -161,7 +161,7 @@ public class SystemAssemblerTest extends TestCase {
                        Component application = new Application(_registry);
                        Container system = new Container("all", _registry,
                                        new Component[] { application },
-                                       new ProvidedInterfaceDescriptor[0], application
+                                       new ProvidedInterface[0], application
                                                        .getRequiredServices());
                        system.start("root", new Service[0]);
                } catch (SystemAssemblyException e) {
@@ -177,13 +177,13 @@ public class SystemAssemblerTest extends TestCase {
                Component application = new Application(_registry);
                Container system = new Container("all", _registry,
                                new Component[] { application },
-                               new ProvidedInterfaceDescriptor[0], application
+                               new ProvidedInterface[0], application
                                                .getRequiredServices());
                Service[] envServices = environment.start("env", new Service[0]);
                system.start("root", envServices);
-               RequiredInterfaceDescriptor[] required = system.getRequiredServices();
+               RequiredInterface[] required = system.getRequiredServices();
                assertEquals(2, required.length);
-               ProvidedInterfaceDescriptor[] provided = system.getProvidedServices();
+               ProvidedInterface[] provided = system.getProvidedServices();
                assertEquals(0, provided.length);
 
        }
@@ -195,7 +195,7 @@ public class SystemAssemblerTest extends TestCase {
                        Component application = new Application(_registry);
                        SystemAssembler assembler = new SystemAssembler(new Component[] {
                                        environment1, environment2, application },
-                                       new ProvidedInterfaceDescriptor[0]);
+                                       new ProvidedInterface[0]);
                        assembler.start(_registry, new Service[0]);
 
                } catch (SystemAssemblyException e) {
@@ -209,8 +209,8 @@ public class SystemAssemblerTest extends TestCase {
                        Component application = new Application(_registry);
                        Container system = new Container("all", _registry,
                                        new Component[] { application },
-                                       new ProvidedInterfaceDescriptor[0],
-                                       new RequiredInterfaceDescriptor[0]);
+                                       new ProvidedInterface[0],
+                                       new RequiredInterface[0]);
                        system.start("root", new Service[0]);
                } catch (SystemAssemblyException e) {
                        return;
index a5dd685d4d6074be65811bac4dd3f1197956edfb..b9a2648c7ca706838795538637e0c0d584aa3271 100644 (file)
@@ -11,8 +11,8 @@ import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 import org.springframework.context.support.GenericApplicationContext;
 import org.wamblee.system.AbstractComponent;
-import org.wamblee.system.ProvidedInterfaceDescriptor;
-import org.wamblee.system.RequiredInterfaceDescriptor;
+import org.wamblee.system.ProvidedInterface;
+import org.wamblee.system.RequiredInterface;
 import org.wamblee.system.Service;
 import org.wamblee.system.ServiceRegistry;
 import org.wamblee.system.SystemAssembler;
@@ -34,8 +34,8 @@ public class SpringComponent extends AbstractComponent {
 
        private Properties _properties; 
        private String[] _configFiles;
-       private Map<String, ProvidedInterfaceDescriptor> _provided;
-       private Map<RequiredInterfaceDescriptor, String> _required;
+       private Map<String, ProvidedInterface> _provided;
+       private Map<RequiredInterface, String> _required;
        /**
         * Parent application context containing required services.
         */
@@ -63,10 +63,10 @@ public class SpringComponent extends AbstractComponent {
         *            service.
         */
        public SpringComponent(String aName, ServiceRegistry aRegistry, String[] aConfigFiles,
-                       Map<String, ProvidedInterfaceDescriptor> aProvided,
-                       Map<RequiredInterfaceDescriptor, String> aRequired) {
-               super(aName, aRegistry, aProvided.values().toArray(new ProvidedInterfaceDescriptor[0]),
-                               aRequired.keySet().toArray(new RequiredInterfaceDescriptor[0]));
+                       Map<String, ProvidedInterface> aProvided,
+                       Map<RequiredInterface, String> aRequired) {
+               super(aName, aRegistry, aProvided.values().toArray(new ProvidedInterface[0]),
+                               aRequired.keySet().toArray(new RequiredInterface[0]));
                _properties = new Properties(); 
                _configFiles = aConfigFiles;
                _provided = aProvided;
@@ -141,10 +141,10 @@ public class SpringComponent extends AbstractComponent {
 
                for (Service svc: aRequiredServices) { 
                        String id = svc.getId();
-                       ProvidedInterfaceDescriptor descriptor = svc.getDescriptor();
-                       RequiredInterfaceDescriptor[] requiredServices = SystemAssembler.filterRequiredServices(descriptor,
+                       ProvidedInterface descriptor = svc.getDescriptor();
+                       RequiredInterface[] requiredServices = SystemAssembler.filterRequiredServices(descriptor,
                                        _required.keySet()); 
-                       for (RequiredInterfaceDescriptor required: requiredServices) { 
+                       for (RequiredInterface required: requiredServices) { 
                                String beanName = _required.get(required);
                                ConstructorArgumentValues cargs = new ConstructorArgumentValues();
                                cargs.addGenericArgumentValue(id); 
index f83e2ec116a885cb7a78dd23f4f03a59e95635f9..b0f7f8abd82734244288475825599f7c98523a90 100644 (file)
@@ -11,8 +11,8 @@ import org.wamblee.io.ClassPathResource;
 import org.wamblee.system.DefaultProvidedInterfaceDescriptor;
 import org.wamblee.system.DefaultRequiredInterfaceDescriptor;
 import org.wamblee.system.DefaultServiceRegistry;
-import org.wamblee.system.ProvidedInterfaceDescriptor;
-import org.wamblee.system.RequiredInterfaceDescriptor;
+import org.wamblee.system.ProvidedInterface;
+import org.wamblee.system.RequiredInterface;
 import org.wamblee.system.Service;
 import org.wamblee.system.ServiceRegistry;
 import org.wamblee.system.SystemAssemblyException;
@@ -35,8 +35,8 @@ public class SpringComponentTest extends TestCase {
        public void testBlackboxSystem() {
                SpringComponent system = new SpringComponent("system", _registry,
                                new String[] { HELLO_SERVICE_SPRING_XML },
-                               new HashMap<String, ProvidedInterfaceDescriptor>(),
-                               new HashMap<RequiredInterfaceDescriptor, String>());
+                               new HashMap<String, ProvidedInterface>(),
+                               new HashMap<RequiredInterface, String>());
                system.start("Hello", new Service[0]);
                Service[] services = system.getRunningServices();
                assertEquals(0, services.length);
@@ -45,13 +45,13 @@ public class SpringComponentTest extends TestCase {
        }
 
        public void testOneProvidedService() {
-               Map<String, ProvidedInterfaceDescriptor> provided = new HashMap<String, ProvidedInterfaceDescriptor>();
+               Map<String, ProvidedInterface> provided = new HashMap<String, ProvidedInterface>();
                provided.put("helloService", new DefaultProvidedInterfaceDescriptor(
                                "hello", HelloService.class));
 
                SpringComponent system = new SpringComponent("system", _registry,
                                new String[] { HELLO_SERVICE_SPRING_XML }, provided,
-                               new HashMap<RequiredInterfaceDescriptor, String>());
+                               new HashMap<RequiredInterface, String>());
                system.start("Hello", new Service[0]);
                Service[] services = system.getRunningServices();
                assertEquals(1, services.length);
@@ -62,13 +62,13 @@ public class SpringComponentTest extends TestCase {
        }
        
        public void testWithProperties() throws IOException {
-               Map<String, ProvidedInterfaceDescriptor> provided = new HashMap<String, ProvidedInterfaceDescriptor>();
+               Map<String, ProvidedInterface> provided = new HashMap<String, ProvidedInterface>();
                provided.put("helloService", new DefaultProvidedInterfaceDescriptor(
                                "hello", HelloService.class));
                SpringComponent system = new SpringComponent("system", _registry,
                                new String[] { HELLO_SERVICE_SPRING_WITH_PROPERTIES_XML },
                                provided,
-                               new HashMap<RequiredInterfaceDescriptor, String>());
+                               new HashMap<RequiredInterface, String>());
                Properties props = new Properties();
                props.load(new ClassPathResource(PROPERTY_FILE).getInputStream());
                system.addProperties(props);
@@ -82,8 +82,8 @@ public class SpringComponentTest extends TestCase {
                try {
                        SpringComponent system = new SpringComponent("system", _registry,
                                        new String[] { HELLO_SERVICE_SPRING_WITH_REQS_XML },
-                                       new HashMap<String, ProvidedInterfaceDescriptor>(),
-                                       new HashMap<RequiredInterfaceDescriptor, String>());
+                                       new HashMap<String, ProvidedInterface>(),
+                                       new HashMap<RequiredInterface, String>());
                        system.start("Bla", new Service[0]);
                } catch (SystemAssemblyException e) {
                        //e.printStackTrace();
@@ -93,12 +93,12 @@ public class SpringComponentTest extends TestCase {
        }
 
        public void testWithRequirement() {
-               Map<RequiredInterfaceDescriptor, String> required = new HashMap<RequiredInterfaceDescriptor, String>();
+               Map<RequiredInterface, String> required = new HashMap<RequiredInterface, String>();
                required.put(new DefaultRequiredInterfaceDescriptor("hello", HelloService.class),
                                "helloService");
                SpringComponent system = new SpringComponent("system", _registry,
                                new String[] { HELLO_SERVICE_SPRING_WITH_REQS_XML },
-                               new HashMap<String, ProvidedInterfaceDescriptor>(), required);
+                               new HashMap<String, ProvidedInterface>(), required);
                
                HelloService helloObject = new HelloService("ladida"); 
                Service helloService = _registry.register(new DefaultProvidedInterfaceDescriptor("hello", HelloService.class), helloObject);
@@ -107,10 +107,10 @@ public class SpringComponentTest extends TestCase {
        }
        
        public void testWithRequirementAndProvidedService() {
-               Map<RequiredInterfaceDescriptor, String> required = new HashMap<RequiredInterfaceDescriptor, String>();
+               Map<RequiredInterface, String> required = new HashMap<RequiredInterface, String>();
                required.put(new DefaultRequiredInterfaceDescriptor("hello", HelloService.class),
                                "helloService");
-               Map<String,ProvidedInterfaceDescriptor> provided = new HashMap<String, ProvidedInterfaceDescriptor>();
+               Map<String,ProvidedInterface> provided = new HashMap<String, ProvidedInterface>();
                provided.put("blaService", new DefaultProvidedInterfaceDescriptor("bla",
                                BlaService.class));