Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: RES: [aspectj-users] thisJoinPointStaticPart & warning



Andre,

You might like to pick up a copy of Eclipse AspectJ
(http://www.awprofessional.com/title/0321245873) and read Chapter 11. Here
is an extract showing the SystemArchitecture aspect which describes the
structure of the Simple Insurance application:

public aspect SystemArchitecture {

      public pointcut uiCall() :
            call(* insurance.ui..*(..)) ||
            call(insurance.ui..new(..));

      public pointcut modelCall() :
            (call(* insurance.model..*(..)) ||
            call(insurance.model..new(..)))
            && !javaLangObjectCall();

      public pointcut modelImplCall() :
            call(* insurance.model.impl..*(..)) ||
            call(insurance.model.impl..new(..));

      ...

      public pointcut inUI() : within(insurance.ui.*);
      public pointcut inModel() : within(insurance.model.*);
      public pointcut inModelImpl() : within(insurance.model.impl.*);

      ...
}

And the PermittedComponentInteractions aspect which polices dependencies
between them:

public aspect PermittedComponentInteractions {

      declare warning : SystemArchitecture.uiCall() &&
                  !SystemArchitecture.inUI()
            : "No calls into the user interface";

      declare warning : SystemArchitecture.modelImplCall() &&
                  !SystemArchitecture.inModelImpl()
            : "Please use interfaces in insurance.model instead";
      ...
}

Enjoy!

Matthew Webster
AOSD Project
Java Technology Centre, MP146
IBM Hursley Park, Winchester,  SO21 2JN, England
Telephone: +44 196 2816139 (external) 246139 (internal)
Email: Matthew Webster/UK/IBM @ IBMGB, matthew_webster@xxxxxxxxxx
http://w3.hursley.ibm.com/~websterm/

André Dantas Rocha <ad-rocha@xxxxxxxxxx>@eclipse.org on 21/01/2005 14:07:29

Please respond to aspectj-users@xxxxxxxxxxx

Sent by:    aspectj-users-admin@xxxxxxxxxxx


To:    <aspectj-users@xxxxxxxxxxx>
cc:
Subject:    RES: [aspectj-users] thisJoinPointStaticPart & warning


Wes,

 I'm trying to check dependences between classes:

 pointcut pc() : call(* *.*(..)) && !call(* MyClass.*(..)) ;

 before() : pc() {
   String callerType =
 thisJoinPointStaticPart.getSourceLocation().getWithinType().getName();
   System.out.println("MyClass depends on '" + callerType);
 }

 I would like to inform dependences statically, using declare warning...

 André


 De: aspectj-users-admin@xxxxxxxxxxx
 [mailto:aspectj-users-admin@xxxxxxxxxxx] Em nome de Wes Isberg
 Enviada em: sábado, 15 de janeiro de 2005 23:38
 Para: aspectj-users@xxxxxxxxxxx
 Assunto: Re: [aspectj-users] thisJoinPointStaticPart & warning

 Would you make a case why it should and how it could?

 Wes

 ------------Original Message------------
 From: André Dantas Rocha <ad-rocha@xxxxxxxxxx>
 To: aspectj-users@xxxxxxxxxxx
 Date: Sat, Jan-15-2005 12:46 PM
 Subject: [aspectj-users] thisJoinPointStaticPart & warning
 Hi,

 Why it's not possible to use thisJoinPointStaticPart in "declare warning"
 ?

 Thanks,

 André



Back to the top