users@glassfish.java.net

How to address / lookup a local interface from a helper class

From: <glassfish_at_javadesktop.org>
Date: Fri, 09 May 2008 04:21:22 PDT

We have a stateless SessionBean "OrderManagementBean" which implements both local and remote interfaces.
We try to call it from a helper class of another MDB and therefore injection via @EJB does not work.

Currently we do lookup and get the remote. But for the helper class CreateOrder we would like to get the local interface.

Our question is how to address the local interface?


---
public class CreateOrder 
   implements ApplicationRule {
    private OrderManagerInterface       manager     = null;
    // ...
    public ApplicationMessage action( ApplicationMessage inMessage )  
        throws ApplicationRuleException {
        
        try {
            if ( null == manager ) {
                InitialContext context = new InitialContext(); 
                manager = (OrderManagerInterface)context.lookup( OrderManagerRemote.DEFAULT_JNDI_NAME );
            }
            
    // ...
}
---
@Local
public interface OrderManagerLocal
    extends OrderManagerInterface {
    // ...
}
---
@Remote
public interface OrderManagerRemote 
    extends OrderManagerInterface {
    
    public final static String DEFAULT_JNDI_NAME = "ejb/OrderManagerBean";
    // ...
}
---
@Stateless( mappedName=OrderManagerRemote.DEFAULT_JNDI_NAME )
public class OrderManagerBean
    implements OrderManagerRemote, OrderManagerLocal {
    // ...
}
[Message sent by forum member 'ralf_zalas' (ralf_zalas)]
http://forums.java.net/jive/thread.jspa?messageID=273496