WebSphere Process Server – skipping steps in the process

A customer of mine has decided to build an application that can monitor his processes, instead of the regular WPS supplied tool.

His main concern was skipping steps. Turns out that when a process has executed a specific activity, and this activity is in a special position (like user task) – an outside application can cause a skip in the process.
I have developed a short demo for this, and I’m enclosing the main method here. Just make sure to disable the process security before running it – or you’ll get a non authorized exception…
// Connect to the server
Properties props = new Properties();
props.put(Context.PROVIDER_URL, “iiop://localhost:2811”);
javax.naming.InitialContext ctx = new javax.naming.InitialContext(props);
// Lookup the BusinessFlowManager. If you get casting exception – read the InfoCenter – you need to add some JARs to your code – it’s WPS/ProcessChoreographer/client/bpe137650.jar
Object lookupResult = ctx.lookup(“com/ibm/bpe/api/BusinessFlowManagerHome”);
BusinessFlowManagerHome processHome = (BusinessFlowManagerHome) PortableRemoteObject
.narrow(lookupResult, BusinessFlowManagerHome.class);
BusinessFlowManager bfm = processHome.create();
// Replace with any process id
ProcessInstanceData pid = bfm.getProcessInstance(“_PI:90030124.f71386d4.dbed54f5.5d84025c”);
// Replace with any activity name
ActivityInstanceData aid = bfm.getActivityInstance(pid.getID(),”Wait”);

// Skip to the specific activity
bfm.skipAndJump(aid.getID(), “TargetActivity”);

AspectJ 1.6 with runtime weaving and WPS 6.2

Well, I haven’t blogged in ages, and it’s not because I lacked things to share…

Anyway, almost all of my WPS customers are looking for some level of polymorphism (or process templating) and AOP. For the first – I currently have no solution. For the second – here comes…
  1. Download AspectJ 1.6.2.
  2. Since it’s been a long time since I worked with AspectJ, I wrote a small program in Eclipse. I just made sure that it used the WPS JDK – to make sure the -javaagent flag works. It does. However, you can’t use it when your eclipse works with a Sun JDK. So – add a -vm to your eclipse.ini file. (See here for details: http://wiki.eclipse.org/Eclipse.ini
  3. Now, I opened a new WID module, wrote a short process.
  4. I also created a small Java Project, which will create a JAR in the WAS/lib directory. It will include my aspects and the aop.xml file (under the META-INF directory)
  5. I started my WPS server, and put the -javaagent flag in the startup options. WAIT!!! Since WPS security is enabled by default, and the aspectJ weaver is located outside the WPS libraries – java security policy won’t let it load – and you can’t start your server!!! Copy the jars into the WPS lib directory. Just make sure you don’t override existing files (aspectj.jar should be in WPS/lib – just rename it to something that doesn’t end with JAR)
  6. That should be it – the aspects now work. However, how do we tie them to the process itself?
  7. It seems that the way WPS works is that for every BPEL activity there is a class in the com.ibm.bpe.engine package, and the doActivate method is called. So our pointcut will need to look like this – @Before(“call(void com.ibm.bpe.engine.BpelActivityKind*.*(..))”) – this should also explain why we put the aspect in the JAR in the WAS/lib directory – it should be in the correct class-loader level.
  8. Well the only thing missing is the actual pointcut – but it’s too late for that – will publish it tomorrow morning… Don’t hold it against me. I will also post the required code to get which Activity we are on. Quite cool…