[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] accessing protected methods in parent class


The "Active.saveErrors()" method is protected which is only visible to
subclasses and types in the same package. You need to make your aspect
"privileged" e.g.

   public privileged aspect MyAspect {

While there is no restriction on the join points a pointcut can match
advice and methods within an aspect are subject to the normal Java
visibility rules. Looking at you snippet you may wish to expose "this"
through the pointcut rather than using a cast:

   public privileged aspect MyAspect {

      pointcut somePointcut (Action action) :

      before (Action action) : somePointcut (action) {


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

"Charles N. Harvey III" <charlieh@xxxxxxxxx>@eclipse.org on 16/11/2004

Please respond to aspectj-users@xxxxxxxxxxx

Sent by:    aspectj-users-admin@xxxxxxxxxxx

To:    aspectj-users@xxxxxxxxxxx
Subject:    [aspectj-users] accessing protected methods in parent class

My aspect cuts into my Struts Action classes.  If there is an error
somewhere I want to be able to do the saveErrors( request, messages );
thing that works out so well in my Action classes.  Thing is,
is protected.  And when I try one of these:

((Action)thisJoinPoint.getThis()).saveErrors( request, errors );

I get the error that "saveErrors()" is not visible.  Which it isn't.
But I thought since my aspect was weaving into a class that extended
Action, I would be able to use that method.

Is this possible?  Is there a way around it?  Thanks a lot.


aspectj-users mailing list