public interface Component<T extends Component<T>> extends AbstractComponent
Modifier and Type | Interface and Description |
---|---|
static class |
Component.ServiceScope
Component service scopes
|
Modifier and Type | Method and Description |
---|---|
T |
add(ComponentStateListener listener)
Adds a component state listener to this component.
|
T |
add(Dependency... dependencies)
Adds dependency(ies) to this component, atomically.
|
ServiceRegistration |
getServiceRegistration()
Returns the service registration for this component.
|
T |
remove(ComponentStateListener listener)
Removes a component state listener from this component.
|
T |
remove(Dependency d)
Removes a dependency from the component.
|
T |
setAutoConfig(java.lang.Class<?> clazz,
boolean autoConfig)
Configures auto configuration of injected classes in the component instance.
|
T |
setAutoConfig(java.lang.Class<?> clazz,
java.lang.String instanceName)
Configures auto configuration of injected classes in the component instance.
|
T |
setCallbacks(java.lang.Object instance,
java.lang.String init,
java.lang.String start,
java.lang.String stop,
java.lang.String destroy)
Sets the names of the methods used as callbacks.
|
T |
setCallbacks(java.lang.String init,
java.lang.String start,
java.lang.String stop,
java.lang.String destroy)
Sets the names of the methods used as callbacks.
|
T |
setComposition(java.lang.Object instance,
java.lang.String getMethod)
Sets the instance and method to invoke to get back all instances that
are part of a composition and need dependencies injected.
|
T |
setComposition(java.lang.String getMethod)
Sets the method to invoke on the service implementation to get back all
instances that are part of a composition and need dependencies injected.
|
T |
setDebug(java.lang.String label)
Activate debug for this component.
|
T |
setFactory(java.lang.Object factory,
java.lang.String createMethod)
Sets the factory to use to create the implementation.
|
T |
setFactory(java.lang.String createMethod)
Sets the factory to use to create the implementation.
|
T |
setImplementation(java.lang.Object implementation)
Sets the implementation for this component.
|
T |
setInterface(java.lang.Class<?>[] serviceNames,
java.util.Dictionary<?,?> properties)
Sets the public interfaces under which this component should be registered
in the OSGi service registry.
|
T |
setInterface(java.lang.Class<?> serviceName,
java.util.Dictionary<?,?> properties)
Sets the public interface under which this component should be registered
in the OSGi service registry.
|
T |
setInterface(java.lang.String[] serviceNames,
java.util.Dictionary<?,?> properties)
Sets the public interfaces under which this component should be registered
in the OSGi service registry.
|
T |
setInterface(java.lang.String serviceName,
java.util.Dictionary<?,?> properties)
Sets the public interface under which this component should be registered
in the OSGi service registry.
|
T |
setScope(Component.ServiceScope scope)
Sets the component scope.
|
T |
setServiceProperties(java.util.Dictionary<?,?> serviceProperties)
Sets the service properties associated with the component.
|
getComponentDeclaration, getDependencyManager, getInstance, getInstances, getServiceProperties
T setScope(Component.ServiceScope scope)
scope
- the component scope (default=SINGLETON)T setImplementation(java.lang.Object implementation)
Class
that will be instantiated using its default constructor when the
required dependencies are resolved, effectively giving you a lazy
instantiation mechanism.
There are four special methods that are called when found through
reflection to give you life cycle management options:
init()
is invoked after the instance has been
created and dependencies have been resolved, and can be used to
initialize the internal state of the instance or even to add more
dependencies based on runtime statestart()
is invoked right before the service is
registeredstop()
is invoked right after the service is
unregistereddestroy()
is invoked after all dependencies are
removedimplementation
- the implementationComponentStateListener
T add(Dependency... dependencies)
dependencies
- the dependencies to add.T remove(Dependency d)
d
- the dependency to removeT add(ComponentStateListener listener)
listener
- the state listenerT remove(ComponentStateListener listener)
listener
- the state listenerT setInterface(java.lang.String serviceName, java.util.Dictionary<?,?> properties)
serviceName
- the name of the service interfaceproperties
- the properties for this serviceT setInterface(java.lang.String[] serviceNames, java.util.Dictionary<?,?> properties)
serviceNames
- the names of the service interfaceproperties
- the properties for these servicesT setInterface(java.lang.Class<?> serviceName, java.util.Dictionary<?,?> properties)
serviceName
- the name of the service interfaceproperties
- the properties for this serviceT setInterface(java.lang.Class<?>[] serviceNames, java.util.Dictionary<?,?> properties)
serviceNames
- the names of the service interfaceproperties
- the properties for these servicesT setAutoConfig(java.lang.Class<?> clazz, boolean autoConfig)
clazz
- the class (from the list above)autoConfig
- false
to turn off auto configurationT setAutoConfig(java.lang.Class<?> clazz, java.lang.String instanceName)
clazz
- the class (from the list above)instanceName
- the name of the instance to inject the class intosetAutoConfig(Class, boolean)
ServiceRegistration getServiceRegistration()
null
if no service registration is
available, for example if this component is not registered as a
service at all.T setServiceProperties(java.util.Dictionary<?,?> serviceProperties)
serviceProperties
- the propertiesT setCallbacks(java.lang.String init, java.lang.String start, java.lang.String stop, java.lang.String destroy)
init
- the name of the init methodstart
- the name of the start methodstop
- the name of the stop methoddestroy
- the name of the destroy methodT setCallbacks(java.lang.Object instance, java.lang.String init, java.lang.String start, java.lang.String stop, java.lang.String destroy)
See setCallbacks(String init, String start, String stop, String destroy) for more information on the signatures. Specifying an instance means you can create a manager that will be invoked whenever the life cycle of a component changes and this manager can then decide how to expose this life cycle to the actual component, offering an important indirection when developing your own component models.
T setFactory(java.lang.Object factory, java.lang.String createMethod)
setComposition
to create a
composition of instances that work together to implement a component. The
factory itself can also be instantiated lazily by not specifying an
instance, but a Class
.factory
- the factory instance or classcreateMethod
- the name of the create methodT setFactory(java.lang.String createMethod)
setComposition
to create a composition of instances that
work together to implement a component.
Note that currently, there is no default for the factory, so please use
setFactory(factory, createMethod)
instead.
createMethod
- the name of the create methodT setComposition(java.lang.Object instance, java.lang.String getMethod)
Object[]
.instance
- the instance that has the methodgetMethod
- the method to invokeT setComposition(java.lang.String getMethod)
Object[]
.getMethod
- the method to invokeT setDebug(java.lang.String label)
label
-