Home | April 2009 >>

Running pebble inside Equinox

A casestudy: Running a standard war file inside an OSGi container.

Pebble goes OSGi

Building OSGi ready pebble with maven

Setting up a maven build using OSGi bundles

Building Pebble with maven

Third time it's a charm

Migration from Acegi to Spring Security

Moving from Acegi to Spring-Security

Creating the core bundle

the first cut is the deepest

Creating the core bundle

Extract the DAO layer

this one was easy

moving the DAOs out of the standard war

Adding the listener aspect

bundle the listeners

Listeners are configured as properties like this:

#net.sourceforge.pebble.event.response.DeleteRejectedListener
#net.sourceforge.pebble.event.comment.EmailAuthorNotificationListener
And added during creation of the domain object Blog like this
if (!classes[i].startsWith("#")) {
try {
Class c = Class.forName(classes[i].trim());
BlogListener listener = (BlogListener)c.newInstance();
eventListenerList.addBlogListener(listener);
Class.forName will not work in an OSGi environment. Thus requires the Listeners to reside inside the bundle creating them. To use the dynamics of the OSGi runtime Listeners should be deployed in separate bundles.

The Listeners are part of the pebble API and the core implementation moved to a separate bundle

<bean id="emailNotificationListener" class="net.sourceforge.pebble.event.blogentry.EmailNotificationListener" autowire="constructor"/>

<!-- OSGi service -->
<osgi:service ref="emailNotificationListener" interface="net.sourceforge.pebble.api.event.blogentry.BlogEntryListener" />
<osgi:service interface="net.sourceforge.pebble.api.event.blogentry.BlogEntryListener">
<bean class="net.sourceforge.pebble.event.blogentry.EmailSubscriptionListener" autowire="constructor" />
</osgi:service>
<!-- OSGi service -->
<osgi:service ref="emailNotificationListener" interface="net.sourceforge.pebble.api.event.blogentry.BlogEntryListener" />
<osgi:service interface="net.sourceforge.pebble.api.event.blogentry.BlogEntryListener">
<bean class="net.sourceforge.pebble.event.blogentry.EmailSubscriptionListener" autowire="constructor" />
</osgi:service>
All available implementations are gathered using:
<osgi:set id="blogEntryListenerSet" interface="net.sourceforge.pebble.api.event.blogentry.BlogEntryListener" cardinality="0..N"/>
Additionally the Listeners are now registered by name:
ipAddressListener
linkSpamListener
contentSpamListener
spamScoreListener
markApprovedWhenAuthenticatedListener
Identified using a name, defaulting to:
@Override
public String getName() {
return getClass().getSimpleName();
}