rename service to interface.
authorerik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Wed, 9 Apr 2008 18:32:06 +0000 (18:32 +0000)
committererik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Wed, 9 Apr 2008 18:32:06 +0000 (18:32 +0000)
system/general/src/main/java/org/wamblee/system/core/AbstractComponent.java
system/general/src/main/java/org/wamblee/system/core/Component.java
system/general/src/main/java/org/wamblee/system/core/Container.java
system/general/src/test/java/org/wamblee/system/core/ContainerTest.java
system/general/src/test/java/org/wamblee/system/core/Environment.java
system/spring/src/main/java/org/wamblee/system/spring/RequiredServiceBean.java
system/spring/src/main/java/org/wamblee/system/spring/SpringComponent.java
system/spring/src/test/java/org/wamblee/system/spring/SpringComponentTest.java

index 5d89e4a46f839078c7adc5876bae684a3d2cdb8f..d86277d880a16068c33dfa0d00f73a2b7487eae4 100644 (file)
@@ -89,12 +89,12 @@ public abstract class AbstractComponent implements Component {
        }
 
        @Override
-       public final ProvidedInterface[] getProvidedServices() {
+       public final ProvidedInterface[] getProvidedInterfaces() {
                return _provided.toArray(new ProvidedInterface[0]);
        }
 
        @Override
-       public final RequiredInterface[] getRequiredServices() {
+       public final RequiredInterface[] getRequiredInterfaces() {
                return _required.toArray(new RequiredInterface[0]);
        }
 
index b9b5dad4e5d9cd7ebcf461126ec379b447987693..9409e44f6b0cb9a1c2eef2d95cc6ce9ebd3c5e3b 100644 (file)
@@ -56,13 +56,13 @@ public interface Component {
         * Gets a description of the provided interfaces. 
         * @return Provided interfaces. 
         */
-       ProvidedInterface[] getProvidedServices();
+       ProvidedInterface[] getProvidedInterfaces();
        
        /**
         * Gets a description of the required interfaces. 
         * @return Required interfaces. 
         */
-       RequiredInterface[] getRequiredServices();
+       RequiredInterface[] getRequiredInterfaces();
 
        
        /**
@@ -71,11 +71,6 @@ public interface Component {
         */
        void start();
        
-       /**
-        * Stops a subsystem. 
-        */
-       void stop(); 
-       
        /**
         * Gets the list of running services in the subsystem. 
         * 
@@ -84,4 +79,9 @@ public interface Component {
         * @return
         */
        ProvidedInterface[] getRunningServices();
+       
+       /**
+        * Stops a subsystem. 
+        */
+       void stop(); 
 }
index b6f0a4ce318b361a9f375c6a7f94842921dbf07f..ec45283e2d0fff00b1bc711658d80f5310414994 100644 (file)
@@ -87,22 +87,22 @@ public class Container extends AbstractComponent {
        private void validate(RequiredInterface[] aRequired) {
                List<ProvidedInterface> provided = new ArrayList<ProvidedInterface>();
                for (Component system : _systems) {
-                       provided.addAll(Arrays.asList(system.getProvidedServices()));
+                       provided.addAll(Arrays.asList(system.getProvidedInterfaces()));
                }
 
                List<RequiredInterface> required = new ArrayList<RequiredInterface>();
                for (Component system : _systems) {
-                       required.addAll(Arrays.asList(system.getRequiredServices()));
+                       required.addAll(Arrays.asList(system.getRequiredInterfaces()));
                }
 
-               for (ProvidedInterface service : getProvidedServices()) {
+               for (ProvidedInterface service : getProvidedInterfaces()) {
                        if (!(provided.contains(service))) {
                                throw new SystemAssemblyException(getName() + ": Service '" + service
                                                + "' is not provided by any of the subsystems");
                        }
                }
 
-               for (RequiredInterface service : getRequiredServices()) {
+               for (RequiredInterface service : getRequiredInterfaces()) {
                        if (!(required.contains(service))) {
                                info("Service '"
                                                + service
@@ -138,7 +138,7 @@ public class Container extends AbstractComponent {
                
                // all interfaces from the required list of this container are
                // provided to the components inside it.
-               RequiredInterface[] required = getRequiredServices();
+               RequiredInterface[] required = getRequiredInterfaces();
                for (RequiredInterface intf: required) { 
                    ProvidedInterface provider = intf.getProvider(); 
                    if ( provider == null ) { 
@@ -163,14 +163,14 @@ public class Container extends AbstractComponent {
                
                // Add the provides of all externally required interfaces to the list of available
                // interfaces
-               for (RequiredInterface required: getRequiredServices()) { 
+               for (RequiredInterface required: getRequiredInterfaces()) { 
                        allProvided.add(required.getProvider());
                }
                
                for (Component system : _systems) {
                        // Check if all required services are already provided by earlier
                        // systems.
-                       RequiredInterface[] required = system.getRequiredServices();
+                       RequiredInterface[] required = system.getRequiredInterfaces();
 
                        for (RequiredInterface descriptor : required) {
                                ProvidedInterface[] filtered = filterProvidedServices(
@@ -200,7 +200,7 @@ public class Container extends AbstractComponent {
                        system.start();
 
                        // add all provided services
-                       ProvidedInterface[] provided = system.getProvidedServices();
+                       ProvidedInterface[] provided = system.getProvidedInterfaces();
                        allProvided.addAll(Arrays.asList(provided));
                }
        }
index 9bb53a6a6c1a615c7bd4c0218e90a4bc78921679..0c0a9935feb8b1da4f78321235d5c905d5aecf59 100644 (file)
@@ -129,9 +129,9 @@ public class ContainerTest extends TestCase {
                                new RequiredInterface[0]);
                assertEquals(Status.NOT_STARTED, system.getStatus());
                system.start();
-               RequiredInterface[] required = system.getRequiredServices();
+               RequiredInterface[] required = system.getRequiredInterfaces();
                assertEquals(0, required.length);
-               ProvidedInterface[] provided = system.getProvidedServices();
+               ProvidedInterface[] provided = system.getProvidedInterfaces();
                assertEquals(0, provided.length);
                assertEquals(Status.RUNNING, environment.getStatus());
                assertEquals(Status.RUNNING, application.getStatus());
@@ -191,12 +191,12 @@ public class ContainerTest extends TestCase {
                                application }, new ProvidedInterface[0],
                                new RequiredInterface[] { new DefaultRequiredInterface(
                                                "string", String.class) });
-               system.getRequiredServices()[0]
+               system.getRequiredInterfaces()[0]
                                .setProvider(new DefaultProvidedInterface("hallo", String.class));
                system.start();
-               RequiredInterface[] required = system.getRequiredServices();
+               RequiredInterface[] required = system.getRequiredInterfaces();
                assertEquals(1, required.length);
-               ProvidedInterface[] provided = system.getProvidedServices();
+               ProvidedInterface[] provided = system.getProvidedInterfaces();
                assertEquals(0, provided.length);
        }
 
@@ -206,7 +206,7 @@ public class ContainerTest extends TestCase {
                        Component application = new Application();
                        Container system = new Container("all",
                                        new Component[] { application }, new ProvidedInterface[0],
-                                       application.getRequiredServices());
+                                       application.getRequiredInterfaces());
                        system.start();
                } catch (SystemAssemblyException e) {
                        return;
@@ -221,17 +221,17 @@ public class ContainerTest extends TestCase {
                Component application = new Application();
                Container system = new Container("all",
                                new Component[] { application }, new ProvidedInterface[0],
-                               application.getRequiredServices());
+                               application.getRequiredInterfaces());
                environment.start();
-               system.getRequiredServices()[0].setProvider(environment
-                               .getProvidedServices()[0]);
-               system.getRequiredServices()[1].setProvider(environment
-                               .getProvidedServices()[1]);
+               system.getRequiredInterfaces()[0].setProvider(environment
+                               .getProvidedInterfaces()[0]);
+               system.getRequiredInterfaces()[1].setProvider(environment
+                               .getProvidedInterfaces()[1]);
 
                system.start();
-               RequiredInterface[] required = system.getRequiredServices();
+               RequiredInterface[] required = system.getRequiredInterfaces();
                assertEquals(2, required.length);
-               ProvidedInterface[] provided = system.getProvidedServices();
+               ProvidedInterface[] provided = system.getProvidedInterfaces();
                assertEquals(0, provided.length);
 
        }
index 2fa1c4cf374471412837905cfa76ffe30bf676d9..4406e4431026272bcc27cea6dee9814ef1e93faf 100644 (file)
@@ -46,8 +46,8 @@ public class Environment extends AbstractComponent {
        
        @Override
        protected void doStart() {
-           addService(getProvidedServices()[0], new Integer(1));
-           addService(getProvidedServices()[1], new Integer(2));
+           addService(getProvidedInterfaces()[0], new Integer(1));
+           addService(getProvidedInterfaces()[1], new Integer(2));
            track("start." + getName());
        }
 
index 88ebed1f39b600fd38be8790b6aefe068de0c8ba..6c18cc8ce8e776b454eb1a1ea251ecbc3d18ffd1 100644 (file)
@@ -35,7 +35,7 @@ class RequiredServiceBean implements FactoryBean {
         * @param aId Id of the bean in the service registry.  
         */
        public RequiredServiceBean(String aId) { 
-               RequiredInterface[] required = SpringComponent.THIS.get().getRequiredServices();
+               RequiredInterface[] required = SpringComponent.THIS.get().getRequiredInterfaces();
                for ( RequiredInterface intf: required) { 
                        if ( intf.getName().equals(aId)) { 
                                _required = intf; 
index 36b50e78f38db31b22993386daf00e9024a91f81..09ef341175657aae0e7da781a6299c2b5cf0a95e 100644 (file)
@@ -148,7 +148,7 @@ public class SpringComponent extends AbstractComponent {
 
        private void registerRequiredServices() {
                // Register required services in a parent context
-               for (RequiredInterface required: getRequiredServices()) { 
+               for (RequiredInterface required: getRequiredInterfaces()) { 
                        String beanName = _required.get(required);
                        ConstructorArgumentValues cargs = new ConstructorArgumentValues();
                        cargs.addGenericArgumentValue(required.getName());
index bbbda99925d5ea48c42c2d7cc11082da198b0e6b..c8f8798a8e09a46fb183fb68b4b77f1b0ac10563 100644 (file)
@@ -113,7 +113,7 @@ public class SpringComponentTest extends TestCase {
                HelloService helloObject = new HelloService("ladida"); 
                ProvidedInterface helloService = new DefaultProvidedInterface("hello", HelloService.class);
                helloService.publish(helloObject);
-               system.getRequiredServices()[0].setProvider(helloService);
+               system.getRequiredInterfaces()[0].setProvider(helloService);
                
                system.start();
                system.stop();
@@ -135,9 +135,9 @@ public class SpringComponentTest extends TestCase {
                ProvidedInterface helloService = 
                        new DefaultProvidedInterface("hello", HelloService.class);
                helloService.publish(helloObject);
-               system.getRequiredServices()[0].setProvider(helloService);
+               system.getRequiredInterfaces()[0].setProvider(helloService);
                system.start();
-               ProvidedInterface started = system.getProvidedServices()[0];
+               ProvidedInterface started = system.getProvidedInterfaces()[0];
                
            assertNotNull(started.getImplementation());
            assertTrue(started.getImplementation() instanceof BlaService);