有关PortableRemoteObject.narrow()和InitialContext的问题
本人刚学EJB不久,在学习中碰到一些问题向高手们请教。
1、为什么有时候要用
Properties p = new Properties ();
p.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
p.put (Context.PROVIDER_URL, "t3://localhost:7001");
Context ctx = new InitialContext (p);
来初始化,而有时候只要
Context ctx = new InitialContext ();就可以了
2、还有为什么有时候要用
Object ref = context.lookup("SbLocalHome");
SbLocalHome testHome = (SbLocalHome)
PortableRemoteObject.narrow( ref , SbLocalHome.class );
而有时候只要
SbLocalHome sbh=(SbLocalHome)ctx.lookup("java:/SbLocalHome");
就可以了呢?
还请高手们指点迷津。