Knopflerfish OSGi 1.3.3

org.knopflerfish.util.cm
Class CMDataManager

java.lang.Object
  extended byorg.knopflerfish.util.cm.CMDataManager
All Implemented Interfaces:
org.knopflerfish.util.cm.CMDataNames

public class CMDataManager
extends java.lang.Object
implements org.knopflerfish.util.cm.CMDataNames

Loads/saves Configuration Management data from/to XML files that uses the cm_data DTD.

Public methods in this class intentionally avoids throwing any XML related exceptions. However, at any XML parse error, IllegalArgumentException is thrown instead, with a nice descriptive string of the error.

Version:
$Id: CMDataManager.java,v 1.1.1.1 2004/03/05 20:34:49 wistrand Exp $
Author:
Gatespace

Field Summary
static java.lang.String BUNDLE_LOCATION
          This should really be in org.osgi.framework.Constants but it is not.
static java.lang.String CM_DATA_0_1_ID
          The Public ID of the cm_data DTD.
static java.lang.String CM_DATA_0_1_URI
          The file name of the cm_data DTD.
static java.lang.String CM_DATA_ARRAY_NAME
          Name of a 'array' element.
static java.lang.String CM_DATA_CONFIGRUATION_NAME
          Name of a 'configuration' node.
static java.lang.String CM_DATA_FACTORYCONFIGRUATION_NAME
          Name of a 'factoryconfiguration' node.
static java.lang.String CM_DATA_FILTER_NAME
          Name of a 'filter' node.
static java.lang.String CM_DATA_INCLUDE_NAME
          Name of a 'include' node.
static java.lang.String CM_DATA_PRIMITIVEVALUE_NAME
          Name of a 'primitveValue' element.
static java.lang.String CM_DATA_PROPERTY_NAME
          Name of a 'property' element.
static java.lang.String CM_DATA_ROOT_NAME
          Name of the root node in cm_data
static java.lang.String CM_DATA_VALUE_NAME
          Name of a 'value' element.
static java.lang.String CM_DATA_VECTOR_NAME
          Name of a 'value' element.
static java.lang.String CM_DATA_VERSION_ANAME
          Name of 'version' attribute.
static java.lang.String FACTORY_PID
          This should really be in org.osgi.framework.Constants but it is not.
 
Method Summary
static void exportCMData(Configuration[] configs, boolean deleteAllOldConfigs, boolean template, ConfigurationAdmin cfgAdmin, java.io.OutputStream output)
          Exports the specified configurations in a cm_data XML file.
static void exportCMData(Configuration[] configs, boolean deleteAllOldConfigs, java.io.OutputStream output)
          Exports the specified configurations in a cm_data XML file.
static void exportCMData(java.lang.String pid, java.lang.String factoryPid, java.lang.String ldapfilter, java.util.Dictionary properties, java.io.OutputStream output)
          Exports a configuration into a cm_data XML file.
static void handleCMData(java.io.InputStream is, ConfigurationAdmin cfgAdmin)
          Parses an cm_data DTD XML-stream and updates CM using the specified cfgAdmin service.
static void handleCMData(java.io.InputStream is, java.lang.String url, ConfigurationAdmin cfgAdmin)
          Parses an cm_data DTD XML-stream and updates CM using the specified cfgAdmin service.
static void handleCMData(java.lang.String url, ConfigurationAdmin cfgAdmin)
          Parses an cm_data DTD XML-file and updates CM using the specified cfgAdmin service.
static java.util.Collection parseCMData(java.io.InputStream is)
          Parses a cm_data DTD XML-stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CM_DATA_0_1_ID

public static final java.lang.String CM_DATA_0_1_ID
The Public ID of the cm_data DTD.

See Also:
Constant Field Values

CM_DATA_0_1_URI

public static final java.lang.String CM_DATA_0_1_URI
The file name of the cm_data DTD.

See Also:
Constant Field Values

CM_DATA_ROOT_NAME

public static final java.lang.String CM_DATA_ROOT_NAME
Name of the root node in cm_data

See Also:
Constant Field Values

CM_DATA_CONFIGRUATION_NAME

public static final java.lang.String CM_DATA_CONFIGRUATION_NAME
Name of a 'configuration' node.

See Also:
Constant Field Values

CM_DATA_FACTORYCONFIGRUATION_NAME

public static final java.lang.String CM_DATA_FACTORYCONFIGRUATION_NAME
Name of a 'factoryconfiguration' node.

See Also:
Constant Field Values

CM_DATA_FILTER_NAME

public static final java.lang.String CM_DATA_FILTER_NAME
Name of a 'filter' node.

See Also:
Constant Field Values

CM_DATA_INCLUDE_NAME

public static final java.lang.String CM_DATA_INCLUDE_NAME
Name of a 'include' node.

See Also:
Constant Field Values

CM_DATA_PROPERTY_NAME

public static final java.lang.String CM_DATA_PROPERTY_NAME
Name of a 'property' element.

See Also:
Constant Field Values

CM_DATA_VALUE_NAME

public static final java.lang.String CM_DATA_VALUE_NAME
Name of a 'value' element.

See Also:
Constant Field Values

CM_DATA_PRIMITIVEVALUE_NAME

public static final java.lang.String CM_DATA_PRIMITIVEVALUE_NAME
Name of a 'primitveValue' element.

See Also:
Constant Field Values

CM_DATA_ARRAY_NAME

public static final java.lang.String CM_DATA_ARRAY_NAME
Name of a 'array' element.

See Also:
Constant Field Values

CM_DATA_VECTOR_NAME

public static final java.lang.String CM_DATA_VECTOR_NAME
Name of a 'value' element.

See Also:
Constant Field Values

CM_DATA_VERSION_ANAME

public static final java.lang.String CM_DATA_VERSION_ANAME
Name of 'version' attribute.

See Also:
Constant Field Values

FACTORY_PID

public static final java.lang.String FACTORY_PID
This should really be in org.osgi.framework.Constants but it is not.

See Also:
Constant Field Values

BUNDLE_LOCATION

public static final java.lang.String BUNDLE_LOCATION
This should really be in org.osgi.framework.Constants but it is not.

See Also:
Constant Field Values
Method Detail

handleCMData

public static void handleCMData(java.lang.String url,
                                ConfigurationAdmin cfgAdmin)
                         throws java.io.IOException
Parses an cm_data DTD XML-file and updates CM using the specified cfgAdmin service.

Parameters:
url - String with URL syntax pointing to the XML-file to parse.
cfgAdmin - Configuration admin service to use when updating CM with data from the specified XML-file.
Throws:
java.io.IOException
java.lang.IllegalArgumentException - If the cfgAdmin is null or the root element of the XML-file is not named 'cm_data', or if the XML parse failed.

handleCMData

public static void handleCMData(java.io.InputStream is,
                                ConfigurationAdmin cfgAdmin)
                         throws java.io.IOException
Parses an cm_data DTD XML-stream and updates CM using the specified cfgAdmin service.

Parameters:
is - XML stream to parse.
cfgAdmin - Configuration admin service to use when updating CM with data from the specified XML-file.
Throws:
java.io.IOException
java.lang.IllegalArgumentException - If the cfgAdmin is null or the root element of the XML-file is not named 'cm_data', or if the XML parse failed.

handleCMData

public static void handleCMData(java.io.InputStream is,
                                java.lang.String url,
                                ConfigurationAdmin cfgAdmin)
                         throws java.io.IOException
Parses an cm_data DTD XML-stream and updates CM using the specified cfgAdmin service.

Parameters:
is - XML stream to parse.
url - URL of the stream to parse, must be a correct value if the document contains an <include> element with a realtive URL.
cfgAdmin - Configuration admin service to use when updating CM with data from the specified XML-file.
Throws:
java.io.IOException
java.lang.IllegalArgumentException - If the cfgAdmin is null or the root element of the XML-file is not named 'cm_data', or if the XML parse failed.

parseCMData

public static java.util.Collection parseCMData(java.io.InputStream is)
                                        throws java.io.IOException
Parses a cm_data DTD XML-stream.

Parameters:
is - XML stream to parse.
Returns:
collection of org.osgi.service.cm.Configuration
Throws:
java.io.IOException
java.lang.IllegalArgumentException - If the root element of the XML-file is not named 'cm_data', or if the XML parse failed.

exportCMData

public static void exportCMData(Configuration[] configs,
                                boolean deleteAllOldConfigs,
                                java.io.OutputStream output)
                         throws java.io.IOException
Exports the specified configurations in a cm_data XML file.

Parameters:
configs - Array with configurations to export.
deleteAllOldConfigs - If true start the generated file with an instruction to delete all existing configurations.
output - An output stream to write to.
Throws:
java.io.IOException
java.lang.IllegalArgumentException

exportCMData

public static void exportCMData(Configuration[] configs,
                                boolean deleteAllOldConfigs,
                                boolean template,
                                ConfigurationAdmin cfgAdmin,
                                java.io.OutputStream output)
                         throws java.io.IOException
Exports the specified configurations in a cm_data XML file.

The template saves a configuration where some data is left out so that it can be filled in by GDSPconf based on information from the system platform that the template is used on.

The follwoing data is left out

Parameters:
configs - Array with configurations to export.
deleteAllOldConfigs - If true start the generated file with an instruction to delete all existing configurations. Also sets the mode of all (factory) configurations to 'new' and not 'update'.
template - If true create an XML file suitable as a GDSPconf template.
cfgAdmin - If template is true then a configuration admin service is required. Used to determine template details from configuration data.
output - An output stream to write to.
Throws:
java.io.IOException

exportCMData

public static void exportCMData(java.lang.String pid,
                                java.lang.String factoryPid,
                                java.lang.String ldapfilter,
                                java.util.Dictionary properties,
                                java.io.OutputStream output)
                         throws java.io.IOException
Exports a configuration into a cm_data XML file.

If pid != null, factorypPid and ldapFilter are ignored and the properties contained in properties are exported into a non factory configuration.

If pid == null, a factory configuration will be exported. factorypPid and ldapFilter must in this case not be null.

Parameters:
pid - Configiration pid
factoryPid - Configuration factory pid
ldapfilter - Filter for the factory configuration
properties - Properties for the configuration
output - An output stream to write to.
Throws:
java.io.IOException

Knopflerfish OSGi 1.3.3