The Artima Developer Community
Sponsored Link

Java Buzz Forum
CGLIB proxies are doing AspectWerkz

1 reply on 1 page. Most recent reply: Nov 30, 2010 10:06 AM by benoit rolland

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Jonas Bonér

Posts: 77
Nickname: jonas
Registered: Jul, 2003

Jonas Bonér is a ski and jazz addict who tries to squeeze in some time for open source development.
CGLIB proxies are doing AspectWerkz Posted: Dec 13, 2004 9:20 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Jonas Bonér.
Original Post: CGLIB proxies are doing AspectWerkz
Feed Title: grubbel
Feed URL: http://docs.codehaus.org/dashboard.action
Feed Description: Weblog of Jonas Bonér [jonas AT codehaus DOT org]
Latest Java Buzz Posts
Latest Java Buzz Posts by Jonas Bonér
Latest Posts From grubbel

Advertisement

The idea

After implementing the AW Proxy extension to AspectWerkz I figured, why not hook into the most widely used proxy implementation out there: cglib and let AspectWerkz weave in the aspects that are around just before the proxy is returned to the user.

The solution

So, this is all that this cglib extension does: asks AspectWerkz if it has anything to say about the class that has just been proxied. If so, then let the AspectWerkz weaver do its job, e.g. weave in the aspects that are currently deployed (on the classpath), and when returns the proxy to the user.

If no AspectWerkz aspects are found that has pointcuts that matches the class being proxied then nothing happens.

All that was needed to make this work was to add 30 lines of code to one single cglib class.

How do I use it?

This means that all you need to do to make any cglib based applications, and there are many: Geronimo, dynaop, Spring AOP, Hibernate etc., become "aspectwerkz-aware" is to replace one single class in the cglib.jar jar.

Or.

If you can't or don't want to patch the cglib.jar jar, you can just put the class before the jar on the classpath.

What is the impact on my existing code?

If no AspectWerkz aspects are found that has pointcuts that matches the class being proxied then nothing happens. And if AspectWerkz is not available then the whole process is skipped. So basically, there is nothing to loose, it is pay as you go (or should I rather say: gain as you go ;-) ).

How do I get it?

The single file you need can be found in the AspectWerkz RC2 distribution, which you can find here.

The cglib extension is in the ./src/cglib-ext dir (in the root of the AspectWerkz distribution). So step into this directory and type ant dist and it will compile the class and put it in a jar that is to be found in the ./src/cglib-ext/target . This jar only contains one single class file (which you either put in the cglib.jar jar or make sure that it is before the jar on the classpath).

In the ./src/cglib-ext dir you also have a sample that you can run. This sample is just a sample taken from the cglib distribution, but it has a tracing aspect on the classpath, that is weaved into the proxy. You can run this test by invoking ant samples:trace .

Enjoy.

Read: CGLIB proxies are doing AspectWerkz


benoit rolland

Posts: 1
Nickname: benroll
Registered: Nov, 2010

Re: CGLIB proxies are doing AspectWerkz Posted: Nov 30, 2010 10:06 AM
Reply to this message Reply
Would you mind to tel us your objectives, like what do you expect to do with your aspectwerkz integration that you can't with cglib ?

Thanks!

Flat View: This topic has 1 reply on 1 page
Topic: Moving into our new Set Direction offices on University Ave; Spying on Sencha Previous Topic   Next Topic Topic: Top 10 Best Most Popular Open-Source Social Networking Software

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use