Grails on OSGi (3): Released Grails OSGi plugin 0.1
The Grails OSGi plugin provides scripts to package a Grails application as an OSGi bundle. Additionally the bundle(s) may be run in an OSGi container assembled ad hoc by the excellent Pax Runner or deployed to a SpringSource DM Server.
License
The OSGi plugin is released under the Apache License 2.0.
Installation
Simply call grails install-plugin osgi to install the OSGi plugin.
Usage:
Creating an OSGi bundle from the Grails application
grails bundle
grails prod bundle
Running the bundle
grails run-bundle
grails prod run-bundle
The application can be accessed at http://localhost:8080/myapp/.
Note: at first start the OSGi runtime is assembled, which may take some time, while Maven is downloading the internet…
Creating a zipped OSGi runtime
grails assemble-osgi-runtime
grails prod assemble-osgi-runtime
Deploy bundle to DM Server
grails dmserver deploy (Not yet implemented)
Getting around the OSGi runtime
The OSGi runtime is based on the Equinox OSGi framework, Pax Web and some additional bundles.
Web Console
The Felix Web Management Console provides excellent insight into the inner workings (see Screenshots). It can be accessed at http://localhost:8080/system/console/ with user “admin” and password “admin”.
Shell Console
The command grails run-bundle drops the user in the Equinox Shell. Typing help shows the available commands.
How it works
In order to be a valid OSGi bundle, the application is war’ed and provided with the necessary bundle manifest headers (see scripts/_Event.groovy for details).
The bundle can be created using grails bundle.
The OSGi runtime is assembled in the target/osgi directory.
Source code and Issues
The source code is hosted at GitHub, issues can be reported here.
Roadmap
- make bundle generation configurable (e.g. include/exclude dependencies, …)
- make OSGi runtime created by
grails run-bundleandgrails assemble-osgi-runtimeconfigurable - support auto-reloading of changed artifacts
- use Spring DM instead of Pax Web as Web extender
- remove dependencies from bundle and package them as their own plugins (re-using existing bundles from the SpringSource Enterprise Repository
- export main Grails beans and application context as OSGi service
- export services as OSGi service (via
static expose = 'osgi') - provide access to OSGi
BundleContextto artifacts (controllers, services, …) - implement deployment to DM Server
- consider other deployment options: Apache Karaf, …

