Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] access properties from class

Gerado,

The problem you are having without exactly knowing the log4j class is that the method you are trying execute is protected or private.  You need to make you aspect privileged.  

So your declaration whould be:

    public privileged aspect xPatternParser

See the following in the aspectj documentation:

http://www.eclipse.org/aspectj/doc/released/progguide/semantics-aspects.html#aspect-privilege

Ron


-----Original Message-----
From: aspectj-users-bounces@xxxxxxxxxxx on behalf of Gerardo
Sent: Tue 5/9/2006 7:44 PM
To: aspectj-users@xxxxxxxxxxx
Subject: [aspectj-users] access properties from class
 
Hi all,
how can I access properties defined inside a class into which an aspect 
is inserted?
I'm trying to extend the log4j PatternParser so it recognizes custom 
conversion characters,

1:   public aspect xPatternParser {  
2:
3:   void around(PatternParser pp, char c):
4:         all(void finalizeConverter(char))  && target(pp) && args(c)
5:   {
6:       if(c=='i')
7:           pp.addConverter(new IPConverter(formattingInfo)) ;
8:       else
9:           proceed(pp,c) ;
10:   }
11:
12:   private class IPConverter extends PatternConverter {
13:  
14:      IPConverter(FormattingInfo formattingInfo) {
15:         super(formattingInfo);
16:      }
17:
18:      public String convert(LoggingEvent event) {
19:        return event.getIP() ;
20:      }
21:  }
22:       
23:}

in line 7 I tried to access a property and method I know PatternParser 
has but two errors ocurr:

7: [error] The method addConverter(PatternConverter) from the type 
PatternParser is not visible
pp.addConverter(new IPConverter(formattingInfo)) ;
     ^^^^^^^^
7: [error] formattingInfo cannot be resolved
pp.addConverter(new IPConverter(formattingInfo)) ;
                                                        ^^^^^^^^^^

so how can I access properties from the class I'm trying to extend?

regards,
Gerardo


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



Back to the top