Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Regarding queuing methods using AspectJ

Title: Re: [aspectj-users] Regarding queuing methods using AspectJ
Admittedly, I didn’t read all the details of this post thread; however, accomplishing what I inferred from skimming is very simple indeed.  I have written code that looks exactly like the following and works like a charm (copy/pasted and trivially tweaked it for you).

void around() : execution( @RequireTransaction * *(..) )
{
        if( isTransactionThread() )        {            proceed();        }        else        {            Runnable runnable = new Runnable()            {                public void run()                {                    proceed();                }            };            transactionQueue.add( runnable );        }
}

This allows you to avoid writing any complex pointcuts and place whatever methods you like into the queue by using annotations.  Is this what you were thinking?



From: Matthew Webster <matthew_webster@xxxxxxxxxx>
Reply-To: <aspectj-users@xxxxxxxxxxx>
Date: Wed, 18 Apr 2007 15:07:49 +0100
To: <aspectj-users@xxxxxxxxxxx>
Subject: Re: [aspectj-users] Regarding queuing methods using AspectJ


Sarthak,

How about simply queueing "thisJoinPoint" then use wait() and notify(). The thread running the method that has been queued will then wake up and execute the original method with its context. If required you can use some additional coordination to ensure that each method completes before the next is notified.

Matthew Webster
Tools UI Strategy
CICS Technical Planning & Strategy, MP189
IBM United Kingdom Limited
Hursley Park, Winchester,  SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)


"Sarthak Grover" <sarthak.grover@xxxxxxxxx>
Sent by: aspectj-users-bounces@xxxxxxxxxxx 18/04/2007 03:02

Please respond to
aspectj-users@xxxxxxxxxxx

To

aspectj-users@xxxxxxxxxxx

cc
Subject

[aspectj-users] Regarding queuing methods using AspectJ




Hello all,

What started with as a simple idea is turning out more confusing than
I initially thought (or I am making it that way for myself)

What I am trying to achieve is a transaction queue which is executed
only when a particular method is called.

Currently I have a bunch of pointcuts identifying methods which I want
to capture and prevent execution till the 'trigger' method is called.
So, my pseudo algorithm
was something like this:

In the following, myMethodA, myMethodB are the target methods that I
want to queue and myMethodC is the trigger method.

===================
pointcut A: execution (myMethodA)

void around(): A()
  {
   Add the methodCall(joinpointSignature) to an ArrayList();
// I don't want to proceed with the execution of the method right now
  }

pointcut B: execution (myMethodB)

void around() : B()
  {
  Add the methodCall to the above ArrayList();
  }

pointcut C: execution (myMethodC)

void around(): C()
 {

 Execute myMethodA();
 Execute myMethodB();
 }

===================
I am able to save the method information using reflection, but I am
not sure how to make a call in the advice of myMethodC to execute
myMethodA() and myMethodB() from within the aspect.

Is there some way of saving the state of these methods and then
executing them? Perhaps there is a simpler way and I am just not aware
of it?

I appreciate any ideas or advice in this regards.

Thanks,

Sarthak
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users








Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU









_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Back to the top