Class OSGiRuntimeService

java.lang.Object
org.nuxeo.runtime.AbstractRuntimeService
org.nuxeo.runtime.osgi.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
  • Field Details

  • Constructor Details

    • OSGiRuntimeService

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

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

    • 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()
    • getBundle

      public org.osgi.framework.Bundle getBundle(String symbolicName)
      Description copied from interface: RuntimeService
      Get an installed bundle given its symbolic name. This method is not handling versions.
      Specified by:
      getBundle in interface RuntimeService
      Overrides:
      getBundle in class AbstractRuntimeService
    • getBundlesMap

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

      public ComponentPersistence getComponentPersistence()
    • 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)
    • getContext

      public RuntimeContext getContext(String symbolicName)
    • doStart

      protected void doStart()
      Overrides:
      doStart in class AbstractRuntimeService
    • doStop

      protected void doStop()
      Overrides:
      doStop in class AbstractRuntimeService
    • 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
    • loadConfig

      protected void loadConfig() throws IOException
      Overrides:
      loadConfig in class AbstractRuntimeService
      Throws:
      IOException
    • reloadProperties

      public void reloadProperties() throws IOException
      Description copied from interface: RuntimeService
      Reread all property files loaded at startup.
      Specified by:
      reloadProperties in interface RuntimeService
      Throws:
      IOException
    • loadDefaultConfig

      protected void loadDefaultConfig()
      Loads default properties.

      Used for backward compatibility when adding new mandatory properties

    • loadProperties

      public void loadProperties(File file) throws IOException
      Throws:
      IOException
    • loadProperties

      public void loadProperties(URL url) throws IOException
      Throws:
      IOException
    • loadProperties

      @Deprecated(since="2025.0", forRemoval=true) public void loadProperties(InputStream in) throws IOException
      Deprecated, for removal: This API element is subject to removal in a future version.
      since 2025.0, Properties.load(InputStream) loads properties with ISO-8859-1 encoding whereas we want UTF-8, use loadProperties(Reader) instead
      Throws:
      IOException
    • loadProperties

      public void loadProperties(Reader reader) throws IOException
      Throws:
      IOException
    • 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
    • expandVars

      public String expandVars(String expression)
      Overrides the default method to be able to include OSGi properties.
      Specified by:
      expandVars in interface RuntimeService
      Overrides:
      expandVars in class AbstractRuntimeService
      Parameters:
      expression - the expression to process
      Returns:
      the expanded expression
    • 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)