Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Annotation PointCut Advisor, and Transaction Advice in CVS
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Mark Mandel  
View profile  
 More options Mar 4 2009, 6:29 pm
From: Mark Mandel <mark.man...@gmail.com>
Date: Thu, 5 Mar 2009 10:29:21 +1100
Local: Wed, Mar 4 2009 6:29 pm
Subject: Annotation PointCut Advisor, and Transaction Advice in CVS
Hey guys,

I've committed a couple of enhancements to ColdSpring CVS that may be
useful to you all.

The first is PointCutAdvisor that uses annotations (extra meta data on
cffunction), to specify where you want to use Advice.

Example usage:

<cffunction name="loginUser" hint="logs in a user" access="public"
returntype="boolean" output="false" transaction="true">
       <cfargument name="username" hint="the username" type="string"
required="Yes">
       <cfargument name="password" hint="the password" type="string"
required="Yes">

      //stuff
</cffunction>

Where 'transaction' is the annotation.

To configure the annotation, there is a <map> passed into the
AnnotationPointCutAdvisor, with key-value pairs for the annotation to
look for, and the value it should have.

       <!-- User Service -->
       <bean id="UserService" class="coldspring.aop.framework.ProxyFactoryBean">
               <property name="target">
                       <ref bean="UserServiceTarget"/>
               </property>
               <property name="interceptorNames">
                       <list>
                               <value>TransactionAdvisor</value>
                       </list>
               </property>
       </bean>

       <!-- AOP Classes -->
       <bean id="TransactionAdvice" class="model.java.cs.TransactionAdvice"/>

       <bean id="TransactionAdvisor"
class="coldspring.aop.support.AnnotationPointCutAdvisor">
               <property name="advice">
                       <ref bean="TransactionAdvice" />
               </property>
               <property name="annotations">
                       <map>
                               <entry key="transaction">
                                       <value>true</value>
                               </entry>
                       </map>
               </property>
       </bean>

To map to any value of the annotation (or really just check that it is
there), you can use the wildcard '*' as

     <bean id="TransactionAdvisor"
class="coldspring.aop.support.AnnotationPointCutAdvisor">
             <property name="advice">
                     <ref bean="TransactionAdvice" />
             </property>
             <property name="annotations">
                     <map>
                             <entry key="transaction">
                                     <value>*</value>
                             </entry>
                     </map>
             </property>
     </bean>

The second is a Transaction Advice, that is nestable - i.e. if a
Transaction Advised method calls another Transaction Advised method,
the inner one will be escaped, and will be merged into the Outer
transaction.

You can apply the Transaction advice as per normal (I like it with the
AnnoationPointCutAdvisor myself), and can be configured as such:

       <bean id="TransactionAdvice"
class="coldspring.aop.advice.SimpleTransactionAdvice"/>

Let me know if you run into any issues.

Mark

--
E: mark.man...@gmail.com
W: www.compoundtheory.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter J. Farrell  
View profile  
 More options Mar 4 2009, 6:38 pm
From: "Peter J. Farrell" <pe...@mach-ii.com>
Date: Wed, 04 Mar 2009 17:38:12 -0600
Local: Wed, Mar 4 2009 6:38 pm
Subject: Re: [coldspring-users] Annotation PointCut Advisor, and Transaction Advice in CVS
Thanks for the enhancement Mark.  Definitely looks promising.  Wondering
if you add support to namespace the annotations (configurable).  
Something like:

<bean id="TransactionAdvisor"
class="coldspring.aop.support.AnnotationPointCutAdvisor">
   <property name="advice">
      <ref bean="TransactionAdvice" />
   </property>
   <property name="annotations">
      <map>
         <entry key="transaction">
            <value>true</value>
         </entry>
      </map>
   </property>
   <property name="namespacePrefix"><value>cs</value></property>
</bean>

And then the method would look something like this:

<cffunction name="loginUser" access="public" returntype="boolean"
output="false" cs:transaction="true">

This way it's a lot easier to see that the annotation belongs to
ColdSpring and not part of some magic CFML stuff. Thoughts?

Best,
Peter

Mark Mandel said the following on 3/4/2009 5:29 PM:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tony Nelson  
View profile  
 More options Mar 5 2009, 10:47 am
From: Tony Nelson <tonynelso...@gmail.com>
Date: Thu, 5 Mar 2009 07:47:25 -0800 (PST)
Local: Thurs, Mar 5 2009 10:47 am
Subject: Re: Annotation PointCut Advisor, and Transaction Advice in CVS
Couldn't you simply set your annotation to <entry
key="cs:transaction">?

-Tony

On Mar 4, 5:38 pm, "Peter J. Farrell" <pe...@mach-ii.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mark Mandel  
View profile  
 More options Mar 5 2009, 7:36 pm
From: Mark Mandel <mark.man...@gmail.com>
Date: Fri, 6 Mar 2009 11:36:07 +1100
Local: Thurs, Mar 5 2009 7:36 pm
Subject: Re: [coldspring-users] Re: Annotation PointCut Advisor, and Transaction Advice in CVS
I suppose it depends if you feel that annotations should come from
*somewhere*, or if they should be just markers, that could be used by
anyone.

Regardless, I just committed a bug fix to the
AnnotationPointCutAdvisor... it was returning a match on ALL methods
in a CFC, if only 1 method in that cfc had the annotation, which was
pretty silly.

Mark

--
E: mark.man...@gmail.com
W: www.compoundtheory.com

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »