|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Component
Component interface. Components are the main building blocks for OSGi applications. They can publish themselves as a service, and they can have dependencies. These dependencies will influence their life cycle as component will only be activated when all required dependencies are available.
Method Summary | |
---|---|
Component |
add(Dependency dependency)
Adds a new dependency to this component. |
Component |
add(List dependencies)
|
void |
addStateListener(ComponentStateListener listener)
Adds a component state listener to this component. |
boolean |
getAutoConfig(Class clazz)
Returns the status of auto configuration of the specified class. |
String |
getAutoConfigInstance(Class clazz)
Returns the instance variable name of auto configuration of the specified class. |
Object[] |
getCompositionInstances()
Returns the composition instances that make up this component, or just the component instance if it does not have a composition, or an empty array if the component has not even been instantiated. |
List |
getDependencies()
Returns a list of dependencies. |
DependencyManager |
getDependencyManager()
Returns the dependency manager associated with this component. |
Object |
getService()
Returns the component instance for this component. |
Dictionary |
getServiceProperties()
Returns the service properties associated with the component. |
ServiceRegistration |
getServiceRegistration()
Returns the service registration for this component. |
void |
invokeCallbackMethod(Object[] instances,
String methodName,
Class[][] signatures,
Object[][] parameters)
|
Component |
remove(Dependency dependency)
Removes a dependency from this component. |
void |
removeStateListener(ComponentStateListener listener)
Removes a component state listener from this component. |
Component |
setAutoConfig(Class clazz,
boolean autoConfig)
Configures auto configuration of injected classes in the component instance. |
Component |
setAutoConfig(Class clazz,
String instanceName)
Configures auto configuration of injected classes in the component instance. |
Component |
setCallbacks(Object instance,
String init,
String start,
String stop,
String destroy)
Sets the names of the methods used as callbacks. |
Component |
setCallbacks(String init,
String start,
String stop,
String destroy)
Sets the names of the methods used as callbacks. |
Component |
setComposition(Object instance,
String getMethod)
Sets the instance and method to invoke to get back all instances that are part of a composition and need dependencies injected. |
Component |
setComposition(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. |
Component |
setFactory(Object factory,
String createMethod)
Sets the factory to use to create the implementation. |
Component |
setFactory(String createMethod)
Sets the factory to use to create the implementation. |
Component |
setImplementation(Object implementation)
Sets the implementation for this component. |
Component |
setInterface(String[] serviceNames,
Dictionary properties)
Sets the public interfaces under which this component should be registered in the OSGi service registry. |
Component |
setInterface(String serviceName,
Dictionary properties)
Sets the public interface under which this component should be registered in the OSGi service registry. |
Component |
setServiceProperties(Dictionary serviceProperties)
Sets the service properties associated with the component. |
void |
start()
Starts the component. |
void |
stop()
Stops the component. |
Method Detail |
---|
Component add(Dependency dependency)
dependency
- the dependency to add
Component add(List dependencies)
Component remove(Dependency dependency)
dependency
- the dependency to remove
Component setInterface(String serviceName, Dictionary properties)
serviceName
- the name of the service interfaceproperties
- the properties for this service
Component setInterface(String[] serviceNames, Dictionary properties)
serviceNames
- the names of the service interfaceproperties
- the properties for these services
Component setImplementation(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
removed
implementation
- the implementation
ComponentStateListener
List getDependencies()
ServiceRegistration getServiceRegistration()
null
if no service registration is
available, for example if this component is not registered as a
service at all.
Object getService()
null
if no component instance is available.
Dictionary getServiceProperties()
null
if there are noneComponent setServiceProperties(Dictionary serviceProperties)
serviceProperties
- the propertiesComponent setCallbacks(String init, String start, String stop, 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 method
Component setCallbacks(Object instance, String init, String start, String stop, 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.
void addStateListener(ComponentStateListener listener)
listener
- the state listenervoid removeStateListener(ComponentStateListener listener)
listener
- the state listenervoid start()
void stop()
Component setFactory(Object factory, 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 methodComponent setFactory(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 methodComponent setComposition(Object instance, String getMethod)
Object[]
.
instance
- the instance that has the methodgetMethod
- the method to invokeComponent setComposition(String getMethod)
Object[]
.
getMethod
- the method to invokeObject[] getCompositionInstances()
void invokeCallbackMethod(Object[] instances, String methodName, Class[][] signatures, Object[][] parameters)
DependencyManager getDependencyManager()
Component setAutoConfig(Class clazz, boolean autoConfig)
clazz
- the class (from the list above)autoConfig
- false
to turn off auto configurationComponent setAutoConfig(Class clazz, String instanceName)
clazz
- the class (from the list above)instanceName
- the name of the instance to inject the class intosetAutoConfig(Class, boolean)
boolean getAutoConfig(Class clazz)
String getAutoConfigInstance(Class clazz)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |