private Status _status;
private String _name;
private ServiceRegistry _registry;
- private List<InterfaceDescriptor> _provided;
- private List<InterfaceDescriptor> _required;
- private Map<InterfaceDescriptor, Service> _running;
+ private List<ProvidedInterfaceDescriptor> _provided;
+ private List<RequiredInterfaceDescriptor> _required;
+ private Map<ProvidedInterfaceDescriptor, Service> _running;
/**
* Constructs the subsystem.
_status = Status.NOT_STARTED;
_name = aName;
_registry = aRegistry;
- _provided = new ArrayList<InterfaceDescriptor>();
+ _provided = new ArrayList<ProvidedInterfaceDescriptor>();
_provided.addAll(Arrays.asList(aProvided));
- _required = new ArrayList<InterfaceDescriptor>();
+ _required = new ArrayList<RequiredInterfaceDescriptor>();
_required.addAll(Arrays.asList(aRequired));
- _running = new HashMap<InterfaceDescriptor, Service>();
+ _running = new HashMap<ProvidedInterfaceDescriptor, Service>();
}
@Override
* Also logs a warning in case of superfluous requirements.
*/
private void validate() {
- List<InterfaceDescriptor> provided = new ArrayList<InterfaceDescriptor>();
+ List<ProvidedInterfaceDescriptor> provided = new ArrayList<ProvidedInterfaceDescriptor>();
for (Component system : _systems) {
provided.addAll(Arrays.asList(system.getProvidedServices()));
}
- List<InterfaceDescriptor> required = new ArrayList<InterfaceDescriptor>();
+ List<RequiredInterfaceDescriptor> required = new ArrayList<RequiredInterfaceDescriptor>();
for (Component system : _systems) {
required.addAll(Arrays.asList(system.getRequiredServices()));
}
}
}
- for (InterfaceDescriptor service : getRequiredServices()) {
+ for (RequiredInterfaceDescriptor service : getRequiredServices()) {
if (!(required.contains(service))) {
info("Service '"
+ service
}
}
- List<InterfaceDescriptor> reallyRequired = new ArrayList<InterfaceDescriptor>(
+ List<RequiredInterfaceDescriptor> reallyRequired = new ArrayList<RequiredInterfaceDescriptor>(
required);
- for (InterfaceDescriptor service : provided) {
+ for (ProvidedInterfaceDescriptor service : provided) {
reallyRequired.remove(service);
}
- for (InterfaceDescriptor service: getRequiredServices()) {
+ for (RequiredInterfaceDescriptor service: getRequiredServices()) {
reallyRequired.remove(service);
}
String missingRequired = "";
- for (InterfaceDescriptor service: reallyRequired) {
+ for (RequiredInterfaceDescriptor service: reallyRequired) {
missingRequired += service + "\n";
}
if ( missingRequired.length() > 0 ) {
package org.wamblee.system;
-public interface RequiredInterfaceDescriptor extends InterfaceDescriptor {
+public interface RequiredInterfaceDescriptor {
- boolean implementedBy(ProvidedInterfaceDescriptor aDescriptor);
+ /**
+ * Name for the interface.
+ */
+ public String getName();
+
+ /**
+ * Checks if the service is provided by a given provided interface.
+ * @param aInterface Provided interface.
+ * @return
+ */
+ boolean implementedBy(ProvidedInterfaceDescriptor aInterface);
}
new RequiredInterfaceDescriptor[0]);
assertEquals(Status.NOT_STARTED, system.getStatus());
system.start("root", new Service[0]);
- InterfaceDescriptor[] required = system.getRequiredServices();
+ RequiredInterfaceDescriptor[] required = system.getRequiredServices();
assertEquals(0, required.length);
InterfaceDescriptor[] provided = system.getProvidedServices();
assertEquals(0, provided.length);