给出代码如下:
package com.zhengxin.eoms.wsm.domain.process;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.ejb.CreateException;
import javax.ejb.EJBException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.security.auth.Subject;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;
import org.apache.log4j.Logger;
import com.ibm.bpe.api.ATID;
import com.ibm.bpe.api.ActivityServiceTemplateData;
import com.ibm.bpe.api.BusinessFlowManager;
import com.ibm.bpe.api.BusinessFlowManagerHome;
import com.ibm.bpe.api.BusinessFlowManagerService;
import com.ibm.bpe.api.ClientObjectWrapper;
import com.ibm.bpe.api.EHTID;
import com.ibm.bpe.api.EventHandlerTemplateData;
import com.ibm.bpe.api.LocalBusinessFlowManager;
import com.ibm.bpe.api.PIID;
import com.ibm.bpe.api.ProcessInstanceData;
import com.ibm.bpe.api.ProcessTemplateData;
import com.ibm.bpe.api.QueryResultSet;
import com.ibm.bpe.api.VTID;
import com.ibm.task.api.HumanTaskManager;
import com.ibm.task.api.HumanTaskManagerHome;
import com.ibm.task.api.HumanTaskManagerService;
import com.ibm.task.api.IdWrongFormatException;
import com.ibm.task.api.IdWrongTypeException;
import com.ibm.task.api.LocalHumanTaskManager;
import com.ibm.task.api.NotAuthorizedException;
import com.ibm.task.api.ObjectDoesNotExistException;
import com.ibm.task.api.TKIID;
import com.ibm.task.api.Task;
import com.ibm.task.api.UnexpectedFailureException;
import com.ibm.websphere.bo.BOCopy;
import com.ibm.websphere.bo.BOFactory;
import com.ibm.websphere.sca.ServiceManager;
import com.ibm.websphere.security.auth.WSSubject;
import com.ibm.websphere.security.auth.callback.WSCallbackHandlerImpl;
import com.zhengxin.eoms.wsm.api.WsmProcessManager;
import com.zhengxin.eoms.wsm.bpel.BO;
import com.zhengxin.eoms.wsm.web.action.exception.WsmProcessException;
import commonj.sdo.DataObject;
public class WsmProcessManagerImpl implements WsmProcessManager {
private static Logger logger = Logger.getLogger(WsmProcessManagerImpl.class.getName());
private static String WPSLoginModule = "WSLogin";
private static WsmProcessManagerImpl instance = null;
private static Context context = null;
private static LocalBusinessFlowManager localProcessManager = null;
private static BusinessFlowManager processManager = null;
private static LocalHumanTaskManager localTaskManager = null;
private static HumanTaskManager taskManager = null;
private static ServiceManager serviceManager = null;
private static BOFactory bof = null;
private static BOCopy copy = null;
protected WsmProcessManagerImpl() throws WsmProcessException {
logger.debug("WPSFactory...");
initialContext();
}
private synchronized void initialContext() throws WsmProcessException {
logger.debug("initialContext...");
InitialContext initialContext = null;
try {
logger.debug("初始化");
if (context == null) {
context = new InitialContext();
}
if (serviceManager == null) {
initServiceManager();
}
logger.debug("初始化流程服务接口类");
if (processManager == null) {
initProcessManager();
}
logger.debug("初始化流程人工任务服务类");
if (taskManager == null) {
initTaskManager();
}
} catch (Exception err) {
logger.error(err.getMessage());
//throw new WsmProcessException("流程服务初始化失败!");
err.printStackTrace();
}
}
private void initServiceManager() {
logger.debug("initServiceManager");
logger.debug("获取ServiceManager实例");
serviceManager = ServiceManager.INSTANCE;
logger.debug("获取BOFactory工厂");
bof = (BOFactory) serviceManager.locateService("com/ibm/websphere/bo/BOFactory");
logger.debug("获取BO拷贝方法");
copy = (BOCopy) serviceManager.locateService("com/ibm/websphere/bo/BOCopy");
}
private void initProcessManager() throws NamingException, RemoteException, CreateException {
logger.debug("initProcessManager...");
BusinessFlowManagerHome processHome = (BusinessFlowManagerHome) context.lookup("com/ibm/bpe/api/BusinessFlowManagerHome");
processManager = processHome.create();
}
/**
*功能描述:初始化流程人工任务服务类
@throws CreateException
*/
private void initTaskManager() throws NamingException, RemoteException, CreateException {
logger.debug("initTaskManager...");
HumanTaskManagerHome taskHome = (HumanTaskManagerHome) context.lookup("com/ibm/task/api/HumanTaskManagerHome");
taskManager = taskHome.create();
}
/**
*功能描述:获取流程管理API实例
@throws WsmProcessException
*/
public static WsmProcessManagerImpl getInstance() throws WsmProcessException {
logger.debug("getInstance...");
if (instance == null) {
instance = new WsmProcessManagerImpl();
}
return instance;
}
/* (non-Javadoc)
* @see com.zhengxin.eoms.wsm.api.WsmProcessManager#getProcessManager()
*/
public BusinessFlowManagerService getProcessManager() throws WsmProcessException {
logger.debug("getProcessManager...");
try {
if (processManager != null)
return processManager;
initProcessManager();
} catch (Exception err) {
logger.error(err.getMessage());
throw new WsmProcessException("管理流程的程序无法完成初始化!");
}
return processManager;
}
/* (non-Javadoc)
* @see com.zhengxin.eoms.wsm.api.WsmProcessManager#getTaskManager()
*/
public HumanTaskManagerService getTaskManager() throws WsmProcessException {
logger.debug("getTaskManager...");
try {
if (taskManager != null)
return taskManager;
initTaskManager();
} catch (Exception err) {
logger.error(err.getMessage());
throw new WsmProcessException("管理流程的人工任务程序无法完成初始化!");
}
return taskManager;
}
/* (non-Javadoc)
* @see com.zhengxin.eoms.wsm.api.WsmProcessManager#getServiceManager()
*/
public ServiceManager getServiceManager() {
logger.debug("getServiceManager...");
if (serviceManager != null)
return serviceManager;
initServiceManager();
return serviceManager;
}
/* (non-Javadoc)
* @see com.zhengxin.eoms.wsm.api.WsmProcessManager#getBOFactory()
*/
public BOFactory getBOFactory() {
logger.debug("getBOFactory...");
if (bof != null)
return bof;
initServiceManager();
return bof;
}
/* (non-Javadoc)
* @see com.zhengxin.eoms.wsm.api.WsmProcessManager#getBOCopy()
*/
public BOCopy getBOCopy() {
logger.debug("getBOCopy");
if (copy != null)
return copy;
initServiceManager();
return copy;
}
/* (non-Javadoc)
* @see com.zhengxin.eoms.wsm.api.WsmProcessManager#getProcessTemplateData(java.lang.String)
*/
public ProcessTemplateData getProcessTemplateData(String ptid) throws WsmProcessException {