org.apache.aries.blueprint.compendium.cm
Class CmNamespaceHandler

java.lang.Object
  extended by org.apache.aries.blueprint.compendium.cm.CmNamespaceHandler
All Implemented Interfaces:
NamespaceHandler

public class CmNamespaceHandler
extends java.lang.Object
implements NamespaceHandler

Namespace handler for the Config Admin service. This handler will parse the various elements defined and populate / modify the registry accordingly.

Version:
$Rev: 1002327 $, $Date: 2010-09-28 20:06:56 +0100 (Tue, 28 Sep 2010) $
See Also:
CmManagedProperties, CmManagedServiceFactory, CmProperties, CmPropertyPlaceholder

Field Summary
static java.lang.String AUTO_EXPORT_ALL
           
static java.lang.String AUTO_EXPORT_ATTRIBUTE
           
static java.lang.String AUTO_EXPORT_CLASS_HIERARCHY
           
static java.lang.String AUTO_EXPORT_DEFAULT
           
static java.lang.String AUTO_EXPORT_DISABLED
           
static java.lang.String AUTO_EXPORT_INTERFACES
           
static java.lang.String BLUEPRINT_CM_NAMESPACE_1_0
           
static java.lang.String BLUEPRINT_CM_NAMESPACE_1_1
           
static java.lang.String BLUEPRINT_NAMESPACE
           
static java.lang.String CM_PROPERTIES_ELEMENT
           
static java.lang.String DEFAULT_PROPERTIES_ELEMENT
           
static java.lang.String DEFAULTS_REF_ATTRIBUTE
           
static java.lang.String FACTORY_PID_ATTRIBUTE
           
static java.lang.String ID_ATTRIBUTE
           
static java.lang.String INTERFACE_ATTRIBUTE
           
static java.lang.String INTERFACES_ELEMENT
           
static java.lang.String MANAGED_COMPONENT_ELEMENT
           
static java.lang.String MANAGED_PROPERTIES_ELEMENT
           
static java.lang.String MANAGED_SERVICE_FACTORY_ELEMENT
           
static java.lang.String PERSISTENT_ID_ATTRIBUTE
           
static java.lang.String PLACEHOLDER_PREFIX_ATTRIBUTE
           
static java.lang.String PLACEHOLDER_SUFFIX_ATTRIBUTE
           
static java.lang.String PROPERTY_ELEMENT
           
static java.lang.String PROPERTY_PLACEHOLDER_ELEMENT
           
static java.lang.String RANKING_ATTRIBUTE
           
static java.lang.String RANKING_DEFAULT
           
static java.lang.String UPDATE_ATTRIBUTE
           
static java.lang.String UPDATE_METHOD_ATTRIBUTE
           
static java.lang.String UPDATE_STRATEGY_ATTRIBUTE
           
static java.lang.String VALUE_ELEMENT
           
 
Constructor Summary
CmNamespaceHandler()
           
 
Method Summary
 ComponentMetadata decorate(org.w3c.dom.Node node, ComponentMetadata component, ParserContext context)
          Process a child node of an enclosing blueprint component.
 void generateIdIfNeeded(ParserContext context, MutableComponentMetadata metadata)
           
static org.osgi.service.cm.ConfigurationAdmin getConfigAdmin()
           
 java.lang.String getId(ParserContext context, org.w3c.dom.Element element)
           
 int getIdCounter()
           
 java.util.Set<java.lang.Class> getManagedClasses()
          Specify a set of classes that must be consistent between a blueprint bundle and this namespace handler The blueprint extender will not invoke a namespace handler if any of the managed classes are inconsistent with the class space of the blueprint bundle (i.e.
 java.net.URL getSchemaLocation(java.lang.String namespace)
          Retrieve a URL from where the schema for a given namespace can be retrieved
static boolean isBlueprintNamespace(java.lang.String ns)
           
 Metadata parse(org.w3c.dom.Element element, ParserContext context)
          Parse a stand-alone blueprint component Given an Element node as a root, this method parses the stand-alone component and returns its metadata.
 java.util.List<java.lang.String> parseInterfaceNames(org.w3c.dom.Element element)
           
 void setConfigAdmin(org.osgi.service.cm.ConfigurationAdmin configAdmin)
           
 void setIdCounter(int idCounter)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BLUEPRINT_NAMESPACE

public static final java.lang.String BLUEPRINT_NAMESPACE
See Also:
Constant Field Values

BLUEPRINT_CM_NAMESPACE_1_0

public static final java.lang.String BLUEPRINT_CM_NAMESPACE_1_0
See Also:
Constant Field Values

BLUEPRINT_CM_NAMESPACE_1_1

public static final java.lang.String BLUEPRINT_CM_NAMESPACE_1_1
See Also:
Constant Field Values

PROPERTY_PLACEHOLDER_ELEMENT

public static final java.lang.String PROPERTY_PLACEHOLDER_ELEMENT
See Also:
Constant Field Values

MANAGED_PROPERTIES_ELEMENT

public static final java.lang.String MANAGED_PROPERTIES_ELEMENT
See Also:
Constant Field Values

MANAGED_SERVICE_FACTORY_ELEMENT

public static final java.lang.String MANAGED_SERVICE_FACTORY_ELEMENT
See Also:
Constant Field Values

CM_PROPERTIES_ELEMENT

public static final java.lang.String CM_PROPERTIES_ELEMENT
See Also:
Constant Field Values

DEFAULT_PROPERTIES_ELEMENT

public static final java.lang.String DEFAULT_PROPERTIES_ELEMENT
See Also:
Constant Field Values

PROPERTY_ELEMENT

public static final java.lang.String PROPERTY_ELEMENT
See Also:
Constant Field Values

INTERFACES_ELEMENT

public static final java.lang.String INTERFACES_ELEMENT
See Also:
Constant Field Values

VALUE_ELEMENT

public static final java.lang.String VALUE_ELEMENT
See Also:
Constant Field Values

MANAGED_COMPONENT_ELEMENT

public static final java.lang.String MANAGED_COMPONENT_ELEMENT
See Also:
Constant Field Values

ID_ATTRIBUTE

public static final java.lang.String ID_ATTRIBUTE
See Also:
Constant Field Values

PERSISTENT_ID_ATTRIBUTE

public static final java.lang.String PERSISTENT_ID_ATTRIBUTE
See Also:
Constant Field Values

PLACEHOLDER_PREFIX_ATTRIBUTE

public static final java.lang.String PLACEHOLDER_PREFIX_ATTRIBUTE
See Also:
Constant Field Values

PLACEHOLDER_SUFFIX_ATTRIBUTE

public static final java.lang.String PLACEHOLDER_SUFFIX_ATTRIBUTE
See Also:
Constant Field Values

DEFAULTS_REF_ATTRIBUTE

public static final java.lang.String DEFAULTS_REF_ATTRIBUTE
See Also:
Constant Field Values

UPDATE_STRATEGY_ATTRIBUTE

public static final java.lang.String UPDATE_STRATEGY_ATTRIBUTE
See Also:
Constant Field Values

UPDATE_METHOD_ATTRIBUTE

public static final java.lang.String UPDATE_METHOD_ATTRIBUTE
See Also:
Constant Field Values

FACTORY_PID_ATTRIBUTE

public static final java.lang.String FACTORY_PID_ATTRIBUTE
See Also:
Constant Field Values

AUTO_EXPORT_ATTRIBUTE

public static final java.lang.String AUTO_EXPORT_ATTRIBUTE
See Also:
Constant Field Values

RANKING_ATTRIBUTE

public static final java.lang.String RANKING_ATTRIBUTE
See Also:
Constant Field Values

INTERFACE_ATTRIBUTE

public static final java.lang.String INTERFACE_ATTRIBUTE
See Also:
Constant Field Values

UPDATE_ATTRIBUTE

public static final java.lang.String UPDATE_ATTRIBUTE
See Also:
Constant Field Values

AUTO_EXPORT_DISABLED

public static final java.lang.String AUTO_EXPORT_DISABLED
See Also:
Constant Field Values

AUTO_EXPORT_INTERFACES

public static final java.lang.String AUTO_EXPORT_INTERFACES
See Also:
Constant Field Values

AUTO_EXPORT_CLASS_HIERARCHY

public static final java.lang.String AUTO_EXPORT_CLASS_HIERARCHY
See Also:
Constant Field Values

AUTO_EXPORT_ALL

public static final java.lang.String AUTO_EXPORT_ALL
See Also:
Constant Field Values

AUTO_EXPORT_DEFAULT

public static final java.lang.String AUTO_EXPORT_DEFAULT
See Also:
Constant Field Values

RANKING_DEFAULT

public static final java.lang.String RANKING_DEFAULT
See Also:
Constant Field Values
Constructor Detail

CmNamespaceHandler

public CmNamespaceHandler()
Method Detail

getIdCounter

public int getIdCounter()

setIdCounter

public void setIdCounter(int idCounter)

getConfigAdmin

public static org.osgi.service.cm.ConfigurationAdmin getConfigAdmin()

setConfigAdmin

public void setConfigAdmin(org.osgi.service.cm.ConfigurationAdmin configAdmin)

getSchemaLocation

public java.net.URL getSchemaLocation(java.lang.String namespace)
Description copied from interface: NamespaceHandler
Retrieve a URL from where the schema for a given namespace can be retrieved

Specified by:
getSchemaLocation in interface NamespaceHandler
Parameters:
namespace - The schema's namespace
Returns:
A URL that points to the location of the schema or null if the namespace validation is not needed

getManagedClasses

public java.util.Set<java.lang.Class> getManagedClasses()
Description copied from interface: NamespaceHandler
Specify a set of classes that must be consistent between a blueprint bundle and this namespace handler The blueprint extender will not invoke a namespace handler if any of the managed classes are inconsistent with the class space of the blueprint bundle (i.e. if the blueprint bundle loads any of the managed classes from a different classloader).

Specified by:
getManagedClasses in interface NamespaceHandler
Returns:
a Set of classes that must be compatible with any blueprint bundle for which this namespace handler is to apply or null if no compatibility checks are to be performed

parse

public Metadata parse(org.w3c.dom.Element element,
                      ParserContext context)
Description copied from interface: NamespaceHandler
Parse a stand-alone blueprint component Given an Element node as a root, this method parses the stand-alone component and returns its metadata. The supplied ParserContext should be used to parse embedded blueprint elements as well as creating metadata.

Specified by:
parse in interface NamespaceHandler
Parameters:
element - The DOM element representing the custom component
context - The ParserContext for parsing sub-components and creating metadata objects
Returns:
A metadata instance representing the custom component. This should be an instance of an appropriate MutableMetadata type to enable further decoration by other namespace handlers

decorate

public ComponentMetadata decorate(org.w3c.dom.Node node,
                                  ComponentMetadata component,
                                  ParserContext context)
Description copied from interface: NamespaceHandler
Process a child node of an enclosing blueprint component. If the decorator method returns a new ComponentMetadata instance, this will replace the argument ComponentMetadata in subsequent parsing and namespace handler invocations. A namespace handler that elects to return a new ComponentMetadata instance should ensure that existing interceptors are registered against the new instance if appropriate. Due to the interaction with interceptors, a namespace handler should prefer to change a component metadata instead of returning a new instance wherever possible. This can be achieved by casting a ComponentMetadata to its corresponding MutabableComponentMetadata instance. Note however that a given ComponentMetadata instance cannot be guaranteed to implement the mutable interface if it was constructed by an agent other than the blueprint extender.

Specified by:
decorate in interface NamespaceHandler
Parameters:
node - The node associated with this NamespaceHandler that should be used to decorate the enclosing component
component - The enclosing blueprint component
context - The parser context
Returns:
The decorated component to be used instead of the original enclosing component. This can of course be the original component.

isBlueprintNamespace

public static boolean isBlueprintNamespace(java.lang.String ns)

getId

public java.lang.String getId(ParserContext context,
                              org.w3c.dom.Element element)

generateIdIfNeeded

public void generateIdIfNeeded(ParserContext context,
                               MutableComponentMetadata metadata)

parseInterfaceNames

public java.util.List<java.lang.String> parseInterfaceNames(org.w3c.dom.Element element)


Copyright © 2009-2011 The Apache Software Foundation. All Rights Reserved.