Fortunately, the newest containers available today such equally Glassfish 3.1.x in addition to JBoss 7.x, listing all the available services on Startup, simply await at the log.
Here are the unlike ways:
1.) JBoss
public static Object getLocalInterface(String nameEJB) { InitialContext ctx; displace { ctx = (InitialContext) getInitialContext(); supply ctx.lookup(nameEJB); } select care of (NamingException ex) { ex.printStackTrace(); } supply null; } populace MyBeanLocal getService() { supply ((MyBeanLocal)Utils.getLocalInterface("workflow/MyBeanBean/local")); }
2.) Glassfish
a.) Long name:
InitialContext ic = novel InitialContext(); IMyService myService = (IMyService) ic .lookup("java:global/myProject-ear-1.0.0/myModule/MyService!com.czetsuya.service.MyService");b.) App access
InitialContext ic = novel InitialContext(); IMyService promoService = (IMyService) ic .lookup("java:app/myProject-ear/myModule/MyService");
0 komentar:
Please comment if there are any that need to be asked.