【Java开源代码栏目提醒】:网学会员为广大网友收集整理了,BaseClient.java,希望对大家有所帮助!
package com.learnweblogic.examples;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
public abstract class BaseClient {
private Context ctx;
private String url = "t3://localhost:7001";
protected Object narrow(Object o, Class c) {
return PortableRemoteObject.narrow(o, c);
}
protected Context getInitialContext() throws NamingException {
if (ctx == null) {
try {
Properties p = new Properties();
p.put(
Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
p.put(Context.PROVIDER_URL, url);
ctx = new InitialContext(p);
} catch (NamingException ne) {
System.err.println(
"** Unable to connect to the server at:" + url);
ne.printStackTrace();
throw ne;
}
}
return ctx;
}
public BaseClient(String[] argv) {
if (argv.length > 0)
url = argv[0];
}
}
上一篇:
BaseBugReport.java
下一篇:
扛起年轻化大旗,哈弗F系玩转行业新风潮