[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-dev] RE: [aspectj-users] Call Join points

The version that uses DataContracts.*.*(..) does not work because this 
will match any type in a package DataContracts (AspectJ expects a type 
pattern in this position), but DataContracts.ACCOUNT_ACTIONS is not a type 
- it's a the name of a public field. The version that Ramnivas proposes I 
would expect to work. I created a simple replica of your project and tried 
all of:

call( * AccountActionsData.*(..))
call(* *(..)) && target(AccountActionsData)  // also matches the toString 
call
call(* *(..)) && target(aad) && if (aad == DataContracts.ACCOUNT_ACTIONS) 
// only matches for the ACCOUNT_ACTIONS instance

which all worked for me as expected.

Here is my source code:

package abc;

public class Driver {

    public static void main(String[] args) {
      DataContracts.ACCOUNT_ACTIONS.boo();
      DataContracts.ACCOUNT_ACTIONS.toString();
    }

}

=============

package abc;

public interface DataContracts {

    public static AccountActionsData ACCOUNT_ACTIONS = 
        new AccountActionsData();
 
}

=============

package abc;

public class AccountActionsData {
 
    public void boo() {}

}

=============

package abc;

public aspect ExceptionHandling {

    pointcut exceptionHandling(AccountActionsData aad) :
        call(* *(..)) && target(aad) && if(aad == 
DataContracts.ACCOUNT_ACTIONS);
 
    Object around() : exceptionHandling(AccountActionsData) {
        System.out.println("handling " + thisJoinPoint);
        try {
            return proceed();
        } catch (Exception ex) {
            return null;
        }
    }
 
}

=============

when I run this I get the output:

handling call(void abc.AccountActionsData.boo())
handling call(String java.lang.Object.toString())


So I guess that leads to 2 questions:
* does my source code work in your environment?, and
* can you think of any difference between my example and yours that could 
be causing the failure to match?

I'm travelling again today and will be offline again for the next few 
hours...

-- Adrian
Adrian_Colyer@xxxxxxxxxx



"DiFrango, Ron" <ron.difrango@xxxxxxxxxxxxxx> 
Sent by: aspectj-dev-bounces@xxxxxxxxxxx
09/05/2005 12:14
Please respond to
AspectJ developer discussions <aspectj-dev@xxxxxxxxxxx>


To
"AspectJ developer discussions" <aspectj-dev@xxxxxxxxxxx>
cc

Subject
[aspectj-dev] RE: [aspectj-users] Call Join points






Can one of the developers look into the situation below and let me know
if this is a bug or if it is something that I am doing wrong?

Thanks in advance,

Ron

-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx
[mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of DiFrango, Ron
Sent: Thursday, May 05, 2005 8:12 AM
To: aspectj-users@xxxxxxxxxxx
Subject: RE: [aspectj-users] Call Join points


Thanks for the suggestion, but that does not work either.  Actually,
neither of those approaches work for some reason.  I think we need one
of the developers to comment on why this might be happening.

-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx
[mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Ramnivas Laddad
Sent: Wednesday, May 04, 2005 11:22 PM
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] Call Join points


Ron,

I think your pointcut should be like the following:
    pointcut exceptionHandlingInsertion() :
        call(* AccountActionsData.*(..));

    Or if you want to apply to only ACCOUNT_ACTIONS instances:

     pointcut exceptionHandlingInsertion(AccountActionsData aad) :
        call(* AccountActionsData.*(..)) && target(aad) && if(aad == 
DataContracts.ACCOUNT_ACTIONS) ;

-Ramnivas

===
Ramnivas Laddad,
Author, AspectJ in Action
http://ramnivas.com
M: (408)203-4621



DiFrango, Ron wrote:

>Okay, I have a situation that I can not figure out.  I have the
>following interface declared:
>
>
>public interface DataContracts
>{
>    /**
>     *  Constant for the <code>AccountActionsData</code> interface(s).
>     */
>    public static AccountActionsData ACCOUNT_ACTIONS =
>        AccountActionsDataService.getDataInstance();
>}
>
>What I want to do is pick out any calls to the
>DataContracts.ACCOUNT_ACTIONS so I created the following aspect:
>
>public aspect ExceptionHandlerInsertion {
>                pointcut exceptionHandlingInsertion() :
>                                call(* DataContracts.*.*(..));
> 
>                Object around() : exceptionHandlingInsertion()
>                {
>                                try
>                                {
>                                                return proceed();
>                                }
>                                catch(Exception e)
>                                {
>                                                return null;
>                                }
>                }
>}
>
>The only thing is that it does not pick out any calls such as the
>following:
>
>
>DataContracts.ACCOUNT_ACTIONS.update("Aspectj");
>
>Any thoughts on how I can make this work?
>
>Thanks in advance,
>
>Ron
>_______________________________________________
>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
_______________________________________________
aspectj-dev mailing list
aspectj-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-dev