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

Yes, combining within{code}(..) and call(..) is a good way to say, 
"don't make these calls from here!"  The same is true for
combinations with handler(..), set(..), and get(..).

This is one of many good reasons to read Eclipse AspectJ.

There are also samples on point on the AspectJ web site.  Go to the 
documentation page and click the samples link. e.g.,

http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/aspectj-home/sample-code.html#declares-inoculated-validExceptionHandlingMethod

If you want to contribute samples, just email them to the list.

Thanks -
Wes

> ------------Original Message------------
> From: Matthew Webster <matthew_webster@xxxxxxxxxx>
> To: aspectj-users@xxxxxxxxxxx
> Date: Fri, Jan-21-2005 6:41 AM
> Subject: 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Ã
> 
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> http://dev.eclipse.org/mailman/listinfo/aspectj-users
>