baseclient.java
来自「J2EE开发与Weblogic一书中的源代码」· Java 代码 · 共 51 行
JAVA
51 行
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];
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?