||
Skip to end of metadata
Go to start of metadata

The WSO2 Carbon platform supports OSGi JRE SPI mechanisms by integrating ‘Apache Aries SPI Fly’, which provides OSGi support for JRE SPI mechanisms, including the usage of java.util.ServiceLoader, META-INF/services and similar methods. Developers can integrate Apache Aries SPI-Fly support by adding the relevant bundles to the <AS_HOME>/repository/components/dropins/ directory as explained below. Since the Carbon Runtime is higher than the OSGi 4.3 compliant framework that supports WeavingHooks, we can use either Dynamic or Static weaving in the Application Server.

The following steps explain how SPI Fly support can be enabled for AS:

  1. Copy the relevant bundles from Apache Aries to the <AS_HOME>/repository/components/dropins directory. The bundles you should copy depend on whether Dynamic weaving or Static weaving should be enabled as explained below.
    • For Dynamic weaving, copy the following bundles:

        • SPI Fly Dynamic Weaving Bundle

        • Aries Util

        • ASM

    • For Static weaving, copy the following bundles:

        • SPI Fly Static Weaving Bundle

        • Aries Util
  2. These bundles will provide the necessary support for SPI Fly. Along with them, you can apply your SPI providers and consumers to the dropins directory.

    Sample bundles for SPI providers and consumers are given here. Even though these are the same bundles that are provided by Aries, we have modified the client bundle to address an issue with the static weaving bundle.

  3. If Static weaving is used, it is necessary to process the consumer bundles before the provider bundles. You can do this by executing the following command on a command line:

    java -jar org.apache.aries.spifly.static.tool-1.0.0-jar-with-dependencies.jar <provider-bundle>.jar 

    This command will change the bytecode of the bundle so that static weaving can be used at runtime. Note that the following tool is used in the above command: org.apache.aries.spifly.static.tool.

  4. Start the server.

  5. Check the console logs and you will observe the logs from the consumer bundle that invoked the SPI.

See the Apache Aries documentation for samples and more information.

  • No labels