?? buildercontext.java
字號:
package custom_management;
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容器的上下文環(huán)境
* @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;
}
}
/**
* 獲得默認的,簡單的上下文環(huán)境
* @return Context
*/
public static final Context getSimpleInitialContext() {
try {
return new InitialContext();
}
catch (NamingException ex) {
return null;
}
}
/**
* 信息輸出函數(shù)
* @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 + -