7.2. MessageListener

The org.apache.jetspeed.portlet.event.MessageListener interface must be implemented by the portlets receiving a message. The interface defines the single method listed in Example 7-1 on page 227. Since the portlet may be notified by more than one other portlet and therefore may receive different types of messages, it should validate the type of message received prior to working with the object. This is illustrated in Example 7-1 on page 227.

Example 7-1. Implementing the MessageListener interface
public void messageReceived(MessageEvent event) throws PortletException { PortletMessage msg = event.getMessage(); if( msg instanceof DefaultPortletMessage ) { String messageText = ((DefaultPortletMessage)msg).getMessage(); // Add ...

Get IBM Rational Application Developer V6 Portlet Application Development and Portal Tools now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.