The usage will be something like following. *ConnectionCreatorAspect *
becomes context holder for crosscutting concern objects. *SomeOtherAspect *is
your other aspect that needs to look up for connection object.
*public aspect ConnectionCreatorAspect percflow(callPointCut()) {*
* private Connection connection;*
* pointcut callPointCut() : call(* *.foo(..) ); *
* before( ) : callPointCut( ) && !within(ConnectionCreatorAspect +) { *
* // create your connection here and set it to instance variable of
ConnectionCreatorAspect*
* // Since this is percflow association you dun have to clean up
thread local explicitly as it's handled by aspectj behind the scene*
* }*
* public Connection getConnection() { return this.connection; } *
*}*
*public aspect SomeOtherAspect {*
* before( ) : // some pointcuts { *
* ConnectionCreatorAspect.aspectOf().getConnection()*
* }*
*}*
For more information about that, check out aspectj in action book that
explains well about this.
Regards,
Anggiat
On Sun, Feb 22, 2015 at 12:01 PM, Dave Brosius <[email protected]>
wrote:
> However you access them, the ThreadLocal variable should be static,
> otherwise odd things occur when you have multiple instances of the class
> holding the ThreadLocal.
>
> You almost always want to to override the intialValue() method of the
> ThreadLocal class.
>
>
> On 02/21/2015 10:42 PM, Archie Cobbs wrote:
>
> On Sat, Feb 21, 2015 at 6:33 PM, Holger King <[email protected]> wrote:
>
>> So, when using a ThreadLocal you would declare it as "public static" to
>> allow accessing the added connection object in the target code, here the
>> "FSIdmAdaptor"?
>>
>
> That would work. More commonly you make it private and provide access
> via a static method e.g.
>
> public static Connection getCurrentConnection()
> throws IllegalStateException { // if no connection is set in the
> current thread
>
> For lots of examples look at Spring, e.g., TransactionAspectSupport
> <http://grepcode.com/file/repo1.maven.org/maven2/org.springframework/spring-tx/4.1.3.RELEASE/org/springframework/transaction/interceptor/TransactionAspectSupport.java#TransactionAspectSupport>
> .
>
> -Archie
>
> --
> Archie L. Cobbs
>
>
> _______________________________________________
> aspectj-users mailing [email protected]
> To change your delivery options, retrieve your password, or unsubscribe from
> this list, visithttps://dev.eclipse.org/mailman/listinfo/aspectj-users
>
>
>
> _______________________________________________
> aspectj-users mailing list
> [email protected]
> To change your delivery options, retrieve your password, or unsubscribe
> from this list, visit
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>
_______________________________________________
aspectj-users mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from
this list, visit
https://dev.eclipse.org/mailman/listinfo/aspectj-users