public abstract class IPojoFactory extends java.lang.Object implements Factory
Modifier and Type | Class and Description |
---|---|
static class |
IPojoFactory.DefaultNameGenerator
This generator implements the default naming strategy.
|
static interface |
IPojoFactory.NameGenerator
Generate a unique name for a component instance.
|
protected class |
IPojoFactory.RequiredHandler
Structure storing required handlers.
|
static class |
IPojoFactory.RetryNameGenerator
This generator implements a retry naming strategy.
|
Modifier and Type | Field and Description |
---|---|
protected static java.util.List<java.lang.String> |
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<java.lang.String,ComponentInstance> |
m_componentInstances
The list of the managed instance managers.
|
protected org.apache.felix.ipojo.metadata.Element |
m_componentMetadata
The component type metadata.
|
protected org.osgi.framework.BundleContext |
m_context
The bundle context reference.
|
protected java.lang.String |
m_factoryName
The factory name.
|
protected boolean |
m_isPublic
Is the factory public (exposed as services).
|
protected java.util.List<FactoryStateListener> |
m_listeners
The list of factory state listeners.
|
protected Logger |
m_logger
The logger for the factory.
|
protected java.util.List<IPojoFactory.RequiredHandler> |
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.
|
FACTORY_VERSION_PROPERTY, INSTANCE_NAME_PROPERTY, INVALID, VALID
Constructor and Description |
---|
IPojoFactory(org.osgi.framework.BundleContext context,
org.apache.felix.ipojo.metadata.Element metadata)
Creates an iPOJO Factory.
|
Modifier and Type | Method and Description |
---|---|
void |
addFactoryStateListener(FactoryStateListener listener)
Adds a factory listener.
|
void |
checkAcceptability(java.util.Dictionary<java.lang.String,?> 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.
|
void |
dispose()
Destroys the factory.
|
void |
disposed(ComponentInstance instance)
Callback called by instance when disposed.
|
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.
|
org.apache.felix.ipojo.metadata.Element |
getComponentMetadata()
Gets the component metadata.
|
ComponentTypeDescription |
getComponentTypeDescription()
Gets the component type description.
|
org.apache.felix.ipojo.metadata.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.
|
ComponentInstance |
getInstanceByName(java.lang.String name)
Gets a component instance created by the current factory.
|
java.util.List<ComponentInstance> |
getInstances()
Gets the list of instances created by the factory.
|
java.util.List<java.lang.String> |
getInstancesNames()
Gets the list of the names of the instances created by the factory.
|
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<java.lang.String> |
getMissingHandlers()
Computes the list of missing handlers.
|
java.lang.String |
getName()
Gets the factory name.
|
abstract java.util.List<IPojoFactory.RequiredHandler> |
getRequiredHandlerList()
Computes the required handler list.
|
java.util.List<java.lang.String> |
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 |
restart()
For testing purpose ONLY.
|
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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getVersion
protected static final java.util.List<java.lang.String> INSTANCE_NAME
protected ComponentTypeDescription m_componentDesc
Factory
service.protected final java.util.Map<java.lang.String,ComponentInstance> m_componentInstances
protected final org.apache.felix.ipojo.metadata.Element m_componentMetadata
protected final org.osgi.framework.BundleContext m_context
protected java.lang.String m_factoryName
protected final java.util.List<IPojoFactory.RequiredHandler> m_requiredHandlers
protected java.util.List<FactoryStateListener> m_listeners
FactoryStateListener
protected final Logger m_logger
protected final boolean m_isPublic
protected final java.lang.String m_version
protected org.osgi.framework.ServiceRegistration m_sr
ManagedServiceFactory
,
Factory
protected int m_state
Factory.INVALID
Factory.VALID
public IPojoFactory(org.osgi.framework.BundleContext context, org.apache.felix.ipojo.metadata.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.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 java.lang.String getFactoryName()
public abstract java.util.List<IPojoFactory.RequiredHandler> getRequiredHandlerList() throws ConfigurationException
ConfigurationException
- when the list of handler cannot be computed.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 useConfigurationException
- if the instance creation failed during the configuration process.public ComponentInstance createComponentInstance(java.util.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(java.util.Dictionary configuration, ServiceContext serviceContext) throws UnacceptableConfiguration, MissingHandlerException, ConfigurationException
createInstance(Dictionary, IPojoContext, HandlerManager[])
method.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 org.osgi.framework.BundleContext getBundleContext()
getBundleContext
in interface Factory
Factory.getBundleContext()
public abstract java.lang.String getClassName()
getClassName
in interface Factory
Factory.getClassName()
public ComponentTypeDescription getComponentDescription()
getComponentDescription
in interface Factory
Null
if not already computed.public org.apache.felix.ipojo.metadata.Element getDescription()
getDescription
in interface Factory
Factory.getDescription()
public org.apache.felix.ipojo.metadata.Element getComponentMetadata()
getComponentMetadata
in interface Factory
Factory.getComponentMetadata()
public java.util.List<ComponentInstance> getInstances()
getInstances
in interface Factory
public java.util.List<java.lang.String> getInstancesNames()
getInstancesNames
in interface Factory
public java.util.List<java.lang.String> getMissingHandlers()
getMissingHandlers
in interface Factory
Factory.getMissingHandlers()
public java.lang.String getName()
getName
in interface Factory
Factory.getName()
public java.util.List<java.lang.String> getRequiredHandlers()
getRequiredHandlers
in interface Factory
Factory.getRequiredHandlers()
public int getState()
getState
in interface Factory
Factory.getState()
public ComponentInstance getInstanceByName(java.lang.String name)
name
- the instance namepublic boolean isAcceptable(java.util.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(java.util.Dictionary<java.lang.String,?> 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 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 void dispose()
Extender
can call this method.public abstract void starting()
public void start()
starting()
method,
and published services if the factory is public.public void restart()
protected final org.osgi.framework.BundleContext getIPOJOBundleContext()
public void updated(java.lang.String name, java.util.Dictionary properties) throws org.osgi.service.cm.ConfigurationException
name
- the name of the instanceproperties
- the new configuration of the instanceorg.osgi.service.cm.ConfigurationException
public void deleted(java.lang.String name)
name
- the name of the instance to deletepublic 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 requirementprotected HandlerManager getHandler(IPojoFactory.RequiredHandler req, ServiceContext context) throws MissingHandlerException, UnacceptableConfiguration, ConfigurationException
req
- the handler to create.context
- the service context in which the handler is created (same as the instance context).MissingHandlerException
UnacceptableConfiguration
ConfigurationException
Copyright © 2006-2014 The Apache Software Foundation. All Rights Reserved.