|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.felix.ipojo.IPojoFactory
public abstract class IPojoFactory
This class defines common mechanisms of iPOJO component factories (i.e. component type). This class implements both the Factory and ManagedServiceFactory services.
| Nested Class Summary | |
|---|---|
protected class |
IPojoFactory.RequiredHandler
Structure storing required handlers. |
| Field Summary | |
|---|---|
protected static java.util.List |
INSTANCE_NAME
The list of the managed instance name. |
protected ComponentTypeDescription |
m_componentDesc
The component type description exposed by the Factory service. |
protected java.util.Map |
m_componentInstances
The list of the managed instance managers. |
protected Element |
m_componentMetadata
The component type metadata. |
protected org.osgi.framework.BundleContext |
m_context
The bundle context reference. |
private boolean |
m_described
The flag indicating if this factory has already a computed description or not. |
protected java.lang.String |
m_factoryName
The factory name. |
private long |
m_index
The index used to generate instance name if not set. |
protected boolean |
m_isPublic
Is the factory public (exposed as services). |
protected java.util.List |
m_listeners
The list of factory state listeners. |
protected Logger |
m_logger
The logger for the factory (and all component instances). |
protected java.util.List |
m_requiredHandlers
The list of required handlers. |
protected org.osgi.framework.ServiceRegistration |
m_sr
The service registration of this factory (Factory & ManagedServiceFactory). |
protected int |
m_state
The factory state. |
protected java.lang.String |
m_version
The version of the component type. |
| Fields inherited from interface org.apache.felix.ipojo.Factory |
|---|
INVALID, VALID |
| Constructor Summary | |
|---|---|
IPojoFactory(org.osgi.framework.BundleContext context,
Element metadata)
Creates an iPOJO Factory. |
|
| Method Summary | |
|---|---|
void |
addFactoryStateListener(FactoryStateListener listener)
Adds a factory listener. |
void |
checkAcceptability(java.util.Dictionary conf)
Checks if the configuration is acceptable. |
protected void |
computeDescription()
Computes the component type description. |
protected void |
computeFactoryState()
Computes factory state. |
ComponentInstance |
createComponentInstance(java.util.Dictionary configuration)
Creates an instance. |
ComponentInstance |
createComponentInstance(java.util.Dictionary configuration,
ServiceContext serviceContext)
Creates an instance in the specified service context. |
abstract ComponentInstance |
createInstance(java.util.Dictionary config,
IPojoContext context,
HandlerManager[] handlers)
Creates an instance. |
void |
deleted(java.lang.String name)
Deletes an instance. |
(package private) void |
dispose()
Destroys the factory. |
void |
disposed(ComponentInstance instance)
Callback called by instance when disposed. |
protected java.lang.String |
generateName()
Helper method generating a new unique name. |
org.osgi.framework.BundleContext |
getBundleContext()
Gets the bundle context of the factory. |
abstract java.lang.String |
getClassName()
Gets the factory class name. |
ComponentTypeDescription |
getComponentDescription()
Gets the component type description. |
ComponentTypeDescription |
getComponentTypeDescription()
Gets the component type description. |
Element |
getDescription()
Gets the component type description (Element-Attribute form). |
abstract java.lang.String |
getFactoryName()
Computes the factory name. |
protected HandlerManager |
getHandler(IPojoFactory.RequiredHandler req,
ServiceContext context)
Returns the handler object for the given required handler. |
protected org.osgi.framework.BundleContext |
getIPOJOBundleContext()
Gets the iPOJO Bundle Context. |
Logger |
getLogger()
Gets the logger used by instances created by the current factory. |
java.util.List |
getMissingHandlers()
Computes the list of missing handlers. |
java.lang.String |
getName()
Gets the factory name. |
abstract java.util.List |
getRequiredHandlerList()
Computes the required handler list. |
java.util.List |
getRequiredHandlers()
Gets the list of required handlers. |
int |
getState()
Gets the actual factory state. |
boolean |
isAcceptable(java.util.Dictionary conf)
Checks if the configuration is acceptable. |
protected boolean |
match(IPojoFactory.RequiredHandler req,
org.osgi.framework.ServiceReference ref)
Checks if the given handler identifier and the service reference match. |
void |
reconfigure(java.util.Dictionary properties)
Reconfigures an existing instance. |
void |
removeFactoryStateListener(FactoryStateListener listener)
Removes a factory listener. |
void |
start()
Starts the factory. |
abstract void |
starting()
Starting method. |
void |
stop()
Stops all the instance managers. |
abstract void |
stopping()
Stopping method. |
void |
updated(java.lang.String name,
java.util.Dictionary properties)
Creates or updates an instance. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.apache.felix.ipojo.Factory |
|---|
getVersion |
| Field Detail |
|---|
protected static final java.util.List INSTANCE_NAME
protected ComponentTypeDescription m_componentDesc
Factory service.
protected final java.util.Map m_componentInstances
protected final Element m_componentMetadata
protected final org.osgi.framework.BundleContext m_context
protected java.lang.String m_factoryName
protected java.util.List m_requiredHandlers
protected java.util.List m_listeners
FactoryStateListenerprotected final Logger m_logger
protected final boolean m_isPublic
protected final java.lang.String m_version
protected org.osgi.framework.ServiceRegistration m_sr
ManagedServiceFactory,
Factoryprotected int m_state
Factory.INVALIDFactory.VALID
private long m_index
private boolean m_described
| Constructor Detail |
|---|
public IPojoFactory(org.osgi.framework.BundleContext context,
Element metadata)
throws ConfigurationException
context - the bundle context of the bundle containing the factory.metadata - the description of the component type.
ConfigurationException - if the element describing the factory is malformed.| Method Detail |
|---|
public ComponentTypeDescription getComponentTypeDescription()
public void addFactoryStateListener(FactoryStateListener listener)
addFactoryStateListener in interface Factorylistener - the factory listener to add.Factory.addFactoryStateListener(org.apache.felix.ipojo.FactoryStateListener)public Logger getLogger()
public abstract java.lang.String getFactoryName()
public abstract java.util.List getRequiredHandlerList()
public abstract ComponentInstance createInstance(java.util.Dictionary config,
IPojoContext context,
HandlerManager[] handlers)
throws ConfigurationException
config - the instance configurationcontext - the iPOJO context to usehandlers - the handler array to use
ConfigurationException - if the instance creation failed during the configuration process.
public ComponentInstance createComponentInstance(java.util.Dictionary configuration)
throws UnacceptableConfiguration,
MissingHandlerException,
ConfigurationException
createComponentInstance in interface Factoryconfiguration - the configuration of the created instance.
UnacceptableConfiguration - if the given configuration is not consistent with the component type of this factory.
MissingHandlerException - if an handler is unavailable when the instance is created.
ConfigurationException - if the instance or type configuration are not correct.Factory.createComponentInstance(java.util.Dictionary)
public ComponentInstance createComponentInstance(java.util.Dictionary configuration,
ServiceContext serviceContext)
throws UnacceptableConfiguration,
MissingHandlerException,
ConfigurationException
createComponentInstance in interface Factoryconfiguration - the configuration of the created instance.serviceContext - the service context to push for this instance.
UnacceptableConfiguration - if the given configuration is not consistent with the component type of this factory.
MissingHandlerException - if an handler is unavailable when creating the instance.
ConfigurationException - if the instance configuration failed.Factory.createComponentInstance(java.util.Dictionary)public org.osgi.framework.BundleContext getBundleContext()
getBundleContext in interface FactoryFactory.getBundleContext()public abstract java.lang.String getClassName()
getClassName in interface FactoryFactory.getClassName()public ComponentTypeDescription getComponentDescription()
getComponentDescription in interface FactoryNull if not already computed.public Element getDescription()
getDescription in interface FactoryFactory.getDescription()public java.util.List getMissingHandlers()
getMissingHandlers in interface FactoryFactory.getMissingHandlers()public java.lang.String getName()
getName in interface FactorygetName in interface org.osgi.service.cm.ManagedServiceFactoryFactory.getName()public java.util.List getRequiredHandlers()
getRequiredHandlers in interface FactoryFactory.getRequiredHandlers()public int getState()
getState in interface FactoryFactory.getState()public boolean isAcceptable(java.util.Dictionary conf)
isAcceptable in interface Factoryconf - the configuration to test.
true if the configuration is acceptable.Factory.isAcceptable(java.util.Dictionary)
public void checkAcceptability(java.util.Dictionary conf)
throws UnacceptableConfiguration,
MissingHandlerException
conf - the configuration to test.
UnacceptableConfiguration - if the configuration is unacceptable.
MissingHandlerException - if an handler is missing.
public void reconfigure(java.util.Dictionary properties)
throws UnacceptableConfiguration,
MissingHandlerException
reconfigure in interface Factoryproperties - the new configuration to push.
UnacceptableConfiguration - if the new configuration is not consistent with the component type.
MissingHandlerException - if the current factory is not valid.Factory.reconfigure(java.util.Dictionary)public void removeFactoryStateListener(FactoryStateListener listener)
removeFactoryStateListener in interface Factorylistener - the factory listener to remove.Factory.removeFactoryStateListener(org.apache.felix.ipojo.FactoryStateListener)public abstract void stopping()
public void stop()
stopping() method,
notifies listeners, and disposes created instances. Moreover,
if the factory is public, services are also unregistered.
void dispose()
Extender can call this method.
public abstract void starting()
public void start()
starting() method,
and published services if the factory is public.
protected final org.osgi.framework.BundleContext getIPOJOBundleContext()
public void updated(java.lang.String name,
java.util.Dictionary properties)
throws org.osgi.service.cm.ConfigurationException
updated in interface org.osgi.service.cm.ManagedServiceFactoryname - the name of the instanceproperties - the new configuration of the instance
org.osgi.service.cm.ConfigurationException - if the configuration is not consistent for this component typeManagedServiceFactory.updated(java.lang.String, java.util.Dictionary)public void deleted(java.lang.String name)
deleted in interface org.osgi.service.cm.ManagedServiceFactoryname - the name of the instance to deleteManagedServiceFactory.deleted(java.lang.String)public void disposed(ComponentInstance instance)
instance - the destroyed instanceprotected void computeDescription()
Handler#initializeComponentFactory(ComponentTypeDescription, Element)
method. The handler instance is then deleted.
The factory must be valid when calling this method.
This method is called with the lock.
protected void computeFactoryState()
protected boolean match(IPojoFactory.RequiredHandler req,
org.osgi.framework.ServiceReference ref)
req - the handler identifier.ref - the service reference.
true if the service reference can fulfill the handler requirement
protected HandlerManager getHandler(IPojoFactory.RequiredHandler req,
ServiceContext context)
req - the handler to create.context - the service context in which the handler is created (same as the instance context).
protected java.lang.String generateName()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||