From 31eaf22e775e8f809aed21c0d0e0eff5aaf0a916 Mon Sep 17 00:00:00 2001 From: erik Date: Fri, 4 Apr 2008 18:59:15 +0000 Subject: [PATCH] RequiredInterfaceDescriptor no longer extends InterfaceDescriptor. --- .../java/org/wamblee/system/AbstractComponent.java | 12 ++++++------ .../main/java/org/wamblee/system/Container.java | 14 +++++++------- .../system/RequiredInterfaceDescriptor.java | 14 ++++++++++++-- .../org/wamblee/system/SystemAssemblerTest.java | 2 +- 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/system/general/src/main/java/org/wamblee/system/AbstractComponent.java b/system/general/src/main/java/org/wamblee/system/AbstractComponent.java index 9354a5c3..885cad6e 100644 --- a/system/general/src/main/java/org/wamblee/system/AbstractComponent.java +++ b/system/general/src/main/java/org/wamblee/system/AbstractComponent.java @@ -21,9 +21,9 @@ public abstract class AbstractComponent implements Component { private Status _status; 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. @@ -42,11 +42,11 @@ public abstract class AbstractComponent implements Component { _status = Status.NOT_STARTED; _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 diff --git a/system/general/src/main/java/org/wamblee/system/Container.java b/system/general/src/main/java/org/wamblee/system/Container.java index a80aa1a2..158c0a06 100644 --- a/system/general/src/main/java/org/wamblee/system/Container.java +++ b/system/general/src/main/java/org/wamblee/system/Container.java @@ -42,12 +42,12 @@ public class Container extends AbstractComponent { * Also logs a warning in case of superfluous requirements. */ private void validate() { - List provided = new ArrayList(); + List provided = new ArrayList(); for (Component system : _systems) { provided.addAll(Arrays.asList(system.getProvidedServices())); } - List required = new ArrayList(); + List required = new ArrayList(); for (Component system : _systems) { required.addAll(Arrays.asList(system.getRequiredServices())); } @@ -59,7 +59,7 @@ public class Container extends AbstractComponent { } } - for (InterfaceDescriptor service : getRequiredServices()) { + for (RequiredInterfaceDescriptor service : getRequiredServices()) { if (!(required.contains(service))) { info("Service '" + service @@ -67,16 +67,16 @@ public class Container extends AbstractComponent { } } - List reallyRequired = new ArrayList( + List reallyRequired = new ArrayList( required); - for (InterfaceDescriptor service : provided) { + for (ProvidedInterfaceDescriptor service : provided) { reallyRequired.remove(service); } - for (InterfaceDescriptor service: getRequiredServices()) { + for (RequiredInterfaceDescriptor service: getRequiredServices()) { reallyRequired.remove(service); } String missingRequired = ""; - for (InterfaceDescriptor service: reallyRequired) { + for (RequiredInterfaceDescriptor service: reallyRequired) { missingRequired += service + "\n"; } if ( missingRequired.length() > 0 ) { diff --git a/system/general/src/main/java/org/wamblee/system/RequiredInterfaceDescriptor.java b/system/general/src/main/java/org/wamblee/system/RequiredInterfaceDescriptor.java index 1a1237b8..9e86767a 100644 --- a/system/general/src/main/java/org/wamblee/system/RequiredInterfaceDescriptor.java +++ b/system/general/src/main/java/org/wamblee/system/RequiredInterfaceDescriptor.java @@ -1,6 +1,16 @@ package org.wamblee.system; -public interface RequiredInterfaceDescriptor extends InterfaceDescriptor { +public interface RequiredInterfaceDescriptor { - boolean implementedBy(ProvidedInterfaceDescriptor aDescriptor); + /** + * Name for the interface. + */ + public String getName(); + + /** + * Checks if the service is provided by a given provided interface. + * @param aInterface Provided interface. + * @return + */ + boolean implementedBy(ProvidedInterfaceDescriptor aInterface); } diff --git a/system/general/src/test/java/org/wamblee/system/SystemAssemblerTest.java b/system/general/src/test/java/org/wamblee/system/SystemAssemblerTest.java index df08998e..7b3ea273 100644 --- a/system/general/src/test/java/org/wamblee/system/SystemAssemblerTest.java +++ b/system/general/src/test/java/org/wamblee/system/SystemAssemblerTest.java @@ -107,7 +107,7 @@ public class SystemAssemblerTest extends TestCase { new RequiredInterfaceDescriptor[0]); assertEquals(Status.NOT_STARTED, system.getStatus()); system.start("root", new Service[0]); - InterfaceDescriptor[] required = system.getRequiredServices(); + RequiredInterfaceDescriptor[] required = system.getRequiredServices(); assertEquals(0, required.length); InterfaceDescriptor[] provided = system.getProvidedServices(); assertEquals(0, provided.length); -- 2.31.1