Hello Ranchers,
well I am working in ejb 3 in my current project but i dont know indepth of ejb, as only this time i just read about ejb first time, while doing this current project.
i don't understand the concept of JNDI, much can you please help me to know it .. here are some code from my project...
there is code "servicelocator.java" class doing jndi work whcih i didn't understand (pls explain me every stuff, step by step) and code that is calling it..
------------------------ServiceLocator.java---------------------
public class ServiceLocator {
private static InitialContext ic = null;
public static Object lookupEJB(String jndiName){
Object ejbObj = null;
try {
ejbObj = ic.lookup(jndiName);
} catch (NamingException e) {
e.printStackTrace();
}
return ejbObj;
}
static {
Properties properties = new Properties();
properties.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
properties.put("java.naming.factory.url.pkgs", "=org.jboss.naming rg.jnp.interfaces");
properties.put("java.naming.provider.url", "localhost:1099");
try {
ic = new InitialContext(properties);
} catch (NamingException e) {
e.printStackTrace();
}
}
}
---------------------------------------------------------------
the code that is calling above code is
----------------
private static final String JNDI_NAME = "ems/ManageMasterDataBean/local";
ManageMasterDataLocal manageMasterLocal = (ManageMasterDataLocal)ServiceLocator.lookupEJB(JNDI_NAME);
where,
ManageMasterDataBean is the stateless session bean
ManageMasterDataLocal is the interface for teh session bean ManageMasterDataBean
ems is the name of the project
so my question is ..pls explain me the above stuff in details and tell me what is the significance of the local/remote and in what circumstances we will use that ... how we formulate JNDI name ?
please answer all these question if any body , can .. its a voluntary help that can benifit lots of new ranchers too..
please reply..
well I am working in ejb 3 in my current project but i dont know indepth of ejb, as only this time i just read about ejb first time, while doing this current project.
i don't understand the concept of JNDI, much can you please help me to know it .. here are some code from my project...
there is code "servicelocator.java" class doing jndi work whcih i didn't understand (pls explain me every stuff, step by step) and code that is calling it..
------------------------ServiceLocator.java---------------------
public class ServiceLocator {
private static InitialContext ic = null;
public static Object lookupEJB(String jndiName){
Object ejbObj = null;
try {
ejbObj = ic.lookup(jndiName);
} catch (NamingException e) {
e.printStackTrace();
}
return ejbObj;
}
static {
Properties properties = new Properties();
properties.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
properties.put("java.naming.factory.url.pkgs", "=org.jboss.naming rg.jnp.interfaces");
properties.put("java.naming.provider.url", "localhost:1099");
try {
ic = new InitialContext(properties);
} catch (NamingException e) {
e.printStackTrace();
}
}
}
---------------------------------------------------------------
the code that is calling above code is
----------------
private static final String JNDI_NAME = "ems/ManageMasterDataBean/local";
ManageMasterDataLocal manageMasterLocal = (ManageMasterDataLocal)ServiceLocator.lookupEJB(JNDI_NAME);
where,
ManageMasterDataBean is the stateless session bean
ManageMasterDataLocal is the interface for teh session bean ManageMasterDataBean
ems is the name of the project
so my question is ..pls explain me the above stuff in details and tell me what is the significance of the local/remote and in what circumstances we will use that ... how we formulate JNDI name ?
please answer all these question if any body , can .. its a voluntary help that can benifit lots of new ranchers too..
please reply..