+ "' required by system '"
+ aComponent
+ "' matches multiple services provided by other systems: "
- + Arrays.asList(filtered));
+ + getServers(filtered));
} else {
// filtered.length == 0
if ( !descriptor.isOptional()) {
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<Component> getClients(RequiredInterface aRequirement) {
List<Component> clients = new ArrayList<Component>();
@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();
}
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<String> _tracker;
+ private String _string;
+ private Integer _integer;
public Application() {
super("application", new ProvidedInterface[0], required(false));
@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
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;
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);
private static final ProvidedInterface[] provided() {
return new ProvidedInterface[] {
- new DefaultProvidedInterface("datasource", DataSource.class),
+ new DefaultProvidedInterface("datasource", String.class),
new DefaultProvidedInterface("integer", Integer.class)
};
}
_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());
}