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.
The OSGi plugin is released under the Apache License 2.0.
grails install-plugin osgi to install the OSGi plugin.
Creating an OSGi bundle from the Grails application
grails prod bundle
Running the 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 prod assemble-osgi-runtime
Deploy bundle to DM Server
grails dmserver deploy (Not yet implemented)
Getting around the OSGi runtime
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”.
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
The OSGi runtime is assembled in the
Source code and Issues
- make bundle generation configurable (e.g. include/exclude dependencies, …)
- make OSGi runtime created by
- 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, …