In some cases, extending the Agentry Product JARs (like the SAPWM-x.x.x.x.jar) in an object oriented way is not an easy task and it can be tiresome if you want to add some generic functionality like adding additional (trace) logging, error handing, monitoring and so forth to "every" StepHandler/BAPI/etc.-class. If you do not want to touch the actual SAPWM-x.x.x.x.jar, you might want to consider using AspectJ load-time weaving. I will not explain the basic concepts of AspectJ here as there are plenty of tutorials and examples in the net. If you are new to aspect-oriented coding, I strongly recommend, you get your feet wet with some standalone Java application first. In the following, I just want to explain, how to set up AspectJ for the Agentry Java Backend of the SMP 3.0.
First, you need some tools and libraries:
Basic configuration of the SMP for AspectJ:
Export-Package: org.aspectj.lang;org.aspectj.runtime
Write your AspectJ code (or use the attached code), compile and JAR it (e.g. as aopdemo.jar) and put it into the Agentry Application Java folder (where the Agentry-v5.jar is located). Don't forget to add your JAR to the Agentry.ini classpath property (e.g. ;./Java/aopdemo.jar).
AppClassLoader@142e6767 info AspectJ Weaver Version 1.8.2 built on Thursday Aug 14, 2014 at 21:45:02 GMT
AppClassLoader@142e6767 info register classloader sun.misc.Launcher$AppClassLoader@142e6767
AppClassLoader@142e6767 info using configuration file:/.../aopdemo.jar!/META-INF/aop.xml
AppClassLoader@142e6767 info register aspect aopdemo.MyAspect
AgentryApplicationClassLoader@7cc49e01 weaveinfo Join point 'method-execution(java.util.ArrayList com.syclo.sap.bapi.GetUserProfileDataBAPI.processResults())' in Type 'com.syclo.sap.bapi.GetUserProfileDataBAPI' (GetUserProfileDataBAPI.java:68) advised by around advice from 'aopdemo.MyAspect' (MyAspect.aj:42)
[AOP] (BAPIFactory.java:34) boolean com.syclo.sap.BAPIFactory.validateClass(String, String) returns java.lang.Boolean: true
[AOP] (BAPIFactory.java:34) boolean com.syclo.sap.BAPIFactory.validateClass(String, String)
[AOP] (BAPIFactory.java:34) arg java.lang.String: WorkorderTransferBAPI
[AOP] (BAPIFactory.java:34) arg java.lang.String: com.syclo.sap.component.workorder.bapi.WorkorderTransferBAPI
[AOP] (BAPIFactory.java:82) void com.syclo.sap.BAPIFactory.register(String, String)
[AOP] (BAPIFactory.java:82) arg java.lang.String: WorkorderTransferBAPI
[AOP] (BAPIFactory.java:82) arg java.lang.String: com.syclo.sap.component.workorder.bapi.WorkorderTransferBAPI
[AOP] (BAPIFactory.java:82) void com.syclo.sap.BAPIFactory.register(String, String) returns <null>
[AOP] (BAPIFactory.java:34) boolean com.syclo.sap.BAPIFactory.validateClass(String, String) returns java.lang.Boolean: true
For the aopdemo.MyAspect, the client sync should be extremely slow due to the amount of logging data. Your next step should be to change the AspectJ code to reduce the number of join points by adjusting the pointcut definition. This should lead to less logging and better performance.
If you have been able to reproduce the above steps for your SMP installation, you have done it. From here on, its up to you, to identify those extensions, that are a pain with the object-oriented approach and can be done nicely by using aspect-orientation.
I would be interested to hear about your ideas on where AspectJ can be beneficial. Feel free to post them here...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
46 | |
5 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 | |
2 | |
2 |