License

Building

Simply run gradle build. If Gradle >= 0.9-rc-2 is not installed, run ./gradlew build from the top-level directory, in order to automatically download the correct Gradle version. The resulting jars can be found at the following locations:

groovyx-osgi/build/libs/groovyx-osgi-0.1.jar

groovyx-osgi-runtime/build/libs/groovyx-osgi-runtime-0.1.jar

Note: when performing test for groovyx.osgi, please re-create the bundle using gradle assemble after changing any code before running the tests, as the tests simply load the jar into the OSGi framework. Changed code is NOT picked up automatically!

Reference

All examples can be run in a fashion similar to the simple example above. For brevity,
only the configuration closure is included in the following snippets.

Provision an OSGi runtime with Eclipse Equinox

osgi.configure {
framework 'equinox'
}

Provision an OSGi runtime with Apache Felix

osgi.configure {
framework 'felix'
}

Provision an OSGi runtime with a custom runtime

osgi.configure {
framework MyRuntimeFactory.class
}

MyRuntimeFactory should implement groovyx.osgi.runtime.OsgiRuntimeFactory and create
instances of groovyx.osgi.runtime.OsgiRuntime, which are usually derived from abstract
base class org.codehaus.groovy.osgi.runtime.AbstractOsgiRuntime.

Configuration of an external OSGi runtime is performed by provisioning bundles into a drop-in
directory, which is monitored by the runtime. Bundles, which are dropped into the directory
are automatically installed and started. The directoy usually resides within the installation
directory and is called dropin, load, or pickup.

Groovy script support

The script is executed with a Binding containing a builder instance as property builder and
the builder’s configure() method.

OsgiRuntimeBuilder also has a static run() method which creates an instance if OsgiRuntimeBuilder,
configures it with all arguments (which are either handled as URLs or as DSL script), starts the runtime
and waits for it to shutdown.

Roadmap

groovyx.osgi

implement OsgiCategory and extend BundleContext with some convenience methods and filter DSL

improve docs

groovyx.osgi.runtime

add support for pre-defined provisioning profiles

add support for OSGi ConfigurationAdmin

improve handling of external OSGi runtimes

improve docs

History

0.1 (2010-12-22)

initial version

How it works

The OsgiRuntimeBuilder collects bundles to be installed, runtime properties, and other information and delegates creation of the framework to an OsgiRuntimeFactory, which creates an OsgiRuntime, which in turn creates and starts the actual OSGi framework.

Getting around the OSGi runtime

Web Console

The Felix Web Management Console provides excellent insight into the inner workings. When using webConsole() or webConsole(<port>) in your configuration script, it can be accessed at http://localhost:8080/system/console/ with user “admin” and password “admin”.
(Note: the initial release is missing automatic inclusion of dependencies required to run Web Console. See script src/main/resources/extended.groovy for an example with all dependencies)

Shell Console

When using console(), the user is dropped into the Equinox or Felix Shell (press RETURN if you don’t see the osgi> prompt). Calling console(<port>) opens a console with telnet access on the specified port or on port 8023, if omitted. Only a single user can use the console at any time.