ProvidedInterfaceDescriptor no longer extends InterfaceDescriptor.
authorerik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Fri, 4 Apr 2008 19:06:35 +0000 (19:06 +0000)
committererik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Fri, 4 Apr 2008 19:06:35 +0000 (19:06 +0000)
system/general/src/main/java/org/wamblee/system/AbstractProvidedInterfaceDescriptor.java [moved from system/general/src/main/java/org/wamblee/system/AbstractInterfaceDescriptor.java with 77% similarity]
system/general/src/main/java/org/wamblee/system/Container.java
system/general/src/main/java/org/wamblee/system/DefaultProvidedInterfaceDescriptor.java [deleted file]
system/general/src/main/java/org/wamblee/system/DefaultRequiredInterfaceDescriptor.java
system/general/src/main/java/org/wamblee/system/InterfaceDescriptor.java [deleted file]
system/general/src/main/java/org/wamblee/system/ProvidedInterfaceDescriptor.java
system/general/src/test/java/org/wamblee/system/DefaultInterfaceDescriptorTest.java
system/general/src/test/java/org/wamblee/system/Environment.java
system/general/src/test/java/org/wamblee/system/SystemAssemblerTest.java
system/spring/src/test/java/org/wamblee/system/spring/SpringComponentTest.java

similarity index 77%
rename from system/general/src/main/java/org/wamblee/system/AbstractInterfaceDescriptor.java
rename to system/general/src/main/java/org/wamblee/system/AbstractProvidedInterfaceDescriptor.java
index 361cd2ece5e788e63b6c82cfaa0636a024f117b1..2d60e34e44b55442b1223ede2c68f41b9cb46539 100644 (file)
@@ -7,7 +7,7 @@ import java.util.Arrays;
  *
  * @author Erik Brakkee
  */
-public abstract class AbstractInterfaceDescriptor implements InterfaceDescriptor {
+public class AbstractProvidedInterfaceDescriptor implements ProvidedInterfaceDescriptor {
        
        private String _name; 
        private Class[] _interfaces; 
@@ -16,12 +16,12 @@ public abstract class AbstractInterfaceDescriptor implements InterfaceDescriptor
         * Constructs the descriptor. 
         * @param aInterface Type of service. 
         */
-       public AbstractInterfaceDescriptor(String aName, Class aInterface) {
+       public AbstractProvidedInterfaceDescriptor(String aName, Class aInterface) {
                _name = aName; 
                _interfaces = new Class[] { aInterface };  
        }
        
-       public AbstractInterfaceDescriptor(String aName, Class[] aInterfaces) {
+       public AbstractProvidedInterfaceDescriptor(String aName, Class[] aInterfaces) {
                _name = aName; 
                _interfaces = Arrays.copyOf(aInterfaces, aInterfaces.length);  
        }
@@ -38,10 +38,10 @@ public abstract class AbstractInterfaceDescriptor implements InterfaceDescriptor
        
        @Override
        public boolean equals(Object obj) {
-               if ( !(obj instanceof AbstractInterfaceDescriptor)) { 
+               if ( !(obj instanceof AbstractProvidedInterfaceDescriptor)) { 
                        return false; 
                }
-               AbstractInterfaceDescriptor descr = (AbstractInterfaceDescriptor)obj;
+               AbstractProvidedInterfaceDescriptor descr = (AbstractProvidedInterfaceDescriptor)obj;
                if ( _interfaces.length != descr._interfaces.length ) { 
                        return false; 
                }
index 158c0a06b5c04c394269ccf74ce9004466e1eaf0..ee3a053595db2d7a7444d091db19947b0cd4c527 100644 (file)
@@ -52,7 +52,7 @@ public class Container extends AbstractComponent {
                        required.addAll(Arrays.asList(system.getRequiredServices()));
                }
 
-               for (InterfaceDescriptor service : getProvidedServices()) {
+               for (ProvidedInterfaceDescriptor service : getProvidedServices()) {
                        if (!(provided.contains(service))) {
                                throw new SystemAssemblyException(getName() + ": Service '" + service
                                                + "' is not provided by any of the subsystems");
diff --git a/system/general/src/main/java/org/wamblee/system/DefaultProvidedInterfaceDescriptor.java b/system/general/src/main/java/org/wamblee/system/DefaultProvidedInterfaceDescriptor.java
deleted file mode 100644 (file)
index 97e62da..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-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);
-       }
-       
-}
index fbee3155870ce16d16d52a16e78c48bf573ca0ba..a6e85bc53f33cf8fe0fef3c69cc017515a2de152 100644 (file)
@@ -1,6 +1,6 @@
 package org.wamblee.system;
 
-public class DefaultRequiredInterfaceDescriptor extends AbstractInterfaceDescriptor
+public class DefaultRequiredInterfaceDescriptor extends AbstractProvidedInterfaceDescriptor
                implements RequiredInterfaceDescriptor {
 
        public DefaultRequiredInterfaceDescriptor(String aName, Class aInterface) {
diff --git a/system/general/src/main/java/org/wamblee/system/InterfaceDescriptor.java b/system/general/src/main/java/org/wamblee/system/InterfaceDescriptor.java
deleted file mode 100644 (file)
index 987a859..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-package org.wamblee.system;
-
-/**
- * Service descriptor providing a description and characteristics
- * of the provided service. 
- * 
- * NOTE: The current implemention only stores the type of the 
- * descriptor but his can be extended towards more complex rules
- * for matching services. 
- * 
- * Implementations must implement {@link #equals(Object)} and {@link #hashCode()}.
- *
- * @author Erik Brakkee
- */
-public interface InterfaceDescriptor {
-       
-       /**
-        * Symbolic name for the service as used by the subsystem.  
-        * @return Service name. 
-        */
-       String getName();
-       
-       /**
-        * Returns the service type. 
-        * @return Service type. 
-        */
-       Class[] getInterfaceTypes();
-}
index 1af949c9f358f44b54e4b667e0afe1386b5d60dd..9afe375219dd4d12d12d3bdcc1098d4d20d4bf29 100644 (file)
@@ -2,6 +2,22 @@ package org.wamblee.system;
 
 import java.util.Collection;
 
-public interface ProvidedInterfaceDescriptor extends InterfaceDescriptor {
-    // Empty
+/**
+ * Represents an interface provided by a component.
+ *  
+ * @author Erik Brakkee
+ */
+public interface ProvidedInterfaceDescriptor {
+    
+       /**
+        * Symbolic name for the service as used by the subsystem.  
+        * @return Service name. 
+        */
+       String getName();
+       
+       /**
+        * Returns the service type. 
+        * @return Service type. 
+        */
+       Class[] getInterfaceTypes();
 }
index dd3451dbc1cf0ed8427e630d58eccacca0e53257..7f9dc9333bf0d571f4d5b9f9a2e00f130538a1d9 100644 (file)
@@ -7,25 +7,25 @@ import junit.framework.TestCase;
 public class DefaultInterfaceDescriptorTest extends TestCase {
 
        public void testOneRequiredOneProvidedMatch() { 
-               ProvidedInterfaceDescriptor provided = new DefaultProvidedInterfaceDescriptor("name", String.class);
+               ProvidedInterfaceDescriptor provided = new AbstractProvidedInterfaceDescriptor("name", String.class);
                RequiredInterfaceDescriptor required = new DefaultRequiredInterfaceDescriptor("name", String.class);
                assertTrue(required.implementedBy(provided));
        }
        
        public void testOneRequiredOneProvidedMatchSubClass() { 
-               ProvidedInterfaceDescriptor provided = new DefaultProvidedInterfaceDescriptor("name", Integer.class);
+               ProvidedInterfaceDescriptor provided = new AbstractProvidedInterfaceDescriptor("name", Integer.class);
                RequiredInterfaceDescriptor required = new DefaultRequiredInterfaceDescriptor("name", Number.class);
                assertTrue(required.implementedBy(provided));
        }
        
        public void testOneRequiredOneProvidedNoMatch() { 
-               ProvidedInterfaceDescriptor provided = new DefaultProvidedInterfaceDescriptor("name", String.class);
+               ProvidedInterfaceDescriptor provided = new AbstractProvidedInterfaceDescriptor("name", String.class);
                RequiredInterfaceDescriptor required = new DefaultRequiredInterfaceDescriptor("name", Number.class);
                assertFalse(required.implementedBy(provided));
        }
        
        public void testOneRequiredMultipleProvidedMatch() { 
-               ProvidedInterfaceDescriptor provided = new DefaultProvidedInterfaceDescriptor("name", 
+               ProvidedInterfaceDescriptor provided = new AbstractProvidedInterfaceDescriptor("name", 
                                new Class[] { String.class, Integer.class} );
                RequiredInterfaceDescriptor required = new DefaultRequiredInterfaceDescriptor("name", String.class);
                assertTrue(required.implementedBy(provided));
@@ -39,7 +39,7 @@ public class DefaultInterfaceDescriptorTest extends TestCase {
        }
        
        public void testMultipleRequiredOneProvidedMatch() { 
-               ProvidedInterfaceDescriptor provided = new DefaultProvidedInterfaceDescriptor("name", 
+               ProvidedInterfaceDescriptor provided = new AbstractProvidedInterfaceDescriptor("name", 
                                MyMultiple.class );
                RequiredInterfaceDescriptor required = new DefaultRequiredInterfaceDescriptor("name", 
                                new Class[] {Runnable.class, Serializable.class} );
@@ -47,7 +47,7 @@ public class DefaultInterfaceDescriptorTest extends TestCase {
        }
        
        public void testMultipleRequiredOneProvidedNoMatch() { 
-               ProvidedInterfaceDescriptor provided = new DefaultProvidedInterfaceDescriptor("name", 
+               ProvidedInterfaceDescriptor provided = new AbstractProvidedInterfaceDescriptor("name", 
                                MyMultiple.class );
                RequiredInterfaceDescriptor required = new DefaultRequiredInterfaceDescriptor("name", 
                                new Class[] { String.class, Runnable.class} );
@@ -55,7 +55,7 @@ public class DefaultInterfaceDescriptorTest extends TestCase {
        }
        
        public void testMultipleRequiredMultipleProvidedMatch() { 
-               ProvidedInterfaceDescriptor provided = new DefaultProvidedInterfaceDescriptor("name", 
+               ProvidedInterfaceDescriptor provided = new AbstractProvidedInterfaceDescriptor("name", 
                                new Class[] { Runnable.class, Serializable.class, String.class}  );
                RequiredInterfaceDescriptor required = new DefaultRequiredInterfaceDescriptor("name", 
                                new Class[] {Runnable.class, Serializable.class} );
index ebc432657c88c227197f1ec0fd46d92964adc64e..6c9512ca2b75383c92c96ab24135276fe4616f23 100644 (file)
@@ -7,8 +7,8 @@ public class Environment extends AbstractComponent {
        
        private static final ProvidedInterfaceDescriptor[] PROVIDED = 
                new ProvidedInterfaceDescriptor[] { 
-                       new DefaultProvidedInterfaceDescriptor("datasource", DataSource.class), 
-                       new DefaultProvidedInterfaceDescriptor("integer", Integer.class)
+                       new AbstractProvidedInterfaceDescriptor("datasource", DataSource.class), 
+                       new AbstractProvidedInterfaceDescriptor("integer", Integer.class)
        };
        
        public Environment(ServiceRegistry aRegistry) { 
index 7b3ea273513253d283a3916f4456de56d1cab1b0..810ff4c7d4cfcdeebd990866e60006e2c0ed1f27 100644 (file)
@@ -31,11 +31,11 @@ public class SystemAssemblerTest extends TestCase {
                                "name", Runnable.class);
                RequiredInterfaceDescriptor req2 = new DefaultRequiredInterfaceDescriptor(
                                "name", Serializable.class);
-               ProvidedInterfaceDescriptor prov1 = new DefaultProvidedInterfaceDescriptor(
+               ProvidedInterfaceDescriptor prov1 = new AbstractProvidedInterfaceDescriptor(
                                "name", Runnable.class);
-               ProvidedInterfaceDescriptor prov2 = new DefaultProvidedInterfaceDescriptor(
+               ProvidedInterfaceDescriptor prov2 = new AbstractProvidedInterfaceDescriptor(
                                "name", Serializable.class);
-               ProvidedInterfaceDescriptor prov3 = new DefaultProvidedInterfaceDescriptor(
+               ProvidedInterfaceDescriptor prov3 = new AbstractProvidedInterfaceDescriptor(
                                "name", MyMultiple.class);
 
                AssertionUtils.assertEquals(new RequiredInterfaceDescriptor[] { req1 },
@@ -109,7 +109,7 @@ public class SystemAssemblerTest extends TestCase {
                system.start("root", new Service[0]);
                RequiredInterfaceDescriptor[] required = system.getRequiredServices();
                assertEquals(0, required.length);
-               InterfaceDescriptor[] provided = system.getProvidedServices();
+               ProvidedInterfaceDescriptor[] provided = system.getProvidedServices();
                assertEquals(0, provided.length);
                assertEquals(Status.RUNNING, environment.getStatus());
                assertEquals(Status.RUNNING, application.getStatus());
@@ -129,7 +129,7 @@ public class SystemAssemblerTest extends TestCase {
                                        "all",
                                        _registry,
                                        new Component[] { environment, application },
-                                       new ProvidedInterfaceDescriptor[] { new DefaultProvidedInterfaceDescriptor(
+                                       new ProvidedInterfaceDescriptor[] { new AbstractProvidedInterfaceDescriptor(
                                                        "string", String.class) },
                                        new DefaultRequiredInterfaceDescriptor[0]);
                } catch (SystemAssemblyException e) {
index dc7a5845c659f68c47bbcd7db8f855bd3fa1c5b2..c02f951ae82f63836067683e8e948a9b9d58140d 100644 (file)
@@ -8,8 +8,8 @@ import java.util.Properties;
 import junit.framework.TestCase;
 
 import org.wamblee.io.ClassPathResource;
-import org.wamblee.system.AbstractInterfaceDescriptor;
-import org.wamblee.system.DefaultProvidedInterfaceDescriptor;
+import org.wamblee.system.AbstractProvidedInterfaceDescriptor;
+import org.wamblee.system.AbstractProvidedInterfaceDescriptor;
 import org.wamblee.system.DefaultRequiredInterfaceDescriptor;
 import org.wamblee.system.DefaultServiceRegistry;
 import org.wamblee.system.ProvidedInterfaceDescriptor;
@@ -48,7 +48,7 @@ public class SpringComponentTest extends TestCase {
 
        public void testOneProvidedService() {
                Map<String, ProvidedInterfaceDescriptor> provided = new HashMap<String, ProvidedInterfaceDescriptor>();
-               provided.put("helloService", new DefaultProvidedInterfaceDescriptor(
+               provided.put("helloService", new AbstractProvidedInterfaceDescriptor(
                                "hello", HelloService.class));
 
                SpringComponent system = new SpringComponent("system", _registry,
@@ -65,7 +65,7 @@ public class SpringComponentTest extends TestCase {
        
        public void testWithProperties() throws IOException {
                Map<String, ProvidedInterfaceDescriptor> provided = new HashMap<String, ProvidedInterfaceDescriptor>();
-               provided.put("helloService", new DefaultProvidedInterfaceDescriptor(
+               provided.put("helloService", new AbstractProvidedInterfaceDescriptor(
                                "hello", HelloService.class));
                SpringComponent system = new SpringComponent("system", _registry,
                                new String[] { HELLO_SERVICE_SPRING_WITH_PROPERTIES_XML },
@@ -103,7 +103,7 @@ public class SpringComponentTest extends TestCase {
                                new HashMap<String, ProvidedInterfaceDescriptor>(), required);
                
                HelloService helloObject = new HelloService("ladida"); 
-               Service helloService = _registry.register(new DefaultProvidedInterfaceDescriptor("hello", HelloService.class), helloObject);
+               Service helloService = _registry.register(new AbstractProvidedInterfaceDescriptor("hello", HelloService.class), helloObject);
                system.start("Bla", new Service[] { helloService } );
                system.stop();
        }
@@ -113,7 +113,7 @@ public class SpringComponentTest extends TestCase {
                required.put(new DefaultRequiredInterfaceDescriptor("hello", HelloService.class),
                                "helloService");
                Map<String,ProvidedInterfaceDescriptor> provided = new HashMap<String, ProvidedInterfaceDescriptor>();
-               provided.put("blaService", new DefaultProvidedInterfaceDescriptor("bla",
+               provided.put("blaService", new AbstractProvidedInterfaceDescriptor("bla",
                                BlaService.class));
 
                SpringComponent system = new SpringComponent("system", _registry,
@@ -121,7 +121,7 @@ public class SpringComponentTest extends TestCase {
                                provided, required);
                
                HelloService helloObject = new HelloService("ladida"); 
-               Service helloService = _registry.register(new DefaultProvidedInterfaceDescriptor("hello", HelloService.class), helloObject);
+               Service helloService = _registry.register(new AbstractProvidedInterfaceDescriptor("hello", HelloService.class), helloObject);
                Service[] services = system.start("Bla", new Service[] { helloService } );
                assertEquals(1, services.length);