org.apache.felix.ipojo.handlers.configuration
Class ConfigurationHandler

java.lang.Object
  extended by org.apache.felix.ipojo.Handler
      extended by org.apache.felix.ipojo.PrimitiveHandler
          extended by org.apache.felix.ipojo.handlers.configuration.ConfigurationHandler
All Implemented Interfaces:
ConstructorInjector, FieldInterceptor, MethodInterceptor, ManagedService

public class ConfigurationHandler
extends PrimitiveHandler
implements ManagedService

Handler managing the Configuration Admin.

Author:
Felix Project Team

Field Summary
 
Fields inherited from class org.apache.felix.ipojo.PrimitiveHandler
HANDLER_TYPE
 
Fields inherited from class org.apache.felix.ipojo.Handler
HANDLER_LEVEL_PROPERTY, HANDLER_NAME_PROPERTY, HANDLER_NAMESPACE_PROPERTY, HANDLER_TYPE_PROPERTY, m_instance, m_isValid
 
Constructor Summary
ConfigurationHandler()
           
 
Method Summary
protected  void addProperty(Property prop)
          Adds the given property metadata to the property metadata list.
 void configure(Element metadata, Dictionary configuration)
          Configures the handler.
protected  boolean containsProperty(String name)
          Checks if the list contains the property.
 HandlerDescription getDescription()
          Gets the configuration handler description.
 void initializeComponentFactory(ComponentTypeDescription desc, Element metadata)
          Initialize the component type.
 void onCreation(Object instance)
          Handler createInstance method.
 void reconfigure(Dictionary configuration)
          Reconfigure the component instance.
 void reconfigureProperty(Property prop, Object value)
          Reconfigures the given property with the given value.
 void start()
          Start method.
 void stop()
          Stop method.
 void updated(Dictionary conf)
          Managed Service method.
 
Methods inherited from class org.apache.felix.ipojo.PrimitiveHandler
attach, getConstructorParameter, getConstructorParameterType, getFactory, getHandler, getInstanceManager, getLogger, getPojoMetadata, onEntry, onError, onExit, onFinally, onGet, onSet, setFactory
 
Methods inherited from class org.apache.felix.ipojo.Handler
debug, error, error, getHandlerManager, getValidity, info, isValid, setValidity, stateChanged, warn, warn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConfigurationHandler

public ConfigurationHandler()
Method Detail

initializeComponentFactory

public void initializeComponentFactory(ComponentTypeDescription desc,
                                       Element metadata)
                                throws ConfigurationException
Initialize the component type.

Overrides:
initializeComponentFactory in class Handler
Parameters:
desc - : component type description to populate.
metadata - : component type metadata.
Throws:
ConfigurationException - : metadata are incorrect.
See Also:
Handler.initializeComponentFactory(org.apache.felix.ipojo.architecture.ComponentTypeDescription, org.apache.felix.ipojo.metadata.Element)

configure

public void configure(Element metadata,
                      Dictionary configuration)
               throws ConfigurationException
Configures the handler. Access to field does not require synchronization as this method is executed before any thread access to this object.

Specified by:
configure in class Handler
Parameters:
metadata - the metadata of the component
configuration - the instance configuration
Throws:
ConfigurationException - one property metadata is not correct
See Also:
org.apache.felix.ipojo.Handler#configure(org.apache.felix.ipojo.InstanceManager, org.apache.felix.ipojo.metadata.Element)

stop

public void stop()
Stop method. This method is synchronized to avoid the configuration admin pushing a configuration during the un-registration. Do nothing.

Specified by:
stop in class Handler
See Also:
Handler.stop()

start

public void start()
Start method. This method is synchronized to avoid the config admin pushing a configuration before ending the method. Propagate properties if the propagation is activated.

Specified by:
start in class Handler
See Also:
Handler.start()

addProperty

protected void addProperty(Property prop)
Adds the given property metadata to the property metadata list.

Parameters:
prop - : property metadata to add

containsProperty

protected boolean containsProperty(String name)
Checks if the list contains the property.

Parameters:
name - : name of the property
Returns:
true if the property exist in the list

reconfigure

public void reconfigure(Dictionary configuration)
Reconfigure the component instance. Check if the new configuration modifies the current configuration. Invokes the updated method is needed.

Overrides:
reconfigure in class Handler
Parameters:
configuration - : the new configuration
See Also:
Handler.reconfigure(java.util.Dictionary)

reconfigureProperty

public void reconfigureProperty(Property prop,
                                Object value)
Reconfigures the given property with the given value. This methods handles InstanceManager#onSet(Object, String, Object) call and the callback invocation. The reconfiguration occurs only if the value changes.

Parameters:
prop - the property object to reconfigure
value - the new value.

onCreation

public void onCreation(Object instance)
Handler createInstance method. This method is override to allow delayed callback invocation. Invokes the updated method is needed.

Overrides:
onCreation in class PrimitiveHandler
Parameters:
instance - : the created object
See Also:
org.apache.felix.ipojo.Handler#onCreation(java.lang.Object)

updated

public void updated(Dictionary conf)
             throws ConfigurationException
Managed Service method. This method is called when the instance is reconfigured by the ConfigurationAdmin. When called, it must hold the monitor lock.

Specified by:
updated in interface ManagedService
Parameters:
conf - : pushed configuration.
Throws:
ConfigurationException - the reconfiguration failed.
See Also:
ManagedService.updated(java.util.Dictionary)

getDescription

public HandlerDescription getDescription()
Gets the configuration handler description.

Overrides:
getDescription in class Handler
Returns:
the configuration handler description.
See Also:
Handler.getDescription()


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.