org.apache.struts2.osgi

## Class OsgiUtil

- java.lang.Object
- - org.apache.struts2.osgi.OsgiUtil

-     public class OsgiUtil
      extends Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `OsgiUtil()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static boolean` | `containsBean(Object beanFactory, String beanId)` Calls containsBean on the passed object using reflection.
    `static String` | `generateJava_SE_SystemPackageVersionString(String systemJavaVersion)` Attempt to generate an OSGi compatible Java SE system package version String from the System "java.version" property, with the form (where x or xx is the major version number): 0.0.0.JavaSE_001_00x for Java 8 and earlier (e.g.
    `static String` | `generateJavaVersionForSystemPackages(String systemJavaVersion)` Attempt to generate an OSGi compatible Java version String from the System "java.version" property, with the form (where x is the major version number): 1.x for Java 8 and earlier, x.y for Java 9+.
    `static Object` | `getBean(Object beanFactory, String beanId)` Calls getBean() on the passed object using reflection.
    `static URL` | `translateBundleURLToJarURL(URL bundleUrl, org.osgi.framework.Bundle bundle)` A bundle is a jar, and a bundle URL will be useless to clients, this method translates a URL to a resource inside a bundle from "bundle:something/path" to "jar:file:bundlelocation!/path"

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

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

- - ### Constructor Detail

    - #### OsgiUtil

          public OsgiUtil()

  - ### Method Detail

    - #### translateBundleURLToJarURL

          public static URL translateBundleURLToJarURL(URL bundleUrl,
                                                       org.osgi.framework.Bundle bundle)
                                                throws MalformedURLException

      A bundle is a jar, and a bundle URL will be useless to clients, this method translates a URL to a resource inside a bundle from "bundle:something/path" to "jar:file:bundlelocation!/path"
      Parameters:
        `bundleUrl` - URL to translate
        `bundle` - the bundle
      Returns:
        translated URL
      Throws:
        `MalformedURLException` - if URL is malformed

    - #### getBean

          public static Object getBean(Object beanFactory,
                                       String beanId)

      Calls getBean() on the passed object using reflection. Used on Spring context because they are loaded from bundles (in another class loader)
      Parameters:
        `beanFactory` - bean factory
        `beanId` - id of bean
      Returns:
        the object found

    - #### containsBean

          public static boolean containsBean(Object beanFactory,
                                             String beanId)

      Calls containsBean on the passed object using reflection. Used on Spring context because they are loaded from bundles (in another class loader)
      Parameters:
        `beanFactory` - bean factory
        `beanId` - id of bean
      Returns:
        true if bean factory contains bean with bean id

    - #### generateJavaVersionForSystemPackages

          public static String generateJavaVersionForSystemPackages(String systemJavaVersion)

      Attempt to generate an OSGi compatible Java version String from the System "java.version" property, with the form (where x is the major version number): 1.x for Java 8 and earlier, x.y for Java 9+. See JEP 223: New Version-String Scheme for details on version naming changes.
      Parameters:
        `systemJavaVersion` - a Java version string from System.getProperty("java.version") or equivalent.
      Returns:
        a String of the form (where x is the major version number): 1.x for Java 8 and earlier, x.y for Java 9+.

    - #### generateJava_SE_SystemPackageVersionString

          public static String generateJava_SE_SystemPackageVersionString(String systemJavaVersion)

      Attempt to generate an OSGi compatible Java SE system package version String from the System "java.version" property, with the form (where x or xx is the major version number): 0.0.0.JavaSE_001_00x for Java 8 and earlier (e.g. 0.0.0.JavaSE_001_008), 0.0.0.JavaSE_0xx for Java 9+ (e.g. 0.0.0.JavaSE_009 for Java 9, 0.0.0.JavaSE_011 for Java 11).
      Parameters:
        `systemJavaVersion` - a Java version string from System.getProperty("java.version") or equivalent.
      Returns:
        a String of the form (where x or xx is the major version number): JavaSE_001_00x for Java 8 and earlier, JavaSE_0xx for Java 9+.

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