|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.felix.scr.impl.DelayedComponentManager
public class DelayedComponentManager
The DelayedComponentManager TODO
| Field Summary |
|---|
| Fields inherited from interface org.apache.felix.scr.Component |
|---|
STATE_ACTIVATING, STATE_ACTIVE, STATE_DEACTIVATING, STATE_DESTROYED, STATE_DISABLED, STATE_ENABLED, STATE_FACTORY, STATE_REGISTERED, STATE_UNSATISFIED |
| Constructor Summary | |
|---|---|
DelayedComponentManager(org.apache.felix.scr.impl.BundleComponentActivator activator,
ComponentMetadata metadata,
long componentId)
|
|
| Method Summary | |
|---|---|
void |
activate()
Activates this component if satisfied. |
protected Dictionary |
copyTo(Dictionary target,
Dictionary source)
Copies the properties from the source Dictionary
into the target Dictionary. |
protected boolean |
createComponent()
Method is called by activate() in STATE_ACTIVATING or by
getService(Bundle, ServiceRegistration)
in STATE_REGISTERED. |
protected Object |
createImplementationObject(ComponentContext componentContext)
|
void |
deactivate()
Deactivates the component. |
protected void |
deleteComponent()
Method is called by deactivate() in STATE_DEACTIVATING |
void |
disable()
Disables this component and - if active - first deactivates it. |
void |
dispose()
Before doing real disposal, we also have to unregister the managed service which was registered when the instance was created. |
protected void |
disposeImplementationObject(Object implementationObject,
ComponentContext componentContext)
|
void |
enable()
Enables this component and - if satisfied - also activates it. |
protected void |
enable(boolean synchronous)
Enables this component and - if satisfied - also activates it synchronously or asynchronously. |
Bundle |
getBundle()
Returns the Bundle declaring this component. |
String |
getClassName()
Returns the class name of the Component implementation. |
ComponentMetadata |
getComponentMetadata()
Get the component information |
String |
getFactory()
Returns the component factory name or null if this component
is not defined as a component factory. |
long |
getId()
Returns the component ID of this component. |
Object |
getInstance()
Get the object that is implementing this descriptor |
String |
getName()
Returns the name of the component, which is also used as the service PID. |
Dictionary |
getProperties()
Returns the (private copy) of the Component properties to be used for the ComponentContext as well as eventual service registration. |
Reference[] |
getReferences()
Returns an array of Reference instances representing the service
references (or dependencies) of this Component. |
protected Object |
getService()
Returns the service object to be registered if the service element is specified. |
Object |
getService(Bundle arg0,
ServiceRegistration arg1)
|
String[] |
getServices()
Returns an array of service names provided by this Component or null if the Component is not registered as a service. |
int |
getState()
Returns the current state of the Component, which is one of the STATE_* constants defined in this interface. |
boolean |
isDefaultEnabled()
Returns whether the Component is declared to be enabled initially. |
boolean |
isImmediate()
Returns whether the Component is an Immediate or a Delayed Component. |
boolean |
isServiceFactory()
Returns true if this component is a service factory. |
void |
reactivate()
Cycles this component by deactivating it and - if still satisfied - activating it again asynchronously. |
void |
reconfigure()
Reconfigures this component by deactivating and activating it. |
void |
reconfigure(Dictionary configuration)
Called by the Configuration Admin Service to update the component with Configuration properties. |
protected ServiceRegistration |
registerComponentService()
|
protected void |
setFactoryProperties(Dictionary dictionary)
|
protected void |
setState(int newState)
sets the state of the manager |
protected boolean |
setStateConditional(int requiredStates,
int newState)
If the state is currently one of the requiredStates, the
state is set to newState and true is returned. |
String |
stateToString(int state)
|
String |
toString()
|
void |
ungetService(Bundle arg0,
ServiceRegistration arg1,
Object arg2)
|
protected void |
unregisterComponentService()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public DelayedComponentManager(org.apache.felix.scr.impl.BundleComponentActivator activator,
ComponentMetadata metadata,
long componentId)
activator - metadata - componentId - | Method Detail |
|---|
protected boolean createComponent()
activate() in STATE_ACTIVATING or by
getService(Bundle, ServiceRegistration)
in STATE_REGISTERED.
true if creation of the component succeeded. If
false is returned, the cause should have been logged.protected void deleteComponent()
deactivate() in STATE_DEACTIVATING
protected Object getService()
Extensions of this class may overwrite this method to return a ServiceFactory to register in the case of a delayed or a service factory component.
public Object getService(Bundle arg0,
ServiceRegistration arg1)
getService in interface ServiceFactory
public void ungetService(Bundle arg0,
ServiceRegistration arg1,
Object arg2)
ungetService in interface ServiceFactorypublic void dispose()
dispose in interface ComponentManagerdispose in interface ComponentInstancepublic Object getInstance()
getInstance in interface ComponentInstanceprotected Object createImplementationObject(ComponentContext componentContext)
protected void disposeImplementationObject(Object implementationObject,
ComponentContext componentContext)
protected void setFactoryProperties(Dictionary dictionary)
public Dictionary getProperties()
Method implements the Component Properties provisioning as described in 112.6, Component Properties.
getProperties in interface Componentpublic void reconfigure(Dictionary configuration)
This causes the component to be reactivated with the new configuration
unless no configuration has ever been set on this component and the
configuration parameter is null. In this case
nothing is to be done. If a configuration has previously been set and
now the configuration is deleted, the configuration
parameter is null and the component has to be reactivated
with the default configuration.
configuration - The configuration properties for the component from
the Configuration Admin Service or null if there is
no configuration or if the configuration has just been deleted.public final void enable()
This method ignores the enabled flag of the component metadata and just enables as requested.
This method schedules the enablement for asynchronous execution.
enable in interface Componentenable in interface ComponentManagerprotected final void enable(boolean synchronous)
This method ignores the enabled flag of the component metadata and just enables as requested.
synchronous - If true the component is immediately
enabled synchronously. Otherwise the component enabled is scheduled
for asynchronous enabled by calling enable().public final void activate()
This method schedules the activation for asynchronous execution.
public final void reconfigure()
reconfigure in interface ComponentManagerpublic final void reactivate()
This method schedules the deactivation and reactivation for asynchronous execution.
public final void deactivate()
Deactivation of the component happens when a service is unregistered (or modified). Since such a service change may take place while a bundle is being stopped and the bundle lock is held, we have to be careful and schedule the deactivation for asynchronous execution.
The drawback is, that the user of the removed (or modified) service is still bound to the old service for a small amount of time and thus may run into issues. But weighing this against the deadlock possibility, it is more important to be deadlock save.
If services have a problem with this delayed deactivation, they should consider marking the reference as optional and dynamic and be prepared to the service not being present, since service bind and unbind will always be synchronous.
public final void disable()
enable() method.
This method schedules the disablement for asynchronous execution.
disable in interface Componentdisable in interface ComponentManagerpublic long getId()
Component
getId in interface Componentpublic String getName()
Componentname attribute of the
component element.
getName in interface Componentpublic Bundle getBundle()
ComponentBundle declaring this component.
getBundle in interface Componentpublic String getClassName()
Componentclass attribute of the
implementation element.
getClassName in interface Componentpublic String getFactory()
Componentnull if this component
is not defined as a component factory. This method provides access to
the factory attribute of the component
element.
getFactory in interface Componentpublic Reference[] getReferences()
ComponentReference instances representing the service
references (or dependencies) of this Component. If the Component has no
references, null is returned.
getReferences in interface Componentpublic boolean isImmediate()
Componentimmediate attribute of
the component element.
isImmediate in interface Componentpublic boolean isDefaultEnabled()
Componentenabled attribute of the
component element.
isDefaultEnabled in interface Componentpublic boolean isServiceFactory()
Componenttrue if this component is a service factory. This
method returns the value of the serviceFactory attribute of
the service element. If the component has no service
element, this method returns false.
isServiceFactory in interface Componentpublic String[] getServices()
Componentnull if the Component is not registered as a service. This
method provides access to the interface attributes of the
provide elements.
getServices in interface Componentprotected ServiceRegistration registerComponentService()
protected void unregisterComponentService()
public String toString()
toString in class Object
protected Dictionary copyTo(Dictionary target,
Dictionary source)
source Dictionary
into the target Dictionary.
target - The Dictionary into which to copy the
properties. If null a new Hashtable is
created.source - The Dictionary providing the properties to
copy. If null or empty, nothing is copied.
target is returned, which may be empty if
source is null or empty and
target was null.public ComponentMetadata getComponentMetadata()
ComponentManager
getComponentMetadata in interface ComponentManagerpublic int getState()
ComponentSTATE_* constants defined in this interface.
getState in interface Componentprotected void setState(int newState)
protected boolean setStateConditional(int requiredStates,
int newState)
requiredStates, the
state is set to newState and true is returned.
Otherwise the state is not changed and false is returned.
This method atomically checks the current state and sets the new state.
requiredStates - The set of states required for the state change to
happen.newState - The new state to go into.
true if the state was one of the required states and
the new state has now been entered.public String stateToString(int state)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||