org.apache.felix.ipojo

## Interface Factory

All Known Subinterfaces:
  HandlerFactory

All Known Implementing Classes:
  ComponentFactory, HandlerManagerFactory, 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

Fields
`static java.lang.String` `FACTORY_VERSION_PROPERTY` Instance configuration can set the factory version they target using this property.
`static java.lang.String` `INSTANCE_NAME_PROPERTY` Instance configuration can set the instance name using this property.
`static int` `INVALID` Factory State.
`static int` `VALID` Factory State.

### Method Summary

All Methods Instance Methods Abstract Methods Deprecated Methods
`void` `addFactoryStateListener(FactoryStateListener listener)` Adds a factory state listener on the current factory.
`ComponentInstance` `createComponentInstance(java.util.Dictionary configuration)` Creates an instance manager (i.e.
`ComponentInstance` `createComponentInstance(java.util.Dictionary configuration, ServiceContext serviceContext)` Creates an instance manager (i.e.
`org.osgi.framework.BundleContext` `getBundleContext()` Gets the bundle context of the factory.
`java.lang.String` `getClassName()` Deprecated.
`ComponentTypeDescription` `getComponentDescription()` Gets the component type description.
`org.apache.felix.ipojo.metadata.Element` `getComponentMetadata()` Gets the component type metadata (Element - Attribute structure)
`org.apache.felix.ipojo.metadata.Element` `getDescription()` Gets the component type information containing provided service, configuration properties ...
`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.
`java.util.List` `getMissingHandlers()` Gets the list of missing handlers.
`java.lang.String` `getName()` Returns the factory name.
`java.util.List` `getRequiredHandlers()` Get the list of required handlers.
`int` `getState()` Returns the state of the factory.
`java.lang.String` `getVersion()` Gets the version of the component type.
`boolean` `isAcceptable(java.util.Dictionary conf)` Checks if the given configuration is acceptable as a configuration of a component instance.
`void` `reconfigure(java.util.Dictionary conf)` Reconfigures an instance already created.
`void` `removeFactoryStateListener(FactoryStateListener listener)` Removes 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

#### INSTANCE_NAME_PROPERTY

    static final java.lang.String INSTANCE_NAME_PROPERTY

Instance configuration can set the instance name using this property.

See Also:
  Constant Field Values

#### FACTORY_VERSION_PROPERTY

    static final java.lang.String FACTORY_VERSION_PROPERTY

Instance configuration can set the factory version they target using this property.

See Also:
  Constant Field Values

### Method Detail

#### createComponentInstance

    ComponentInstance createComponentInstance(java.util.Dictionary configuration)
                                       throws UnacceptableConfiguration,
                                              MissingHandlerException,
                                              ConfigurationException

Creates an instance manager (i.e. component type instance).

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

#### createComponentInstance

    ComponentInstance createComponentInstance(java.util.Dictionary configuration,
                                              ServiceContext serviceContext)
                                       throws UnacceptableConfiguration,
                                              MissingHandlerException,
                                              ConfigurationException

Creates an instance manager (i.e. component type instance). The instance is created 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` - if the given configuration is not valid.
  `MissingHandlerException` - if an handler is missing.
  `ConfigurationException` - if the instance configuration failed.

#### getDescription

    org.apache.felix.ipojo.metadata.Element getDescription()

Gets the component type information containing provided service, configuration properties ...

Returns:
  the component type information.

#### getComponentDescription

    ComponentTypeDescription getComponentDescription()

Gets the component type description.

Returns:
  the component type description object

#### isAcceptable

    boolean isAcceptable(java.util.Dictionary conf)

Checks 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()

Returns the factory name.

Returns:
  the name of the factory.

#### reconfigure

    void reconfigure(java.util.Dictionary conf)
              throws UnacceptableConfiguration,
                     MissingHandlerException

Reconfigures an instance already created. This configuration needs to have the name property to identify the instance.

Parameters:
  `conf` - the configuration to reconfigure the instance. The instance.name property must be set to identify the instance to reconfigure.
Throws:
  `UnacceptableConfiguration` - if the given configuration is not consistent for the targeted instance.
  `MissingHandlerException` - if an handler is missing.

#### addFactoryStateListener

    void addFactoryStateListener(FactoryStateListener listener)

Adds a factory state listener on the current factory.

Parameters:
  `listener` - the listener to add

#### removeFactoryStateListener

    void removeFactoryStateListener(FactoryStateListener listener)

Removes the given factory state listener from the listener list.

Parameters:
  `listener` - the listener to remove

#### getMissingHandlers

    java.util.List getMissingHandlers()

Gets the list of missing handlers. The handlers are given under the form namespace:name

Returns:
  the list containing the name of missing handlers

#### getRequiredHandlers

    java.util.List getRequiredHandlers()

Get the list of required handlers. The handlers are given under the form namespace:name

Returns:
  the list containing the name of required handlers

#### getClassName

    java.lang.String getClassName()

Deprecated.
Returns the class name 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()

Returns the state of the factory.

Returns:
  the state of the factory

#### getBundleContext

    org.osgi.framework.BundleContext getBundleContext()

Gets the bundle context of the factory.

Returns:
  the bundle context of the factory.

#### getVersion

    java.lang.String getVersion()

Gets the version of the component type.

Returns:
  the component type version or `null` if not specified.

#### getComponentMetadata

    org.apache.felix.ipojo.metadata.Element getComponentMetadata()

Gets the component type metadata (Element - Attribute structure)

Returns:
  the root element of the component metadata. The result must not be modified.

#### getInstances

    java.util.List<ComponentInstance> getInstances()

Gets the list of instances created by the factory. The instances must be still alive.

Returns:
  the list of created (and living) instances
Since:
  1.11.0

#### getInstancesNames

    java.util.List<java.lang.String> getInstancesNames()

Gets the list of the names of the instances created by the factory. The instances must be still alive.

Returns:
  the list of the names of created (and living) instances
Since:
  1.11.0