Hi all,
In issue FELIX-284, I stipulate the definition of a management API for
the Felix Declarative Services Implementationn (SCR). Disregarding
anything else in the first step, I come up with a very simple API. The
goal is to be easily usable as a Management API and not to directly
reflect the service declaration. For this reason, the <rerference
cardinality> configuration is split in two methods isOptional and
isMultiple and the <service> and <provide> elements are folded into the
isServiceFactory getServices method.
In addtion the Component interface has two methods to enable and disable
a component and the Refernce interface provides access to an array of
ServiceReference objects denoting the services currently bound to the
component.
This API may be used by some shell or JMX integration.
What do you think ?
Regards
Felix
API follows:
// registered as a service accessible to management agents
public interface ScrService {
// return all known components in ascending order of theire
component.id
Component[] getComponents();
// return the component with the given ID or null if none
Component getComponent(long componentId);
}
public interface Component {
// the name of the component (<component name>)
String getName();
// the component ID (assigned by SCR)
long getId();
// the component factory name or null (<component factory>)
String getFactory();
// the component class name (<implementation class>)
String getClassName();
// the current state of the component (to be defined as constants)
int getState();
// true if the component is a service factory (<service
serviceFactory>)
boolen isServiceFactory();
// the list of service names or null if not a service (<provide
interface>)
String[] getServices();
// the component properties (same as ComponentContext.getProperties())
Dictionary getProperties();
// the service references of the Component
Reference[] getReferences();
// enables the component if disabled
void enable();
// disables the component if enabled
void disable();
// whether the component is defined to be initially enabled
(<component enabled>)
boolean isDefaultEnabled();
// whether the component is defined to be created immediately
(<component immediate>)
boolean isImmediate();
}
public interface Reference {
// the local name of the reference (<reference name>)
String getName();
// the name of the service referred to (<reference interface>)
String getServiceName();
// services bound to the component per this Reference
ServiceReference[] getServiceReferences();
// whether this reference is satisfied
boolean isSatisfied();
// whether the service is optional (<reference cardinality>)
boolean isOptional();
// whether the service is multiple (<reference cardinality>)
boolean isMultiple();
// whether the service is bound statically or dynamically (<reference
policy>)
boolean isStatic();
// the target selection filter or null if none
// (getName()+".target" property of component based on <reference
target>)
String getTarget();
// the name of the bind method or null (<reference bind>)
String getBindMethodName();
// the name of the unbind method or null (<reference unbind>)
String getUnbindMethodName();
}