Re: [Nanning-developer] Activity?

Jon Tirsen <[email protected]> Mon, 05 Jan 2004 17:48:04 +0000
Newsgroups gmane.comp.java.nanning.devel
Message-ID <[email protected]>
Francois Beauregard wrote:

>We are using successfully Webwork/XWork with Pico and make use of XWork
>interceptors.
>This allows interceptors on actions but not interceptors and mixins on our
>other Pico services.
>Therefore, we are looking at what we should use to achieve this.
>  
>

I've been planning to support the AOP Alliance interfaces in Nanning. 
That way you could reuse interceptors written for Spring Framework. It 
should be possible to persuade the XWork guys to support AOP Alliance 
too and in that case one could reuse these interceptors too.
If anyone got a really cool AOP Alliance compatible interceptor they 
want to use for Nanning I'd be motivated enough to implement support for 
that in Nanning.

>A few questions :
>1. Where can I find the code for the Pico-Nanning integration?
>  
>

In PicoExtras, check it out using
cvs -d :pserver:[email protected]:/cvsroot/picocontainer co 
picoextras

Or to download a jar for it:
http://dist.codehaus.org/picocontainer/jars/picoextras-nanning-1.0-alpha-1-SNAPSHOT.jar
(may not be entirely compatible with current Pico CVS but should be 
compatible with 1.0-alpha-1)

>2. Is there a bit of documentation on the features and strategy of the
>integration?
>  
>

Not really, the integration is quite simple. You create a PicoContainer 
with the NanningComponentAdapterFactory and then register the aspect as 
an ordinary Pico-component. The aspect will be applied to components 
registered after that aspect.

Something like this:
public class MyAspect {
    public MyAspect(Dependency dependency) {}

*  public* *void* introduce(AspectInstance instance) {
	// add mixins to instance
  }
*  public* *void* advise(AspectInstance instance) {
	// add interceptors to instance
  }
}

DefaultPicoContainer container = *new* DefaultPicoContainer(*new* CachingComponentAdapterFactory(*new* NanningComponentAdapterFactory()));
container.registerComponentImplementation(Dependency.class);
container.registerComponentImplementation(MyAspect.*class*);
container.registerComponentImplementation(Component.*class*);
container.start();

The best way to see how it works is to read the unit-tests (as with all 
open-source projects doing TDD):
http://cvs.codehaus.org/viewcvs.cgi/picoextras/nanning/src/test/org/picoextras/nanning/NanningNanoContainerTestCase.java?rev=1.3&root=picocontainer&view=auto
Especially the last two tests: 
testTransactionAspectStartsAndCommitsTransaction &  
testTransactionAspectStartsAndRollsBackTransaction
I should really try to write some better documentation on this. :-)

Stephan, you could tell them about your experiences and how the code 
looks like in SnipSnap to use it.

Hope this helps.

Cheers,
Jon




-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click