Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] only weave certain aspects from aspect library with ajdt

Hi Kurt,

A quick thought if it helps.

I've been doing some stuff recently that's using Spring's transaction
management, and using Maven for dependency resolution.

The challenge that you face with your library is in pulling in the
dependencies too.  I would break it into components:
- core
- spring
- hibernate

So that the user either needs to have the Hibernate aspect library
(which depends on core - whatever is common within your library), or the
Spring one.

I also suspect that you could also write some AJ advice which would
ensure that only one implementation was being woven, and would cause an
error to be raised if someone accidentally included both.

Cheers,

Neale



> My use case is, that all transaction aspects are doing the same. They 
> differntiate in the transaction-libraries they use.
> One weaves the Spring managed transactions into the code, another one 
> uses the Hibernate transactions, if the user
> doesnt want a dependency to Spring. Or the user solves the transaction 
> problem in a completely different way, not
> using any of the transaction aspects, by using proxies for example. The 
> library is just supposed to present solutions.
> Which solution the user chooses is up to him. Compared to traditional 
> classes in a library, when there are some
> classes that present solutions for the same problem, there is no problem 
> to choose a class and instantiate it. The
> same should be possible with aspects.
> 
> A question to you first suggestion: I think, if i annotate my class with 
> @RuleBasedTransactionAware etc,
> the seperation of concerns is again beeing hurt, because now the class 
> has the information, that it is
> RuleBasedTransactionAware. Don't you think so?
> 
> Regards
> 
> Andrew Eisenberg schrieb:
> > Hi Kurt,
> >
> > That sounds like some poorly designed aspects in your library if they
> > are accidentally applying in places where they shouldn't.  The way
> > that the library *should* have been designed is that you should be
> > able to easily choose which transaction aspect should apply in which
> > part of your code.  Ways of doing this could be:
> >
> > 1. The aspects only weave based on a certain annotation being present:
> > eg-
> > @RuleBasedTransactionAware  class Class1 { ...}
> > @RollbackTransactionAware class Class2 { ... }
> >
> > 2. The aspects are all declared abstract and concrete aspects can
> > determine exactly where their advice applies to the code.
> >
> > 3. Remodularize your aspect library and delete the aspects that you do
> > not want to apply.
> >
> > Of course, the way you are describing things, it does not seem that
> > the first two are possible.  However, that would be the ideal way of
> > doing things.  #3, though less desirable should be possible.
> >
> > As far as I know, there is no way to weave only a subset of existing
> > aspects for compile time weaving (for load-time weaving, however, that
> > is a different story).
> >
> > On Mon, Jul 27, 2009 at 1:13 PM, Kurt Zitze<Garz@xxxxxxx> wrote:
> >   
> >> hi,
> >>
> >> thx for your reply, this is very kind of you.
> >>
> >> i will try to describe my problem more precisly. :)
> >>
> >> i have a library (a jar file) with some classes and in the same library, there are some aspects. the concrete use case is, there are different aspects for transaction management that advised to the classes that need
> >> it. obviously, weaving one transaction aspect is enough. but the library
> >> cant know, which one is needed, it just comes with all available transaction
> >> aspects. so it is the task of the user of the library to choose a certain
> >> transaction aspect. so i include this library into my project and then i want to somehow enable the desired transaction aspect. since i'm using
> >> eclipse and ajdt, it would be a dream if this could be done with it. can it be done?
> >>
> >> otherwise i think i can do it with:
> >> "ajc -injars mylibrary.jar -aspectpath mylibrary.jar"
> >> but this weaves all aspects. how can i specify that only some desired aspects from the mylibrary.jar are woven?
> >>
> >> best regards and thx again!
> >> --
> >> GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
> >> Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01
> >> _______________________________________________
> >> aspectj-users mailing list
> >> aspectj-users@xxxxxxxxxxx
> >> https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >>
> >>     
> > _______________________________________________
> > aspectj-users mailing list
> > aspectj-users@xxxxxxxxxxx
> > https://dev.eclipse.org/mailman/listinfo/aspectj-users
> >
> >   
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
-- 
  Neale Upstone
  neale@xxxxxxxxxxxxxxxx



Back to the top