这样在注入的时候直接public interface RemoteTest {
public static final String NAME = "Test/RemoteTest";
public static final String JNDI_NAME = "Test/RemoteTest/remote";
public String getTest();
/**
* Local interface for session bean
*/
public static interface Local extends RemoteTest{}
/**
* Remote interface for session bean
*/
public static interface Remote extends RemoteTest{}
}
Get EJB instance by lookup global in java: Namespace.
Syntax: java:global/<ear-name>/<jar-name>/<bean-name>[!<fully-qualified-interface-name>]
Sample:
SampleBean implements SampleBeanRemote
interface SampleBeanRemote
{
JNDI_NAME="SampleBean";
}
sampleBeanInstance = (SampleBeanRemote)lookupByGlobal(SampleBeanLocal.JNDI_NAME);
Get EJB instance by lookup app in java: Namespace.
Note: Only effect when the expect bean is in the same ear file with the POJO calling this method.
Syntax: java:app/<jar-name>/<bean-name>[!<fully-qualified-interface-name>]
Sample:
SampleBean implements SampleBeanLocal
interface SampleBeanLocal
{
NAME="SampleBean";
}
sampleBeanInstance = (SampleBeanLocal)lookupByApp(SampleBeanLocal.NAME);
Get EJB instance by lookup module in java: Namespace.
Note: Only effect when the expect bean is in the same jar file with the POJO calling this method.
Syntax: java:module/<bean-name>[!<fully-qualified-interface-name>]
Sample:
SampleBean implements SampleBeanLocal
SampleBeanLocal
{
NAME="SampleBean";
}
sampleBeanInstance = (SampleBeanLocal)lookupByModule(SampleBeanLocal.NAME);
方便快捷。RemoteTest rt = (RemoteTest)ctx.lookup(RemoteTest.JNDI_NAME);