public final class FactoryPoolClient implements FactoryPool {
public FactoryPoolClient() {
super();
} private static String FACTORYPOOLEJB = "FactoryPoolEJB"; private Context _context = null;
private FactoryPoolEJB _factoryPoolEJB = null;
private FactoryPoolEJBHome _factoryPoolEJBHome = null; private ContextInfo _contextInfo = new ContextInfo(); private class ContextInfo {
public ContextInfo() { } String _url = "";
String _initial_context = "";
String _user = "";
String _pass = ""; public boolean EqualContext(String url, String initial_context, String user, String pass) {
if (url.equals(_url)) {
if (initial_context.equals(_initial_context)) {
if (user.equals(_user)) {
if (pass.equals(_pass)) {
return true;
} else {
_pass = pass;
}
} else {
_user = user;
}
} else {
_initial_context = initial_context;
}
} else {
_url = url;
} return false;
}
}
public PoolMark CreatePoolMark(String host, String url, String initial_context, String user,
String pass, String database) throws CreatePoolMarkException {
boolean bCreateFlag = CreateFactoryPoolEJB(url, initial_context, user, pass);
System.out.println(bCreateFlag);
if (bCreateFlag) {
try {
return _factoryPoolEJB.CreatePoolMark(host, url, initial_context, user, pass,
database);
} catch (RemoteException ex) {
throw new CreatePoolMarkException(ex);
}
}
return null;
} public ServiceFactory AcquireServiceFactory(PoolMark poolMark) throws
UnsupportedProtocolException, StartupException, AcquireServiceFactoryException,
PoolMarkNotExistException {
try {
return _factoryPoolEJB.AcquireServiceFactory(poolMark);
} catch (RemoteException ex) {
throw new StartupException(ex);
}
} public void ReleaseServiceFactory(PoolMark poolMark) throws ShutdownException {
try {
_factoryPoolEJB.ReleaseServiceFactory(poolMark);
} catch (RemoteException ex) {
throw new ShutdownException(ex.getMessage());
}
} protected Context getInitialContext(String url, String user, String password,
String inital_context) throws Exception {
Properties properties;
try {
properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, inital_context);
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) {
e.printStackTrace();
throw e;
}
} protected boolean CreateFactoryPoolEJB(String url, String initial_context, String user,
String pass) {
try {
if (_contextInfo.EqualContext(url, initial_context, user, pass)) {
if (_context == null) {
_context = getInitialContext(url, initial_context, user, pass);
} else {
if (_factoryPoolEJB != null) {
return true;
}
}
} else {
_context = getInitialContext(url, initial_context, user, pass);
} if (_context == null) {
return false;
} Object ref = _context.lookup(FACTORYPOOLEJB);
_factoryPoolEJBHome = (FactoryPoolEJBHome) PortableRemoteObject.narrow(ref,
FactoryPoolEJBHome.class); _factoryPoolEJB = _factoryPoolEJBHome.create(); return true;
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
} public void ForceReleaseServiceFactory(PoolMark poolMark) throws ShutdownException {
}
public void setMinMax(int iMin, int iMax) throws RemoteException {
_factoryPoolEJB.setMinMax(iMin, iMax);
}
}
public FactoryPoolClient() {
super();
} private static String FACTORYPOOLEJB = "FactoryPoolEJB"; private Context _context = null;
private FactoryPoolEJB _factoryPoolEJB = null;
private FactoryPoolEJBHome _factoryPoolEJBHome = null; private ContextInfo _contextInfo = new ContextInfo(); private class ContextInfo {
public ContextInfo() { } String _url = "";
String _initial_context = "";
String _user = "";
String _pass = ""; public boolean EqualContext(String url, String initial_context, String user, String pass) {
if (url.equals(_url)) {
if (initial_context.equals(_initial_context)) {
if (user.equals(_user)) {
if (pass.equals(_pass)) {
return true;
} else {
_pass = pass;
}
} else {
_user = user;
}
} else {
_initial_context = initial_context;
}
} else {
_url = url;
} return false;
}
}
public PoolMark CreatePoolMark(String host, String url, String initial_context, String user,
String pass, String database) throws CreatePoolMarkException {
boolean bCreateFlag = CreateFactoryPoolEJB(url, initial_context, user, pass);
System.out.println(bCreateFlag);
if (bCreateFlag) {
try {
return _factoryPoolEJB.CreatePoolMark(host, url, initial_context, user, pass,
database);
} catch (RemoteException ex) {
throw new CreatePoolMarkException(ex);
}
}
return null;
} public ServiceFactory AcquireServiceFactory(PoolMark poolMark) throws
UnsupportedProtocolException, StartupException, AcquireServiceFactoryException,
PoolMarkNotExistException {
try {
return _factoryPoolEJB.AcquireServiceFactory(poolMark);
} catch (RemoteException ex) {
throw new StartupException(ex);
}
} public void ReleaseServiceFactory(PoolMark poolMark) throws ShutdownException {
try {
_factoryPoolEJB.ReleaseServiceFactory(poolMark);
} catch (RemoteException ex) {
throw new ShutdownException(ex.getMessage());
}
} protected Context getInitialContext(String url, String user, String password,
String inital_context) throws Exception {
Properties properties;
try {
properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY, inital_context);
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) {
e.printStackTrace();
throw e;
}
} protected boolean CreateFactoryPoolEJB(String url, String initial_context, String user,
String pass) {
try {
if (_contextInfo.EqualContext(url, initial_context, user, pass)) {
if (_context == null) {
_context = getInitialContext(url, initial_context, user, pass);
} else {
if (_factoryPoolEJB != null) {
return true;
}
}
} else {
_context = getInitialContext(url, initial_context, user, pass);
} if (_context == null) {
return false;
} Object ref = _context.lookup(FACTORYPOOLEJB);
_factoryPoolEJBHome = (FactoryPoolEJBHome) PortableRemoteObject.narrow(ref,
FactoryPoolEJBHome.class); _factoryPoolEJB = _factoryPoolEJBHome.create(); return true;
} catch (Exception ex) {
ex.printStackTrace();
return false;
}
} public void ForceReleaseServiceFactory(PoolMark poolMark) throws ShutdownException {
}
public void setMinMax(int iMin, int iMax) throws RemoteException {
_factoryPoolEJB.setMinMax(iMin, iMax);
}
}
解决方案 »
- jbpm4.4,如何使用AssignmentHandler接口
- Ext中的分页问题
- 求助criteria问题!
- 菜鸟请教:jboss和j2ee应用服务器在应用上有什么区别?
- 请问下这段代码,通过传递类的Class这个参数有什么好处?
- 保存gif图片问题
- 有人做过JFreeReport或JasperReport报表的开发吗?有点经验的请来赐教
- 怎么查看tomcat到底运行了那些程序?
- 写SQL语句时,如何把byte[] b转换成JDBC中的BLOB?
- 请教hibernate和struts做的作业,做了一半,其中验证框架没起作用
- BufferedReader --> MS SQL 2005
- 有谁了解“江苏新晨信息科技发展有限公司”吗,公司怎么样?
将weblogic.jar加到classpath中就可以了。
Good luck
这个我已经加进去了,但是还是不行,有没有是别的原因
再一个就是他也没有报weblogic.jndi.WLInitialContextFactory这个类的异常。