Monday, March 30, 2009

Obtain a list of JPDs?

I'm expanding my search for help with a WLST script that will terminate all the aborted processes in WLI 9.2.2 I have an open case with Oracle, but we haven't come up with my "ideal" solution. What I have right now is a Java program that I can pass a JPD to, and it will terminate all the aborted processes for that JPD. This works ok, but I would like to find a way for the program to find all the JPDs in the environment and then parse through them. Ideally, all of this would be done in WLST, but I can live with Java if it gets the job done. Anyone out there have thoughts on how to do this? Unfortunately, I am a middleware guy and not a Java programmer, so I can't do much with this on my own. The code I have right now is included below:

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.*;
import com.bea.wli.bpm.runtime.ProcessStatus;

public class TerminateProcess {

public static void main(String[] args){

    //Parameters to be configured
    //String JPDURI = "/IDXWEB/processes/Process.jpd";
    //String Provider_URL = "t3://localhost:7001";
    //String Security_Principal = "weblogic";
    //String Security_Credentials = "weblogic";

   if (args.length != 5) {
  String adminURL = args[0];
  System.out.println("Admin URL is$$$ "+adminURL);
  String jpdURI = args[1];
  System.out.println("jpdURI is$$$ "+jpdURI);
  String adminUserName = args[2];
  String adminPassword = args[3];
  int exitCount = Integer.parseInt(args[4]);
  boolean blnExitOnCount = false;//Flag to run the terminate process in batch. If true, it will
                                               //only the number of instances in the exitCount parameter.
                                               //If false, it will terminate all the instances of that JPD.

 try {
    String CONTEXT_FACTORY = "weblogic.jndi.WLInitialContextFactory";
    Properties p = new Properties();
    p.put(Context.PROVIDER_URL, adminURL );

    Context ctx = new InitialContext(p);

    MBeanHome home = (MBeanHome)ctx.lookup(MBeanHome.ADMIN_JNDI_NAME);

    Set s = home.getMBeansByType("ProcessRuntime");
    Iterator it = s.iterator();

    while (it.hasNext())
            ProcessRuntimeMBean bean = (ProcessRuntimeMBean);

            //Query for JPD
            ProcessInstanceQuery query = new ProcessInstanceQuery();
   ProcessInstanceQueryResult info = bean.getProcessInstances(query);
            String[] instances = info.getInstanceIds();
            System.out.println("Instance Ids " + instances.toString());
            System.out.println("Instance Count " + instances.length);

            for(int i=0;i= exitCount-1))
    } catch (Exception ex) {



Monday, March 9, 2009

Ctrl-S in vi hangs my edit session

Sometimes I'm a bit stubborn and continue to work around an issue even though I know there must be a better way. Here's a great example: Working in vi, every now and again, I find myself hitting Ctrl-S when I want to save (Ctrl-S is a windows shortcut for Save for those that don't know...) And when you do that vi gets very unhappy. in fact, it seems to stop responding to all commands, and the only way I was ever able to "fix" my mistake was to close my connection to the server, and log back in. Then I would need to delete the .swp file vi creates when you are in an edit session, and then I could go back in and make all those changes over again (because, of course, I couldn't really save it...) I've been doing this sporadically, as needed, for the better part of 3 years. Today I got fed up and a quick google search (less than a minute) turned up a solution. Ctrl-Q will apparently put vi back in its place and accepting cryptic orders from me again.