org.apache.felix.ipojo
Interface Factory

All Known Implementing Classes:
ComponentFactory, HandlerFactory, IPojoFactory

public interface Factory

Component Type Factory Service. This service is exposed by a instance manager factory, and allows the dynamic creation of component instance.

Author:
Felix Project Team

Field Summary
static int INVALID
          Factory State.
static int VALID
          Factory State.
 
Method Summary
 void addFactoryStateListener(FactoryStateListener listener)
          Add a factory state listener on the current factory.
 ComponentInstance createComponentInstance(java.util.Dictionary configuration)
          Create an instance manager (i.e.
 ComponentInstance createComponentInstance(java.util.Dictionary configuration, ServiceContext serviceContext)
          Create an instance manager (i.e.
 org.osgi.framework.BundleContext getBundleContext()
          Get the bundle context of the factory.
 java.lang.String getClassName()
          Return the classname of the component type.
 ComponentTypeDescription getComponentDescription()
          Get the component type description.
 org.apache.felix.ipojo.metadata.Element getDescription()
          Get the component type information containing provided service, configuration properties ...
 java.util.List getMissingHandlers()
          Get the list of missing handlers.
 java.lang.String getName()
          Return the factory name.
 java.util.List getRequiredHandlers()
          Get the list of required handlers.
 int getState()
          Return the state of the factory.
 boolean isAcceptable(java.util.Dictionary conf)
          Check if the given configuration is acceptable as a configuration of a component instance.
 void reconfigure(java.util.Dictionary conf)
          Reconfigure an instance already created.
 void removeFactoryStateListener(FactoryStateListener listener)
          Remove the given factory state listener from the listener list.
 

Field Detail

VALID

static final int VALID
Factory State. A valid factory is a factory where all required handlers are available.

See Also:
Constant Field Values

INVALID

static final int INVALID
Factory State. An invalid factory is a factory where at least one required handler is unavailable. Creating an instance with an invalid factory failed.

See Also:
Constant Field Values
Method Detail

createComponentInstance

ComponentInstance createComponentInstance(java.util.Dictionary configuration)
                                          throws UnacceptableConfiguration,
                                                 MissingHandlerException,
                                                 ConfigurationException
Create an instance manager (i.e. component type instance).

Parameters:
configuration - : the configuration properties for this component.
Returns:
the created instance manager.
Throws:
UnacceptableConfiguration - : when a given configuration is not valid.
MissingHandlerException - : when an handler is missing.
ConfigurationException - : when the instance configuration failed.

createComponentInstance

ComponentInstance createComponentInstance(java.util.Dictionary configuration,
                                          ServiceContext serviceContext)
                                          throws UnacceptableConfiguration,
                                                 MissingHandlerException,
                                                 ConfigurationException
Create an instance manager (i.e. component type instance). This has these service interaction in the scope given in argument.

Parameters:
configuration - : the configuration properties for this component.
serviceContext - : the service context of the component.
Returns:
the created instance manager.
Throws:
UnacceptableConfiguration - : when the given configuration is not valid.
MissingHandlerException - : when an handler is missing.
ConfigurationException - : when the instance configuration failed.

getDescription

org.apache.felix.ipojo.metadata.Element getDescription()
Get the component type information containing provided service, configuration properties ...

Returns:
the component type information.

getComponentDescription

ComponentTypeDescription getComponentDescription()
Get the component type description.

Returns:
the component type description object

isAcceptable

boolean isAcceptable(java.util.Dictionary conf)
Check if the given configuration is acceptable as a configuration of a component instance.

Parameters:
conf - : the configuration to test
Returns:
true if the configuration is acceptable

getName

java.lang.String getName()
Return the factory name.

Returns:
the name of the factory.

reconfigure

void reconfigure(java.util.Dictionary conf)
                 throws UnacceptableConfiguration,
                        MissingHandlerException
Reconfigure an instance already created. This configuration need to have the name property to identify the instance.

Parameters:
conf - : the configuration to reconfigure the instance.
Throws:
UnacceptableConfiguration - : if the given configuration is not consistent for the targeted instance.
MissingHandlerException - : when an handler is missing.

addFactoryStateListener

void addFactoryStateListener(FactoryStateListener listener)
Add a factory state listener on the current factory.

Parameters:
listener - : the listener to add

removeFactoryStateListener

void removeFactoryStateListener(FactoryStateListener listener)
Remove the given factory state listener from the listener list.

Parameters:
listener - : the listener to remove

getMissingHandlers

java.util.List getMissingHandlers()
Get the list of missing handlers.

Returns:
the list containing the name of missing handlers (Name : namespace:name)

getRequiredHandlers

java.util.List getRequiredHandlers()
Get the list of required handlers.

Returns:
the list containing the name of required handlers (Name : namespace:name)

getClassName

java.lang.String getClassName()
Return the classname of the component type. For factories which does not contains a class, return "composite"

Returns:
the class name of the component type or "composite"

getState

int getState()
Return the state of the factory.

Returns:
the state of the factory

getBundleContext

org.osgi.framework.BundleContext getBundleContext()
Get the bundle context of the factory.

Returns:
the bundle context of the factory.