RequiredInterfaceDescriptor no longer extends InterfaceDescriptor.
authorerik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Fri, 4 Apr 2008 18:59:15 +0000 (18:59 +0000)
committererik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Fri, 4 Apr 2008 18:59:15 +0000 (18:59 +0000)
system/general/src/main/java/org/wamblee/system/AbstractComponent.java
system/general/src/main/java/org/wamblee/system/Container.java
system/general/src/main/java/org/wamblee/system/RequiredInterfaceDescriptor.java
system/general/src/test/java/org/wamblee/system/SystemAssemblerTest.java

index 9354a5c3f8dde26b52ec885c1fb67de039383cc5..885cad6e1056980a5b2c769b2b9866ce8d7842fc 100644 (file)
@@ -21,9 +21,9 @@ public abstract class AbstractComponent implements Component {
        private Status _status; 
        private String _name;
        private ServiceRegistry _registry; 
-       private List<InterfaceDescriptor> _provided;
-       private List<InterfaceDescriptor> _required;
-       private Map<InterfaceDescriptor, Service> _running;
+       private List<ProvidedInterfaceDescriptor> _provided;
+       private List<RequiredInterfaceDescriptor> _required;
+       private Map<ProvidedInterfaceDescriptor, Service> _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<InterfaceDescriptor>();
+               _provided = new ArrayList<ProvidedInterfaceDescriptor>();
                _provided.addAll(Arrays.asList(aProvided));
-               _required = new ArrayList<InterfaceDescriptor>();
+               _required = new ArrayList<RequiredInterfaceDescriptor>();
                _required.addAll(Arrays.asList(aRequired));
-               _running = new HashMap<InterfaceDescriptor, Service>();
+               _running = new HashMap<ProvidedInterfaceDescriptor, Service>();
        }
        
        @Override
index a80aa1a21f0c7136b2acd66d8c2b8f9eff6091bf..158c0a06b5c04c394269ccf74ce9004466e1eaf0 100644 (file)
@@ -42,12 +42,12 @@ public class Container extends AbstractComponent {
         * Also logs a warning in case of superfluous requirements.  
         */
        private void validate() {
-               List<InterfaceDescriptor> provided = new ArrayList<InterfaceDescriptor>();
+               List<ProvidedInterfaceDescriptor> provided = new ArrayList<ProvidedInterfaceDescriptor>();
                for (Component system : _systems) {
                        provided.addAll(Arrays.asList(system.getProvidedServices()));
                }
 
-               List<InterfaceDescriptor> required = new ArrayList<InterfaceDescriptor>();
+               List<RequiredInterfaceDescriptor> required = new ArrayList<RequiredInterfaceDescriptor>();
                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<InterfaceDescriptor> reallyRequired = new ArrayList<InterfaceDescriptor>(
+               List<RequiredInterfaceDescriptor> reallyRequired = new ArrayList<RequiredInterfaceDescriptor>(
                                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 ) { 
index 1a1237b88d36fc2c39f52214bacbc1385e234077..9e86767a95c987465f092d259a9272b40a99e1f8 100644 (file)
@@ -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);
 }
index df08998e4b7351b2b1cd82963da44efa32b9b4e5..7b3ea273513253d283a3916f4456de56d1cab1b0 100644 (file)
@@ -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);