>
>
>
> You can impl AOP using many different techniques. I proposed the
> simplest one (used by Spring, Guice etc.). Using a regular JDK Dynamic
> Proxy (which is the 'build in Java reflect proxy thingy'). What is
> your question?
>
> >> >
> >> > So, what does AOP give us that can't be done at another phase?
>
> AOP is not about a specific phase. It can be done at:
> * compile time
> * class load time
> * runtime
>
> Can be done with:
> * Bytecode mods
> * Generated proxy
> * Dynamic proxy
> * JVM-level hooks
>
> >> >
> >>
> >> Semantics to annotations.
> >
> > Can you help out with an example?
>
> Annotate a class with f.e.
> @transactional(type=Required) class Foo { ..}
> and have all methods in this class being invoked under a transaction
> with Required semantics
>
> or annotate a specific method
> @transactional(type=RequiresNew) def foo { ..}
> to get the same behavior for a method only
>
> Annotations is the way most JEE devs are used to handle these things
> since it is the approach both Spring, Guice, EJB 3 etc. etc. has
> taken.
>
I use this all the time in java, because there is no other "good" option for
transactions in java. It's basically the best method. However I don't
believe this is the case in Scala, and I'd rather think through the options
and determine the best one.
>
> The stuff I have written allow using AspectJ pointcuts as well.
> E.g. f.e. apply transactions to all methods in the service layer:
> match('* com.biz.service.*(..)')
>
> Or to a specific method:
> match('void Store.buy(Item)')
>
Point-cuts after-the fact seem a decent use of transactions. This is under
the following assumptions:
1) Your code will be used in more than one configuration type
2) Your transaction granularity is determined by the configuration of your
"module", not by the module itself.
Regarding 2, I think all-to-often real world problems begin to break this
assumption, making internal business logic and external transaction
configuration dependent on each other.
>
> But you could just use call-by-name:
>
> transactional(TransactionType.Required) { // tx begin
> .. // do stuff in TX
> } // tx commit or rollback
>
> But that pollutes the code, makes it harder to change, configure and
> is not declarative.
> Perhaps give the user options?
>
How is it not declarative? I agree that Aspects really do give you better
configuration abilities for code, however I'm not sure transactions are
ideally suited for AOP. I think Java is not ideally suited for
transactional code, so we use AOP.
I'd love to hear your response! This is something I've been mulling through
recently, and I'm still on the fence for "Transactions should be done using
AOP on the JVM"
-Josh
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Lift" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---