see http://download-llnw.oracle.com/docs/cd/E13214_01/wli/docs92/wli.javadoc/com/bea/wli/management/runtime/ProcessRuntimeMBean.html#terminate(java.lang.String,%20java.lang.String)
package com.acme.wli;
import java.util.Iterator;
import java.util.Set;
import javax.naming.Context;
import javax.naming.NamingException;
import com.bea.wli.bpm.runtime.ProcessStatus;
import com.bea.wli.management.runtime.ProcessInstanceQuery;
import com.bea.wli.management.runtime.ProcessInstanceQueryResult;
import com.bea.wli.management.runtime.ProcessRuntimeMBean;
import weblogic.jndi.Environment;
import weblogic.management.MBeanHome;
/**
* Ajouter D:\beawliwlp103\wli_10.3\lib\jpdpublic.jar:
* @author vernetto
*
*/
public class WLITerminator {
//private static final String SERVICE_URI = "/ProtectionProcesses/com/acme/corp/protectionProcesses/iris/ReceiveCIUN_v5.jpd";
//private static final String SERVICE_URI = "/ProtectionProcesses/com/acme/corp/protectionProcesses/iris/CotationDataReady_v4.jpd";
private static final String SERVICE_URI = "/ProtectionProcesses/com/acme/corp/protectionProcesses/iris/HandleCIUN_v1.jpd";
public static void main(String[] args) throws NamingException {
Environment env = new Environment();
env.setSecurityPrincipal("weblogic");
env.setSecurityCredentials("weblogic");
env.setProviderUrl("t3://admmaintatlas.acme.dns:8501");
Context ctx = env.getInitialContext();
MBeanHome home = (MBeanHome)ctx.lookup(MBeanHome.ADMIN_JNDI_NAME);
System.out.println("Got the Server-specific MBeanHome: " + home);
Set s = home.getMBeansByType("ProcessRuntime");
Iterator it = s.iterator();
try {
if (it.hasNext()) {
ProcessRuntimeMBean bean = (ProcessRuntimeMBean)it.next();
ProcessInstanceQuery query = new ProcessInstanceQuery();
//query.setServiceURI(SERVICE_URI);
query.setStatus(ProcessStatus.ABORTED);
ProcessInstanceQueryResult info = bean.getProcessInstances(query);
int count = info.getResultCard();
String[] instances = info.getInstanceIds();
System.out.println("found " + instances.length + " instances");
for (int i = 0 ; i < instances.length; i++) {
String instanceId = instances[i];
ProcessInstanceInfo pi = bean.getProcessInstanceInfo(instanceId, false);
System.out.println(pi.getServiceURI() + " " + instanceId);
//bean.terminate(pi.getServiceURI(), instanceId);
}}
} catch (Exception ex) {
System.out.println(ex);
ex.printStackTrace();
}
}
}
Thursday, November 12, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment