Class OSGiRuntimeService

  • All Implemented Interfaces:
    EventListener, RuntimeService, org.osgi.framework.FrameworkListener
    Direct Known Subclasses:
    OSGiRuntimeTestService

    public class OSGiRuntimeService
    extends AbstractRuntimeService
    implements org.osgi.framework.FrameworkListener
    The default implementation of NXRuntime over an OSGi compatible environment.
    Author:
    Bogdan Stefanescu, Florent Guillaume
    • Constructor Detail

      • OSGiRuntimeService

        public OSGiRuntimeService​(org.osgi.framework.BundleContext context)
      • OSGiRuntimeService

        public OSGiRuntimeService​(OSGiRuntimeContext runtimeContext,
                                  org.osgi.framework.BundleContext context)
    • Method Detail

      • getName

        public String getName()
        Description copied from interface: RuntimeService
        Gets the name of this runtime service.
        Specified by:
        getName in interface RuntimeService
        Returns:
        the runtime service name
      • getVersion

        public Version getVersion()
        Description copied from interface: RuntimeService
        Gets the version of this runtime service.
        Specified by:
        getVersion in interface RuntimeService
        Returns:
        the runtime service version
      • getBundleContext

        public org.osgi.framework.BundleContext getBundleContext()
      • getBundlesMap

        public Map<String,​org.osgi.framework.Bundle> getBundlesMap()
      • createContext

        public RuntimeContext createContext​(org.osgi.framework.Bundle bundle)
      • destroyContext

        public void destroyContext​(org.osgi.framework.Bundle bundle)
      • getContext

        public RuntimeContext getContext​(org.osgi.framework.Bundle bundle)
      • loadComponents

        protected void loadComponents​(org.osgi.framework.Bundle bundle,
                                      RuntimeContext ctx,
                                      boolean isFragment)
      • getComponentsList

        public static String getComponentsList​(org.osgi.framework.Bundle bundle)
      • loadConfigurationFromProvider

        protected boolean loadConfigurationFromProvider()
                                                 throws IOException
        Throws:
        IOException
      • loadDefaultConfig

        protected void loadDefaultConfig()
        Loads default properties.

        Used for backward compatibility when adding new mandatory properties

      • getProperty

        public String getProperty​(String name,
                                  String defValue)
        Overrides the default method to be able to include OSGi properties.
        Specified by:
        getProperty in interface RuntimeService
        Overrides:
        getProperty in class AbstractRuntimeService
        Parameters:
        name - the property name
        defValue - the default value to use when the property doesn't exists
        Returns:
        the property value
      • startComponents

        protected void startComponents()
      • frameworkEvent

        public void frameworkEvent​(org.osgi.framework.FrameworkEvent event)
        Specified by:
        frameworkEvent in interface org.osgi.framework.FrameworkListener
      • deployFrameworkStartedComponent

        protected void deployFrameworkStartedComponent()
      • findHostBundle

        public org.osgi.framework.Bundle findHostBundle​(org.osgi.framework.Bundle bundle)
      • getBundleFile

        public File getBundleFile​(org.osgi.framework.Bundle bundle)
        Description copied from interface: RuntimeService
        OSGi frameworks are using a string Bundle.getLocation() to identify bundle locations.

        This method try to convert the bundle location to real file if possible. If this bundle location cannot be converted to a file (e.g. it may be a remote URL), null is returned.

        This method works only for bundles that are installed as files on the host file system.

        Specified by:
        getBundleFile in interface RuntimeService
        Overrides:
        getBundleFile in class AbstractRuntimeService
        Returns:
        the bundle file, or null
      • isJBoss4

        public static boolean isJBoss4​(Environment env)
      • isPropertiesFile

        protected static boolean isPropertiesFile​(String name)