org.apache.struts2.osgi.host

## Class FelixOsgiHost

- java.lang.Object
- - org.apache.struts2.osgi.host.BaseOsgiHost
  - - org.apache.struts2.osgi.host.FelixOsgiHost

- All Implemented Interfaces:
    OsgiHost

      public class FelixOsgiHost
      extends BaseOsgiHost

  Apache felix implementation of an OsgiHost See http://felix.apache.org/site/apache-felix-framework-launching-and-embedding.html
  Servlet config params:

  struts.osgi.clearBundleCache: Defaults to "true" delete installed bundles when the container starts

  struts.osgi.logLevel: Defaults to "1". Felix log level. 1 = error, 2 = warning, 3 = information, and 4 = debug

  struts.osgi.runLevel: Defaults to "3". Run level to start the container.

  struts.osgi.felixCacheLocking: Defaults to "true". Set to true to enable Felix cache locking, false to disable it.

  struts.osgi.searchForPropertiesFilesInRelativePath: Defaults to "false". Set to "true" for fallback search for properties files in relative path (e.g. for unit testing).

  struts.osgi.felixPropertiesPath: Defaults to "default.properties". Path to Felix properties (prefix "/" will be prepended).

  struts.osgi.strutsOSGiPropertiesPath: Defaults to "struts-osgi.properties". Path to Struts OSGi properties (prefix "/" will be prepended).

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected org.apache.felix.framework.Felix` | `felix`
    `protected static String` | `FELIX_DETECT_JAVA_VERSION`
    `protected static String` | `FELIX_EE_CAP_DETECT_JPMS`
    `protected static String` | `FELIX_EE_CAP_JAVA_SPECIFICATION_VERSION`
    `protected static String` | `FELIX_EE_FELIX_DETECT_JPMS`
    `protected static String` | `FELIX_EE_JAVA_SPECIFICATION_VERSION`
    `protected static String` | `FELIX_JRE_BASE_PREFIX`
    `protected static String` | `FELIX_JRE_BASE_SUFFIX`
    `protected static String` | `FELIX_JRE_DETECT_JAVA_SPECIFICATION_VERSION`
    `protected static String` | `FELIX_JRE_DETECT_JPMS`
    `protected static String` | `FELIX_SERVICE_CAPS`
    `protected static String` | `FELIX_SERVICE_CAPS_KEY`
    `protected static String` | `OSGI_FRAMEWORK_EXECUTIONENVIRONMENT`
    `protected static String` | `OSGI_FRAMEWORK_SYSTEM_CAPABILITIES`

    - ### Fields inherited from class org.apache.struts2.osgi.host.BaseOsgiHost

      `DETECT_JAVA_VERSION, JRE_JAVA_SPECIFICATION_VERSION, SCANNING_PACKAGE_INCLUDES, servletContext, VERSION_PATTERN, versionPattern`

    - ### Fields inherited from interface org.apache.struts2.osgi.host.OsgiHost

      `OSGI_BUNDLE_CONTEXT, OSGI_HEADER_STRUTS_ENABLED`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FelixOsgiHost()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addSpringOSGiSupport()`
    `void` | `destroy()`
    `protected String` | `expandAllFelixJREBaseElements(String jreProperty, Properties properties)` Recursive method to expand all Felix JRE base elements from the configuration.
    `protected String` | `expandAllOsgiFrameworkExecutionEnvironments(String executionEnvironment, Properties properties)` Method to expand all OSGi framework execution environment elements from the configuration.
    `protected String` | `expandAllOsgiFrameworkSystemCapabilities(String capabilities, Properties properties)` Method to expand all OSGi framework system capabilities elements from the configuration.
    `Map<String,org.osgi.framework.Bundle>` | `getActiveBundles()`
    `org.osgi.framework.BundleContext` | `getBundleContext()`
    `Map<String,org.osgi.framework.Bundle>` | `getBundles()` This bundle map will not change, but the status of the bundles can change over time.
    `void` | `init(javax.servlet.ServletContext servletContext)`
    `protected void` | `replaceFelixExecutionEnvironment(Properties properties)` Replace all instances of the `FELIX_EE_JAVA_SPECIFICATION_VERSION` and `FELIX_EE_FELIX_DETECT_JPMS` within the `Constants.FRAMEWORK_EXECUTIONENVIRONMENT` property of the provided properties.
    `protected void` | `replaceFelixFrameworkSystemCapabilities(Properties properties)` Replace all instances of the `FELIX_SERVICE_CAPS`, `FELIX_EE_CAP_JAVA_SPECIFICATION_VERSION` and `FELIX_EE_CAP_DETECT_JPMS` within the `Constants.FRAMEWORK_SYSTEMCAPABILITIES` property of the provided properties.
    `protected void` | `replaceFelixSystemPackages(Properties properties)` Replace all instances of `FELIX_JRE_DETECT_JAVA_SPECIFICATION_VERSION` and `FELIX_JRE_DETECT_JPMS`, within the `Constants.FRAMEWORK_SYSTEMPACKAGES` property of the provided properties.
    `protected void` | `startFelix()`

    - ### Methods inherited from class org.apache.struts2.osgi.host.BaseOsgiHost

      `addAutoStartBundles, addExportedPackages, findPropertiesFileInRelativePath, getBundlesInDir, getJarUrl, getProperties, getRunLevelDirs, getServletContextParam, getVersion, getVersionFromString, replaceSystemPackages, searchForPropertiesFilesInRelativePath`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### FELIX_JRE_DETECT_JAVA_SPECIFICATION_VERSION

          protected static final String FELIX_JRE_DETECT_JAVA_SPECIFICATION_VERSION

      See Also:
        Constant Field Values

    - #### FELIX_JRE_DETECT_JPMS

          protected static final String FELIX_JRE_DETECT_JPMS

      See Also:
        Constant Field Values

    - #### FELIX_DETECT_JAVA_VERSION

          protected static final String FELIX_DETECT_JAVA_VERSION

      See Also:
        Constant Field Values

    - #### FELIX_JRE_BASE_PREFIX

          protected static final String FELIX_JRE_BASE_PREFIX

      See Also:
        Constant Field Values

    - #### FELIX_JRE_BASE_SUFFIX

          protected static final String FELIX_JRE_BASE_SUFFIX

      See Also:
        Constant Field Values

    - #### OSGI_FRAMEWORK_SYSTEM_CAPABILITIES

          protected static final String OSGI_FRAMEWORK_SYSTEM_CAPABILITIES

      See Also:
        Constant Field Values

    - #### OSGI_FRAMEWORK_EXECUTIONENVIRONMENT

          protected static final String OSGI_FRAMEWORK_EXECUTIONENVIRONMENT

      See Also:
        Constant Field Values

    - #### FELIX_SERVICE_CAPS_KEY

          protected static final String FELIX_SERVICE_CAPS_KEY

      See Also:
        Constant Field Values

    - #### FELIX_SERVICE_CAPS

          protected static final String FELIX_SERVICE_CAPS

      See Also:
        Constant Field Values

    - #### FELIX_EE_CAP_JAVA_SPECIFICATION_VERSION

          protected static final String FELIX_EE_CAP_JAVA_SPECIFICATION_VERSION

      See Also:
        Constant Field Values

    - #### FELIX_EE_CAP_DETECT_JPMS

          protected static final String FELIX_EE_CAP_DETECT_JPMS

      See Also:
        Constant Field Values

    - #### FELIX_EE_JAVA_SPECIFICATION_VERSION

          protected static final String FELIX_EE_JAVA_SPECIFICATION_VERSION

      See Also:
        Constant Field Values

    - #### FELIX_EE_FELIX_DETECT_JPMS

          protected static final String FELIX_EE_FELIX_DETECT_JPMS

      See Also:
        Constant Field Values

    - #### felix

          protected org.apache.felix.framework.Felix felix

  - ### Constructor Detail

    - #### FelixOsgiHost

          public FelixOsgiHost()

  - ### Method Detail

    - #### startFelix

          protected void startFelix()

    - #### init

          public void init(javax.servlet.ServletContext servletContext)

      Specified by:
        `init` in interface `OsgiHost`
      Specified by:
        `init` in class `BaseOsgiHost`

    - #### getBundles

          public Map<String,org.osgi.framework.Bundle> getBundles()

      Description copied from class: `BaseOsgiHost`
      This bundle map will not change, but the status of the bundles can change over time. Use getActiveBundles() for active bundles
      Specified by:
        `getBundles` in interface `OsgiHost`
      Specified by:
        `getBundles` in class `BaseOsgiHost`
      Returns:
        map with bundles

    - #### getActiveBundles

          public Map<String,org.osgi.framework.Bundle> getActiveBundles()

      Specified by:
        `getActiveBundles` in interface `OsgiHost`
      Specified by:
        `getActiveBundles` in class `BaseOsgiHost`

    - #### getBundleContext

          public org.osgi.framework.BundleContext getBundleContext()

      Specified by:
        `getBundleContext` in interface `OsgiHost`
      Specified by:
        `getBundleContext` in class `BaseOsgiHost`

    - #### destroy

          public void destroy()
                       throws Exception

      Specified by:
        `destroy` in interface `OsgiHost`
      Specified by:
        `destroy` in class `BaseOsgiHost`
      Throws:
        `Exception`

    - #### addSpringOSGiSupport

          protected void addSpringOSGiSupport()

      Specified by:
        `addSpringOSGiSupport` in class `BaseOsgiHost`

    - #### replaceFelixSystemPackages

          protected void replaceFelixSystemPackages(Properties properties)

      Replace all instances of `FELIX_JRE_DETECT_JAVA_SPECIFICATION_VERSION` and `FELIX_JRE_DETECT_JPMS`, within the `Constants.FRAMEWORK_SYSTEMPACKAGES` property of the provided properties. The replacement will be the value for the key "jre-x.y" in the properties parameter (where x.y is the JRE version after transforming the System "java.version" property. For example: "jre-x.y" is "jre-1.8" for Java 8, "jre-9.0" for Java 9, and "jre-11.0" for Java 11. While performing the replacement, the elements within jre-x.y will also undergo a replacement of the substring `FELIX_DETECT_JAVA_VERSION` into something like "0.0.0.JavaSE_001_008" for Java 8 and earlier, "0.0.0.JavaSE_009" for Java 9 and newer. If you prefer manual control, use literal strings rather than `FELIX_DETECT_JAVA_VERSION` in your properties file.
      Parameters:
        `properties` - OSGi properties for which the `Constants.FRAMEWORK_SYSTEMPACKAGES` property's values substrings `FELIX_JRE_DETECT_JAVA_SPECIFICATION_VERSION` and `FELIX_JRE_DETECT_JPMS` will be replaced by the value for the key "jre-xxx" (where xxx is the JRE version). If no `Constants.FRAMEWORK_SYSTEMPACKAGES` property exists, this is a no-op.

    - #### replaceFelixFrameworkSystemCapabilities

          protected void replaceFelixFrameworkSystemCapabilities(Properties properties)

      Replace all instances of the `FELIX_SERVICE_CAPS`, `FELIX_EE_CAP_JAVA_SPECIFICATION_VERSION` and `FELIX_EE_CAP_DETECT_JPMS` within the `Constants.FRAMEWORK_SYSTEMCAPABILITIES` property of the provided properties. The replacements will be based on the lookups within the properties for the keys that match the substitution strings for each element (i.e. the element without "${}", transformed for JRE version if required).
      Parameters:
        `properties` - OSGi properties for which the `Constants.FRAMEWORK_SYSTEMCAPABILITIES` property's values substrings `FELIX_SERVICE_CAPS`, `FELIX_EE_CAP_JAVA_SPECIFICATION_VERSION` and `FELIX_EE_CAP_DETECT_JPMS` will be replaced by the value for the keys that match the substitution strings for each element (i.e. the element without "${}", transformed for JRE version if required). If no `Constants.FRAMEWORK_SYSTEMCAPABILITIES` property exists, this is a no-op.

    - #### replaceFelixExecutionEnvironment

          protected void replaceFelixExecutionEnvironment(Properties properties)

      Replace all instances of the `FELIX_EE_JAVA_SPECIFICATION_VERSION` and `FELIX_EE_FELIX_DETECT_JPMS` within the `Constants.FRAMEWORK_EXECUTIONENVIRONMENT` property of the provided properties. The replacements will be based on the lookups within the properties for the keys that match the substitution strings for each element (i.e. the element without "${}", transformed for JRE version if required).
      Parameters:
        `properties` - OSGi properties for which the `Constants.FRAMEWORK_EXECUTIONENVIRONMENT` property's values substrings `FELIX_EE_JAVA_SPECIFICATION_VERSION` and `FELIX_EE_FELIX_DETECT_JPMS` will be replaced by the value for the keys that match the substitution strings for each element (i.e. the element without "${}", transformed for JRE version if required). If no `Constants.FRAMEWORK_EXECUTIONENVIRONMENT` property exists, this is a no-op.

    - #### expandAllFelixJREBaseElements

          protected String expandAllFelixJREBaseElements(String jreProperty,
                                                         Properties properties)

      Recursive method to expand all Felix JRE base elements from the configuration. Once complete the resulting string should be the expansion of all ${jre-base} elements into a single string incorporating all the base elements.
      Parameters:
        `jreProperty` - A string retrieval of a JRE property entry (e.g. jre-1.7), that may or may not contain JRE base elements (e.g. ${jre-base-1.7}).
        `properties` - The Felix properties.
      Returns:
        A fully-expanded version of jreProperty, after recursively expanding all jre-base elements in the Felix properties.

    - #### expandAllOsgiFrameworkSystemCapabilities

          protected String expandAllOsgiFrameworkSystemCapabilities(String capabilities,
                                                                    Properties properties)

      Method to expand all OSGi framework system capabilities elements from the configuration. Once complete the resulting string should be the expansion of all entries found in the `Constants.FRAMEWORK_SYSTEMCAPABILITIES` content passed into the method.
      Parameters:
        `capabilities` - A string retrieval of an OSGi framework system capabilities property entry `Constants.FRAMEWORK_SYSTEMCAPABILITIES` containing one or more of `FELIX_SERVICE_CAPS` `FELIX_EE_CAP_JAVA_SPECIFICATION_VERSION` `FELIX_EE_CAP_DETECT_JPMS`.
        `properties` - The Felix properties.
      Returns:
        A fully-expanded version of the `Constants.FRAMEWORK_SYSTEMCAPABILITIES` content, after expanding all its contained elements in the Felix properties.

    - #### expandAllOsgiFrameworkExecutionEnvironments

          protected String expandAllOsgiFrameworkExecutionEnvironments(String executionEnvironment,
                                                                       Properties properties)

      Method to expand all OSGi framework execution environment elements from the configuration. Once complete the resulting string should be the expansion of all entries found in the `Constants.FRAMEWORK_EXECUTIONENVIRONMENT` content passed into the method.
      Parameters:
        `executionEnvironment` - A string retrieval of an OSGi framework execution environment property entry `Constants.FRAMEWORK_EXECUTIONENVIRONMENT` containing one or more of `FELIX_EE_JAVA_SPECIFICATION_VERSION` `FELIX_EE_FELIX_DETECT_JPMS`.
        `properties` - The Felix properties.
      Returns:
        A fully-expanded version of the `Constants.FRAMEWORK_EXECUTIONENVIRONMENT` content, after expanding all its contained elements in the Felix properties.

Copyright © 2000–2023 Apache Software Foundation. All rights reserved.