From f4bb0b383ded9c7303a5d81cc6ee87df530d6716 Mon Sep 17 00:00:00 2001 From: erik Date: Wed, 9 Apr 2008 18:32:06 +0000 Subject: [PATCH] rename service to interface. --- .../system/core/AbstractComponent.java | 4 +-- .../org/wamblee/system/core/Component.java | 14 +++++----- .../org/wamblee/system/core/Container.java | 16 ++++++------ .../wamblee/system/core/ContainerTest.java | 26 +++++++++---------- .../org/wamblee/system/core/Environment.java | 4 +-- .../system/spring/RequiredServiceBean.java | 2 +- .../system/spring/SpringComponent.java | 2 +- .../system/spring/SpringComponentTest.java | 6 ++--- 8 files changed, 37 insertions(+), 37 deletions(-) diff --git a/system/general/src/main/java/org/wamblee/system/core/AbstractComponent.java b/system/general/src/main/java/org/wamblee/system/core/AbstractComponent.java index 5d89e4a4..d86277d8 100644 --- a/system/general/src/main/java/org/wamblee/system/core/AbstractComponent.java +++ b/system/general/src/main/java/org/wamblee/system/core/AbstractComponent.java @@ -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]); } diff --git a/system/general/src/main/java/org/wamblee/system/core/Component.java b/system/general/src/main/java/org/wamblee/system/core/Component.java index b9b5dad4..9409e44f 100644 --- a/system/general/src/main/java/org/wamblee/system/core/Component.java +++ b/system/general/src/main/java/org/wamblee/system/core/Component.java @@ -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(); } diff --git a/system/general/src/main/java/org/wamblee/system/core/Container.java b/system/general/src/main/java/org/wamblee/system/core/Container.java index b6f0a4ce..ec45283e 100644 --- a/system/general/src/main/java/org/wamblee/system/core/Container.java +++ b/system/general/src/main/java/org/wamblee/system/core/Container.java @@ -87,22 +87,22 @@ public class Container extends AbstractComponent { private void validate(RequiredInterface[] aRequired) { List provided = new ArrayList(); for (Component system : _systems) { - provided.addAll(Arrays.asList(system.getProvidedServices())); + provided.addAll(Arrays.asList(system.getProvidedInterfaces())); } List required = new ArrayList(); 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)); } } diff --git a/system/general/src/test/java/org/wamblee/system/core/ContainerTest.java b/system/general/src/test/java/org/wamblee/system/core/ContainerTest.java index 9bb53a6a..0c0a9935 100644 --- a/system/general/src/test/java/org/wamblee/system/core/ContainerTest.java +++ b/system/general/src/test/java/org/wamblee/system/core/ContainerTest.java @@ -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); } diff --git a/system/general/src/test/java/org/wamblee/system/core/Environment.java b/system/general/src/test/java/org/wamblee/system/core/Environment.java index 2fa1c4cf..4406e443 100644 --- a/system/general/src/test/java/org/wamblee/system/core/Environment.java +++ b/system/general/src/test/java/org/wamblee/system/core/Environment.java @@ -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()); } diff --git a/system/spring/src/main/java/org/wamblee/system/spring/RequiredServiceBean.java b/system/spring/src/main/java/org/wamblee/system/spring/RequiredServiceBean.java index 88ebed1f..6c18cc8c 100644 --- a/system/spring/src/main/java/org/wamblee/system/spring/RequiredServiceBean.java +++ b/system/spring/src/main/java/org/wamblee/system/spring/RequiredServiceBean.java @@ -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; diff --git a/system/spring/src/main/java/org/wamblee/system/spring/SpringComponent.java b/system/spring/src/main/java/org/wamblee/system/spring/SpringComponent.java index 36b50e78..09ef3411 100644 --- a/system/spring/src/main/java/org/wamblee/system/spring/SpringComponent.java +++ b/system/spring/src/main/java/org/wamblee/system/spring/SpringComponent.java @@ -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()); diff --git a/system/spring/src/test/java/org/wamblee/system/spring/SpringComponentTest.java b/system/spring/src/test/java/org/wamblee/system/spring/SpringComponentTest.java index bbbda999..c8f8798a 100644 --- a/system/spring/src/test/java/org/wamblee/system/spring/SpringComponentTest.java +++ b/system/spring/src/test/java/org/wamblee/system/spring/SpringComponentTest.java @@ -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); -- 2.31.1