Now the component provides read-only access to the interfaces.
authorerik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Thu, 5 Jun 2008 20:47:52 +0000 (20:47 +0000)
committererik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Thu, 5 Jun 2008 20:47:52 +0000 (20:47 +0000)
22 files changed:
trunk/system/general/src/main/java/org/wamblee/system/container/Container.java
trunk/system/general/src/main/java/org/wamblee/system/core/AbstractComponent.java
trunk/system/general/src/main/java/org/wamblee/system/core/Component.java
trunk/system/general/src/main/java/org/wamblee/system/core/NamedInterface.java [new file with mode: 0644]
trunk/system/general/src/main/java/org/wamblee/system/core/ProvidedInterface.java
trunk/system/general/src/main/java/org/wamblee/system/core/ProvidedInterfaces.java [new file with mode: 0644]
trunk/system/general/src/main/java/org/wamblee/system/core/ReadOnlyNamedInterfaces.java [new file with mode: 0644]
trunk/system/general/src/main/java/org/wamblee/system/core/ReadWriteNamedInterfaces.java [new file with mode: 0644]
trunk/system/general/src/main/java/org/wamblee/system/core/ReadWriteProvidedInterfaces.java [new file with mode: 0644]
trunk/system/general/src/main/java/org/wamblee/system/core/ReadWriteRequiredInterfaces.java [new file with mode: 0644]
trunk/system/general/src/main/java/org/wamblee/system/core/RequiredInterface.java
trunk/system/general/src/main/java/org/wamblee/system/core/RequiredInterfaces.java [new file with mode: 0644]
trunk/system/general/src/test/java/org/wamblee/system/container/Application.java
trunk/system/general/src/test/java/org/wamblee/system/container/ContainerTest.java
trunk/system/general/src/test/java/org/wamblee/system/core/AbstractComponentTest.java
trunk/system/general/src/test/java/org/wamblee/system/core/Environment.java
trunk/system/general/src/test/java/org/wamblee/system/core/IntegerComponent.java
trunk/system/general/src/test/java/org/wamblee/system/core/StringComponent.java
trunk/system/general/src/test/java/org/wamblee/system/graph/CompositeEdgeFilterTest.java
trunk/system/general/src/test/java/org/wamblee/system/graph/component/ConnectExternalProvidedProvidedEdgeFilterTest.java
trunk/system/general/src/test/java/org/wamblee/system/graph/component/ConnectRequiredExternallyRequiredEdgeFilterTest.java
trunk/system/general/src/test/java/org/wamblee/system/graph/component/ConnectRequiredProvidedEdgeFilterTest.java

index a69ac98eb7c41732527350327e3fdf48aa2193f4..fe744f74c8be805d95842588e173b724a7091e22 100644 (file)
@@ -194,7 +194,7 @@ public class Container extends AbstractComponent<Scope> {
      * @return Scope.
      */
     public Scope start() {
-        Scope scope = new DefaultScope(getProvidedInterfaces());
+        Scope scope = new DefaultScope(getProvidedInterfaces().toArray());
         return super.start(scope);
     }
 
@@ -202,7 +202,7 @@ public class Container extends AbstractComponent<Scope> {
     protected Scope doStart(Scope aExternalScope) {
         checkSealed();
         validate();
-        Scope scope = new DefaultScope(getProvidedInterfaces(), aExternalScope);
+        Scope scope = new DefaultScope(getProvidedInterfaces().toArray(), aExternalScope);
         ComponentGraph graph = doStartOptionalDryRun(scope, false);
         exposeProvidedInterfaces(graph, aExternalScope, scope);
         seal();
index 9000f4ae5234a1bc8e2b54536fdd20d29f15c0a2..38df3bc4c9bc297874834eaf1953fd3083e8962d 100644 (file)
@@ -35,8 +35,8 @@ public abstract class AbstractComponent<Type> implements Component<Type> {
 
        private String _context;
        private String _name;
-       private List<ProvidedInterface> _provided;
-       private List<RequiredInterface> _required;
+       private ReadWriteProvidedInterfaces _provided;
+       private ReadWriteRequiredInterfaces _required;
 
        /**
         * Constructs the subsystem.
@@ -53,10 +53,8 @@ public abstract class AbstractComponent<Type> implements Component<Type> {
                _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 ReadWriteProvidedInterfaces(aProvided);
+               _required = new ReadWriteRequiredInterfaces(aRequired);
        }
        
        protected AbstractComponent(String aName) {
@@ -101,20 +99,20 @@ public abstract class AbstractComponent<Type> implements Component<Type> {
        }
 
        @Override
-       public final ProvidedInterface[] getProvidedInterfaces() {
-               return _provided.toArray(new ProvidedInterface[0]);
+       public final ProvidedInterfaces getProvidedInterfaces() {
+               return _provided.readOnlyView();
        }
 
        @Override
-       public final RequiredInterface[] getRequiredInterfaces() {
-               return _required.toArray(new RequiredInterface[0]);
+       public final RequiredInterfaces getRequiredInterfaces() {
+               return _required.readOnlyView();
        }
 
        @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())));
+               _remaining.set(new ArrayList<ProvidedInterface>(Arrays.asList(getProvidedInterfaces().toArray())));
                try {
                        Type runtime = doStart(aScope);
                        checkNotStartedInterfaces();
index 37a9c84dbe938c9f9ee2300257016cff375f8c35..49ed1c7dc26cee0c70ddb8d4b390f98044ef7fd0 100644 (file)
@@ -60,13 +60,13 @@ public interface Component<Type> {
         * Gets a description of the provided interfaces. 
         * @return Provided interfaces. 
         */
-       ProvidedInterface[] getProvidedInterfaces();
+       ProvidedInterfaces getProvidedInterfaces();
        
        /**
         * Gets a description of the required interfaces. 
         * @return Required interfaces. 
         */
-       RequiredInterface[] getRequiredInterfaces();
+       RequiredInterfaces getRequiredInterfaces();
 
        
        /**
diff --git a/trunk/system/general/src/main/java/org/wamblee/system/core/NamedInterface.java b/trunk/system/general/src/main/java/org/wamblee/system/core/NamedInterface.java
new file mode 100644 (file)
index 0000000..9800621
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2008 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.core;
+
+public interface NamedInterface {
+    /**
+     * Name for the interface. 
+     */
+    String getName();
+}
index f717535cf71f0369f9a3595ffa1c3d962422d998..46bf5f24528d143b9c1b488b32c56456f55d0631 100644 (file)
@@ -23,13 +23,7 @@ import java.util.Collection;
  *  
  * @author Erik Brakkee
  */
-public interface ProvidedInterface {
-    
-       /**
-        * Symbolic name for the service as used by the subsystem.  
-        * @return Service name. 
-        */
-       String getName();
+public interface ProvidedInterface extends NamedInterface {
        
        /**
         * Returns the service type. 
diff --git a/trunk/system/general/src/main/java/org/wamblee/system/core/ProvidedInterfaces.java b/trunk/system/general/src/main/java/org/wamblee/system/core/ProvidedInterfaces.java
new file mode 100644 (file)
index 0000000..9fd8c06
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2008 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.core;
+
+import java.util.List;
+
+/**
+ * Read-only access to the provided interfaces of a component. 
+ * 
+ * @author Erik Brakkee. 
+ *
+ */
+public class ProvidedInterfaces extends ReadOnlyNamedInterfaces<ProvidedInterface> {
+    
+    /**
+     * Constructs the provided interfaces. 
+     * @param aInterfaces List of interfaces. 
+     */
+    public ProvidedInterfaces(List<ProvidedInterface> aInterfaces) { 
+        super(ProvidedInterface.class, aInterfaces);
+    }
+}
diff --git a/trunk/system/general/src/main/java/org/wamblee/system/core/ReadOnlyNamedInterfaces.java b/trunk/system/general/src/main/java/org/wamblee/system/core/ReadOnlyNamedInterfaces.java
new file mode 100644 (file)
index 0000000..4248b1d
--- /dev/null
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2008 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.core;
+
+import java.lang.reflect.Array;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * A set of interfaces that cannot be changed with useful added functionality. 
+ * 
+ * @author Erik Brakkee
+ *
+ * @param <T>
+ */
+public class ReadOnlyNamedInterfaces<T extends NamedInterface> implements Iterable<T> {
+
+    private Class<T> _type; 
+    private List<T> _interfaces; 
+
+    public ReadOnlyNamedInterfaces(Class<T> aType, List<T> aInterfaces) {
+        _type = aType; 
+        _interfaces = Collections.unmodifiableList(aInterfaces); 
+    }
+    
+    /**
+     * @return Number of interfaces. 
+     */
+    public int size() { 
+        return _interfaces.size();
+    }
+    /**
+     * Gets the interface at a given index. 
+     * @param aIndex Index of the interface to return. 
+     * @return Interface.
+     */
+    public T get(int aIndex) { 
+        return _interfaces.get(aIndex);
+    }
+    
+    /**
+     * Gets the interface with a specific name. 
+     * @param aName Interface name. 
+     * @return Interface. 
+     */
+    public T get(String aName) { 
+        for (T intf: _interfaces) { 
+            if ( intf.getName().equals(aName)) { 
+                return intf; 
+            }
+        }
+        return null; 
+    }
+    
+    @Override
+    public Iterator<T> iterator() {
+        return _interfaces.iterator();
+    }
+    
+    /**
+     * Converts the interfaces to an array. 
+     * @return List of interfaces in an array. 
+     */
+    public T[] toArray() { 
+        T[] storage = (T[])Array.newInstance(_type, _interfaces.size());
+        return _interfaces.toArray(storage);
+    }
+}
diff --git a/trunk/system/general/src/main/java/org/wamblee/system/core/ReadWriteNamedInterfaces.java b/trunk/system/general/src/main/java/org/wamblee/system/core/ReadWriteNamedInterfaces.java
new file mode 100644 (file)
index 0000000..0dcd418
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2008 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.core;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+public class ReadWriteNamedInterfaces<T extends NamedInterface> implements Iterable<T> {
+    
+    protected List<T> _interfaces; 
+
+    public ReadWriteNamedInterfaces() {
+        _interfaces = new ArrayList<T>(); 
+    }
+    
+    public ReadWriteNamedInterfaces(T[] aInterfaces) { 
+        _interfaces = new ArrayList<T>();
+        _interfaces.addAll(Arrays.asList(aInterfaces));
+    }
+    
+    public int size() { 
+        return _interfaces.size();
+    }
+    
+    public T get(int aIndex) { 
+        return _interfaces.get(aIndex);
+    }
+    
+    public T get(String aName) { 
+        for (T intf: _interfaces) { 
+            if ( intf.getName().equals(aName)) { 
+                return intf; 
+            }
+        }
+        return null; 
+    }
+    
+    public void add(T aInterface) { 
+        _interfaces.add(aInterface);
+    }
+    
+    @Override
+    public Iterator<T> iterator() {
+        return _interfaces.iterator();
+    }
+
+}
diff --git a/trunk/system/general/src/main/java/org/wamblee/system/core/ReadWriteProvidedInterfaces.java b/trunk/system/general/src/main/java/org/wamblee/system/core/ReadWriteProvidedInterfaces.java
new file mode 100644 (file)
index 0000000..8581c93
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2008 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.core;
+
+public class ReadWriteProvidedInterfaces extends ReadWriteNamedInterfaces<ProvidedInterface> {
+    
+    public ReadWriteProvidedInterfaces() { 
+        super(); 
+    }
+    
+    public ReadWriteProvidedInterfaces(ProvidedInterface[] aInterfaces) { 
+        super(aInterfaces);
+    }
+
+    public ProvidedInterfaces readOnlyView() { 
+        return new ProvidedInterfaces(_interfaces);
+    }
+}
diff --git a/trunk/system/general/src/main/java/org/wamblee/system/core/ReadWriteRequiredInterfaces.java b/trunk/system/general/src/main/java/org/wamblee/system/core/ReadWriteRequiredInterfaces.java
new file mode 100644 (file)
index 0000000..3cdcceb
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2008 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.core;
+
+public class ReadWriteRequiredInterfaces extends ReadWriteNamedInterfaces<RequiredInterface> {
+
+    public ReadWriteRequiredInterfaces() { 
+        super();
+    }
+    
+    public ReadWriteRequiredInterfaces(RequiredInterface[] aInterfaces) { 
+        super(aInterfaces);
+    }
+    
+    public RequiredInterfaces readOnlyView() {
+        return new RequiredInterfaces(_interfaces);
+    }
+}
index 74c132e02aa7532cde7ec98e982b5be58c82573f..4dd77fc7dad510dcbc062eaab20a402008de627f 100644 (file)
  */ 
 package org.wamblee.system.core;
 
-public interface RequiredInterface {
-
-       /**
-        * Name for the interface. 
-        */
-       String getName();
+public interface RequiredInterface extends NamedInterface {
        
        /**
         * @return True iff the required interface is optional. 
diff --git a/trunk/system/general/src/main/java/org/wamblee/system/core/RequiredInterfaces.java b/trunk/system/general/src/main/java/org/wamblee/system/core/RequiredInterfaces.java
new file mode 100644 (file)
index 0000000..bd747cd
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2008 the original author or authors.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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.core;
+
+import java.util.List;
+
+/**
+ * Read-only access to required interfaces of a component. 
+ * @author Erik Brakkee
+ *
+ */
+public class RequiredInterfaces extends ReadOnlyNamedInterfaces<RequiredInterface> {
+
+    public RequiredInterfaces(List<RequiredInterface> aInterfaces) { 
+        super(RequiredInterface.class, aInterfaces);
+    }
+    
+}
index 946037670584c2162698703f7ecbee7c694f73d7..56c267fed6d9f80a76adf1c09d8674317c452f50 100644 (file)
@@ -66,8 +66,8 @@ public class Application extends AbstractComponent {
        @Override
        public Object doStart(Scope aScope) {
                track("start." + getName());
-               _string = aScope.getInterfaceImplementation(getRequiredInterfaces()[0].getProvider(), String.class);
-           _integer = aScope.getInterfaceImplementation(getRequiredInterfaces()[1].getProvider(), Integer.class);
+               _string = aScope.getInterfaceImplementation(getRequiredInterfaces().get(0).getProvider(), String.class);
+           _integer = aScope.getInterfaceImplementation(getRequiredInterfaces().get(1).getProvider(), Integer.class);
            return _random; 
        }
        
index 83abf3c2302debf477dc907efb5b0ffa7a6358d4..5da0f025b1715a4fa99ecb48228d896ec8e587f9 100644 (file)
@@ -31,7 +31,9 @@ import org.wamblee.system.core.DefaultRequiredInterface;
 import org.wamblee.system.core.DefaultScope;
 import org.wamblee.system.core.Environment;
 import org.wamblee.system.core.ProvidedInterface;
+import org.wamblee.system.core.ProvidedInterfaces;
 import org.wamblee.system.core.RequiredInterface;
+import org.wamblee.system.core.RequiredInterfaces;
 import org.wamblee.system.core.Scope;
 import org.wamblee.system.core.StringComponent;
 import org.wamblee.system.core.SystemAssemblyException;
@@ -125,10 +127,10 @@ public class ContainerTest extends TestCase {
                 application }, new ProvidedInterface[0],
                 new RequiredInterface[0]);
         Scope runtime = system.start();
-        RequiredInterface[] required = system.getRequiredInterfaces();
-        assertEquals(0, required.length);
-        ProvidedInterface[] provided = system.getProvidedInterfaces();
-        assertEquals(0, provided.length);
+        RequiredInterfaces required = system.getRequiredInterfaces();
+        assertEquals(0, required.size());
+        ProvidedInterfaces provided = system.getProvidedInterfaces();
+        assertEquals(0, provided.size());
 
         AssertionUtils.assertEquals(new String[] { "start.environment",
                 "start.application" }, _tracker.getEvents(
@@ -180,13 +182,13 @@ public class ContainerTest extends TestCase {
                 application }, new ProvidedInterface[0],
                 new RequiredInterface[] { new DefaultRequiredInterface("float",
                         Float.class) });
-        system.getRequiredInterfaces()[0]
+        system.getRequiredInterfaces().get(0)
                 .setProvider(new DefaultProvidedInterface("hallo", Float.class));
         system.start();
-        RequiredInterface[] required = system.getRequiredInterfaces();
-        assertEquals(1, required.length);
-        ProvidedInterface[] provided = system.getProvidedInterfaces();
-        assertEquals(0, provided.length);
+        RequiredInterfaces required = system.getRequiredInterfaces();
+        assertEquals(1, required.size());
+        ProvidedInterfaces provided = system.getProvidedInterfaces();
+        assertEquals(0, provided.size());
     }
 
     public void testCompositeWithExternalDependencesNotProvided() {
@@ -195,7 +197,7 @@ public class ContainerTest extends TestCase {
             Component application = new Application();
             Container system = new Container("all",
                     new Component[] { application }, new ProvidedInterface[0],
-                    application.getRequiredInterfaces());
+                    application.getRequiredInterfaces().toArray());
             system.start();
         } catch (SystemAssemblyException e) {
             return;
@@ -233,18 +235,18 @@ public class ContainerTest extends TestCase {
         Component application = new Application();
         Container system = new Container("all",
                 new Component[] { application }, new ProvidedInterface[0],
-                application.getRequiredInterfaces());
+                application.getRequiredInterfaces().toArray());
         environment.start(new DefaultScope(new ProvidedInterface[0]));
-        system.getRequiredInterfaces()[0].setProvider(environment
-                .getProvidedInterfaces()[0]);
-        system.getRequiredInterfaces()[1].setProvider(environment
-                .getProvidedInterfaces()[1]);
+        system.getRequiredInterfaces().get(0).setProvider(environment
+                .getProvidedInterfaces().get(0));
+        system.getRequiredInterfaces().get(1).setProvider(environment
+                .getProvidedInterfaces().get(1));
 
         system.start();
-        RequiredInterface[] required = system.getRequiredInterfaces();
-        assertEquals(2, required.length);
-        ProvidedInterface[] provided = system.getProvidedInterfaces();
-        assertEquals(0, provided.length);
+        RequiredInterfaces required = system.getRequiredInterfaces();
+        assertEquals(2, required.size());
+        ProvidedInterfaces provided = system.getProvidedInterfaces();
+        assertEquals(0, provided.size());
 
     }
 
@@ -350,22 +352,22 @@ public class ContainerTest extends TestCase {
                 new Component[] { application }, new ProvidedInterface[0],
                 Application.required(true));
         Environment env = new Environment();
-        container.getRequiredInterfaces()[0].setProvider(env
-                .getProvidedInterfaces()[0]);
-        container.getRequiredInterfaces()[1].setProvider(env
-                .getProvidedInterfaces()[1]);
-        Scope external = new DefaultScope(env.getProvidedInterfaces());
+        container.getRequiredInterfaces().get(0).setProvider(env
+                .getProvidedInterfaces().get(0));
+        container.getRequiredInterfaces().get(1).setProvider(env
+                .getProvidedInterfaces().get(1));
+        Scope external = new DefaultScope(env.getProvidedInterfaces().toArray());
         env.start(external);
 
         container.start(external);
-        assertSame(env.getProvidedInterfaces()[0], container
-                .getRequiredInterfaces()[0].getProvider());
-        assertSame(env.getProvidedInterfaces()[1], container
-                .getRequiredInterfaces()[1].getProvider());
-        assertSame(env.getProvidedInterfaces()[0], application
-                .getRequiredInterfaces()[0].getProvider());
-        assertSame(env.getProvidedInterfaces()[1], application
-                .getRequiredInterfaces()[1].getProvider());
+        assertSame(env.getProvidedInterfaces().get(0), container
+                .getRequiredInterfaces().get(0).getProvider());
+        assertSame(env.getProvidedInterfaces().get(1), container
+                .getRequiredInterfaces().get(1).getProvider());
+        assertSame(env.getProvidedInterfaces().get(0), application
+                .getRequiredInterfaces().get(0).getProvider());
+        assertSame(env.getProvidedInterfaces().get(1), application
+                .getRequiredInterfaces().get(1).getProvider());
     }
 
     public void testOptionalRequiredInterfaceNotProvidedOptionalInternal() {
@@ -374,18 +376,18 @@ public class ContainerTest extends TestCase {
                 new Component[] { application }, new ProvidedInterface[0],
                 Application.required(true));
         Environment env = new Environment();
-        container.getRequiredInterfaces()[0].setProvider(env
-                .getProvidedInterfaces()[0]);
+        container.getRequiredInterfaces().get(0).setProvider(env
+                .getProvidedInterfaces().get(0));
         Scope external = new DefaultScope(new ProvidedInterface[0]);
-        external.publishInterface(env.getProvidedInterfaces()[0], env
+        external.publishInterface(env.getProvidedInterfaces().get(0), env
                 .getString());
         container.start(external);
-        assertSame(env.getProvidedInterfaces()[0], container
-                .getRequiredInterfaces()[0].getProvider());
-        assertNull(container.getRequiredInterfaces()[1].getProvider());
-        assertSame(env.getProvidedInterfaces()[0], application
-                .getRequiredInterfaces()[0].getProvider());
-        assertNull(application.getRequiredInterfaces()[1].getProvider());
+        assertSame(env.getProvidedInterfaces().get(0), container
+                .getRequiredInterfaces().get(0).getProvider());
+        assertNull(container.getRequiredInterfaces().get(1).getProvider());
+        assertSame(env.getProvidedInterfaces().get(0), application
+                .getRequiredInterfaces().get(0).getProvider());
+        assertNull(application.getRequiredInterfaces().get(1).getProvider());
     }
 
     public void testOptionalRequiredInterfaceProvidedMandatoryInternal() {
@@ -394,10 +396,10 @@ public class ContainerTest extends TestCase {
                 new Component[] { application }, new ProvidedInterface[0],
                 Application.required(true));
         Environment env = new Environment();
-        container.getRequiredInterfaces()[0].setProvider(env
-                .getProvidedInterfaces()[0]);
-        container.getRequiredInterfaces()[1].setProvider(env
-                .getProvidedInterfaces()[1]);
+        container.getRequiredInterfaces().get(0).setProvider(env
+                .getProvidedInterfaces().get(0));
+        container.getRequiredInterfaces().get(1).setProvider(env
+                .getProvidedInterfaces().get(1));
         try {
             container.start();
         } catch (SystemAssemblyException e) {
@@ -480,7 +482,7 @@ public class ContainerTest extends TestCase {
 
         ProvidedInterface provided = new DefaultProvidedInterface("hallo",
                 Integer.class);
-        container.getRequiredInterfaces()[0].setProvider(provided);
+        container.getRequiredInterfaces().get(0).setProvider(provided);
 
         Scope external = new DefaultScope(new ProvidedInterface[0]);
         external.publishInterface(provided, 100);
@@ -547,7 +549,7 @@ public class ContainerTest extends TestCase {
             }
         }, SystemAssemblyException.class);
 
-        container.connectExternalRequired("1", app.getRequiredInterfaces()[0]
+        container.connectExternalRequired("1", app.getRequiredInterfaces().get(0)
                 .getName(), "y");
 
         ProvidedInterface i = new DefaultProvidedInterface("i", Integer.class);
@@ -560,9 +562,9 @@ public class ContainerTest extends TestCase {
         externalScope.publishInterface(x, "x-value");
         externalScope.publishInterface(y, "y-value");
 
-        container.getRequiredInterfaces()[0].setProvider(i);
-        container.getRequiredInterfaces()[1].setProvider(x);
-        container.getRequiredInterfaces()[2].setProvider(y);
+        container.getRequiredInterfaces().get(0).setProvider(i);
+        container.getRequiredInterfaces().get(1).setProvider(x);
+        container.getRequiredInterfaces().get(2).setProvider(y);
 
         Scope runtime = container.start(externalScope);
 
@@ -590,8 +592,8 @@ public class ContainerTest extends TestCase {
 
         // now choose env2
 
-        container.connectExternalProvided(container.getProvidedInterfaces()[0]
-                .getName(), env2.getName(), env2.getProvidedInterfaces()[0]
+        container.connectExternalProvided(container.getProvidedInterfaces().get(0)
+                .getName(), env2.getName(), env2.getProvidedInterfaces().get(0)
                 .getName());
 
         Scope scope = container.start();
@@ -599,7 +601,7 @@ public class ContainerTest extends TestCase {
         // check the value of the provided interface of the container
 
         String value = scope.getInterfaceImplementation(container
-                .getProvidedInterfaces()[0], String.class);
+                .getProvidedInterfaces().get(0), String.class);
         assertNotNull(value);
         assertEquals(value, env2.getString());
         assertFalse(value.equals(env1.getString()));
index 39d7dd61506d4ef23f048ffb11f211c3b9f83747..3b1b7d375fc601dfbd647d2df2f5c509ef826fc6 100644 (file)
@@ -35,7 +35,7 @@ public class AbstractComponentTest extends TestCase {
                                        // Empty.
                                }
                        };
-                       component.start(new DefaultScope(component.getProvidedInterfaces()));
+                       component.start(new DefaultScope(component.getProvidedInterfaces().toArray()));
                } catch (SystemAssemblyException e) {
                        //e.printStackTrace();
                        return;
@@ -58,7 +58,7 @@ public class AbstractComponentTest extends TestCase {
                     // Empty.
                 }
             };
-            component.start(new DefaultScope(component.getProvidedInterfaces()));
+            component.start(new DefaultScope(component.getProvidedInterfaces().toArray()));
         } catch (SystemAssemblyException e) {
             //e.printStackTrace();
             return;
index c08f456d117ff6358c7e4cbe0b018038c8f1f320..c1e72ac48807280eeaabc6d9bc9227585cb3920c 100644 (file)
@@ -64,8 +64,8 @@ public class Environment extends AbstractComponent {
 
        @Override
        protected Object doStart(Scope aScope) {
-               addInterface(getProvidedInterfaces()[0], getString(), aScope);
-               addInterface(getProvidedInterfaces()[1], getInteger(), aScope);
+               addInterface(getProvidedInterfaces().get(0), getString(), aScope);
+               addInterface(getProvidedInterfaces().get(1), getInteger(), aScope);
                track("start." + getName());
                return _random;
        }
index 0af4ae3d5d86338c62187f934fd77e3714a00d99..547f831d4e9e4d14447965733728acd6fabc8d0f 100644 (file)
@@ -59,7 +59,7 @@ public class IntegerComponent extends AbstractComponent {
 
        @Override
        protected Object doStart(Scope aScope) {
-               addInterface(getProvidedInterfaces()[1], getInteger(), aScope);
+               addInterface(getProvidedInterfaces().get(1), getInteger(), aScope);
                track("start." + getName());
                return _random;
        }
index 990adaf07bbf40e1f716b7bb08441326d770ccce..c47112aa6c86ab8d50906157c836a196f4cc474e 100644 (file)
@@ -63,7 +63,7 @@ public class StringComponent extends AbstractComponent {
 
        @Override
        protected Object doStart(Scope aScope) {
-               addInterface(getProvidedInterfaces()[0], getString(), aScope);
+               addInterface(getProvidedInterfaces().get(0), getString(), aScope);
                track("start." + getName());
                return _random;
        }
index 6507efa93bcb093553c61198fd50f54d03507651..7889c35723f25e62926c8530b4bc38f6eb6d6b87 100644 (file)
@@ -43,8 +43,8 @@ public class CompositeEdgeFilterTest extends TestCase {
 
     public void testEmpty() { 
         EdgeFilter restriction = new CompositeEdgeFilter(); 
-        assertFalse(restriction.isViolated(createEdge(_app, _app.getRequiredInterfaces()[0]
-                _env, _env.getProvidedInterfaces()[0])));
+        assertFalse(restriction.isViolated(createEdge(_app, _app.getRequiredInterfaces().get(0)
+                _env, _env.getProvidedInterfaces().get(0))));
     }
     
     private void configureRestriction(EdgeFilter base, boolean aResult) {
@@ -64,8 +64,8 @@ public class CompositeEdgeFilterTest extends TestCase {
         configureRestriction(base, false);
         
         control.replay();
-        assertFalse(composite.isViolated(createEdge(_app, _app.getRequiredInterfaces()[0]
-                _env, _env.getProvidedInterfaces()[0])));
+        assertFalse(composite.isViolated(createEdge(_app, _app.getRequiredInterfaces().get(0)
+                _env, _env.getProvidedInterfaces().get(0))));
         control.verify();
         
         // Second let the base return true and verify the result.
@@ -73,8 +73,8 @@ public class CompositeEdgeFilterTest extends TestCase {
         configureRestriction(base, true);
         
         control.replay();
-        assertTrue(composite.isViolated(createEdge(_app, _app.getRequiredInterfaces()[0]
-                _env, _env.getProvidedInterfaces()[0])));
+        assertTrue(composite.isViolated(createEdge(_app, _app.getRequiredInterfaces().get(0)
+                _env, _env.getProvidedInterfaces().get(0))));
         control.verify();
     }
 
@@ -94,8 +94,8 @@ public class CompositeEdgeFilterTest extends TestCase {
         configureRestriction(base1, false);
         configureRestriction(base2, false);
         control.replay();
-        assertFalse(composite.isViolated(createEdge(_app, _app.getRequiredInterfaces()[0]
-                _env, _env.getProvidedInterfaces()[0])));
+        assertFalse(composite.isViolated(createEdge(_app, _app.getRequiredInterfaces().get(0)
+                _env, _env.getProvidedInterfaces().get(0))));
         control.verify();
         control.reset();
         
@@ -103,8 +103,8 @@ public class CompositeEdgeFilterTest extends TestCase {
         configureRestriction(base1, false);
         configureRestriction(base2, true);
         control.replay();
-        assertTrue(composite.isViolated(createEdge(_app, _app.getRequiredInterfaces()[0]
-                _env, _env.getProvidedInterfaces()[0])));
+        assertTrue(composite.isViolated(createEdge(_app, _app.getRequiredInterfaces().get(0)
+                _env, _env.getProvidedInterfaces().get(0))));
         control.verify();
         control.reset();
         
@@ -112,8 +112,8 @@ public class CompositeEdgeFilterTest extends TestCase {
         configureRestriction(base1, true);
         // base 2 should not be called.
         control.replay();
-        assertTrue(composite.isViolated(createEdge(_app, _app.getRequiredInterfaces()[0]
-                _env, _env.getProvidedInterfaces()[0])));
+        assertTrue(composite.isViolated(createEdge(_app, _app.getRequiredInterfaces().get(0)
+                _env, _env.getProvidedInterfaces().get(0))));
         control.verify();
         control.reset();
     }
index 7d93181bef68ba4f8cec6ea7a8992f66916852b5..2adea27bae47b712a47b1b114d03a3e2a9157a65 100644 (file)
@@ -45,15 +45,15 @@ public class ConnectExternalProvidedProvidedEdgeFilterTest extends TestCase {
                         String.class));
         _internal = new Environment("env1");
 
-        _externalInterfaceName = _container.getProvidedInterfaces()[0]
+        _externalInterfaceName = _container.getProvidedInterfaces().get(0)
                 .getName();
         _internalComponentName = _internal.getName();
-        _internalInterfaceName = _internal.getProvidedInterfaces()[0].getName();
+        _internalInterfaceName = _internal.getProvidedInterfaces().get(0).getName();
 
         _edge = new DefaultEdge(new ExternalProvidedInterfaceNode(_container,
-                _container.getProvidedInterfaces()[0]),
+                _container.getProvidedInterfaces().get(0)),
                 new ProvidedInterfaceNode(_internal, _internal
-                        .getProvidedInterfaces()[0]));
+                        .getProvidedInterfaces().get(0)));
     }
 
     public void testWrongExternal() {
index 3fd7c61c03e80873f5657259058c00cbfe745f84..55d6d890e78804de9f3f90ca258806122c4139a5 100644 (file)
@@ -41,38 +41,38 @@ public class ConnectRequiredExternallyRequiredEdgeFilterTest extends TestCase {
                 .addRequiredInterface(new DefaultRequiredInterface("x",
                         String.class));
         Node req = new RequiredInterfaceNode(_comp, _comp
-                .getRequiredInterfaces()[0]);
+                .getRequiredInterfaces().get(0));
         Node external = new ExternalRequiredInterfaceNode(_container,
-                _container.getRequiredInterfaces()[0]);
+                _container.getRequiredInterfaces().get(0));
         _edge = new DefaultEdge(req, external);
     }
 
     public void testRightComponentRightInterface() {
         EdgeFilter filter = new ConnectRequiredExternallyRequiredEdgeFilter(
-                _comp.getName(), _comp.getRequiredInterfaces()[0].getName(),
-                _container.getRequiredInterfaces()[0].getName());
+                _comp.getName(), _comp.getRequiredInterfaces().get(0).getName(),
+                _container.getRequiredInterfaces().get(0).getName());
         assertFalse(filter.isViolated(_edge));
     }
 
     public void testWrongInterface() {
         EdgeFilter filter = new ConnectRequiredExternallyRequiredEdgeFilter(
-                _comp.getName(), _comp.getRequiredInterfaces()[0].getName()
-                        + "xx", _container.getRequiredInterfaces()[0].getName());
+                _comp.getName(), _comp.getRequiredInterfaces().get(0).getName()
+                        + "xx", _container.getRequiredInterfaces().get(0).getName());
         assertFalse(filter.isViolated(_edge));
     }
 
     public void testWrongComponent() {
         EdgeFilter filter = new ConnectRequiredExternallyRequiredEdgeFilter(
-                _comp.getName() + "xx", _comp.getRequiredInterfaces()[0]
-                        .getName(), _container.getRequiredInterfaces()[0]
+                _comp.getName() + "xx", _comp.getRequiredInterfaces().get(0)
+                        .getName(), _container.getRequiredInterfaces().get(0)
                         .getName());
         assertFalse(filter.isViolated(_edge));
     }
 
     public void testWrongExternalInterface() {
         EdgeFilter filter = new ConnectRequiredExternallyRequiredEdgeFilter(
-                _comp.getName(), _comp.getRequiredInterfaces()[0].getName(),
-                _container.getRequiredInterfaces()[0].getName() + "xx");
+                _comp.getName(), _comp.getRequiredInterfaces().get(0).getName(),
+                _container.getRequiredInterfaces().get(0).getName() + "xx");
         assertTrue(filter.isViolated(_edge));
     }
 
@@ -80,8 +80,8 @@ public class ConnectRequiredExternallyRequiredEdgeFilterTest extends TestCase {
         DefaultEdge edge = new DefaultEdge(new DefaultNode("x"),
                 new DefaultNode("y"));
         EdgeFilter filter = new ConnectRequiredExternallyRequiredEdgeFilter(
-                _comp.getName(), _comp.getRequiredInterfaces()[0].getName(),
-                _container.getRequiredInterfaces()[0].getName());
+                _comp.getName(), _comp.getRequiredInterfaces().get(0).getName(),
+                _container.getRequiredInterfaces().get(0).getName());
         assertFalse(filter.isViolated(edge));
     }
 }
index d9ab61bd458f805d4879c7686cfb547fa7eb4c52..ac43c9d00ebfb081ca3db3169e7f724df8060abb 100644 (file)
@@ -49,9 +49,9 @@ public class ConnectRequiredProvidedEdgeFilterTest extends TestCase {
        for (Environment env: new Environment[] { _env1, _env2} ) { 
            for (Application app: new Application[] { _app1, _app2} ) {
                Node from = new RequiredInterfaceNode(
-                       app, app.getRequiredInterfaces()[0]);
+                       app, app.getRequiredInterfaces().get(0));
                Node to = new ProvidedInterfaceNode(
-                       env, env.getProvidedInterfaces()[0]);
+                       env, env.getProvidedInterfaces().get(0));
                Edge edge = new DefaultEdge(from, to); 
                result.add(aRestriction.isViolated(edge));
            }