📄 buildercontext.java~1~
字号:
package personal_payout_manage.utils;
import java.util.Properties;
import javax.naming.Context;
import javax.naming.NamingException;
import javax.naming.InitialContext;
final class BuilderContext {
private static final String ERROR_NULL_REMOTE = "Remote interface reference is null. It must be created by calling one of the Home interface methods first.";
private static final int MAX_OUTPUT_LINE_LENGTH = 100;
/**
* 获得EJB容器的上下文环境
* @return Context
* @throws Exception
*/
public static final Context getWeblogicServerInitialContext() throws Exception {
String url = "t3://127.0.0.1:7001";
String user = null;
String password = null;
Properties properties;
try {
properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, url);
if (user != null) {
properties.put(Context.SECURITY_PRINCIPAL, user);
properties.put(Context.SECURITY_CREDENTIALS,
password == null ? "" : password);
}
return new javax.naming.InitialContext(properties);
} catch (Exception e) {
log("Unable to connect to WebLogic server at " + url);
log("Please make sure that the server is running.");
throw e;
}
}
/**
* 获得默认的,简单的上下文环境
* @return Context
*/
public static final Context getSimpleInitialContext() {
try {
return new InitialContext();
}
catch (NamingException ex) {
return null;
}
}
/**
* 信息输出函数
* @param message String
*/
private static final void log(String message) {
if (message == null) {
System.out.println("-- null");
}
if (message.length() > MAX_OUTPUT_LINE_LENGTH) {
System.out.println("-- " +
message.substring(0, MAX_OUTPUT_LINE_LENGTH) +
" ...");
} else {
System.out.println("-- " + message);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -