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…
- Download AspectJ 1.6.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
- Now, I opened a new WID module, wrote a short process.
- 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)
- 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)
- That should be it – the aspects now work. However, how do we tie them to the process itself?
- 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.
- 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…