public class ComponentFactory extends IPojoFactory implements TrackerCustomizer
Factory
service is exposed.Factory
,
IPojoFactory
,
TrackerCustomizer
IPojoFactory.DefaultNameGenerator, IPojoFactory.NameGenerator, IPojoFactory.RequiredHandler, IPojoFactory.RetryNameGenerator
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
HANDLER_AUTO_PRIMITIVE
System property set to automatically attach primitive handlers to primitive
component types.
|
protected Tracker |
m_tracker
The tracker used to track required handler factories.
|
INSTANCE_NAME, m_componentDesc, m_componentInstances, m_componentMetadata, m_context, m_factoryName, m_isPublic, m_listeners, m_logger, m_requiredHandlers, m_sr, m_state, m_version
FACTORY_VERSION_PROPERTY, INSTANCE_NAME_PROPERTY, INVALID, VALID
Constructor and Description |
---|
ComponentFactory(org.osgi.framework.BundleContext context,
byte[] clazz,
org.apache.felix.ipojo.metadata.Element element)
Creates a instance manager factory.
|
ComponentFactory(org.osgi.framework.BundleContext context,
org.apache.felix.ipojo.metadata.Element element)
Creates a instance manager factory.
|
Modifier and Type | Method and Description |
---|---|
void |
addedService(org.osgi.framework.ServiceReference reference)
This method is called when a matching service has been added to the tracker,
we can no compute the factory state.
|
boolean |
addingService(org.osgi.framework.ServiceReference reference)
This method is called when a new handler factory is detected.
|
void |
check(org.apache.felix.ipojo.metadata.Element element)
Allows a factory to check if the given element is well-formed.
|
ComponentInstance |
createInstance(java.util.Dictionary config,
IPojoContext context,
HandlerManager[] handlers)
Creates a primitive instance.
|
java.lang.Class<? extends java.lang.Object> |
defineClass(java.lang.String name,
byte[] clazz,
java.security.ProtectionDomain domain)
Defines a class.
|
java.lang.ClassLoader |
getBundleClassLoader() |
java.lang.String |
getClassName()
Gets the class name.
|
ComponentTypeDescription |
getComponentTypeDescription()
Gets the component type description of the current factory.
|
java.lang.String |
getFactoryName()
Computes the factory name.
|
PojoMetadata |
getPojoMetadata()
Returns manipulation metadata of this component type.
|
java.util.List<IPojoFactory.RequiredHandler> |
getRequiredHandlerList()
Computes required handlers.
|
java.lang.String |
getVersion()
Gets the version of the component type.
|
java.lang.Class |
loadClass(java.lang.String className)
Loads a class.
|
void |
modifiedService(org.osgi.framework.ServiceReference reference,
java.lang.Object service)
This method is called when a used handler factory is modified.
|
void |
removedService(org.osgi.framework.ServiceReference reference,
java.lang.Object service)
This method is called when a used handler factory disappears.
|
void |
setUseFactoryClassloader(boolean use)
Sets the flag enabling / disabling the factory classloader.
|
void |
starting()
Starts the factory.
|
void |
stopping()
Stops all the instance managers.
|
addFactoryStateListener, checkAcceptability, computeDescription, computeFactoryState, createComponentInstance, createComponentInstance, deleted, dispose, disposed, getBundleContext, getComponentDescription, getComponentMetadata, getDescription, getHandler, getInstanceByName, getInstances, getInstancesNames, getIPOJOBundleContext, getLogger, getMissingHandlers, getName, getRequiredHandlers, getState, isAcceptable, match, reconfigure, removeFactoryStateListener, restart, start, stop, updated
public static final java.lang.String HANDLER_AUTO_PRIMITIVE
namespace:name
.protected Tracker m_tracker
public ComponentFactory(org.osgi.framework.BundleContext context, byte[] clazz, org.apache.felix.ipojo.metadata.Element element) throws ConfigurationException
context
- the bundle contextclazz
- the component classelement
- the metadata of the componentConfigurationException
- if the element describing the factory is malformed.public ComponentFactory(org.osgi.framework.BundleContext context, org.apache.felix.ipojo.metadata.Element element) throws ConfigurationException
context
- the bundle contextelement
- the metadata of the component to createConfigurationException
- if element describing the factory is malformed.public void setUseFactoryClassloader(boolean use)
use
- true
enables the factory classloader.public ComponentTypeDescription getComponentTypeDescription()
getComponentTypeDescription
in class IPojoFactory
IPojoFactory.getComponentTypeDescription()
public void check(org.apache.felix.ipojo.metadata.Element element) throws ConfigurationException
element
- the metadata describing the componentConfigurationException
- if the element describing the factory is malformed.public java.lang.String getClassName()
getClassName
in interface Factory
getClassName
in class IPojoFactory
IPojoFactory.getClassName()
public ComponentInstance createInstance(java.util.Dictionary config, IPojoContext context, HandlerManager[] handlers) throws ConfigurationException
createInstance
in class IPojoFactory
config
- the instance configurationcontext
- the service context (null if the instance has to be created in the global space).handlers
- the handlers to attach to the instanceConfigurationException
- if the configuration process failed.IPojoFactory.createInstance(java.util.Dictionary, org.apache.felix.ipojo.IPojoContext, org.apache.felix.ipojo.HandlerManager[])
public java.lang.Class<? extends java.lang.Object> defineClass(java.lang.String name, byte[] clazz, java.security.ProtectionDomain domain)
define
method invocation to the
factory classloader.name
- the qualified name of the classclazz
- the byte array of the classdomain
- the protection domain of the classpublic java.lang.Class loadClass(java.lang.String className) throws java.lang.ClassNotFoundException
Bundle.loadClass(String)
is called.
The implementation class is loaded using the factory classloader only if the factory classloader was enabledclassName
- the name of the class to loadjava.lang.ClassNotFoundException
- if the class is not foundsetUseFactoryClassloader(boolean)
public void starting()
starting
in class IPojoFactory
public void stopping()
stopping
in class IPojoFactory
public java.lang.String getFactoryName()
getFactoryName
in class IPojoFactory
public java.util.List<IPojoFactory.RequiredHandler> getRequiredHandlerList()
HANDLER_AUTO_PRIMITIVE
system property to add the listed handlers to the required handler set.getRequiredHandlerList
in class IPojoFactory
public boolean addingService(org.osgi.framework.ServiceReference reference)
addingService
in interface TrackerCustomizer
reference
- the new service reference.true
if the given factory reference matches with a required handler.TrackerCustomizer.addingService(org.osgi.framework.ServiceReference)
public void addedService(org.osgi.framework.ServiceReference reference)
addedService
in interface TrackerCustomizer
reference
- the added service reference.TrackerCustomizer.addedService(org.osgi.framework.ServiceReference)
public void removedService(org.osgi.framework.ServiceReference reference, java.lang.Object service)
removedService
in interface TrackerCustomizer
reference
- the leaving service reference.service
- the handler factory object.TrackerCustomizer.removedService(org.osgi.framework.ServiceReference, java.lang.Object)
public void modifiedService(org.osgi.framework.ServiceReference reference, java.lang.Object service)
modifiedService
in interface TrackerCustomizer
reference
- the service referenceservice
- the Factory object (if already get)TrackerCustomizer.modifiedService(org.osgi.framework.ServiceReference, java.lang.Object)
public PojoMetadata getPojoMetadata()
public java.lang.String getVersion()
getVersion
in interface Factory
null
if not set.Factory.getVersion()
public java.lang.ClassLoader getBundleClassLoader()
Copyright © 2006-2014 The Apache Software Foundation. All Rights Reserved.