Class OSGiBundleParser


  • public class OSGiBundleParser
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) static javax.xml.parsers.DocumentBuilderFactory dbFactory  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      private static java.lang.String getBundleName​(java.util.Dictionary<java.lang.String,​java.lang.String> headers, java.lang.String defaultValue)
      Accessor for the Bundle-Name from the manifest.mf file
      private static java.lang.String getBundleSymbolicName​(java.util.Dictionary<java.lang.String,​java.lang.String> headers, java.lang.String defaultValue)
      Accessor for the Bundle-SymbolicName from the manifest.mf file
      private static java.lang.String getBundleVendor​(java.util.Dictionary<java.lang.String,​java.lang.String> headers, java.lang.String defaultValue)
      Accessor for the Bundle-Vendor from the manifest.mf file
      private static java.lang.String getBundleVersion​(java.util.Dictionary<java.lang.String,​java.lang.String> headers, java.lang.String defaultValue)
      Accessor for the Bundle-Version from the manifest.mf file
      static javax.xml.parsers.DocumentBuilder getDocumentBuilder()
      Convenience method to create a document builder for parsing.
      private static java.lang.String getHeaderValue​(java.util.Dictionary<java.lang.String,​java.lang.String> headers, java.lang.String key, java.lang.String defaultValue)  
      private static java.util.List<Bundle.BundleDescription> getRequireBundle​(java.util.Dictionary<java.lang.String,​java.lang.String> headers)
      Accessor for the Bundle-Name from the manifest.mf file
      private static java.util.List<ExtensionPoint> parseExtensionPoints​(org.w3c.dom.Element rootElement, Bundle plugin, org.osgi.framework.Bundle osgiBundle)
      Method to parse ExtensionPoints from plug-in file
      private static java.util.List<Extension> parseExtensions​(org.w3c.dom.Element rootElement, Bundle plugin, org.osgi.framework.Bundle osgiBundle)
      Method to parse Extensions from plug-in file
      static Bundle parseManifest​(org.osgi.framework.Bundle osgiBundle)  
      static java.util.List[] parsePluginElements​(javax.xml.parsers.DocumentBuilder db, PluginRegistry mgr, java.net.URL fileUrl, Bundle plugin, org.osgi.framework.Bundle osgiBundle)
      Method to parse Extensions in plug-in file.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • dbFactory

        static javax.xml.parsers.DocumentBuilderFactory dbFactory
    • Constructor Detail

      • OSGiBundleParser

        public OSGiBundleParser()
    • Method Detail

      • parseManifest

        public static Bundle parseManifest​(org.osgi.framework.Bundle osgiBundle)
      • getRequireBundle

        private static java.util.List<Bundle.BundleDescription> getRequireBundle​(java.util.Dictionary<java.lang.String,​java.lang.String> headers)
        Accessor for the Bundle-Name from the manifest.mf file
        Parameters:
        headers - manifest headers
        Returns:
        the Set with BundleDescription
      • parseExtensionPoints

        private static java.util.List<ExtensionPoint> parseExtensionPoints​(org.w3c.dom.Element rootElement,
                                                                           Bundle plugin,
                                                                           org.osgi.framework.Bundle osgiBundle)
        Method to parse ExtensionPoints from plug-in file
        Parameters:
        rootElement - the root element of the plugin xml
        plugin - the plugin bundle
        osgiBundle - The bundle
        Returns:
        a List of extensionPoints, if any
        Throws:
        NucleusException - if an error occurs during parsing
      • parseExtensions

        private static java.util.List<Extension> parseExtensions​(org.w3c.dom.Element rootElement,
                                                                 Bundle plugin,
                                                                 org.osgi.framework.Bundle osgiBundle)
        Method to parse Extensions from plug-in file
        Parameters:
        rootElement - the root element of the plugin xml
        plugin - the plugin bundle
        osgiBundle - the bundle
        Returns:
        a List of extensions, if any
        Throws:
        NucleusException - if an error occurs during parsing
      • getHeaderValue

        private static java.lang.String getHeaderValue​(java.util.Dictionary<java.lang.String,​java.lang.String> headers,
                                                       java.lang.String key,
                                                       java.lang.String defaultValue)
      • getBundleSymbolicName

        private static java.lang.String getBundleSymbolicName​(java.util.Dictionary<java.lang.String,​java.lang.String> headers,
                                                              java.lang.String defaultValue)
        Accessor for the Bundle-SymbolicName from the manifest.mf file
        Parameters:
        headers - Manifest headers
        defaultValue - a default value, in case no symbolic name found in manifest
        Returns:
        the bundle symbolic name
      • getBundleName

        private static java.lang.String getBundleName​(java.util.Dictionary<java.lang.String,​java.lang.String> headers,
                                                      java.lang.String defaultValue)
        Accessor for the Bundle-Name from the manifest.mf file
        Parameters:
        headers - manifest headers
        defaultValue - a default value, in case no name found in manifest
        Returns:
        the bundle name
      • getBundleVendor

        private static java.lang.String getBundleVendor​(java.util.Dictionary<java.lang.String,​java.lang.String> headers,
                                                        java.lang.String defaultValue)
        Accessor for the Bundle-Vendor from the manifest.mf file
        Parameters:
        headers - manifest headers
        defaultValue - a default value, in case no vendor found in manifest
        Returns:
        the bundle vendor
      • getBundleVersion

        private static java.lang.String getBundleVersion​(java.util.Dictionary<java.lang.String,​java.lang.String> headers,
                                                         java.lang.String defaultValue)
        Accessor for the Bundle-Version from the manifest.mf file
        Parameters:
        headers - the manifest headers
        defaultValue - a default value, in case no version found in manifest
        Returns:
        the bundle version
      • parsePluginElements

        public static java.util.List[] parsePluginElements​(javax.xml.parsers.DocumentBuilder db,
                                                           PluginRegistry mgr,
                                                           java.net.URL fileUrl,
                                                           Bundle plugin,
                                                           org.osgi.framework.Bundle osgiBundle)
        Method to parse Extensions in plug-in file.
        Parameters:
        db - DocumentBuilder to use for parsing
        mgr - the PluginManager
        fileUrl - URL of the plugin.xml file
        plugin - The Bundle
        osgiBundle - The OSGi Bundle
        Returns:
        array of 2 elements. first element is a List of extensionPoints, and 2nd element is a List of Extension
        Throws:
        NucleusException - if an error occurs during parsing
      • getDocumentBuilder

        public static javax.xml.parsers.DocumentBuilder getDocumentBuilder()
        Convenience method to create a document builder for parsing.
        Returns:
        The document builder
        Throws:
        NucleusException - if an error occurs creating the instance