Email Answering System
Version 1.0
Class 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
          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


public Robot()
Construct a Robot. vacuous

Method Detail


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.

CreateException - If there was a problem initializing.


public void replyMessage(Message message,
                         String subject,
                         String contents)
                  throws NamingException,
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.).

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.


public void ejbRemove()
               throws EJBException
Shutdown call.

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


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

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


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

Specified by:
onMessage in interface MessageListener
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.