(no commit message)
authorerik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Fri, 4 Apr 2008 22:11:06 +0000 (22:11 +0000)
committererik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Fri, 4 Apr 2008 22:11:06 +0000 (22:11 +0000)
trunk/system/general/src/main/java/org/wamblee/system/AbstractComponent.java
trunk/system/general/src/main/java/org/wamblee/system/DefaultProvidedInterface.java [moved from trunk/system/general/src/main/java/org/wamblee/system/DefaultProvidedInterfaceDescriptor.java with 80% similarity]
trunk/system/general/src/main/java/org/wamblee/system/DefaultRequiredInterface.java [moved from trunk/system/general/src/main/java/org/wamblee/system/DefaultRequiredInterfaceDescriptor.java with 84% similarity]
trunk/system/general/src/test/java/org/wamblee/system/Application.java
trunk/system/general/src/test/java/org/wamblee/system/DefaultInterfaceDescriptorTest.java
trunk/system/general/src/test/java/org/wamblee/system/Environment.java
trunk/system/general/src/test/java/org/wamblee/system/SystemAssemblerTest.java
trunk/system/spring/src/main/java/org/wamblee/system/spring/SpringComponent.java
trunk/system/spring/src/test/java/org/wamblee/system/spring/SpringComponentTest.java

index 074e3ab0fe408a3e111f569b7a77d1df76bf0c23..93f62c1e718b434e5e89a77237dcdf4d9889d9c3 100644 (file)
@@ -68,6 +68,12 @@ public abstract class AbstractComponent implements Component {
                LOG.info("Initializing '" + aContext + "." + _name + "'");
                doStart(aContext + "." + getName());
                _status = Status.RUNNING;
+               if ( _running.size() != _provided.size()) { 
+                       List<ProvidedInterface> remaining = 
+                               new ArrayList<ProvidedInterface>(_provided);
+                       remaining.removeAll(_running);
+                       throw new SystemAssemblyException(aContext + "." + getName() + ": not all services were started, missing " + remaining);
+               }
        }
 
        /**
similarity index 80%
rename from trunk/system/general/src/main/java/org/wamblee/system/DefaultProvidedInterfaceDescriptor.java
rename to trunk/system/general/src/main/java/org/wamblee/system/DefaultProvidedInterface.java
index 3b38be7a199dbf6ce8b961e3cbd317d19225196a..e80547c53c868ae5aa43fc4b22664b9f31444fd4 100644 (file)
@@ -7,7 +7,7 @@ import java.util.Arrays;
  *
  * @author Erik Brakkee
  */
-public class DefaultProvidedInterfaceDescriptor implements ProvidedInterface {
+public class DefaultProvidedInterface implements ProvidedInterface {
        
        private String _name; 
        private Class[] _interfaces;
@@ -17,12 +17,12 @@ public class DefaultProvidedInterfaceDescriptor implements ProvidedInterface {
         * Constructs the descriptor. 
         * @param aInterface Type of service. 
         */
-       public DefaultProvidedInterfaceDescriptor(String aName, Class aInterface) {
+       public DefaultProvidedInterface(String aName, Class aInterface) {
                _name = aName; 
                _interfaces = new Class[] { aInterface };  
        }
        
-       public DefaultProvidedInterfaceDescriptor(String aName, Class[] aInterfaces) {
+       public DefaultProvidedInterface(String aName, Class[] aInterfaces) {
                _name = aName; 
                _interfaces = Arrays.copyOf(aInterfaces, aInterfaces.length);  
        }
@@ -49,10 +49,10 @@ public class DefaultProvidedInterfaceDescriptor implements ProvidedInterface {
        
        @Override
        public boolean equals(Object obj) {
-               if ( !(obj instanceof DefaultProvidedInterfaceDescriptor)) { 
+               if ( !(obj instanceof DefaultProvidedInterface)) { 
                        return false; 
                }
-               DefaultProvidedInterfaceDescriptor descr = (DefaultProvidedInterfaceDescriptor)obj;
+               DefaultProvidedInterface descr = (DefaultProvidedInterface)obj;
                if ( _interfaces.length != descr._interfaces.length ) { 
                        return false; 
                }
similarity index 84%
rename from trunk/system/general/src/main/java/org/wamblee/system/DefaultRequiredInterfaceDescriptor.java
rename to trunk/system/general/src/main/java/org/wamblee/system/DefaultRequiredInterface.java
index 580b390b4402dbc7fb45b0972ed9bdeb8db248fe..2f06247d3b2883c55f3cebcf5fabc8325d6dfdbc 100644 (file)
@@ -2,17 +2,17 @@ package org.wamblee.system;
 
 import java.util.Arrays;
 
-public class DefaultRequiredInterfaceDescriptor implements RequiredInterface {
+public class DefaultRequiredInterface implements RequiredInterface {
 
        private String _name;
        private Class[] _required;
        private ProvidedInterface _provider; 
        
-       public DefaultRequiredInterfaceDescriptor(String aName, Class aInterface) {
+       public DefaultRequiredInterface(String aName, Class aInterface) {
                this(aName, new Class[] { aInterface }); 
        }
 
-       public DefaultRequiredInterfaceDescriptor(String aName, Class[] aInterfaces) {
+       public DefaultRequiredInterface(String aName, Class[] aInterfaces) {
                _name = aName; 
                _required = aInterfaces; 
        }
@@ -69,10 +69,10 @@ public class DefaultRequiredInterfaceDescriptor implements RequiredInterface {
        
        @Override
        public boolean equals(Object obj) {
-               if ( !(obj instanceof DefaultRequiredInterfaceDescriptor)) { 
+               if ( !(obj instanceof DefaultRequiredInterface)) { 
                        return false; 
                }
-               DefaultRequiredInterfaceDescriptor descr = (DefaultRequiredInterfaceDescriptor)obj;
+               DefaultRequiredInterface descr = (DefaultRequiredInterface)obj;
                if ( _required.length != descr._required.length ) { 
                        return false; 
                }
index b84ca5e247410ea6d0ec7c690edc539b87683c9b..6e9eb675c25861ae7d911109a7ec89c1c378039b 100644 (file)
@@ -6,8 +6,8 @@ public class Application extends AbstractComponent {
        private static RequiredInterface[] required() {
                return
                new RequiredInterface[] { 
-                       new DefaultRequiredInterfaceDescriptor("datasource", DataSource.class), 
-                       new DefaultRequiredInterfaceDescriptor("integer", Integer.class)
+                       new DefaultRequiredInterface("datasource", DataSource.class), 
+                       new DefaultRequiredInterface("integer", Integer.class)
        };
        }
        
index f74557be5c56eeca368e3e7d72215ac9efb73514..b6a5eb8b872ab1b83deb68af21ecd73202968f28 100644 (file)
@@ -7,27 +7,27 @@ import junit.framework.TestCase;
 public class DefaultInterfaceDescriptorTest extends TestCase {
 
        public void testOneRequiredOneProvidedMatch() { 
-               ProvidedInterface provided = new DefaultProvidedInterfaceDescriptor("name", String.class);
-               RequiredInterface required = new DefaultRequiredInterfaceDescriptor("name", String.class);
+               ProvidedInterface provided = new DefaultProvidedInterface("name", String.class);
+               RequiredInterface required = new DefaultRequiredInterface("name", String.class);
                assertTrue(required.implementedBy(provided));
        }
        
        public void testOneRequiredOneProvidedMatchSubClass() { 
-               ProvidedInterface provided = new DefaultProvidedInterfaceDescriptor("name", Integer.class);
-               RequiredInterface required = new DefaultRequiredInterfaceDescriptor("name", Number.class);
+               ProvidedInterface provided = new DefaultProvidedInterface("name", Integer.class);
+               RequiredInterface required = new DefaultRequiredInterface("name", Number.class);
                assertTrue(required.implementedBy(provided));
        }
        
        public void testOneRequiredOneProvidedNoMatch() { 
-               ProvidedInterface provided = new DefaultProvidedInterfaceDescriptor("name", String.class);
-               RequiredInterface required = new DefaultRequiredInterfaceDescriptor("name", Number.class);
+               ProvidedInterface provided = new DefaultProvidedInterface("name", String.class);
+               RequiredInterface required = new DefaultRequiredInterface("name", Number.class);
                assertFalse(required.implementedBy(provided));
        }
        
        public void testOneRequiredMultipleProvidedMatch() { 
-               ProvidedInterface provided = new DefaultProvidedInterfaceDescriptor("name", 
+               ProvidedInterface provided = new DefaultProvidedInterface("name", 
                                new Class[] { String.class, Integer.class} );
-               RequiredInterface required = new DefaultRequiredInterfaceDescriptor("name", String.class);
+               RequiredInterface required = new DefaultRequiredInterface("name", String.class);
                assertTrue(required.implementedBy(provided));
        }
        
@@ -39,25 +39,25 @@ public class DefaultInterfaceDescriptorTest extends TestCase {
        }
        
        public void testMultipleRequiredOneProvidedMatch() { 
-               ProvidedInterface provided = new DefaultProvidedInterfaceDescriptor("name", 
+               ProvidedInterface provided = new DefaultProvidedInterface("name", 
                                MyMultiple.class );
-               RequiredInterface required = new DefaultRequiredInterfaceDescriptor("name", 
+               RequiredInterface required = new DefaultRequiredInterface("name", 
                                new Class[] {Runnable.class, Serializable.class} );
                assertTrue(required.implementedBy(provided));
        }
        
        public void testMultipleRequiredOneProvidedNoMatch() { 
-               ProvidedInterface provided = new DefaultProvidedInterfaceDescriptor("name", 
+               ProvidedInterface provided = new DefaultProvidedInterface("name", 
                                MyMultiple.class );
-               RequiredInterface required = new DefaultRequiredInterfaceDescriptor("name", 
+               RequiredInterface required = new DefaultRequiredInterface("name", 
                                new Class[] { String.class, Runnable.class} );
                assertFalse(required.implementedBy(provided));
        }
        
        public void testMultipleRequiredMultipleProvidedMatch() { 
-               ProvidedInterface provided = new DefaultProvidedInterfaceDescriptor("name", 
+               ProvidedInterface provided = new DefaultProvidedInterface("name", 
                                new Class[] { Runnable.class, Serializable.class, String.class}  );
-               RequiredInterface required = new DefaultRequiredInterfaceDescriptor("name", 
+               RequiredInterface required = new DefaultRequiredInterface("name", 
                                new Class[] {Runnable.class, Serializable.class} );
                assertTrue(required.implementedBy(provided));
        }
index 27537e0a850b9b297dd9058b3f5ca30e519ac3a1..300adf5c43c5dc18f78f7d904648b8d5c8e2d900 100644 (file)
@@ -7,8 +7,8 @@ public class Environment extends AbstractComponent {
        
        private static final ProvidedInterface[] provided() { 
                return new ProvidedInterface[] { 
-                       new DefaultProvidedInterfaceDescriptor("datasource", DataSource.class), 
-                       new DefaultProvidedInterfaceDescriptor("integer", Integer.class)
+                       new DefaultProvidedInterface("datasource", DataSource.class), 
+                       new DefaultProvidedInterface("integer", Integer.class)
        };
        }
        
index 9412caee08a58029eb5fb9d825ab56099e6f6051..d862b15e3eb4d08fbe2f1a64b89ebc60fa7b8425 100644 (file)
@@ -24,15 +24,15 @@ public class SystemAssemblerTest extends TestCase {
        }
 
        public void testFilterProvided() {
-               RequiredInterface req1 = new DefaultRequiredInterfaceDescriptor("name",
+               RequiredInterface req1 = new DefaultRequiredInterface("name",
                                Runnable.class);
-               RequiredInterface req2 = new DefaultRequiredInterfaceDescriptor("name",
+               RequiredInterface req2 = new DefaultRequiredInterface("name",
                                Serializable.class);
-               ProvidedInterface prov1 = new DefaultProvidedInterfaceDescriptor(
+               ProvidedInterface prov1 = new DefaultProvidedInterface(
                                "name", Runnable.class);
-               ProvidedInterface prov2 = new DefaultProvidedInterfaceDescriptor(
+               ProvidedInterface prov2 = new DefaultProvidedInterface(
                                "name", Serializable.class);
-               ProvidedInterface prov3 = new DefaultProvidedInterfaceDescriptor(
+               ProvidedInterface prov3 = new DefaultProvidedInterface(
                                "name", MyMultiple.class);
 
                AssertionUtils.assertEquals(new RequiredInterface[] { req1 },
@@ -117,9 +117,9 @@ public class SystemAssemblerTest extends TestCase {
                        Container system = new Container(
                                        "all",
                                        new Component[] { environment, application },
-                                       new ProvidedInterface[] { new DefaultProvidedInterfaceDescriptor(
+                                       new ProvidedInterface[] { new DefaultProvidedInterface(
                                                        "string", String.class) },
-                                       new DefaultRequiredInterfaceDescriptor[0]);
+                                       new DefaultRequiredInterface[0]);
                } catch (SystemAssemblyException e) {
                        return;
                }
@@ -134,7 +134,7 @@ public class SystemAssemblerTest extends TestCase {
                                        "all",
                                        new Component[] { environment, application },
                                        new ProvidedInterface[0],
-                                       new RequiredInterface[] { new DefaultRequiredInterfaceDescriptor(
+                                       new RequiredInterface[] { new DefaultRequiredInterface(
                                                        "string", String.class) });
                        system.start("root");
                } catch (SystemAssemblyException e) {
@@ -150,10 +150,10 @@ public class SystemAssemblerTest extends TestCase {
                                "all",
                                new Component[] { environment, application },
                                new ProvidedInterface[0],
-                               new RequiredInterface[] { new DefaultRequiredInterfaceDescriptor(
+                               new RequiredInterface[] { new DefaultRequiredInterface(
                                                "string", String.class) });
                system.getRequiredServices()[0].setProvider(
-                               new DefaultProvidedInterfaceDescriptor("hallo", String.class));
+                               new DefaultProvidedInterface("hallo", String.class));
                system.start("root");
                RequiredInterface[] required = system.getRequiredServices();
                assertEquals(1, required.length);
index 0b0921e6dcd6abbb410ee56effb32e6c4f916b03..f7177759aeabe7865ed1f14f72c10d488efd277f 100644 (file)
@@ -13,8 +13,6 @@ import org.springframework.context.support.GenericApplicationContext;
 import org.wamblee.system.AbstractComponent;
 import org.wamblee.system.ProvidedInterface;
 import org.wamblee.system.RequiredInterface;
-import org.wamblee.system.Service;
-import org.wamblee.system.SystemAssembler;
 import org.wamblee.system.SystemAssemblyException;
 
 /**
index 0b4ffb08a9f83eb497f3cf4a73ded1bcb4de1906..2da7a2355ad85c91f018989521c370f4be69eafc 100644 (file)
@@ -8,12 +8,10 @@ import java.util.Properties;
 import junit.framework.TestCase;
 
 import org.wamblee.io.ClassPathResource;
-import org.wamblee.system.DefaultProvidedInterfaceDescriptor;
-import org.wamblee.system.DefaultRequiredInterfaceDescriptor;
-import org.wamblee.system.DefaultService;
+import org.wamblee.system.DefaultProvidedInterface;
+import org.wamblee.system.DefaultRequiredInterface;
 import org.wamblee.system.ProvidedInterface;
 import org.wamblee.system.RequiredInterface;
-import org.wamblee.system.Service;
 import org.wamblee.system.SystemAssemblyException;
 
 public class SpringComponentTest extends TestCase {
@@ -42,7 +40,7 @@ public class SpringComponentTest extends TestCase {
 
        public void testOneProvidedService() {
                Map<String, ProvidedInterface> provided = new HashMap<String, ProvidedInterface>();
-               provided.put("helloService", new DefaultProvidedInterfaceDescriptor(
+               provided.put("helloService", new DefaultProvidedInterface(
                                "hello", HelloService.class));
 
                SpringComponent system = new SpringComponent("system", 
@@ -59,7 +57,7 @@ public class SpringComponentTest extends TestCase {
        
        public void testWithProperties() throws IOException {
                Map<String, ProvidedInterface> provided = new HashMap<String, ProvidedInterface>();
-               provided.put("helloService", new DefaultProvidedInterfaceDescriptor(
+               provided.put("helloService", new DefaultProvidedInterface(
                                "hello", HelloService.class));
                SpringComponent system = new SpringComponent("system", 
                                new String[] { HELLO_SERVICE_SPRING_WITH_PROPERTIES_XML },
@@ -91,14 +89,14 @@ public class SpringComponentTest extends TestCase {
 
        public void testWithRequirement() {
                Map<RequiredInterface, String> required = new HashMap<RequiredInterface, String>();
-               required.put(new DefaultRequiredInterfaceDescriptor("hello", HelloService.class),
+               required.put(new DefaultRequiredInterface("hello", HelloService.class),
                                "helloService");
                SpringComponent system = new SpringComponent("system",
                                new String[] { HELLO_SERVICE_SPRING_WITH_REQS_XML },
                                new HashMap<String, ProvidedInterface>(), required);
                
                HelloService helloObject = new HelloService("ladida"); 
-               ProvidedInterface helloService = new DefaultProvidedInterfaceDescriptor("hello", HelloService.class);
+               ProvidedInterface helloService = new DefaultProvidedInterface("hello", HelloService.class);
                helloService.publish(helloObject);
                system.getRequiredServices()[0].setProvider(helloService);
                
@@ -108,10 +106,10 @@ public class SpringComponentTest extends TestCase {
        
        public void testWithRequirementAndProvidedService() {
                Map<RequiredInterface, String> required = new HashMap<RequiredInterface, String>();
-               required.put(new DefaultRequiredInterfaceDescriptor("hello", HelloService.class),
+               required.put(new DefaultRequiredInterface("hello", HelloService.class),
                                "helloService");
                Map<String,ProvidedInterface> provided = new HashMap<String, ProvidedInterface>();
-               provided.put("blaService", new DefaultProvidedInterfaceDescriptor("bla",
+               provided.put("blaService", new DefaultProvidedInterface("bla",
                                BlaService.class));
 
                SpringComponent system = new SpringComponent("system",
@@ -120,7 +118,7 @@ public class SpringComponentTest extends TestCase {
                
                HelloService helloObject = new HelloService("ladida"); 
                ProvidedInterface helloService = 
-                       new DefaultProvidedInterfaceDescriptor("hello", HelloService.class);
+                       new DefaultProvidedInterface("hello", HelloService.class);
                helloService.publish(helloObject);
                system.getRequiredServices()[0].setProvider(helloService);
                system.start("Bla");