Two Guys Arguing

Custom Continuum Notifier – Step 2: Build a dummy notifier

Posted in java by benjaminplee on 08.07.09

Now that we have Continuum building without any problems, the next step is getting a basic notifier coded up and Continuum aware of it.

The Continuum user wiki makes this process seem simple enough:  create a new notifier extending AbstractContinuumNotifier and register the new notifier in application.xml.  Essentially, this is true … with a few minor modifications.

  1. Create your new notifier project
    1. Under the continuum-notifiers Maven module, create a new module called continuum-notifier-web as a standard Maven project (or dupe one of the existing ones)
    2. Modify the new module’s pom.xml to have continuum-notifiers as its parent and add the continuum-notifier-api artifact as a dependency
    <project ...>
    <parent>
     <artifactId>continuum-notifiers</artifactId>
     <groupId>org.apache.continuum</groupId>
     <version>1.2.3</version>
     </parent>
     <modelVersion>4.0.0</modelVersion>
     <artifactId>continuum-notifier-web</artifactId>
     <name>Continuum :: web-Dashboard</name>
     <dependencies>
     <dependency>
     <groupId>org.apache.continuum</groupId>
     <artifactId>continuum-notifier-api</artifactId>
     <version>1.2.3</version>
     </dependency>
     </dependencies>
    </project>
    
    1. Add the new sub-module to the continuum-notifiers parent pom.xml.
    <modules>
     <module>continuum-notifier-api</module>
     <module>continuum-notifier-irc</module>
     <module>continuum-notifier-jabber</module>
     <module>continuum-notifier-msn</module>
     <module>continuum-notifier-wagon</module>
    
     <module>continuum-notifier-web</module>
     </modules>
    
  2. In your new project, create a basic notifier that simply logs that it was called.  This class should extend AbstractContinuumNotifier and implement getType() and sendMessage():
package org.apache.maven.continuum.notification.atkpwadashboard;

import org.apache.maven.continuum.notification.AbstractContinuumNotifier;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class WebNotifier extends AbstractContinuumNotifier {
 private Logger log = LoggerFactory.getLogger(getClass());

 public String getType() {
 return "web";
 }

 public void sendMessage(String messageId, MessageContext context)
 throws NotificationException {
 log.info("Web Notifier has been called!");
 }
}
  1. Build your new module either by a full build of Continuum or by just building your sub module (mvn package).
  2. Deploy your new notifier
    1. Copy the newly created notifier .jar into your Continuum intallation at <CONTINUUM_BASE_DIR>/apps/continuum/WEB-INF/lib/continuum-notifier-web.jar
    2. Modify <CONTINUUM_BASE_DIR>/apps/continuum/WEB-INF/classes/META-INF/plexus/application.xml to register the new notifier by adding the following code:
    <component>
     <role>org.apache.maven.continuum.notification.Notifier</role>
     <role-hint>web</role-hint>
     <implementation>org.apache.maven.continuum.notification.atkpwadashboard.WebNotifier</implementation>
     </component>
    
  3. Restart Continuum
  4. On one of your managed applications, modify the pom.xml to use the new notifier:
<ciManagement>
 <system>continuum</system>
 <url>http://localhost:8080/</url>
 <notifiers>
 <notifier>
 <type>web</type>
 </notifier>
 </notifiers>
 </ciManagement>
  1. Profit.

Things to note:

  • Continuum uses Plexus for its dependency injection.  Since your notifier is extending AbstractContinuumNotifier which has dependencies, you MUST register your notifier as needing these inject or you will see some lovely and confusing NullPointerExceptions when you try to use the notifier.
  • Technically you don’t need to get Continuum to compile to build a new notifier, but having the source handy and being able to see how the rest of the project is structured helps.
  • I haven’t figured out how to get Continuum builds to auto install my notifier yet …. it is on my to-do list.
  • To simplify creating the new project, I just copied continuum-notifier-jar and made modifications as necessary.
  • The email notifier is called “mail” and is in the continuum-core module.

Big Frustrating Gotcha:  Continuum’s notifier plugin architecture only extends to the internals of Continuum but does NOT include any of the web-app’s GUI.  This means that your new notifier will not show up in any of the admin screens as an option, or have any edit/configuration screens a web user can see.  These GUI elements are managed in the continuum-core and continuum-web-app modules, separate from the notifier code themselves.  For what I was doing I didn’t need this, but it would have been nice.  It looked to be fairly simple to add the new notifier to the approrpiate .jsp’s and have full graphical interface power.

Helpful Links:

  • Continuum user wiki page on building a notifier
  • Email chains one and two talking about doing the same thing
  • Configure your notifier in the application.xml wrong and you might get an error like this

Last step is to make the notifier actually do something related to build ….

About these ads
Tagged with: , ,

One Response

Subscribe to comments with RSS.

  1. [...] everything compiled and installed without problems.  Next up, writing a dummy notifier and getting Continuum to use it. Tagged with: continuum, java, maven [...]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.