Re: first steps with nanning

Jon Tirsén <[email protected]> Wed, 30 Jul 2003 20:32:07 +0200 (CEST)
Newsgroups gmane.comp.java.nanning.devel
Message-ID <20030730183207.56199.qmail__25633.248643908$1059590624@web40605.mail.yahoo.com>
 --- Christoph Sturm <[email protected]> skrev: >
On Wed, 30 Jul 2003 16:44:52 +0200 (CEST), Jon
> Tirsén 
> <[email protected]> wrote:
> 
> > Yes that is most certainly possible. You should
> really
> > start using the AspectSystem stuff instead. That
> makes
> > it possible to modularize your aspects. So to have
> an
> > aspect that adds a singleton mixin I would do:
> >
> > public class ArticleContainerAspect implements
> Aspect
> > {
> > Pointcut objectsHavingArticleContainer =
> > P.or(P.isClass(ClassHavingArticle.class),
> > P.isClass(SecondClassHavingArticle.class));
> >
> > ArticleContainer singletonArticleContainer = new
> > ArticleContainerImpl();
> >
> > public void introduce(AspectInstance instance) {
> > objectsHavingArticleContainer.introduce(new
> > Mixin(ArticleContainer.class,
> > singletonArticleContainer);
> > );
> >
> > public void advise(AspectInstance instance) {}
> > }
> >
> > In your factory you would keep a singleton
> > AspectSystem and add the aspect:
> > private static AspectSystem aspectSystem;
> >
> > static {
> > aspectSystem.addAspect(new
> > FindTargetMixinAspect("Impl")); // this will find
> the
> > implementation of the main class as "Class" ->
> > "ClassImpl"
> > aspectSystem.addAspect(new
> > ArticleContainerAspect());
> > }
> >
> > To actually instantiate an object you'd do:
> > ClassHavingArticle classHavingArticle =
> >
> aspectSystem.newInstance(ClassHavingArticle.class);
> 
> thanks, that sounds good. My problem with nanning is
> that there is 
> absolutely no doco that i can find. I just started
> from the code samples on 
> the snipsnap. Is there anywhere documentation that
> is up to date?

It's the wiki, and that's about it. The stuff I have
in the wiki will be distilled into a proper
documentation along with a lot of new-written stuff
too before 1.0. Really sorry about that. The code is
very small so it would definitely not be possible to
understand all of it in a short while.
I will of course answer any question in the
meantime... The least I could do I suppopse.

> My first day with nanning was really great, I can
> now run the test suite 
> from inside idea, and it takes me 5 seconds to run
> it. before I was running 
> the test suite through maven, and it took about a
> minute. And I can set 
> breakpoints and step through the code. awesome!

Cool!!!

> My next question is, how can I get back to the
> AspectInstance from the 
> proxy object? I need the possibility to create a new
> object from an 
> aspected object with the same aspects. (In
> Aspectwerkz I just used 
> newInstance(obj.getClass())). How can I do that with
> nanning?

With aspects you mean mixins and interceptors right?
You can do the same thing if you use AspectSystem. You
just do aspectSystem.newInstance(obj.getClass()).
Or to get hold of the AspectInstance:
Aspects.getAspectInstance(obj);

> Also I dont get the concept of a classIndentifier.
> Is that the primary type 
> of the aspected object?

Exactly, that's a bit of a weird name. Historical
reasons. It's really supposed to be called mainClass
or something. I will probably change that.

> If this is all documented somewhere, just point me
> to the place where I can 
> find it...

Sorry, sorry, sorry. I will answer any question you
have until proper documentation is produced.

> regards
> -chris
> 
> ps: I read on your blog that you are now a
> ThoughtWorker. Congratulations! 
> What will now happen to your web gui project that
> you did at lecandro? Will 
> they still opensource it? Or will you start a new
> one on your own?

Thanks a lot!
I will continue to work with Lecando regarding
Prevayler, Nanning and Ulvsunda (the name of the web
framework). Ulvsunda should be open-sourced after the
vacations (in Sweden the whole country shut down
during the vacations).
If they don't open-source it I might start a new
framework (or restart the Angkor-project). The problem
is the components, a lot of work went into the
components at Lecando: trees, scrollable/sortable
tables and so on.

_____________________________________________________
Gå före i kön och få din sajt värderad på nolltid med Yahoo! Express
Se mer på: http://se.docs.yahoo.com/info/express/help/index.html