JBoss Community Archive (Read Only)

JBoss AS 7.0

OSGi subsystem configuration

Old Documentation

This documentation applies to AS 7.0 only and has been superceded by documentation that can be found
in the JBoss OSGi Documentation Pages.

OSGi functionality in JBoss AS 7 is provided through the OSGi subsystem.

More information on the OSGi component in JBoss AS 7 can be found on the JBoss OSGi project pages.

The OSGi subsystem can be configured in its section in the JBoss AS 7 configuration XML file.

<subsystem xmlns="urn:jboss:domain:osgi:1.0" activation="lazy">
    <configuration>...</configuration>
    <properties>...</properties>
    <modules>...</modules>
</subsystem>

The following items can be configured:

Subsystem Attributes

Attribute

Description

activation

When set to lazy the OSGi subsystem will not get activated until the first OSGi bundle deployment. When set to eager the OSGi subsystem will be activated at startup of the Application Server.

Configuration Admin

The OSGi Configuration Admin Service (CAS) is a standard service aimed at configuring OSGi-based applications. Many OSGi applications use the CAS to configure themselves.

The OSGi subsystem configuration allows for the specification of CAS configuration information, to configure bundles written for this specification (chapter 104 in the OSGi 4.2 Compendium Specification)

To add CAS configuration information, add <configuration> tags to the OSGi subsystem configuration. For example, the following is used to configure the context root where the Felix Web Console appears:

<subsystem xmlns="urn:jboss:domain:osgi:1.0" activation="lazy">
    <configuration pid="org.apache.felix.webconsole.internal.servlet.OsgiManager">
        <property name="manager.root">jboss-osgi</property>
    </configuration>
....

Configuration information consists of a <configuration> tag specifying a PID (Persistent Identifier) attribute which identifies the system to be configured. The configuration tag can contain any number of embedded <property> tags which hold the configuration information for this PID.

Framework Properties

OSGi Framework properties are specified as embedded <property> elements in the <properties> tag.

<properties>
  <property name="org.jboss.osgi.system.modules">
    org.apache.commons.logging,
    org.apache.log4j,
    org.jboss.as.osgi,
    org.slf4j,
  </property>
  <property name="org.osgi.framework.system.packages.extra">
    org.apache.commons.logging;version=1.1.1,
    org.apache.log4j;version=1.2,
    org.jboss.as.osgi.service;version=7.0,
    org.jboss.osgi.deployment.interceptor;version=1.0,
    org.jboss.osgi.spi.capability;version=1.0,
    org.jboss.osgi.spi.util;version=1.0,
    org.jboss.osgi.testing;version=1.0,
    org.jboss.osgi.vfs;version=1.0,
    org.slf4j;version=1.5.10,
  </property>
  <property name="org.osgi.framework.startlevel.beginning">1</property>
</properties>

The following properties are specified:

Property

Description

org.jboss.osgi.system.modules

A comma-separated list of module identifiers. Each system module is added as a dependency to the OSGi framework module. The packages from these system modules can be made visible as framework system packages by adding them to the org.osgi.framework.system.packages.extra property.

org.osgi.framework.system.packages.extra

Extra packages which the system bundle must export from the current execution environment.

org.osgi.framework.startlevel.beginning

The beginning start level of the OSGi Framework. This also influences which modules are pre-loaded. See the modules section.

Additional OSGi Framework properties can be specified. For more information on OSGi Framework properties see the OSGi 4.2 Core Specification.

Modules

JBoss AS 7 comes with a repository of modules and OSGi bundles that can be automatically loaded at startup. JBoss-Modules compliant modules can be found in the modules/ directory and OSGi bundles can be found in the bundles/ directory. In the <modules> section of the XML configuration both JBoss-Modules as well as OSGi Bundles can be specified.

OSGi Bundles can also be started automatically at startup. This is specified with the startlevel attribute. The default start level of the OSGi Framework is 1. To enable additional functionality in the OSGi Framework, increase the org.osgi.framework.startlevel.beginning framework property.

Note that these modules don't trigger the activation of the OSGi subsystem. Once the subsystem is activated as described above, these modules and bundles will be automatically loaded and optionally started.

<modules>
    <!-- modules registered with the OSGi layer on startup -->
    <module identifier="javaee.api"/>
    <module identifier="org.jboss.logging"/>
    <!-- bundles installed on startup -->
    <module identifier="org.apache.aries.util"/>
    <module identifier="org.jboss.osgi.webconsole"/>
    <module identifier="org.osgi.compendium"/>
    <!-- bundles started in startlevel 1 -->
    <module identifier="org.apache.felix.log" startlevel="1"/>
    <module identifier="org.jboss.osgi.logging" startlevel="1"/>
    <module identifier="org.apache.felix.configadmin" startlevel="1"/>
    <module identifier="org.jboss.as.osgi.configadmin" startlevel="1"/>
    <!-- bundles started in startlevel 2 -->
    <module identifier="org.apache.aries.jmx" startlevel="2"/>
    <module identifier="org.apache.felix.eventadmin" startlevel="2"/>
    <module identifier="org.apache.felix.metatype" startlevel="2"/>
    <module identifier="org.apache.felix.webconsole" startlevel="2"/>
    <module identifier="org.jboss.osgi.jmx" startlevel="2"/>
    <module identifier="org.jboss.osgi.http" startlevel="2"/>
    <!-- bundles started in startlevel 3 -->
    <module identifier="org.jboss.osgi.blueprint" startlevel="3"/>
    <module identifier="org.jboss.osgi.webapp" startlevel="3"/>
    <module identifier="org.jboss.osgi.xerces" startlevel="3"/>
</modules>

The following modules and bundles are listed in the default configuration.

Module Identifier

Description

javaee.api

Provides JavaEE APIs.

org.apache.aries.jmx

Provides JMX support to OSGi as described in chapter 124 of the OSGi 4.2 Enterprise Specification. For more information see Using JMX below.

org.apache.aries.util

Needed by the Aries JMX bundle.

org.apache.felix.configadmin

An implementation of the OSGi Configuration Admin specificaton. Chapter 104 in the OSGi 4.2 Compendium Specification.

org.apache.felix.eventadmin

An implementation of the OSGi Event Admin specification. Chapter 113 in the OSGi 4.2 Compendium Specification.

org.apache.felix.log

An implementation of the OSGi Log Service specification. Chapter 101 in the OSGi 4.2 Compendium Specification.

org.apache.felix.metatype

An implementation of the OSGi Metatype Service specification. Chapter 105 in the OSGi 4.2 Compendium Specification.

org.apache.felix.webconsole

The Felix Web Console. For more information see Using the Felix Web Console below.

org.jboss.as.osgi.configadmin

Component providing the OSGi Configuration Admin Service with information from the OSGi subsystem configuration.

org.jboss.logging

The JBoss Logging Framework.

org.jboss.osgi.blueprint

An implementation of the OSGi Blueprint Specification. Blueprint is a component model and IoC specification for OSGi which significantly simplifies the use of OSGi services. It can be found in chapter 121 in the OSGi 4.2 Enterprise Specification.

org.jboss.osgi.http

An implementation of the OSGi Http Service. Chapter 102 in the OSGi 4.2 Compendium Specification. The port used by this implementation is set by default to <socket-binding name="osgi-http" port="8090"/> in the socket-binding-group.

org.jboss.osgi.jmx

Enhanced JMX API, the MBeans can be found under jboss.osgi.

org.jboss.osgi.logging

Sends log messages sent to the OSGi Log Service to JBoss Logging.

org.jboss.osgi.webapp

OSGi Support for Web Apps, as described in chapter 128 in the OSGi 4.2 Compendium Specification.

org.jboss.osgi.webconsole

Customizations of the Felix Web Console.

org.jboss.osgi.xerces

An implementation of the OSGi XML Parser specification. Chapter 702 in the OSGi 4.2 Compendium Specification.

org.osgi.compendium

A bundle providing the APIs defined by the OSGi Compendium Specification.

Using the Felix Web Console

For fine-grained management of the OSGi Framework, the Apache Felix Web Console can be used. This web console is shipped as part of JBoss AS 7 and is specifically aimed at fine-grained control of the OSGi Framework.

The Web Console is not enabled by default. The relevant modules are marked as having startlevel=2, so to enable the web console set the initial framework start level to 2 or higher:

<properties>
  ... other properties ...
  <property name="org.osgi.framework.startlevel.beginning">2</property>
</properties>

By default the console appears on http://localhost:8090/jboss-osgi with as username and password admin/admin. This can be configured through the OSGi Configuration Admin Service configuration.

<subsystem xmlns="urn:jboss:domain:osgi:1.0">
  <configuration pid="org.apache.felix.webconsole.internal.servlet.OsgiManager">
    <property name="manager.root">jboss-osgi</property>
    <property name="username">myusername</property>
    <property name="password">mypassword</property>
  </configuration>
  ...

Start JBoss AS 7 and make sure the OSGi Framework is active; the framework can be activated by deploying an OSGi bundle into JBoss AS 7 or by setting its activation mode to eager.

Then open a web browser and access: http://localhost:8090/jboss-osgi. A log-in dialog appears. Enter the password configured or the default username and password: admin/admin and the web console will appear:
images/author/download/attachments/4784281/WebConsole.png

Using JMX

The OSGi Framework exposes a number of JMX MBeans that enable remote control of the framework. Both the MBeans that are defined in chapter 124 of the OSGi 4.2 Enterprise Specification as well as JBoss-extended MBeans are available.

The JMX support is not enabled by default. The relevant modules are marked as having startlevel=2, so to enable JMX set the initial framework start level to 2 or higher:

<properties>
  ... other properties ...
  <property name="org.osgi.framework.startlevel.beginning">2</property>
</properties>

Start JBoss AS 7 and make sure the OSGi Framework is active; the framework can be activated by deploying an OSGi bundle into JBoss AS 7 or by setting its activation mode to eager.

The JMX functionality can now be accessed through a JMX console, for instance jconsole which ships with the JDK:
images/author/download/attachments/4784281/JConsole1.png

Connect using the Remote Process URL service:jmx:rmi:///jndi/rmi://127.0.0.1:1090/jmxrmi. (You can also connect directly to the Local Process, the one that starts with jboss-modules.jar -mp ...)

When the connection is established navigate to the MBeans tab to interact with the OSGi MBeans.
images/author/download/attachments/4784281/JConsole2.png

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-13 13:19:56 UTC, last content change 2012-06-28 07:43:06 UTC.