From: erik Date: Thu, 5 Jun 2008 20:47:50 +0000 (+0000) Subject: Now the component provides read-only access to the interfaces. X-Git-Tag: wamblee-utils-0.2~1^2~89 X-Git-Url: http://wamblee.org/gitweb/?a=commitdiff_plain;h=f2df9ad58df735e6f507ffd9330b0f99b8fb1d5e;p=utils Now the component provides read-only access to the interfaces. --- diff --git a/system/spring/src/main/java/org/wamblee/system/spring/RequiredServiceBean.java b/system/spring/src/main/java/org/wamblee/system/spring/RequiredServiceBean.java index 2e72f733..abd5115e 100644 --- a/system/spring/src/main/java/org/wamblee/system/spring/RequiredServiceBean.java +++ b/system/spring/src/main/java/org/wamblee/system/spring/RequiredServiceBean.java @@ -18,6 +18,7 @@ package org.wamblee.system.spring; import org.springframework.beans.factory.FactoryBean; import org.wamblee.system.core.ProvidedInterface; import org.wamblee.system.core.RequiredInterface; +import org.wamblee.system.core.RequiredInterfaces; import org.wamblee.system.core.SystemAssemblyException; /** @@ -35,7 +36,7 @@ class RequiredServiceBean implements FactoryBean { * @param aId Id of the bean in the service registry. */ public RequiredServiceBean(String aId) { - RequiredInterface[] required = SpringComponent.THIS.get().getRequiredInterfaces(); + RequiredInterfaces required = SpringComponent.THIS.get().getRequiredInterfaces(); for ( RequiredInterface intf: required) { if ( intf.getName().equals(aId)) { _required = intf; diff --git a/system/spring/src/main/java/org/wamblee/system/spring/SpringComponent.java b/system/spring/src/main/java/org/wamblee/system/spring/SpringComponent.java index 83a5133b..c1e3a7b3 100644 --- a/system/spring/src/main/java/org/wamblee/system/spring/SpringComponent.java +++ b/system/spring/src/main/java/org/wamblee/system/spring/SpringComponent.java @@ -113,7 +113,7 @@ public class SpringComponent extends AbstractComponent { SpringComponent old = THIS.get(); Scope oldScope = SCOPE.get(); THIS.set(this); - Scope scope = new DefaultScope(getProvidedInterfaces(), aExternalScope); + Scope scope = new DefaultScope(getProvidedInterfaces().toArray(), aExternalScope); SCOPE.set(scope); try { GenericApplicationContext parentContext = new GenericApplicationContext(); diff --git a/system/spring/src/test/java/org/wamblee/system/spring/SpringComponentTest.java b/system/spring/src/test/java/org/wamblee/system/spring/SpringComponentTest.java index 10e2ca8e..67ed048d 100644 --- a/system/spring/src/test/java/org/wamblee/system/spring/SpringComponentTest.java +++ b/system/spring/src/test/java/org/wamblee/system/spring/SpringComponentTest.java @@ -158,7 +158,7 @@ public class SpringComponentTest extends TestCase { HelloService.class); Scope scope = new DefaultScope(new ProvidedInterface[] { helloService }); scope.publishInterface(helloService, helloObject); - system.getRequiredInterfaces()[0].setProvider(helloService); + system.getRequiredInterfaces().get(0).setProvider(helloService); Scope runtime = system.start(scope); system.stop(runtime); @@ -181,7 +181,7 @@ public class SpringComponentTest extends TestCase { HelloService.class); Scope scope = new DefaultScope(new ProvidedInterface[] { helloService }); scope.publishInterface(helloService, helloObject); - system.getRequiredInterfaces()[0].setProvider(helloService); + system.getRequiredInterfaces().get(0).setProvider(helloService); Scope runtime = system.start(scope); ProvidedInterface started = runtime.getProvidedInterfaces()[0]; @@ -222,7 +222,7 @@ public class SpringComponentTest extends TestCase { assertSame(service, service2); Object floatsvc = _externalScope.getInterfaceImplementation(system - .getProvidedInterfaces()[1], Object.class); + .getProvidedInterfaces().get(1), Object.class); assertTrue(floatsvc instanceof Float); assertTrue((((Float) floatsvc).floatValue() - 100.345f) < 0.00001); @@ -251,8 +251,8 @@ public class SpringComponentTest extends TestCase { Scope scope = new DefaultScope(new ProvidedInterface[] { helloService }); scope.publishInterface(helloService, helloObject); scope.publishInterface(floatService, 100.234f); - system.getRequiredInterfaces()[0].setProvider(helloService); - system.getRequiredInterfaces()[1].setProvider(floatService); + system.getRequiredInterfaces().get(0).setProvider(helloService); + system.getRequiredInterfaces().get(1).setProvider(floatService); Scope runtime = system.start(scope); system.stop(runtime);