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
Don't read too much into my specific example. I'm trying to illustrate a point.
My point is that EJB and JPA force us into a model where our domain objects
cannot rely on any container provided services. I fully understand the
reasoning behind it.
However, I'm asking for ideas on elegant ways
Hello!
In the case of the mail-box, why not push the functionallity of reacting to an
email into the implementation of the mailbox? E.g. change the
mailbox.addMessage() method and dynamically set up a reference to the mailbox
when you startup the bean.
In general, you could use an Adapter/Notif