From: erik Date: Mon, 31 Mar 2008 16:53:44 +0000 (+0000) Subject: rename subsystem to component. X-Git-Tag: wamblee-utils-0.2@603~211 X-Git-Url: http://wamblee.org/gitweb/?a=commitdiff_plain;h=b3b089769ce42270c3915f80d056a7955309ce3a;p=utils rename subsystem to component. --- diff --git a/trunk/system/general/src/main/java/org/wamblee/system/AbstractSubSystem.java b/trunk/system/general/src/main/java/org/wamblee/system/AbstractComponent.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 6e9cebbd..5c96b549 100644 --- a/trunk/system/general/src/main/java/org/wamblee/system/AbstractSubSystem.java +++ b/trunk/system/general/src/main/java/org/wamblee/system/AbstractComponent.java @@ -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 _provided; - private List _required; - private Map _running; + private List _provided; + private List _required; + private Map _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(); + _provided = new ArrayList(); _provided.addAll(Arrays.asList(aProvided)); - _required = new ArrayList(); + _required = new ArrayList(); _required.addAll(Arrays.asList(aRequired)); - _running = new HashMap(); + _running = new HashMap(); } @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); diff --git a/trunk/system/general/src/main/java/org/wamblee/system/AbstractServiceDescriptor.java b/trunk/system/general/src/main/java/org/wamblee/system/AbstractInterfaceDescriptor.java 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 f31e4976..361cd2ec 100644 --- a/trunk/system/general/src/main/java/org/wamblee/system/AbstractServiceDescriptor.java +++ b/trunk/system/general/src/main/java/org/wamblee/system/AbstractInterfaceDescriptor.java @@ -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; } diff --git a/trunk/system/general/src/main/java/org/wamblee/system/SubSystem.java b/trunk/system/general/src/main/java/org/wamblee/system/Component.java 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 4e79ed76..6a31e01d 100644 --- a/trunk/system/general/src/main/java/org/wamblee/system/SubSystem.java +++ b/trunk/system/general/src/main/java/org/wamblee/system/Component.java @@ -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(); /** diff --git a/trunk/system/general/src/main/java/org/wamblee/system/CompositeSystem.java b/trunk/system/general/src/main/java/org/wamblee/system/CompositeSystem.java index db94f738..24547a93 100644 --- a/trunk/system/general/src/main/java/org/wamblee/system/CompositeSystem.java +++ b/trunk/system/general/src/main/java/org/wamblee/system/CompositeSystem.java @@ -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 provided = new ArrayList(); - for (SubSystem system : _systems) { + List provided = new ArrayList(); + for (Component system : _systems) { provided.addAll(Arrays.asList(system.getProvidedServices())); } - List required = new ArrayList(); - for (SubSystem system : _systems) { + List required = new ArrayList(); + 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 reallyRequired = new ArrayList( + List reallyRequired = new ArrayList( 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 descriptors = new ArrayList(); + List descriptors = new ArrayList(); 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 index 00000000..97e62da6 --- /dev/null +++ b/trunk/system/general/src/main/java/org/wamblee/system/DefaultProvidedInterfaceDescriptor.java @@ -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 index c270cb80..00000000 --- a/trunk/system/general/src/main/java/org/wamblee/system/DefaultProvidedServiceDescriptor.java +++ /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); - } - -} diff --git a/trunk/system/general/src/main/java/org/wamblee/system/DefaultRequiredServiceDescriptor.java b/trunk/system/general/src/main/java/org/wamblee/system/DefaultRequiredInterfaceDescriptor.java 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 ad63cb4a..fbee3155 100644 --- a/trunk/system/general/src/main/java/org/wamblee/system/DefaultRequiredServiceDescriptor.java +++ b/trunk/system/general/src/main/java/org/wamblee/system/DefaultRequiredInterfaceDescriptor.java @@ -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)) { diff --git a/trunk/system/general/src/main/java/org/wamblee/system/DefaultService.java b/trunk/system/general/src/main/java/org/wamblee/system/DefaultService.java index 9e2e53f1..dc266223 100644 --- a/trunk/system/general/src/main/java/org/wamblee/system/DefaultService.java +++ b/trunk/system/general/src/main/java/org/wamblee/system/DefaultService.java @@ -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; } diff --git a/trunk/system/general/src/main/java/org/wamblee/system/DefaultServiceRegistry.java b/trunk/system/general/src/main/java/org/wamblee/system/DefaultServiceRegistry.java index 464c6be5..ae3f8b32 100644 --- a/trunk/system/general/src/main/java/org/wamblee/system/DefaultServiceRegistry.java +++ b/trunk/system/general/src/main/java/org/wamblee/system/DefaultServiceRegistry.java @@ -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; diff --git a/trunk/system/general/src/main/java/org/wamblee/system/ServiceDescriptor.java b/trunk/system/general/src/main/java/org/wamblee/system/InterfaceDescriptor.java 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 81032ac6..987a8595 100644 --- a/trunk/system/general/src/main/java/org/wamblee/system/ServiceDescriptor.java +++ b/trunk/system/general/src/main/java/org/wamblee/system/InterfaceDescriptor.java @@ -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 index 00000000..1af949c9 --- /dev/null +++ b/trunk/system/general/src/main/java/org/wamblee/system/ProvidedInterfaceDescriptor.java @@ -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 index 94eb43d0..00000000 --- a/trunk/system/general/src/main/java/org/wamblee/system/ProvidedServiceDescriptor.java +++ /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 index 00000000..1a1237b8 --- /dev/null +++ b/trunk/system/general/src/main/java/org/wamblee/system/RequiredInterfaceDescriptor.java @@ -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 index 1c799236..00000000 --- a/trunk/system/general/src/main/java/org/wamblee/system/RequiredServiceDescriptor.java +++ /dev/null @@ -1,6 +0,0 @@ -package org.wamblee.system; - -public interface RequiredServiceDescriptor extends ServiceDescriptor { - - boolean implementedBy(ProvidedServiceDescriptor aDescriptor); -} diff --git a/trunk/system/general/src/main/java/org/wamblee/system/Service.java b/trunk/system/general/src/main/java/org/wamblee/system/Service.java index 1721f401..63988f08 100644 --- a/trunk/system/general/src/main/java/org/wamblee/system/Service.java +++ b/trunk/system/general/src/main/java/org/wamblee/system/Service.java @@ -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. diff --git a/trunk/system/general/src/main/java/org/wamblee/system/ServiceRegistry.java b/trunk/system/general/src/main/java/org/wamblee/system/ServiceRegistry.java index 9fda9eef..17294bbb 100644 --- a/trunk/system/general/src/main/java/org/wamblee/system/ServiceRegistry.java +++ b/trunk/system/general/src/main/java/org/wamblee/system/ServiceRegistry.java @@ -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); diff --git a/trunk/system/general/src/main/java/org/wamblee/system/SystemAssembler.java b/trunk/system/general/src/main/java/org/wamblee/system/SystemAssembler.java index 7b45f8b1..561e3f95 100644 --- a/trunk/system/general/src/main/java/org/wamblee/system/SystemAssembler.java +++ b/trunk/system/general/src/main/java/org/wamblee/system/SystemAssembler.java @@ -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 aDescriptors) { - List required = new ArrayList(); - for (RequiredServiceDescriptor descriptor : aDescriptors) { + public static RequiredInterfaceDescriptor[] filterRequiredServices( + ProvidedInterfaceDescriptor aProvided, + Collection aDescriptors) { + List required = new ArrayList(); + 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 aProvided) { - List provided = new ArrayList(); - for (ProvidedServiceDescriptor descriptor : aProvided) { + public static ProvidedInterfaceDescriptor[] filterProvidedServices( + RequiredInterfaceDescriptor aRequired, + Collection aProvided) { + List provided = new ArrayList(); + 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 allProvided = new ArrayList(); - for (ProvidedServiceDescriptor descriptor : aDescriptors) { + List allProvided = new ArrayList(); + 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 allProvided = new HashMap(); + Map allProvided = new HashMap(); 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 services = new ArrayList(); - for (RequiredServiceDescriptor descriptor : descriptors) { - ProvidedServiceDescriptor[] provided = filterProvidedServices( + for (RequiredInterfaceDescriptor descriptor : descriptors) { + ProvidedInterfaceDescriptor[] provided = filterProvidedServices( descriptor, allProvided.keySet()); services.add(allProvided.get(provided[0])); } diff --git a/trunk/system/general/src/test/java/org/wamblee/system/Application.java b/trunk/system/general/src/test/java/org/wamblee/system/Application.java index 07b1e34c..47c92af8 100644 --- a/trunk/system/general/src/test/java/org/wamblee/system/Application.java +++ b/trunk/system/general/src/test/java/org/wamblee/system/Application.java @@ -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 index 00000000..dd3451db --- /dev/null +++ b/trunk/system/general/src/test/java/org/wamblee/system/DefaultInterfaceDescriptorTest.java @@ -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 index b222d28d..00000000 --- a/trunk/system/general/src/test/java/org/wamblee/system/DefaultServiceDescriptorTest.java +++ /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)); - } - - -} diff --git a/trunk/system/general/src/test/java/org/wamblee/system/Environment.java b/trunk/system/general/src/test/java/org/wamblee/system/Environment.java index 56118ccb..76d3a3c1 100644 --- a/trunk/system/general/src/test/java/org/wamblee/system/Environment.java +++ b/trunk/system/general/src/test/java/org/wamblee/system/Environment.java @@ -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 diff --git a/trunk/system/general/src/test/java/org/wamblee/system/SystemAssemblerTest.java b/trunk/system/general/src/test/java/org/wamblee/system/SystemAssemblerTest.java index 2dba056e..885cff39 100644 --- a/trunk/system/general/src/test/java/org/wamblee/system/SystemAssemblerTest.java +++ b/trunk/system/general/src/test/java/org/wamblee/system/SystemAssemblerTest.java @@ -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(); } + } diff --git a/trunk/system/spring/src/main/java/org/wamblee/system/spring/SpringSystem.java b/trunk/system/spring/src/main/java/org/wamblee/system/spring/SpringSystem.java index 5b7bfce6..7a8b513e 100644 --- a/trunk/system/spring/src/main/java/org/wamblee/system/spring/SpringSystem.java +++ b/trunk/system/spring/src/main/java/org/wamblee/system/spring/SpringSystem.java @@ -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 REGISTRY = new ThreadLocal(); private String[] _configFiles; - private Map _provided; - private Map _required; + private Map _provided; + private Map _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 aProvided, - Map aRequired) { - super(aName, aRegistry, aProvided.values().toArray(new ServiceDescriptor[0]), - aRequired.keySet().toArray(new ServiceDescriptor[0])); + Map aProvided, + Map 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); diff --git a/trunk/system/spring/src/test/java/org/wamblee/system/spring/SpringSystemTest.java b/trunk/system/spring/src/test/java/org/wamblee/system/spring/SpringSystemTest.java index e12e0113..1543b7ab 100644 --- a/trunk/system/spring/src/test/java/org/wamblee/system/spring/SpringSystemTest.java +++ b/trunk/system/spring/src/test/java/org/wamblee/system/spring/SpringSystemTest.java @@ -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(), - new HashMap()); + new HashMap(), + new HashMap()); 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 provided = new HashMap(); - provided.put("helloService", new DefaultProvidedServiceDescriptor( + Map provided = new HashMap(); + provided.put("helloService", new DefaultProvidedInterfaceDescriptor( "hello", HelloService.class)); SpringSystem system = new SpringSystem("system", _registry, new String[] { HELLO_SERVICE_SPRING_XML }, provided, - new HashMap()); + new HashMap()); 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(), - new HashMap()); + new HashMap(), + new HashMap()); system.start("Bla", new Service[0]); } catch (SystemAssemblyException e) { //e.printStackTrace(); @@ -73,25 +73,25 @@ public class SpringSystemTest extends TestCase { } public void testWithRequirement() { - Map required = new HashMap(); - required.put(new DefaultRequiredServiceDescriptor("hello", HelloService.class), + Map required = new HashMap(); + required.put(new DefaultRequiredInterfaceDescriptor("hello", HelloService.class), "helloService"); SpringSystem system = new SpringSystem("system", _registry, new String[] { HELLO_SERVICE_SPRING_WITH_REQS_XML }, - new HashMap(), required); + new HashMap(), 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 required = new HashMap(); - required.put(new DefaultRequiredServiceDescriptor("hello", HelloService.class), + Map required = new HashMap(); + required.put(new DefaultRequiredInterfaceDescriptor("hello", HelloService.class), "helloService"); - Map provided = new HashMap(); - provided.put("blaService", new DefaultProvidedServiceDescriptor("bla", + Map provided = new HashMap(); + 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);