[jboss-user] [EJB 3.0 Users] - Re: Design: When the line between domain objects and service

Wolfgang Knauf do-not-reply at jboss.com
Thu Oct 1 08:34:02 EDT 2009


Hi,

I think you need a layer beetween MailBox and your EJB, which encapsulates the logic specific to the mailbox implementation. "findMailbox" should not return the entity, but the the implementation of the layer.

Assume an interface (or an abstract base class):
public interface IMailBoxHandler
  | {
  |    public void handleMail (Message message);
  | }
  | 
It has only one method which handles an incoming mail.

Now you create subclasses/implementations:
public class MailBoxHandlerHelpDesk implements IMailBoxHandler
  | {
  |   @Override
  |   public void handleMail (Message message)
  |   {
  |      ...
  |   }
  | }
  | 
and so on...

"findMailBox" should probably return an appropriate IMailBoxHandler implementation. 

"incomingMail" would be:
public void incomingMail(String destination, Message message) {
  |     IMailboxHandler mb = findMailBox(destination); 
  |     mb.handleMail (message);
  | }
  | 

This way, your domain model is free of controller logic.

Hope this is a reasonable approach ;-)

Wolfgang

View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4258136#4258136

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4258136



More information about the jboss-user mailing list