|
||||||||||
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 List |
INSTANCE_NAME
The list of the managed instance name. |
protected ComponentTypeDescription |
m_componentDesc
The component type description exposed by the Factory service. |
protected Map |
m_componentInstances
The list of the managed instance managers. |
protected Element |
m_componentMetadata
The component type metadata. |
protected BundleContext |
m_context
The bundle context reference. |
protected String |
m_factoryName
The factory name. |
protected boolean |
m_isPublic
Is the factory public (exposed as services). |
protected List |
m_listeners
The list of factory state listeners. |
protected Logger |
m_logger
The logger for the factory (and all component instances). |
protected List |
m_requiredHandlers
The list of required handlers. |
protected ServiceRegistration |
m_sr
The service registration of this factory (Factory & ManagedServiceFactory). |
protected int |
m_state
The factory state. |
Fields inherited from interface org.apache.felix.ipojo.Factory |
---|
INVALID, VALID |
Constructor Summary | |
---|---|
IPojoFactory(BundleContext context,
Element metadata)
Creates an iPOJO Factory. |
Method Summary | |
---|---|
void |
addFactoryStateListener(FactoryStateListener listener)
Adds a factory listener. |
void |
checkAcceptability(Dictionary conf)
Checks if the configuration is acceptable. |
protected void |
computeDescription()
Computes the component type description. |
protected void |
computeFactoryState()
Computes factory state. |
ComponentInstance |
createComponentInstance(Dictionary configuration)
Creates an instance. |
ComponentInstance |
createComponentInstance(Dictionary configuration,
ServiceContext serviceContext)
Creates an instance in the specified service context. |
abstract ComponentInstance |
createInstance(Dictionary config,
IPojoContext context,
HandlerManager[] handlers)
Creates an instance. |
void |
deleted(String name)
Deletes an instance. |
void |
disposed(ComponentInstance instance)
Callback called by instance when disposed. |
protected String |
generateName()
Helper method generating a new unique name. |
BundleContext |
getBundleContext()
Gets the bundle context of the factory. |
abstract 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 String |
getFactoryName()
Computes the factory name. |
protected HandlerManager |
getHandler(IPojoFactory.RequiredHandler req,
ServiceContext context)
Returns the handler object for the given required handler. |
Logger |
getLogger()
Gets the logger used by instances created by the current factory. |
List |
getMissingHandlers()
Computes the list of missing handlers. |
String |
getName()
Gets the factory name. |
abstract List |
getRequiredHandlerList()
Computes the required handler list. |
List |
getRequiredHandlers()
Gets the list of required handlers. |
int |
getState()
Gets the actual factory state. |
boolean |
isAcceptable(Dictionary conf)
Checks if the configuration is acceptable. |
protected boolean |
match(IPojoFactory.RequiredHandler req,
ServiceReference ref)
Checks if the given handler identifier and the service reference match. |
void |
reconfigure(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(String name,
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 |
Field Detail |
---|
protected static final List INSTANCE_NAME
protected ComponentTypeDescription m_componentDesc
Factory
service.
protected final Map m_componentInstances
protected final Element m_componentMetadata
protected final BundleContext m_context
protected String m_factoryName
protected List m_requiredHandlers
protected List m_listeners
FactoryStateListener
protected final Logger m_logger
protected final boolean m_isPublic
protected ServiceRegistration m_sr
ManagedServiceFactory
,
Factory
protected int m_state
Factory.INVALID
Factory.VALID
Constructor Detail |
---|
public IPojoFactory(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 Factory
listener
- the factory listener to add.Factory.addFactoryStateListener(org.apache.felix.ipojo.FactoryStateListener)
public Logger getLogger()
public abstract String getFactoryName()
public abstract List getRequiredHandlerList()
public abstract ComponentInstance createInstance(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(Dictionary configuration) throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException
createComponentInstance
in interface Factory
configuration
- 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(Dictionary configuration, ServiceContext serviceContext) throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException
createComponentInstance
in interface Factory
configuration
- 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 BundleContext getBundleContext()
getBundleContext
in interface Factory
Factory.getBundleContext()
public abstract String getClassName()
getClassName
in interface Factory
Factory.getClassName()
public ComponentTypeDescription getComponentDescription()
getComponentDescription
in interface Factory
Null
if not already computed.public Element getDescription()
getDescription
in interface Factory
Factory.getDescription()
public List getMissingHandlers()
getMissingHandlers
in interface Factory
Factory.getMissingHandlers()
public String getName()
getName
in interface Factory
getName
in interface ManagedServiceFactory
Factory.getName()
public List getRequiredHandlers()
getRequiredHandlers
in interface Factory
Factory.getRequiredHandlers()
public int getState()
getState
in interface Factory
Factory.getState()
public boolean isAcceptable(Dictionary conf)
isAcceptable
in interface Factory
conf
- the configuration to test.
true
if the configuration is acceptable.Factory.isAcceptable(java.util.Dictionary)
public void checkAcceptability(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(Dictionary properties) throws UnacceptableConfiguration, MissingHandlerException
reconfigure
in interface Factory
properties
- 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 Factory
listener
- 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.
public abstract void starting()
public void start()
starting()
method,
and published services if the factory is public.
public void updated(String name, Dictionary properties) throws ConfigurationException
updated
in interface ManagedServiceFactory
name
- the name of the instanceproperties
- the new configuration of the instance
ConfigurationException
- if the configuration is not consistent for this component typeManagedServiceFactory.updated(java.lang.String, java.util.Dictionary)
public void deleted(String name)
deleted
in interface ManagedServiceFactory
name
- 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, ServiceReference ref)
req
- the handler identifier.ref
- the service reference.
true
if the service reference can fulfill the handler requirementprotected 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 String generateName()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |