(no commit message)
authorErik Brakkee <erik@brakkee.org>
Fri, 6 Jun 2008 18:46:47 +0000 (18:46 +0000)
committerErik Brakkee <erik@brakkee.org>
Fri, 6 Jun 2008 18:46:47 +0000 (18:46 +0000)
18 files changed:
system/general/src/main/java/org/wamblee/system/container/Container.java
system/general/src/main/java/org/wamblee/system/core/AbstractComponent.java
system/general/src/main/java/org/wamblee/system/core/Component.java
system/general/src/main/java/org/wamblee/system/core/DefaultScope.java
system/general/src/main/java/org/wamblee/system/core/Scope.java
system/general/src/main/java/org/wamblee/system/graph/component/ComponentGraph.java
system/general/src/test/java/org/wamblee/system/container/Application.java
system/general/src/test/java/org/wamblee/system/container/ContainerTest.java
system/general/src/test/java/org/wamblee/system/core/AbstractComponentTest.java
system/general/src/test/java/org/wamblee/system/core/Environment.java
system/general/src/test/java/org/wamblee/system/core/IntegerComponent.java
system/general/src/test/java/org/wamblee/system/core/StringComponent.java
system/general/src/test/java/org/wamblee/system/graph/component/ConnectExternalProvidedProvidedEdgeFilterTest.java
system/general/src/test/java/org/wamblee/system/graph/component/ConnectRequiredExternallyRequiredEdgeFilterTest.java
system/general/src/test/java/org/wamblee/system/graph/component/ConnectRequiredProvidedEdgeFilterTest.java
system/spring/src/main/java/org/wamblee/system/spring/RequiredServiceBean.java
system/spring/src/main/java/org/wamblee/system/spring/SpringComponent.java
system/spring/src/test/java/org/wamblee/system/spring/SpringComponentTest.java

index fe744f74c8be805d95842588e173b724a7091e22..60456c5e4cdb98f84b74ab811eeab0c96cac53bf 100644 (file)
@@ -16,6 +16,7 @@
 package org.wamblee.system.container;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -63,7 +64,7 @@ public class Container extends AbstractComponent<Scope> {
      *            Required services by the container.
      */
     public Container(String aName, Component[] aComponents,
-            ProvidedInterface[] aProvided, RequiredInterface[] aRequired) {
+            List<ProvidedInterface> aProvided, List<RequiredInterface> aRequired) {
         super(aName, aProvided, aRequired);
         _components = new ArrayList<Component>();
 
@@ -74,6 +75,23 @@ public class Container extends AbstractComponent<Scope> {
             addComponent(component);
         }
     }
+    
+    /**
+     * Constructs the container
+     * 
+     * @param aName
+     *            Name of the container
+     * @param aComponents
+     *            Components.
+     * @param aProvided
+     *            Provided services of the container
+     * @param aRequired
+     *            Required services by the container.
+     */
+    public Container(String aName, Component[] aComponents,
+            ProvidedInterface[] aProvided, RequiredInterface[] aRequired) {
+        this(aName, aComponents, Arrays.asList(aProvided), Arrays.asList(aRequired));
+    }
 
     public Container(String aName) {
         this(aName, new Component[0], new ProvidedInterface[0],
@@ -194,7 +212,7 @@ public class Container extends AbstractComponent<Scope> {
      * @return Scope.
      */
     public Scope start() {
-        Scope scope = new DefaultScope(getProvidedInterfaces().toArray());
+        Scope scope = new DefaultScope(getProvidedInterfaces());
         return super.start(scope);
     }
 
@@ -202,7 +220,7 @@ public class Container extends AbstractComponent<Scope> {
     protected Scope doStart(Scope aExternalScope) {
         checkSealed();
         validate();
-        Scope scope = new DefaultScope(getProvidedInterfaces().toArray(), aExternalScope);
+        Scope scope = new DefaultScope(getProvidedInterfaces().toArray(new ProvidedInterface[0]), aExternalScope);
         ComponentGraph graph = doStartOptionalDryRun(scope, false);
         exposeProvidedInterfaces(graph, aExternalScope, scope);
         seal();
index 31e50ed58ad251bf90a1cd8afdffde7656aadf89..d2cf69fe76f3b1039133debdc726ae88857a927d 100644 (file)
@@ -18,9 +18,7 @@ package org.wamblee.system.core;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
-import java.util.HashSet;
 import java.util.List;
-import java.util.Set;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -49,27 +47,40 @@ public abstract class AbstractComponent<Type> implements Component<Type> {
         * @param aRequired
         *            Required services.
         */
-       protected AbstractComponent(String aName, ProvidedInterface[] aProvided,
-                       RequiredInterface[] aRequired) {
+       protected AbstractComponent(String aName, List<ProvidedInterface> aProvided,
+                       List<RequiredInterface> aRequired) {
                _remaining = new ThreadLocal<List<ProvidedInterface>>();
                _context = null;
                _name = aName;
-               _provided = new ArrayList<ProvidedInterface>();
-               _provided.addAll(Arrays.asList(aProvided));
-               _required = new ArrayList<RequiredInterface>(); 
-               _required.addAll(Arrays.asList(aRequired));
+               _provided = new ArrayList<ProvidedInterface>(aProvided);
+               _required = new ArrayList<RequiredInterface>(aRequired); 
        }
        
+       /**
+     * Constructs the subsystem.
+     * 
+     * @param aName
+     *            Name of the system.
+     * @param aProvided
+     *            Provided services.
+     * @param aRequired
+     *            Required services.
+     */
+    protected AbstractComponent(String aName, ProvidedInterface[] aProvided,
+            RequiredInterface[] aRequired) {
+        this(aName, Arrays.asList(aProvided), Arrays.asList(aRequired));
+    }
+       
        protected AbstractComponent(String aName) {
                this(aName, new ProvidedInterface[0], new RequiredInterface[0]);
        }
        
-       public AbstractComponent addProvidedInterface(ProvidedInterface aProvided) { 
+       public AbstractComponent<Type> addProvidedInterface(ProvidedInterface aProvided) { 
                _provided.add(aProvided);
                return this; 
        }
        
-       public AbstractComponent addRequiredInterface(RequiredInterface aRequired) { 
+       public AbstractComponent<Type> addRequiredInterface(RequiredInterface aRequired) { 
                _required.add(aRequired);
                return this;
        }
@@ -102,20 +113,20 @@ public abstract class AbstractComponent<Type> implements Component<Type> {
        }
 
        @Override
-       public final ProvidedInterfaces getProvidedInterfaces() {
-               return new ProvidedInterfaces(Collections.unmodifiableList(_provided));
+       public final List<ProvidedInterface> getProvidedInterfaces() {
+               return Collections.unmodifiableList(_provided);
        }
 
        @Override
-       public final RequiredInterfaces getRequiredInterfaces() {
-               return new RequiredInterfaces(Collections.unmodifiableList(_required));
+       public final List<RequiredInterface> getRequiredInterfaces() {
+               return Collections.unmodifiableList(_required);
        }
 
        @Override
        public final Type start(Scope aScope) {
                LOG.info("Initialization starting '" + getQualifiedName() + "'");
                List<ProvidedInterface> oldRemaining = _remaining.get();
-               _remaining.set(new ArrayList<ProvidedInterface>(Arrays.asList(getProvidedInterfaces().toArray())));
+               _remaining.set(new ArrayList<ProvidedInterface>(getProvidedInterfaces()));
                try {
                        Type runtime = doStart(aScope);
                        checkNotStartedInterfaces();
@@ -139,7 +150,7 @@ public abstract class AbstractComponent<Type> implements Component<Type> {
 
        /**
         * Must be implemented for initializing the subsystem. The implementation
-        * must call {@link #addService(Service)} for each service that is started.
+        * must call {@link #addInterface(ProvidedInterface, Object, Scope)} for each service that is started.
         * 
         * @return Returns the runtime of the component.
         */
index 49ed1c7dc26cee0c70ddb8d4b390f98044ef7fd0..9506bb1f32c3fc874b9460cad4ac6e0757c0e6b3 100644 (file)
@@ -15,6 +15,8 @@
  */ 
 package org.wamblee.system.core;
 
+import java.util.List;
+
 /**
  * A component represents a part of a system that requires a 
  * number of interfaces and provides a number of interfaces.
@@ -60,13 +62,13 @@ public interface Component<Type> {
         * Gets a description of the provided interfaces. 
         * @return Provided interfaces. 
         */
-       ProvidedInterfaces getProvidedInterfaces();
+       List<ProvidedInterface> getProvidedInterfaces();
        
        /**
         * Gets a description of the required interfaces. 
         * @return Required interfaces. 
         */
-       RequiredInterfaces getRequiredInterfaces();
+       List<RequiredInterface> getRequiredInterfaces();
 
        
        /**
index 7290a790365eda04712f5ffe5ecd74cc692a2fb4..ad4b09863418b6e7f02b47cfcdfec952f5e4b2db 100644 (file)
@@ -17,6 +17,7 @@ package org.wamblee.system.core;
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -29,7 +30,11 @@ public class DefaultScope implements Scope {
        private Map<String, Object> _properties;
        private Map<String, Object> _runtimes;
        private Map<ProvidedInterface, ProvidedInterfaceImplementation> _provided;
-       private ProvidedInterface[] _externallyProvided;
+       private List<ProvidedInterface> _externallyProvided;
+       
+       public DefaultScope(List<ProvidedInterface>aExternallyProvided) { 
+           this(aExternallyProvided.toArray(new ProvidedInterface[0]));
+       }
 
        public DefaultScope(ProvidedInterface[] aExternallyProvided) {
                this(aExternallyProvided, new ArrayList<Scope>());
@@ -45,12 +50,13 @@ public class DefaultScope implements Scope {
                _properties = new HashMap<String, Object>();
                _runtimes = new HashMap<String, Object>();
                _provided = new HashMap<ProvidedInterface, ProvidedInterfaceImplementation>();
-               _externallyProvided = aExternallyProvided;
+               _externallyProvided = new ArrayList<ProvidedInterface>(); 
+               _externallyProvided.addAll(Arrays.asList(aExternallyProvided));
        }
 
        @Override
-       public ProvidedInterface[] getProvidedInterfaces() {
-               return _externallyProvided;
+       public List<ProvidedInterface> getProvidedInterfaces() {
+               return Collections.unmodifiableList(_externallyProvided);
        }
 
        @Override
index 4f26f53df485e52c7a1cbd5dab5611b0d0459a1b..1b9f66154597e7aaa190a77f5acc3c58dbf0414c 100644 (file)
@@ -15,6 +15,8 @@
  */ 
 package org.wamblee.system.core;
 
+import java.util.List;
+
 /**
  * A scope represents a set of running services and the runtime information for the 
  * started components and is (usually) the result of 
@@ -28,7 +30,7 @@ public interface Scope {
         * Gets the provided interfaces by this scope. 
         * @return Provided interfaces. 
         */
-       ProvidedInterface[] getProvidedInterfaces();
+       List<ProvidedInterface> getProvidedInterfaces();
        
        /**
         * Adds a key value pair to the scope. 
index aedaa0c3e94021a33c86cc7bdaf14bcc47e48a75..008f0026c1127750598fcde2c5f5b296f299951c 100644 (file)
@@ -111,7 +111,7 @@ public class ComponentGraph extends Graph {
      * provided interfaces. 
      * @param aComponent Component to add. 
      */
-    public void addComponent(Component aComponent) { 
+    public void addComponent(Component<?> aComponent) { 
         // Add required interfaces. 
         Node compNode = new ComponentNode(aComponent);
         List<Node> requiredNodes = new ArrayList<Node>();
index 56c267fed6d9f80a76adf1c09d8674317c452f50..58dcba6070348876b513792c2a08a7f850797e28 100644 (file)
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- */ 
+ */
 package org.wamblee.system.container;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
 import org.wamblee.system.core.AbstractComponent;
 import org.wamblee.system.core.DefaultRequiredInterface;
 import org.wamblee.system.core.ProvidedInterface;
@@ -22,76 +26,79 @@ import org.wamblee.system.core.RequiredInterface;
 import org.wamblee.system.core.Scope;
 import org.wamblee.test.EventTracker;
 
-public class Application extends AbstractComponent {
-       public static RequiredInterface[] required(boolean aOptional, String aPrefix) {
-               return
-               new RequiredInterface[] { 
-                       new DefaultRequiredInterface(aPrefix + "string", String.class, aOptional), 
-                       new DefaultRequiredInterface(aPrefix + "integer", Integer.class, aOptional)
-       };
-       }
-       
-       public static RequiredInterface[] required(boolean aOptional) {
+public class Application extends AbstractComponent<Object> {
+    public static RequiredInterface[] required(boolean aOptional,
+            String aPrefix) {
+        return new RequiredInterface[] {
+                new DefaultRequiredInterface(aPrefix + "string", String.class,
+                        aOptional),
+                new DefaultRequiredInterface(aPrefix + "integer",
+                        Integer.class, aOptional) };
+    }
+
+    public static RequiredInterface[] required(boolean aOptional) {
         return required(aOptional, "");
     }
-    
 
-       private EventTracker<String> _tracker;
-       private String _string; 
-       private Integer _integer;
-       private double _random; 
-       
-       public Application() {
-           this("application");
-       }
-       
-       public Application(String aName) {
-           this(aName, "");
+    private EventTracker<String> _tracker;
+    private String _string;
+    private Integer _integer;
+    private double _random;
+
+    public Application() {
+        this("application");
+    }
+
+    public Application(String aName) {
+        this(aName, "");
     }
-       
-       public Application(String aName, String aPrefix) {
-        super(aName, new ProvidedInterface[0], required(false, aPrefix));
+
+    public Application(String aName, String aPrefix) {
+        super(aName, new ProvidedInterface[0], required(false,
+                aPrefix));
         _random = Math.random();
     }
-       
-       public Application(boolean aIsOptinal) { 
-               super("application", new ProvidedInterface[0], required(true, "")); 
-       }
-       
-       public Application(EventTracker<String> aTracker) { 
-               this();
-               _tracker = aTracker; 
-       }
 
-       @Override
-       public Object doStart(Scope aScope) {
-               track("start." + getName());
-               _string = aScope.getInterfaceImplementation(getRequiredInterfaces().get(0).getProvider(), String.class);
-           _integer = aScope.getInterfaceImplementation(getRequiredInterfaces().get(1).getProvider(), Integer.class);
-           return _random; 
-       }
-       
-       public String getString() {
-               return _string;
-       }
-       
-       public Integer getInteger() {
-               return _integer;
-       }
-       
-       @Override
-       public void doStop(Object aRuntime) {
-               track("stop." + getName());
-               if ( _random != (Double)aRuntime) { 
-                       throw new IllegalArgumentException("Wrong runtime: expected " + _random + " but got " +
-                                       aRuntime);
-               }
-       }
-       
-       private void track(String aString) {
-               if ( _tracker == null ) { 
-                       return; 
-               }
-               _tracker.eventOccurred(aString);
-       }
+    public Application(boolean aIsOptinal) {
+        super("application", new ProvidedInterface[0], required(true, ""));
+    }
+
+    public Application(EventTracker<String> aTracker) {
+        this();
+        _tracker = aTracker;
+    }
+
+    @Override
+    public Object doStart(Scope aScope) {
+        track("start." + getName());
+        _string = aScope.getInterfaceImplementation(getRequiredInterfaces()
+                .get(0).getProvider(), String.class);
+        _integer = aScope.getInterfaceImplementation(getRequiredInterfaces()
+                .get(1).getProvider(), Integer.class);
+        return _random;
+    }
+
+    public String getString() {
+        return _string;
+    }
+
+    public Integer getInteger() {
+        return _integer;
+    }
+
+    @Override
+    public void doStop(Object aRuntime) {
+        track("stop." + getName());
+        if (_random != (Double) aRuntime) {
+            throw new IllegalArgumentException("Wrong runtime: expected "
+                    + _random + " but got " + aRuntime);
+        }
+    }
+
+    private void track(String aString) {
+        if (_tracker == null) {
+            return;
+        }
+        _tracker.eventOccurred(aString);
+    }
 }
index 5da0f025b1715a4fa99ecb48228d896ec8e587f9..8cd119f37e7cbe598bb27c10de80f7e5d0e03a10 100644 (file)
@@ -79,7 +79,7 @@ public class ContainerTest extends TestCase {
         AssertionUtils.assertEquals(new String[] { "start.environment",
                 "start.application" }, _tracker.getEvents(
                 Thread.currentThread()).toArray(new String[0]));
-        assertEquals(0, scope.getProvidedInterfaces().length);
+        assertEquals(0, scope.getProvidedInterfaces().size());
 
         assertEquals(environment.getString(), application.getString());
         assertEquals(environment.getInteger(), application.getInteger());
@@ -96,7 +96,7 @@ public class ContainerTest extends TestCase {
         AssertionUtils.assertEquals(new String[] { "start.environment",
                 "start.application" }, _tracker.getEvents(
                 Thread.currentThread()).toArray(new String[0]));
-        assertEquals(0, scope.getProvidedInterfaces().length);
+        assertEquals(0, scope.getProvidedInterfaces().size());
 
         assertEquals(environment.getString(), application.getString());
         assertEquals(environment.getInteger(), application.getInteger());
@@ -105,8 +105,8 @@ public class ContainerTest extends TestCase {
 
     public void testApplicationEnvironment() {
         try {
-            Component environment = new Environment();
-            Component application = new Application();
+            Component<?> environment = new Environment();
+            Component<?> application = new Application();
             Container container = new Container("root", new Component[] {
                     application, environment }, new ProvidedInterface[0],
                     new RequiredInterface[0]);
@@ -119,17 +119,17 @@ public class ContainerTest extends TestCase {
     }
 
     public void testComposite() {
-        Component environment = new Environment(_tracker);
-        Component application = new Application(_tracker);
+        Component<?> environment = new Environment(_tracker);
+        Component<?> application = new Application(_tracker);
         assertEquals(0, _tracker.getEventCount());
 
         Container system = new Container("all", new Component[] { environment,
                 application }, new ProvidedInterface[0],
                 new RequiredInterface[0]);
         Scope runtime = system.start();
-        RequiredInterfaces required = system.getRequiredInterfaces();
+        List<RequiredInterface> required = system.getRequiredInterfaces();
         assertEquals(0, required.size());
-        ProvidedInterfaces provided = system.getProvidedInterfaces();
+        List<ProvidedInterface> provided = system.getProvidedInterfaces();
         assertEquals(0, provided.size());
 
         AssertionUtils.assertEquals(new String[] { "start.environment",
@@ -146,8 +146,8 @@ public class ContainerTest extends TestCase {
 
     public void testCompositeWithWrongProvidedInfo() {
         try {
-            Component environment = new Environment();
-            Component application = new Application();
+            Component<?> environment = new Environment();
+            Component<?> application = new Application();
             Container system = new Container("all", new Component[] {
                     environment, application },
                     new ProvidedInterface[] { new DefaultProvidedInterface(
@@ -162,8 +162,8 @@ public class ContainerTest extends TestCase {
 
     public void testCompositeRequiredInterfaceNotProvided() {
         try {
-            Component environment = new Environment();
-            Component application = new Application();
+            Component<?> environment = new Environment();
+            Component<?> application = new Application();
             Container system = new Container("all", new Component[] {
                     environment, application }, new ProvidedInterface[0],
                     new RequiredInterface[] { new DefaultRequiredInterface(
@@ -176,8 +176,8 @@ public class ContainerTest extends TestCase {
     }
 
     public void testCompositeWithSuperfluousRequiredInfo() {
-        Component environment = new Environment();
-        Component application = new Application();
+        Component<?> environment = new Environment();
+        Component<?> application = new Application();
         Container system = new Container("all", new Component[] { environment,
                 application }, new ProvidedInterface[0],
                 new RequiredInterface[] { new DefaultRequiredInterface("float",
@@ -185,19 +185,19 @@ public class ContainerTest extends TestCase {
         system.getRequiredInterfaces().get(0)
                 .setProvider(new DefaultProvidedInterface("hallo", Float.class));
         system.start();
-        RequiredInterfaces required = system.getRequiredInterfaces();
+        List<RequiredInterface> required = system.getRequiredInterfaces();
         assertEquals(1, required.size());
-        ProvidedInterfaces provided = system.getProvidedInterfaces();
+        List<ProvidedInterface> provided = system.getProvidedInterfaces();
         assertEquals(0, provided.size());
     }
 
     public void testCompositeWithExternalDependencesNotProvided() {
         try {
-            Component environment = new Environment();
-            Component application = new Application();
+            Component<?> application = new Application();
+           
             Container system = new Container("all",
                     new Component[] { application }, new ProvidedInterface[0],
-                    application.getRequiredInterfaces().toArray());
+                    application.getRequiredInterfaces().toArray(new RequiredInterface[0]));
             system.start();
         } catch (SystemAssemblyException e) {
             return;
@@ -207,8 +207,8 @@ public class ContainerTest extends TestCase {
 
     public void testDuplicateComponent() {
         try {
-            Component comp1 = new Application();
-            Component comp2 = new Application();
+            Component<?> comp1 = new Application();
+            Component<?> comp2 = new Application();
             Container system = new Container("top");
             system.addComponent(comp1).addComponent(comp2);
         } catch (SystemAssemblyException e) {
@@ -220,7 +220,7 @@ public class ContainerTest extends TestCase {
 
     public void testInconsistentHierarchy() {
         try {
-            Component comp = new Application();
+            Component<?> comp = new Application();
             Container system = new Container("top").addComponent(comp);
             Container system2 = new Container("top2").addComponent(comp);
         } catch (SystemAssemblyException e) {
@@ -231,11 +231,11 @@ public class ContainerTest extends TestCase {
 
     public void testCompositeWithExternalDependencesProvided() {
 
-        Component environment = new Environment();
-        Component application = new Application();
+        Component<?> environment = new Environment();
+        Component<?> application = new Application();
         Container system = new Container("all",
                 new Component[] { application }, new ProvidedInterface[0],
-                application.getRequiredInterfaces().toArray());
+                application.getRequiredInterfaces().toArray(new RequiredInterface[0]));
         environment.start(new DefaultScope(new ProvidedInterface[0]));
         system.getRequiredInterfaces().get(0).setProvider(environment
                 .getProvidedInterfaces().get(0));
@@ -243,18 +243,18 @@ public class ContainerTest extends TestCase {
                 .getProvidedInterfaces().get(1));
 
         system.start();
-        RequiredInterfaces required = system.getRequiredInterfaces();
+        List<RequiredInterface> required = system.getRequiredInterfaces();
         assertEquals(2, required.size());
-        ProvidedInterfaces provided = system.getProvidedInterfaces();
+        List<ProvidedInterface> provided = system.getProvidedInterfaces();
         assertEquals(0, provided.size());
 
     }
 
     public void testAmbiguousInterfaces() {
         try {
-            Component environment1 = new Environment();
-            Component environment2 = new Environment();
-            Component application = new Application();
+            Component<?> environment1 = new Environment();
+            Component<?> environment2 = new Environment();
+            Component<?> application = new Application();
             Container container = new Container("root", new Component[] {
                     environment1, environment2, application },
                     new ProvidedInterface[0], new RequiredInterface[0]);
@@ -268,7 +268,7 @@ public class ContainerTest extends TestCase {
 
     public void testIncompleteRequirements() {
         try {
-            Component application = new Application();
+            Component<?> application = new Application();
             Container system = new Container("all",
                     new Component[] { application }, new ProvidedInterface[0],
                     new RequiredInterface[0]);
@@ -356,7 +356,7 @@ public class ContainerTest extends TestCase {
                 .getProvidedInterfaces().get(0));
         container.getRequiredInterfaces().get(1).setProvider(env
                 .getProvidedInterfaces().get(1));
-        Scope external = new DefaultScope(env.getProvidedInterfaces().toArray());
+        Scope external = new DefaultScope(env.getProvidedInterfaces());
         env.start(external);
 
         container.start(external);
index 3b1b7d375fc601dfbd647d2df2f5c509ef826fc6..2fd48f6e4c08de37cb13d62aab3ddcb632db3f6c 100644 (file)
@@ -21,7 +21,7 @@ public class AbstractComponentTest extends TestCase {
 
        public void testNotAllInterfacesStarted() {
                try {
-                       Component component = new AbstractComponent("xx",
+                       Component<?> component = new AbstractComponent<Object>("xx",
                                        new ProvidedInterface[] { new DefaultProvidedInterface(
                                                        "xxx", String.class) }, new RequiredInterface[0]) {
                                @Override
@@ -35,7 +35,7 @@ public class AbstractComponentTest extends TestCase {
                                        // Empty.
                                }
                        };
-                       component.start(new DefaultScope(component.getProvidedInterfaces().toArray()));
+                       component.start(new DefaultScope(component.getProvidedInterfaces()));
                } catch (SystemAssemblyException e) {
                        //e.printStackTrace();
                        return;
@@ -45,7 +45,7 @@ public class AbstractComponentTest extends TestCase {
        
        public void testUnexpectedServicesStarted() { 
            try {
-            Component component = new AbstractComponent("xx",
+            Component<?> component = new AbstractComponent<Object>("xx",
                     new ProvidedInterface[0], new RequiredInterface[0]) {
                 @Override
                 protected Object doStart(Scope aScope) {
@@ -58,7 +58,7 @@ public class AbstractComponentTest extends TestCase {
                     // Empty.
                 }
             };
-            component.start(new DefaultScope(component.getProvidedInterfaces().toArray()));
+            component.start(new DefaultScope(component.getProvidedInterfaces()));
         } catch (SystemAssemblyException e) {
             //e.printStackTrace();
             return;
index c1e72ac48807280eeaabc6d9bc9227585cb3920c..d2c052715e7089f8a4a7a2d0a3b9584fe47aedc7 100644 (file)
@@ -23,7 +23,7 @@ import org.wamblee.system.core.ProvidedInterface;
 import org.wamblee.system.core.RequiredInterface;
 import org.wamblee.test.EventTracker;
 
-public class Environment extends AbstractComponent {
+public class Environment extends AbstractComponent<Object> {
 
        private static final ProvidedInterface[] provided(String aPrefix) {
                return new ProvidedInterface[] {
index 547f831d4e9e4d14447965733728acd6fabc8d0f..acf683fef8af7f74a83ea09001db52a0c22fd43a 100644 (file)
@@ -23,7 +23,7 @@ import org.wamblee.system.core.ProvidedInterface;
 import org.wamblee.system.core.RequiredInterface;
 import org.wamblee.test.EventTracker;
 
-public class IntegerComponent extends AbstractComponent {
+public class IntegerComponent extends AbstractComponent<Object> {
 
        private static final ProvidedInterface[] provided(String aPrefix) {
                return new ProvidedInterface[] {
index c47112aa6c86ab8d50906157c836a196f4cc474e..7701c20bb150afc80bb042465c793e646c255986 100644 (file)
@@ -23,7 +23,7 @@ import org.wamblee.system.core.ProvidedInterface;
 import org.wamblee.system.core.RequiredInterface;
 import org.wamblee.test.EventTracker;
 
-public class StringComponent extends AbstractComponent {
+public class StringComponent extends AbstractComponent<Object> {
 
        private static final ProvidedInterface[] provided(String aPrefix) {
                return new ProvidedInterface[] {
index 2adea27bae47b712a47b1b114d03a3e2a9157a65..328796577a48d92f907506ab178e40879f8537d0 100644 (file)
@@ -32,7 +32,7 @@ import org.wamblee.system.graph.Node;
 public class ConnectExternalProvidedProvidedEdgeFilterTest extends TestCase {
 
     private Container _container;
-    private Component _internal;
+    private Component<Object> _internal;
     private String _externalInterfaceName;
     private String _internalComponentName;
     private String _internalInterfaceName;
index 55d6d890e78804de9f3f90ca258806122c4139a5..4f30b538d59c6bbf7f5ef28eef73eb05bf7787a9 100644 (file)
@@ -30,7 +30,7 @@ import junit.framework.TestCase;
 
 public class ConnectRequiredExternallyRequiredEdgeFilterTest extends TestCase {
 
-    private Component _comp;
+    private Component<?> _comp;
     private Container _container;
     private Edge _edge;
 
index ac43c9d00ebfb081ca3db3169e7f724df8060abb..0cb9013b742535a886cbb134d733529e3147d3b3 100644 (file)
@@ -41,6 +41,8 @@ public class ConnectRequiredProvidedEdgeFilterTest extends TestCase {
     private void compare(Boolean[] aExpected, EdgeFilter aRestriction) { 
        List<Boolean> result = new ArrayList<Boolean>();
        
+      
+       
        // order will be: 
        //     env1, app1
        //     env1, app2
index abd5115ea68ab78384175e974280d43fa606fdee..2a34920883014c6b1e0de77b2885820bb693f5e1 100644 (file)
@@ -15,6 +15,8 @@
  */ 
 package org.wamblee.system.spring;
 
+import java.util.List;
+
 import org.springframework.beans.factory.FactoryBean;
 import org.wamblee.system.core.ProvidedInterface;
 import org.wamblee.system.core.RequiredInterface;
@@ -36,7 +38,7 @@ class RequiredServiceBean implements FactoryBean {
         * @param aId Id of the bean in the service registry.  
         */
        public RequiredServiceBean(String aId) { 
-               RequiredInterfaces required = SpringComponent.THIS.get().getRequiredInterfaces();
+               List<RequiredInterface> required = SpringComponent.THIS.get().getRequiredInterfaces();
                for ( RequiredInterface intf: required) { 
                        if ( intf.getName().equals(aId)) { 
                                _required = intf; 
index c1e3a7b302f9098858cc468886b48e1f256bc3cb..88746a5ecc4a94f50a0af17653a49a05bce7f51d 100644 (file)
@@ -113,7 +113,7 @@ public class SpringComponent extends AbstractComponent<Scope> {
                SpringComponent old = THIS.get();
                Scope oldScope = SCOPE.get();
                THIS.set(this);
-               Scope scope = new DefaultScope(getProvidedInterfaces().toArray(), aExternalScope);
+               Scope scope = new DefaultScope(getProvidedInterfaces().toArray(new ProvidedInterface[0]), aExternalScope);
                SCOPE.set(scope);
                try {
                        GenericApplicationContext parentContext = new GenericApplicationContext();
index 67ed048df8f19dbaed681191c855686d785486ac..1cc95c11cb640e7c92ca2ab3192b7977880458ee 100644 (file)
@@ -17,6 +17,7 @@ package org.wamblee.system.spring;
 
 import java.io.IOException;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 
@@ -59,7 +60,7 @@ public class SpringComponentTest extends TestCase {
                 new HashMap<RequiredInterface, String>());
 
         Scope runtime = system.start(_externalScope);
-        assertEquals(0, _externalScope.getProvidedInterfaces().length);
+        assertEquals(0, _externalScope.getProvidedInterfaces().size()); 
 
         system.stop(runtime);
     }
@@ -73,10 +74,10 @@ public class SpringComponentTest extends TestCase {
                 new String[] { HELLO_SERVICE_SPRING_XML }, provided,
                 new HashMap<RequiredInterface, String>());
         Scope runtime = system.start(_externalScope);
-        ProvidedInterface[] services = runtime.getProvidedInterfaces();
+        List<ProvidedInterface> services = runtime.getProvidedInterfaces();
 
-        assertEquals(1, services.length);
-        Object service = runtime.getInterfaceImplementation(services[0],
+        assertEquals(1, services.size());
+        Object service = runtime.getInterfaceImplementation(services.get(0),
                 Object.class);
         assertTrue(service instanceof HelloService);
 
@@ -106,9 +107,9 @@ public class SpringComponentTest extends TestCase {
         // unprocessed property
         // and another time with the processed property.
         assertEquals(1, EVENT_TRACKER.getEventCount());
-        ProvidedInterface[] services = scope.getProvidedInterfaces();
+        List<ProvidedInterface> services = scope.getProvidedInterfaces();
         assertEquals("Property Value", scope.getInterfaceImplementation(
-                services[0], HelloService.class).say());
+                services.get(0), HelloService.class).say());
     }
 
     public void testWithPropertiesAsBean() throws IOException {
@@ -124,9 +125,9 @@ public class SpringComponentTest extends TestCase {
 
         Scope scope = system.start(_externalScope);
 
-        ProvidedInterface[] services = scope.getProvidedInterfaces();
+        List<ProvidedInterface> services = scope.getProvidedInterfaces();
 
-        Properties props2 = scope.getInterfaceImplementation(services[0],
+        Properties props2 = scope.getInterfaceImplementation(services.get(0),
                 HelloService2.class).getProperties();
         assertEquals(props, props2);
     }
@@ -183,7 +184,7 @@ public class SpringComponentTest extends TestCase {
         scope.publishInterface(helloService, helloObject);
         system.getRequiredInterfaces().get(0).setProvider(helloService);
         Scope runtime = system.start(scope);
-        ProvidedInterface started = runtime.getProvidedInterfaces()[0];
+        ProvidedInterface started = runtime.getProvidedInterfaces().get(0);
 
         Object impl = runtime.getInterfaceImplementation(started,
                 BlaService.class);
@@ -208,10 +209,10 @@ public class SpringComponentTest extends TestCase {
                 new HashMap<RequiredInterface, String>());
 
         Scope runtime = system.start(_externalScope);
-        ProvidedInterface[] services = runtime.getProvidedInterfaces();
+        List<ProvidedInterface> services = runtime.getProvidedInterfaces();
 
-        assertEquals(2, services.length);
-        Object service = runtime.getInterfaceImplementation(services[0],
+        assertEquals(2, services.size());
+        Object service = runtime.getInterfaceImplementation(services.get(0),
                 Object.class);
         assertTrue(service instanceof HelloService);