Knopflerfish OSGi 5.2.0

org.knopflerfish.util.metatype
Class SystemMetatypeProvider

java.lang.Object
  extended by org.knopflerfish.util.metatype.MTP
      extended by org.knopflerfish.util.metatype.SystemMetatypeProvider
All Implemented Interfaces:
java.lang.Comparable<MTP>, MetaTypeInformation, MetaTypeProvider, MetaTypeService

public class SystemMetatypeProvider
extends MTP
implements MetaTypeService

Class which monitors installed bundles for metatype and CM default data.

When instantiated, SystemMetatypeProvider will listen for installed bundles and try to extract metatype and CM defaults XML from the bundle jar files. This data will then be available using the getServicePIDs, getFactoryPIDs and getObjectClassDefinition methods.


Field Summary
static java.lang.String ATTRIB_CMDEFAULTSURL
          Manifest attribute name specifying CM defaults XML URL.
static java.lang.String ATTRIB_METATYPEURL
          Manifest attribute name specifying metatype XML URL.
static java.lang.String CMDEFAULTS_RESOURCE
          Default URL to default CM values.
static java.lang.String METATYPE_RESOURCE
          Default URL to metatype XML.
 
Fields inherited from interface org.osgi.service.metatype.MetaTypeService
METATYPE_DOCUMENTS_LOCATION
 
Fields inherited from interface org.osgi.service.metatype.MetaTypeProvider
METATYPE_FACTORY_PID, METATYPE_PID
 
Constructor Summary
SystemMetatypeProvider(BundleContext bc, java.util.Map<ServiceRegistration<MetaTypeProvider>,MTP> confMtpRegs)
          Create a SystemMetatypeProvider, using the specified bundle context for listeners.
 
Method Summary
 void close()
          Stop listening for bundles.
 java.lang.String[] getFactoryPids()
          Return the Factory PIDs (for ManagedServiceFactories) for which ObjectClassDefinition information is available.
 java.lang.String[] getLocales()
          Return a list of available locales.
 MetaTypeInformation getMetaTypeInformation(Bundle bundle)
          Return the MetaType information for the specified bundle.
 MetaTypeInformation getMTP(Bundle b)
          Get a loaded metatype provider, given a bundle.
 ObjectClassDefinition getObjectClassDefinition(java.lang.String pid, java.lang.String locale)
          Get an ObjectClassDefinition given a PID.
 java.lang.String[] getPids()
          Return the PIDs (for ManagedServices) for which ObjectClassDefinition information is available.
 void loadMTP(Bundle b)
          Explicitly load a metatype provider from a bundle and cache it for later retrieval by getMTP(Bundle).
 void open()
          Start listening for bundles.
 
Methods inherited from class org.knopflerfish.util.metatype.MTP
addFactory, addService, compareTo, equals, getBundle, getId, hashCode, toString, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

METATYPE_RESOURCE

public static final java.lang.String METATYPE_RESOURCE
Default URL to metatype XML.

Value is "!/metatype.xml"

See Also:
Constant Field Values

CMDEFAULTS_RESOURCE

public static final java.lang.String CMDEFAULTS_RESOURCE
Default URL to default CM values.

Value is "!/cmdefaults.xml"

See Also:
Constant Field Values

ATTRIB_METATYPEURL

public static final java.lang.String ATTRIB_METATYPEURL
Manifest attribute name specifying metatype XML URL.

Value is "Bundle-MetatypeURL"

See Also:
Constant Field Values

ATTRIB_CMDEFAULTSURL

public static final java.lang.String ATTRIB_CMDEFAULTSURL
Manifest attribute name specifying CM defaults XML URL.

Value is "Bundle-CMDefaultsURL"

See Also:
Constant Field Values
Constructor Detail

SystemMetatypeProvider

public SystemMetatypeProvider(BundleContext bc,
                              java.util.Map<ServiceRegistration<MetaTypeProvider>,MTP> confMtpRegs)
Create a SystemMetatypeProvider, using the specified bundle context for listeners.

Parameters:
bc -
confMtpRegs -
Method Detail

open

public void open()
Start listening for bundles.


close

public void close()
Stop listening for bundles.


loadMTP

public void loadMTP(Bundle b)
             throws java.lang.Exception
Explicitly load a metatype provider from a bundle and cache it for later retrieval by getMTP(Bundle).

Throws:
java.lang.Exception - if loading fails

getPids

public java.lang.String[] getPids()
Description copied from interface: MetaTypeInformation
Return the PIDs (for ManagedServices) for which ObjectClassDefinition information is available.

Specified by:
getPids in interface MetaTypeInformation
Overrides:
getPids in class MTP
Returns:
Array of PIDs.

getFactoryPids

public java.lang.String[] getFactoryPids()
Description copied from interface: MetaTypeInformation
Return the Factory PIDs (for ManagedServiceFactories) for which ObjectClassDefinition information is available.

Specified by:
getFactoryPids in interface MetaTypeInformation
Overrides:
getFactoryPids in class MTP
Returns:
Array of Factory PIDs.

getLocales

public java.lang.String[] getLocales()
Description copied from interface: MetaTypeProvider
Return a list of available locales. The results must be names that consists of language [ _ country [ _ variation ]] as is customary in the Locale class.

Specified by:
getLocales in interface MetaTypeProvider
Overrides:
getLocales in class MTP
Returns:
An array of locale strings or null if there is no locale specific localization can be found.

getMTP

public MetaTypeInformation getMTP(Bundle b)
Get a loaded metatype provider, given a bundle.

Returns:
Provider if such provider is found, otherwise null.

getObjectClassDefinition

public ObjectClassDefinition getObjectClassDefinition(java.lang.String pid,
                                                      java.lang.String locale)
Get an ObjectClassDefinition given a PID.

Specified by:
getObjectClassDefinition in interface MetaTypeProvider
Overrides:
getObjectClassDefinition in class MTP
Parameters:
pid - 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:
ObjectClassDefinition if PID exists, otherwise null.

getMetaTypeInformation

public MetaTypeInformation getMetaTypeInformation(Bundle bundle)
Description copied from interface: MetaTypeService
Return the MetaType information for the specified bundle.

Specified by:
getMetaTypeInformation in interface MetaTypeService
Parameters:
bundle - The bundle for which meta type information is requested.
Returns:
A MetaTypeInformation object for the specified bundle.

Knopflerfish OSGi 5.2.0