From: erik Date: Fri, 11 Apr 2008 21:32:07 +0000 (+0000) Subject: (no commit message) X-Git-Tag: wamblee-utils-0.2@603~181 X-Git-Url: http://wamblee.org/gitweb/?a=commitdiff_plain;h=fcf46bf4ba1749730d584ce0be783c7787fee27c;p=utils --- diff --git a/trunk/system/general/src/main/java/org/wamblee/system/core/Container.java b/trunk/system/general/src/main/java/org/wamblee/system/core/Container.java index fd322c6b..df92c0d0 100644 --- a/trunk/system/general/src/main/java/org/wamblee/system/core/Container.java +++ b/trunk/system/general/src/main/java/org/wamblee/system/core/Container.java @@ -252,7 +252,7 @@ public class Container extends AbstractComponent { + "' required by system '" + aComponent + "' matches multiple services provided by other systems: " - + Arrays.asList(filtered)); + + getServers(filtered)); } else { // filtered.length == 0 if ( !descriptor.isOptional()) { @@ -281,6 +281,22 @@ public class Container extends AbstractComponent { private void warn(String aMsg) { LOG.warn(getQualifiedName() + ": " + aMsg); } + + private String getServers(ProvidedInterface[] aProvidedList ) { + String result = ""; + for (ProvidedInterface provided: aProvidedList) { + result += "(components "; + for (Component component: _components) { + for (ProvidedInterface provided2: component.getProvidedInterfaces()) { + if ( provided.equals(provided2)) { + result += component + " "; + } + } + } + result += ", interface " + provided + ")"; + } + return result; + } private List getClients(RequiredInterface aRequirement) { List clients = new ArrayList(); diff --git a/trunk/system/general/src/main/java/org/wamblee/system/core/DefaultProvidedInterface.java b/trunk/system/general/src/main/java/org/wamblee/system/core/DefaultProvidedInterface.java index b751a671..60c111ed 100644 --- a/trunk/system/general/src/main/java/org/wamblee/system/core/DefaultProvidedInterface.java +++ b/trunk/system/general/src/main/java/org/wamblee/system/core/DefaultProvidedInterface.java @@ -90,8 +90,10 @@ public class DefaultProvidedInterface implements ProvidedInterface { @Override public String toString() { StringBuffer buf = new StringBuffer(); + buf.append(getName()); + buf.append(":"); for (Class intf: _interfaces) { - buf.append("." + intf.getName()); + buf.append(" " + intf.getName()); } return buf.toString(); } diff --git a/trunk/system/general/src/test/java/org/wamblee/system/core/Application.java b/trunk/system/general/src/test/java/org/wamblee/system/core/Application.java index 16d1f36f..ca1467cc 100644 --- a/trunk/system/general/src/test/java/org/wamblee/system/core/Application.java +++ b/trunk/system/general/src/test/java/org/wamblee/system/core/Application.java @@ -27,12 +27,14 @@ public class Application extends AbstractComponent { public static RequiredInterface[] required(boolean aOptional) { return new RequiredInterface[] { - new DefaultRequiredInterface("datasource", DataSource.class, aOptional), + new DefaultRequiredInterface("string", String.class, aOptional), new DefaultRequiredInterface("integer", Integer.class, aOptional) }; } private EventTracker _tracker; + private String _string; + private Integer _integer; public Application() { super("application", new ProvidedInterface[0], required(false)); @@ -49,7 +51,17 @@ public class Application extends AbstractComponent { @Override protected void doStart() { - track("start." + getName()); + track("start." + getName()); + _string = getRequiredInterfaces()[0].getImplementation(String.class); + _integer = getRequiredInterfaces()[1].getImplementation(Integer.class); + } + + public String getString() { + return _string; + } + + public Integer getInteger() { + return _integer; } @Override diff --git a/trunk/system/general/src/test/java/org/wamblee/system/core/ContainerTest.java b/trunk/system/general/src/test/java/org/wamblee/system/core/ContainerTest.java index 27a1937f..86d5760b 100644 --- a/trunk/system/general/src/test/java/org/wamblee/system/core/ContainerTest.java +++ b/trunk/system/general/src/test/java/org/wamblee/system/core/ContainerTest.java @@ -161,7 +161,7 @@ public class ContainerTest extends TestCase { Container system = new Container("all", new Component[] { environment, application }, new ProvidedInterface[] { new DefaultProvidedInterface( - "string", String.class) }, + "float", Float.class) }, new DefaultRequiredInterface[0]); } catch (SystemAssemblyException e) { return; @@ -190,9 +190,9 @@ public class ContainerTest extends TestCase { Container system = new Container("all", new Component[] { environment, application }, new ProvidedInterface[0], new RequiredInterface[] { new DefaultRequiredInterface( - "string", String.class) }); + "float", Float.class) }); system.getRequiredInterfaces()[0] - .setProvider(new DefaultProvidedInterface("hallo", String.class)); + .setProvider(new DefaultProvidedInterface("hallo", Float.class)); system.start(); RequiredInterface[] required = system.getRequiredInterfaces(); assertEquals(1, required.length); diff --git a/trunk/system/general/src/test/java/org/wamblee/system/core/Environment.java b/trunk/system/general/src/test/java/org/wamblee/system/core/Environment.java index 9ee40e39..0f164b62 100644 --- a/trunk/system/general/src/test/java/org/wamblee/system/core/Environment.java +++ b/trunk/system/general/src/test/java/org/wamblee/system/core/Environment.java @@ -28,7 +28,7 @@ public class Environment extends AbstractComponent { private static final ProvidedInterface[] provided() { return new ProvidedInterface[] { - new DefaultProvidedInterface("datasource", DataSource.class), + new DefaultProvidedInterface("datasource", String.class), new DefaultProvidedInterface("integer", Integer.class) }; } @@ -44,10 +44,18 @@ public class Environment extends AbstractComponent { _tracker = aTracker; } + public Integer getInteger() { + return 2; + } + + public String getString() { + return "Hello"; + } + @Override protected void doStart() { - addInterface(getProvidedInterfaces()[0], new Integer(1)); - addInterface(getProvidedInterfaces()[1], new Integer(2)); + addInterface(getProvidedInterfaces()[0], getString()); + addInterface(getProvidedInterfaces()[1], getInteger()); track("start." + getName()); }