first commit
This commit is contained in:
61
hrmsEjb/wenrgise/common/utility/WorkFlowServiceLocator2.java
Normal file
61
hrmsEjb/wenrgise/common/utility/WorkFlowServiceLocator2.java
Normal file
@@ -0,0 +1,61 @@
|
||||
package wenrgise.common.utility;
|
||||
|
||||
import java.util.HashMap;
|
||||
import javax.ejb.EJBLocalHome;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.NamingException;
|
||||
import wenrgise.common.exception.EnrgiseSystemException;
|
||||
|
||||
public class WorkFlowServiceLocator2 {
|
||||
private HashMap homeCache;
|
||||
|
||||
private final HashMap cacheMap = new HashMap();
|
||||
|
||||
private static WorkFlowServiceLocator2 serviceLocator = new WorkFlowServiceLocator2();
|
||||
|
||||
private WorkFlowServiceLocator2() {
|
||||
try {
|
||||
this.homeCache = new HashMap();
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static WorkFlowServiceLocator2 getLocator() {
|
||||
return serviceLocator;
|
||||
}
|
||||
|
||||
public Object getService(String jndiName) throws EnrgiseSystemException {
|
||||
try {
|
||||
if (!this.homeCache.containsKey(jndiName)) {
|
||||
Context context = WorkFlowContextProvider2.getContext();
|
||||
this.homeCache.put(jndiName, context.lookup(jndiName));
|
||||
}
|
||||
} catch (NamingException oNa) {
|
||||
System.out.println(String.valueOf(String.valueOf(String.valueOf("The problem is ").concat(String.valueOf(oNa.getMessage()))).concat(String.valueOf(" the type is "))).concat(String.valueOf(oNa.getClass().getName())));
|
||||
throw new EnrgiseSystemException(oNa);
|
||||
} catch (Exception oEx) {
|
||||
System.out.println(String.valueOf(String.valueOf(String.valueOf("The problem is ").concat(String.valueOf(oEx.getMessage()))).concat(String.valueOf(" the type is "))).concat(String.valueOf(oEx.getClass().getName())));
|
||||
throw new EnrgiseSystemException(oEx);
|
||||
}
|
||||
return this.homeCache.get(jndiName);
|
||||
}
|
||||
|
||||
public EJBLocalHome getLocalHome(String jndiHomeName) throws EnrgiseSystemException {
|
||||
EJBLocalHome home = null;
|
||||
try {
|
||||
jndiHomeName = jndiHomeName.trim();
|
||||
Context context = WorkFlowContextProvider2.getLocalContext();
|
||||
if (this.cacheMap.containsKey(jndiHomeName)) {
|
||||
home = (EJBLocalHome)this.cacheMap.get(jndiHomeName);
|
||||
} else {
|
||||
home = (EJBLocalHome)context.lookup(String.valueOf("java:comp/env/").concat(String.valueOf(jndiHomeName)));
|
||||
this.cacheMap.put(jndiHomeName, home);
|
||||
}
|
||||
} catch (NamingException ne) {
|
||||
ne.printStackTrace();
|
||||
throw new EnrgiseSystemException(ne);
|
||||
}
|
||||
return home;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user