From bfb43f7e25ff26dcb43bbfd671862945855a4d3d Mon Sep 17 00:00:00 2001 From: erik Date: Fri, 4 Apr 2008 19:08:18 +0000 Subject: [PATCH] --- ...ava => DefaultProvidedInterfaceDescriptor.java} | 10 +++++----- .../system/DefaultRequiredInterfaceDescriptor.java | 2 +- .../system/DefaultInterfaceDescriptorTest.java | 14 +++++++------- .../test/java/org/wamblee/system/Environment.java | 4 ++-- .../org/wamblee/system/SystemAssemblerTest.java | 8 ++++---- .../org/wamblee/system/spring/SpringComponent.java | 4 ---- .../wamblee/system/spring/SpringComponentTest.java | 14 ++++++-------- 7 files changed, 25 insertions(+), 31 deletions(-) rename system/general/src/main/java/org/wamblee/system/{AbstractProvidedInterfaceDescriptor.java => DefaultProvidedInterfaceDescriptor.java} (77%) diff --git a/system/general/src/main/java/org/wamblee/system/AbstractProvidedInterfaceDescriptor.java b/system/general/src/main/java/org/wamblee/system/DefaultProvidedInterfaceDescriptor.java similarity index 77% rename from system/general/src/main/java/org/wamblee/system/AbstractProvidedInterfaceDescriptor.java rename to system/general/src/main/java/org/wamblee/system/DefaultProvidedInterfaceDescriptor.java index 2d60e34e..31eb64bb 100644 --- a/system/general/src/main/java/org/wamblee/system/AbstractProvidedInterfaceDescriptor.java +++ b/system/general/src/main/java/org/wamblee/system/DefaultProvidedInterfaceDescriptor.java @@ -7,7 +7,7 @@ import java.util.Arrays; * * @author Erik Brakkee */ -public class AbstractProvidedInterfaceDescriptor implements ProvidedInterfaceDescriptor { +public class DefaultProvidedInterfaceDescriptor implements ProvidedInterfaceDescriptor { private String _name; private Class[] _interfaces; @@ -16,12 +16,12 @@ public class AbstractProvidedInterfaceDescriptor implements ProvidedInterfaceDes * Constructs the descriptor. * @param aInterface Type of service. */ - public AbstractProvidedInterfaceDescriptor(String aName, Class aInterface) { + public DefaultProvidedInterfaceDescriptor(String aName, Class aInterface) { _name = aName; _interfaces = new Class[] { aInterface }; } - public AbstractProvidedInterfaceDescriptor(String aName, Class[] aInterfaces) { + public DefaultProvidedInterfaceDescriptor(String aName, Class[] aInterfaces) { _name = aName; _interfaces = Arrays.copyOf(aInterfaces, aInterfaces.length); } @@ -38,10 +38,10 @@ public class AbstractProvidedInterfaceDescriptor implements ProvidedInterfaceDes @Override public boolean equals(Object obj) { - if ( !(obj instanceof AbstractProvidedInterfaceDescriptor)) { + if ( !(obj instanceof DefaultProvidedInterfaceDescriptor)) { return false; } - AbstractProvidedInterfaceDescriptor descr = (AbstractProvidedInterfaceDescriptor)obj; + DefaultProvidedInterfaceDescriptor descr = (DefaultProvidedInterfaceDescriptor)obj; if ( _interfaces.length != descr._interfaces.length ) { return false; } diff --git a/system/general/src/main/java/org/wamblee/system/DefaultRequiredInterfaceDescriptor.java b/system/general/src/main/java/org/wamblee/system/DefaultRequiredInterfaceDescriptor.java index a6e85bc5..08411f90 100644 --- a/system/general/src/main/java/org/wamblee/system/DefaultRequiredInterfaceDescriptor.java +++ b/system/general/src/main/java/org/wamblee/system/DefaultRequiredInterfaceDescriptor.java @@ -1,6 +1,6 @@ package org.wamblee.system; -public class DefaultRequiredInterfaceDescriptor extends AbstractProvidedInterfaceDescriptor +public class DefaultRequiredInterfaceDescriptor extends DefaultProvidedInterfaceDescriptor implements RequiredInterfaceDescriptor { public DefaultRequiredInterfaceDescriptor(String aName, Class aInterface) { diff --git a/system/general/src/test/java/org/wamblee/system/DefaultInterfaceDescriptorTest.java b/system/general/src/test/java/org/wamblee/system/DefaultInterfaceDescriptorTest.java index 7f9dc933..dd3451db 100644 --- a/system/general/src/test/java/org/wamblee/system/DefaultInterfaceDescriptorTest.java +++ b/system/general/src/test/java/org/wamblee/system/DefaultInterfaceDescriptorTest.java @@ -7,25 +7,25 @@ import junit.framework.TestCase; public class DefaultInterfaceDescriptorTest extends TestCase { public void testOneRequiredOneProvidedMatch() { - ProvidedInterfaceDescriptor provided = new AbstractProvidedInterfaceDescriptor("name", String.class); + ProvidedInterfaceDescriptor provided = new DefaultProvidedInterfaceDescriptor("name", String.class); RequiredInterfaceDescriptor required = new DefaultRequiredInterfaceDescriptor("name", String.class); assertTrue(required.implementedBy(provided)); } public void testOneRequiredOneProvidedMatchSubClass() { - ProvidedInterfaceDescriptor provided = new AbstractProvidedInterfaceDescriptor("name", Integer.class); + ProvidedInterfaceDescriptor provided = new DefaultProvidedInterfaceDescriptor("name", Integer.class); RequiredInterfaceDescriptor required = new DefaultRequiredInterfaceDescriptor("name", Number.class); assertTrue(required.implementedBy(provided)); } public void testOneRequiredOneProvidedNoMatch() { - ProvidedInterfaceDescriptor provided = new AbstractProvidedInterfaceDescriptor("name", String.class); + ProvidedInterfaceDescriptor provided = new DefaultProvidedInterfaceDescriptor("name", String.class); RequiredInterfaceDescriptor required = new DefaultRequiredInterfaceDescriptor("name", Number.class); assertFalse(required.implementedBy(provided)); } public void testOneRequiredMultipleProvidedMatch() { - ProvidedInterfaceDescriptor provided = new AbstractProvidedInterfaceDescriptor("name", + ProvidedInterfaceDescriptor provided = new DefaultProvidedInterfaceDescriptor("name", new Class[] { String.class, Integer.class} ); RequiredInterfaceDescriptor required = new DefaultRequiredInterfaceDescriptor("name", String.class); assertTrue(required.implementedBy(provided)); @@ -39,7 +39,7 @@ public class DefaultInterfaceDescriptorTest extends TestCase { } public void testMultipleRequiredOneProvidedMatch() { - ProvidedInterfaceDescriptor provided = new AbstractProvidedInterfaceDescriptor("name", + ProvidedInterfaceDescriptor provided = new DefaultProvidedInterfaceDescriptor("name", MyMultiple.class ); RequiredInterfaceDescriptor required = new DefaultRequiredInterfaceDescriptor("name", new Class[] {Runnable.class, Serializable.class} ); @@ -47,7 +47,7 @@ public class DefaultInterfaceDescriptorTest extends TestCase { } public void testMultipleRequiredOneProvidedNoMatch() { - ProvidedInterfaceDescriptor provided = new AbstractProvidedInterfaceDescriptor("name", + ProvidedInterfaceDescriptor provided = new DefaultProvidedInterfaceDescriptor("name", MyMultiple.class ); RequiredInterfaceDescriptor required = new DefaultRequiredInterfaceDescriptor("name", new Class[] { String.class, Runnable.class} ); @@ -55,7 +55,7 @@ public class DefaultInterfaceDescriptorTest extends TestCase { } public void testMultipleRequiredMultipleProvidedMatch() { - ProvidedInterfaceDescriptor provided = new AbstractProvidedInterfaceDescriptor("name", + ProvidedInterfaceDescriptor provided = new DefaultProvidedInterfaceDescriptor("name", new Class[] { Runnable.class, Serializable.class, String.class} ); RequiredInterfaceDescriptor required = new DefaultRequiredInterfaceDescriptor("name", new Class[] {Runnable.class, Serializable.class} ); diff --git a/system/general/src/test/java/org/wamblee/system/Environment.java b/system/general/src/test/java/org/wamblee/system/Environment.java index 6c9512ca..ebc43265 100644 --- a/system/general/src/test/java/org/wamblee/system/Environment.java +++ b/system/general/src/test/java/org/wamblee/system/Environment.java @@ -7,8 +7,8 @@ public class Environment extends AbstractComponent { private static final ProvidedInterfaceDescriptor[] PROVIDED = new ProvidedInterfaceDescriptor[] { - new AbstractProvidedInterfaceDescriptor("datasource", DataSource.class), - new AbstractProvidedInterfaceDescriptor("integer", Integer.class) + new DefaultProvidedInterfaceDescriptor("datasource", DataSource.class), + new DefaultProvidedInterfaceDescriptor("integer", Integer.class) }; public Environment(ServiceRegistry aRegistry) { diff --git a/system/general/src/test/java/org/wamblee/system/SystemAssemblerTest.java b/system/general/src/test/java/org/wamblee/system/SystemAssemblerTest.java index 810ff4c7..edd4bc2c 100644 --- a/system/general/src/test/java/org/wamblee/system/SystemAssemblerTest.java +++ b/system/general/src/test/java/org/wamblee/system/SystemAssemblerTest.java @@ -31,11 +31,11 @@ public class SystemAssemblerTest extends TestCase { "name", Runnable.class); RequiredInterfaceDescriptor req2 = new DefaultRequiredInterfaceDescriptor( "name", Serializable.class); - ProvidedInterfaceDescriptor prov1 = new AbstractProvidedInterfaceDescriptor( + ProvidedInterfaceDescriptor prov1 = new DefaultProvidedInterfaceDescriptor( "name", Runnable.class); - ProvidedInterfaceDescriptor prov2 = new AbstractProvidedInterfaceDescriptor( + ProvidedInterfaceDescriptor prov2 = new DefaultProvidedInterfaceDescriptor( "name", Serializable.class); - ProvidedInterfaceDescriptor prov3 = new AbstractProvidedInterfaceDescriptor( + ProvidedInterfaceDescriptor prov3 = new DefaultProvidedInterfaceDescriptor( "name", MyMultiple.class); AssertionUtils.assertEquals(new RequiredInterfaceDescriptor[] { req1 }, @@ -129,7 +129,7 @@ public class SystemAssemblerTest extends TestCase { "all", _registry, new Component[] { environment, application }, - new ProvidedInterfaceDescriptor[] { new AbstractProvidedInterfaceDescriptor( + new ProvidedInterfaceDescriptor[] { new DefaultProvidedInterfaceDescriptor( "string", String.class) }, new DefaultRequiredInterfaceDescriptor[0]); } catch (SystemAssemblyException e) { 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 6f153e57..a5dd685d 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 @@ -2,22 +2,18 @@ package org.wamblee.system.spring; import java.util.Map; import java.util.Properties; -import java.util.Set; import org.springframework.beans.MutablePropertyValues; import org.springframework.beans.factory.config.BeanDefinition; import org.springframework.beans.factory.config.ConstructorArgumentValues; import org.springframework.beans.factory.support.RootBeanDefinition; -import org.springframework.context.ApplicationContext; import org.springframework.context.support.AbstractApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.context.support.GenericApplicationContext; import org.wamblee.system.AbstractComponent; -import org.wamblee.system.Container; import org.wamblee.system.ProvidedInterfaceDescriptor; import org.wamblee.system.RequiredInterfaceDescriptor; import org.wamblee.system.Service; -import org.wamblee.system.InterfaceDescriptor; import org.wamblee.system.ServiceRegistry; import org.wamblee.system.SystemAssembler; import org.wamblee.system.SystemAssemblyException; 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 c02f951a..f83e2ec1 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 @@ -8,14 +8,12 @@ import java.util.Properties; import junit.framework.TestCase; import org.wamblee.io.ClassPathResource; -import org.wamblee.system.AbstractProvidedInterfaceDescriptor; -import org.wamblee.system.AbstractProvidedInterfaceDescriptor; +import org.wamblee.system.DefaultProvidedInterfaceDescriptor; import org.wamblee.system.DefaultRequiredInterfaceDescriptor; import org.wamblee.system.DefaultServiceRegistry; import org.wamblee.system.ProvidedInterfaceDescriptor; import org.wamblee.system.RequiredInterfaceDescriptor; import org.wamblee.system.Service; -import org.wamblee.system.InterfaceDescriptor; import org.wamblee.system.ServiceRegistry; import org.wamblee.system.SystemAssemblyException; @@ -48,7 +46,7 @@ public class SpringComponentTest extends TestCase { public void testOneProvidedService() { Map provided = new HashMap(); - provided.put("helloService", new AbstractProvidedInterfaceDescriptor( + provided.put("helloService", new DefaultProvidedInterfaceDescriptor( "hello", HelloService.class)); SpringComponent system = new SpringComponent("system", _registry, @@ -65,7 +63,7 @@ public class SpringComponentTest extends TestCase { public void testWithProperties() throws IOException { Map provided = new HashMap(); - provided.put("helloService", new AbstractProvidedInterfaceDescriptor( + provided.put("helloService", new DefaultProvidedInterfaceDescriptor( "hello", HelloService.class)); SpringComponent system = new SpringComponent("system", _registry, new String[] { HELLO_SERVICE_SPRING_WITH_PROPERTIES_XML }, @@ -103,7 +101,7 @@ public class SpringComponentTest extends TestCase { new HashMap(), required); HelloService helloObject = new HelloService("ladida"); - Service helloService = _registry.register(new AbstractProvidedInterfaceDescriptor("hello", HelloService.class), helloObject); + Service helloService = _registry.register(new DefaultProvidedInterfaceDescriptor("hello", HelloService.class), helloObject); system.start("Bla", new Service[] { helloService } ); system.stop(); } @@ -113,7 +111,7 @@ public class SpringComponentTest extends TestCase { required.put(new DefaultRequiredInterfaceDescriptor("hello", HelloService.class), "helloService"); Map provided = new HashMap(); - provided.put("blaService", new AbstractProvidedInterfaceDescriptor("bla", + provided.put("blaService", new DefaultProvidedInterfaceDescriptor("bla", BlaService.class)); SpringComponent system = new SpringComponent("system", _registry, @@ -121,7 +119,7 @@ public class SpringComponentTest extends TestCase { provided, required); HelloService helloObject = new HelloService("ladida"); - Service helloService = _registry.register(new AbstractProvidedInterfaceDescriptor("hello", HelloService.class), helloObject); + Service helloService = _registry.register(new DefaultProvidedInterfaceDescriptor("hello", HelloService.class), helloObject); Service[] services = system.start("Bla", new Service[] { helloService } ); assertEquals(1, services.length); -- 2.31.1