Email Answering System
Version 1.0

com.ninecode.email.beans.slave
Class Robot

java.lang.Object
  |
  +--com.ninecode.email.beans.slave.Robot
All Implemented Interfaces:
EnterpriseBean, MessageDrivenBean, MessageListener, Serializable
Direct Known Subclasses:
Dictionary, PhoneBooth, Ticker, WeatherMan, WebFetch

public abstract class Robot
extends Object
implements MessageDrivenBean, MessageListener

Message driven bean base class to handle web requests. The Robot class gathers together the common functionality required of a message driven bean leaving only the onMessage() method to be provided in subclasses.

See Also:
Serialized Form

Constructor Summary
Robot()
          Construct a Robot.
 
Method Summary
 void ejbCreate()
          Startup call.
 void ejbRemove()
          Shutdown call.
abstract  void onMessage(Message message)
          Process a message.
 void replyMessage(Message message, String subject, String contents)
          Reply to a message.
 void setMessageDrivenContext(MessageDrivenContext mdc)
          Remember the context for this instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Robot

public Robot()
Construct a Robot. vacuous

Method Detail

ejbCreate

public void ejbCreate()
               throws CreateException
Startup call. Subclasses should override this method if they need to do any initialization such as getting a database connection.

Throws:
CreateException - If there was a problem initializing.

replyMessage

public void replyMessage(Message message,
                         String subject,
                         String contents)
                  throws NamingException,
                         JMSException
Reply to a message. Sends a text message with the given subject and textual content to the jms/Outbox queue. Usually used to respond to an onMessage() call that is passed a message containing a ReplyTo property where the content of the message is trivial (no mime attachments etc.).

Parameters:
message - The message to reply to. The ReplyTo address (property) from this message is used to set the message To address (property).
subject - The reply message subject.
contents - The reply message contents.
NamingException
JMSException

ejbRemove

public void ejbRemove()
               throws EJBException
Shutdown call.

Specified by:
ejbRemove in interface MessageDrivenBean
Throws:
EJBException - If there was a problem gracefully shutting down.

setMessageDrivenContext

public void setMessageDrivenContext(MessageDrivenContext mdc)
                             throws EJBException
Remember the context for this instance.

Specified by:
setMessageDrivenContext in interface MessageDrivenBean
Parameters:
mdc - The context to be remembered.
Throws:
EJBException - If some problem with setting the context was encountered. Not used.

onMessage

public abstract void onMessage(Message message)
Process a message.

Specified by:
onMessage in interface MessageListener
Parameters:
message - The message to process. This bytes message should have the following string properties:
  • Subject - the email subject line
  • ReplyTo - the email Reply-To address
  • Content - the email body
  • The bytes in the message are the original email message converted to RFC 822 format. A subclass is responsible for replying to the 'Outbox' message queue with a response.
    See Also:
    replyMessage(javax.jms.Message, java.lang.String, java.lang.String)

    Email Answering System
    Version 1.0

    Copyright © 2003 Derrick Oswald. All rights reserved.