org.apache.felix.dm.impl.metatype
Class MetaTypeProviderImpl

java.lang.Object
  extended by org.apache.felix.dm.impl.metatype.MetaTypeProviderImpl
All Implemented Interfaces:
ManagedService, ManagedServiceFactory, MetaTypeProvider

public class MetaTypeProviderImpl
extends Object
implements MetaTypeProvider, ManagedService, ManagedServiceFactory

When a ConfigurationDepdendency is configured with properties metadata, we provide a specific ManagedService which also implements the MetaTypeProvider interface. This interface allows the MetaTypeService to retrieve our properties metadata, which will then be handled by webconsole.


Constructor Summary
MetaTypeProviderImpl(String pid, BundleContext ctx, Logger logger, ManagedService msDelegate, ManagedServiceFactory msfDelegate)
           
 
Method Summary
 void add(PropertyMetaData property)
          Registers the metatype information of a given configuration property
 void deleted(String pid)
          Remove a factory instance.
 String[] getLocales()
          Returns all the Locales our bundle is containing.
 String getName()
          Return a descriptive name of this factory.
 ObjectClassDefinition getObjectClassDefinition(String id, String locale)
          Returns the ObjectClassDefinition for a given Pid/Locale.
 void setDescription(String description)
          A human readable description of the PID this annotation is associated with.
 void setLocalization(String path)
          Points to the basename of the Properties file that can localize the Meta Type informations.
 void setName(String heading)
          The label used to display the tab name (or section) where the properties are displayed.
 void updated(Dictionary properties)
          We also implements the ManagedService and we just delegates the configuration handling to our associated ConfigurationDependency.
 void updated(String pid, Dictionary properties)
          Create a new instance, or update the configuration of an existing instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetaTypeProviderImpl

public MetaTypeProviderImpl(String pid,
                            BundleContext ctx,
                            Logger logger,
                            ManagedService msDelegate,
                            ManagedServiceFactory msfDelegate)
Method Detail

add

public void add(PropertyMetaData property)
Registers the metatype information of a given configuration property

Parameters:
property -

setDescription

public void setDescription(String description)
A human readable description of the PID this annotation is associated with. Example: "Configuration for the PrinterService bundle".


setName

public void setName(String heading)
The label used to display the tab name (or section) where the properties are displayed. Example: "Printer Service".


setLocalization

public void setLocalization(String path)
Points to the basename of the Properties file that can localize the Meta Type informations. By default, (e.g. setLocalization("person") would match person_du_NL.properties in the root bundle directory. The default localization base name for the properties is OSGI-INF/l10n/bundle, but can be overridden by the manifest Bundle-Localization header (see core specification, in section Localization on page 68).


getLocales

public String[] getLocales()
Returns all the Locales our bundle is containing. For instance, if our bundle contains the following localization files: OSGI-INF/l10n/bundle_en_GB_welsh.properties and OSGI-INF/l10n/bundle_en_GB.properties, then this method will return "en_GB", "en_GB_welsh" ...

Specified by:
getLocales in interface MetaTypeProvider
Returns:
the list of Locale supported by our bundle.

getObjectClassDefinition

public ObjectClassDefinition getObjectClassDefinition(String id,
                                                      String locale)
Returns the ObjectClassDefinition for a given Pid/Locale.

Specified by:
getObjectClassDefinition in interface MetaTypeProvider
Parameters:
id - The ID of the requested object class. This can be a pid or factory pid returned by getPids or getFactoryPids.
locale - The locale of the definition or null for default locale.
Returns:
A ObjectClassDefinition object.

updated

public void updated(Dictionary properties)
             throws ConfigurationException
We also implements the ManagedService and we just delegates the configuration handling to our associated ConfigurationDependency.

Specified by:
updated in interface ManagedService
Parameters:
properties - A copy of the Configuration properties, or null. This argument must not contain the "service.bundleLocation" property. The value of this property may be obtained from the Configuration.getBundleLocation method.
Throws:
ConfigurationException - when the update fails

deleted

public void deleted(String pid)
Description copied from interface: ManagedServiceFactory
Remove a factory instance. Remove the factory instance associated with the PID. If the instance was registered with the service registry, it should be unregistered.

If this method throws any Exception, the Configuration Admin service must catch it and should log it.

The Configuration Admin service must call this method asynchronously.

Specified by:
deleted in interface ManagedServiceFactory
Parameters:
pid - the PID of the service to be removed

getName

public String getName()
Description copied from interface: ManagedServiceFactory
Return a descriptive name of this factory.

Specified by:
getName in interface ManagedServiceFactory
Returns:
the name for the factory, which might be localized

updated

public void updated(String pid,
                    Dictionary properties)
             throws ConfigurationException
Description copied from interface: ManagedServiceFactory
Create a new instance, or update the configuration of an existing instance. If the PID of the Configuration object is new for the Managed Service Factory, then create a new factory instance, using the configuration properties provided. Else, update the service instance with the provided properties.

If the factory instance is registered with the Framework, then the configuration properties should be copied to its registry properties. This is not mandatory and security sensitive properties should obviously not be copied.

If this method throws any Exception, the Configuration Admin service must catch it and should log it.

When the implementation of updated detects any kind of error in the configuration properties, it should create a new ConfigurationException which describes the problem.

The Configuration Admin service must call this method asynchronously. This implies that implementors of the ManagedServiceFactory class can be assured that the callback will not take place during registration when they execute the registration in a synchronized method.

Specified by:
updated in interface ManagedServiceFactory
Parameters:
pid - The PID for this configuration.
properties - A copy of the configuration properties. This argument must not contain the service.bundleLocation" property. The value of this property may be obtained from the Configuration.getBundleLocation method.
Throws:
ConfigurationException - when the configuration properties are invalid.


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