*
* @author Erik Brakkee
*/
-public class AbstractProvidedInterfaceDescriptor implements ProvidedInterfaceDescriptor {
+public class DefaultProvidedInterfaceDescriptor implements ProvidedInterfaceDescriptor {
private String _name;
private Class[] _interfaces;
* 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);
}
@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;
}
package org.wamblee.system;
-public class DefaultRequiredInterfaceDescriptor extends AbstractProvidedInterfaceDescriptor
+public class DefaultRequiredInterfaceDescriptor extends DefaultProvidedInterfaceDescriptor
implements RequiredInterfaceDescriptor {
public DefaultRequiredInterfaceDescriptor(String aName, Class aInterface) {
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));
}
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} );
}
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} );
}
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} );
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) {
"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 },
"all",
_registry,
new Component[] { environment, application },
- new ProvidedInterfaceDescriptor[] { new AbstractProvidedInterfaceDescriptor(
+ new ProvidedInterfaceDescriptor[] { new DefaultProvidedInterfaceDescriptor(
"string", String.class) },
new DefaultRequiredInterfaceDescriptor[0]);
} catch (SystemAssemblyException e) {
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;
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;
public void testOneProvidedService() {
Map<String, ProvidedInterfaceDescriptor> provided = new HashMap<String, ProvidedInterfaceDescriptor>();
- provided.put("helloService", new AbstractProvidedInterfaceDescriptor(
+ provided.put("helloService", new DefaultProvidedInterfaceDescriptor(
"hello", HelloService.class));
SpringComponent system = new SpringComponent("system", _registry,
public void testWithProperties() throws IOException {
Map<String, ProvidedInterfaceDescriptor> provided = new HashMap<String, ProvidedInterfaceDescriptor>();
- 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 },
new HashMap<String, ProvidedInterfaceDescriptor>(), 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();
}
required.put(new DefaultRequiredInterfaceDescriptor("hello", HelloService.class),
"helloService");
Map<String,ProvidedInterfaceDescriptor> provided = new HashMap<String, ProvidedInterfaceDescriptor>();
- provided.put("blaService", new AbstractProvidedInterfaceDescriptor("bla",
+ provided.put("blaService", new DefaultProvidedInterfaceDescriptor("bla",
BlaService.class));
SpringComponent system = new SpringComponent("system", _registry,
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);