users@glassfish.java.net

RE: Accessing EJBs from a POJO

From: Martin Gainty <mgainty_at_hotmail.com>
Date: Thu, 29 Jan 2009 21:39:48 -0500

will specify callback methods for
 lifecycle event.
http://java.sun.com/javaee/5/docs/api/javax/persistence/PostLoad.html

Oracle is a bit more specific about TopLink Provider @PostLoad operations specifically
The @PostLoad is used to register a method to
              be called on a object that has just been built from the database.
              TopLink uses the optional event argument of the DatabaseRow. This
              event can be used to correctly initialize an object's non-persistent
              attributes or to perform complex optimizations or mappings.
This
              event is called whenever an object is built.
http://www.oracle.com/technology/tech/java/oc4j/ejb3/howtos/howtoejb30mappingannotations/doc/how-to-ejb30-mapping-annotations.html#callbacks
 
@EJB can specify the beanInterface attribute which is the Home Interface
http://edocs.bea.com/wls/docs100/ejb30/annotations.html#wp1416481

LocalHome vs RemoteHome
A remote home interface extends the javax.ejb.EJBHome
interface,
while a local home interface extends the
javax.ejb.EJBLocalHome interface.
http://www.redhat.com/docs/manuals/rhaps/jonas-guide/s1-session-home.html

HTH/
Martin
______________________________________________
Disclaimer and confidentiality note
Everything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission.




> Date: Thu, 29 Jan 2009 21:03:13 -0500
> From: ryan_at_ijws.com
> To: users_at_glassfish.dev.java.net
> Subject: Re: Accessing EJBs from a POJO
>
> I don't think the @EJB annotation works in POJOs. It only works in
> other EJBs, servlets, and JSF managed beans. It looks like what you are
> trying to create is a "Service Locator", and loading the EJB from JNDI
> is the right way to do it. I remember having difficulties doing this
> with local EJB 3.0 session beans, because all of the examples on the web
> are for remote EJB 3.0 session beans. Someone else will have to help
> you with the exact syntax.
>
> @PostLoad is from JPA and doesn't belong here.
>
>
> Ryan
>
>
>
> glassfish_at_javadesktop.org wrote:
> > Hi,
> >
> > I followed the instructions on this page https://glassfish.dev.java.net/javaee5/ejb/EJB_FAQ.html#POJOLocalEJB but have so far been unsuccessful in getting a true POJO to be able to lookup an ejb through the jndi. I've tried the @EJB annotation as well as the <ejb-local-ref> in the web.xml file and it's a no go either way. Can anyone tell me if there is something I'm missing?
> >
> > Thanks,
> >
> > Drew
> >
> >
> > @EJB(name="test",beanInterface=FormularyManagerLocal.class)
> > public class EntityListener
> > {
> >
> > @PostLoad
> > public void postLoad(FormularyUser user)
> > {
> > InitialContext ctx;
> > try
> > {
> > ctx = new InitialContext();
> > Object obj = ctx.lookup("java:comp/env/test"); //$NON-NLS-1$
> > assert obj != null;
> > }
> > catch (NamingException e1)
> > {
> > // TODO Auto-generated catch block
> > e1.printStackTrace();
> > }
> > }
> > }
> > [Message sent by forum member 'utdrew' (utdrew)]
> >
> > http://forums.java.net/jive/thread.jspa?messageID=329101
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> > For additional commands, e-mail: users-help_at_glassfish.dev.java.net
> >
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>

_________________________________________________________________
Windows Live™: E-mail. Chat. Share. Get more ways to connect.
http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t2_allup_explore_012009