Wednesday, February 6, 2008

Adding Spring AOP into Glue framework

I have recently tried to use Spring AOP to provide crosscutting logging control to our existing Glue framework; it proved to be lot of pain without much gain. I might try AspectJ to see if it provides more way working with Glue.

The most of the difficulties lies in:

Issue 1: Trying to work with an unsupported product Glue doesn't help. There is no easy way to modify Glue internal binding process to add Spring AOP ProxyFactory way of instantiate new object.

Issue 2: There is literally no documentation out there regarding to how to configure spring to work with Glue and Resin.

The alternative I took for the Issue 1 is to bind to, for example, transcriptrequest proxy, it then create a new TranscriptRequestImpl the Spring AOP way:

public TranscriptRequest() {

ProxyFactory factory = new ProxyFactory(new TranscriptRequestImpl());

impl = (ITranscriptRequest)factory.getProxy();

}

This solution is workable. The disadvantage is that for each Web Service, we need to add a proxy.

Issue 2 turns out to be a harder problem. Spring throws the following exceptions when loading applicationContext:

org.springframework.beans.BeanWrapperImpl] ~ Invoked write method [public void org.springframework.aop.framework.ProxyFactoryBean.setProxyInterfaces(java.lang.String[]) throws org.aopalliance.aop.AspectException,java.lang.ClassNotFoundException] with value [[Ljava.lang.String;@21d23b]

org.springframework.beans.BeanWrapperImpl] ~ Invoked write method [public void org.springframework.aop.support.RegexpMethodPointcut.setPattern(java.lang.String) throws org.apache.oro.text.regex.MalformedPatternException] with value [.*]

Don't know why it's using org.apache.oro.text.regex instead of java.util.regex, maybe it is missing some essential components. It could be the problem with dynamically loaded code, specifically stuff that does a class.forName(...). Since they are dynamic in nature, so can't use any static typing info to figure out what is going on.

To verify the Java code is working, it is just the configuration problem. I programmatically added the advice to the ProxyFacotory, it works fine:

public TranscriptRequest() {

ProxyFactory factory = new ProxyFactory(new TranscriptRequestImpl());

impl = (ITranscriptRequest)factory.getProxy();

factory.addInterface(ITranscriptRequest.class);

factory.addBeforeAdvice(new TracingBeforeAdvice());

factory.addAfterReturningAdvice(new TracingAfterAdvice());

factory.addThrowsAdvice(new LoggingThrowsAdvice());

}

At the level of java code that I directly control, I could see the binding and when it happens.

If we programmatically add the advice to the factory, we could get the logging implemented. But this approach undermines the original purpose of adding AOP.

3 comments:

Anonymous said...

Dear friends!

Is it a deal to change iTunes to MP3? I say NOPE :) Its really annoying not being able to play iTunes tracks with my $300 iriver!
Digging for a solution brings certain results. To [url=http://drm-removal.com/features/iTunestoMP3/convert_iTunes_to_MP3.htm]convert iTunes to MP3[/url] I used this tool drm removal (drm-removal.com or something like this, please ask me - will find that web again). I don't care what is drm - what I read, its something dealing with protection and nothing about iTunes.
But this tool really works for me and it converted quickly my iTuines entire library, including video files!.

What you your solution? Why iTunes brings this inconvinience? I didn't like ipods at all! They simple stuck and suck!
What is that drm that I loose converting my itunes to mp3?

thanks in advance!

Anonymous said...

Hello
zithromax medication
Nervous system side effects are dizziness, headache, somnolence and vertigo.
[url=http://www.fitzsoft.com/]order zithromax[/url]
For patients having pharyngitis and tonsilitis is 12 mg/kg on Day 1-5.
http://www.fitzsoft.com/ - zithromax z pak
Prescribing this drug in a patient with no definite diagnosis may increase the risk of developing drug resistant bacteria.

Anonymous said...

Hi
meridia cost

Available in 5 mg, 10 mg, and 15 mg capsules, Sibutramine is taken orally.
[url=http://www.buyrooibos.com/]meridia medication[/url]
The dose can be titrated after four weeks to a maximum of 15 mg once a day if weight loss is not enough.
http://www.buyrooibos.com/ - generic meridia

It is a neurotransmitter reuptake inhibitor which reduces the reuptake of norepinephrine, serotonin, and dopamine that subsequently improves the levels of these substances in synaptic clefts therefore enhancing the feeling of satiety.