Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] I have changed my logger aspect and not it displays some messages twice, how come?

Hi,

My immediate reaction is that the removal of the scope in the two
sub-aspects and its promotion to the top level aspect is simply
letting both aspects advise some things.  With the second aspect
losing the scope:

ServiceLoggerAspect patch:
==================================================
@@ -6,7 +6,6 @@
  declare @type : com.shunra.poc..*Service : @LogMe;
  declare parents: com.shunra.poc..*Service implements ILoggable;

-  public pointcut loggedScope() : within(com.shunra.poc..*Service);
  public pointcut loggedMethodScope() : withincode(public * *.*(..));
  public pointcut loggedMethods() : execution(public * *.*(..));
 }
=================================================

The loggedMethods() pointcut is pretty open 'execution of any public
methods'.  The new scoping in the super aspect is only limiting it to
@LogMe'd types - so any public methods in @LogMe'd types are going to
get woven.  Perhaps you are thinking the 'declare @type/declare
parents' in the ServiceLoggerAspect are going to scope the rest of the
aspect down to the com.shunra.poc..*Service types?  But that isn't the
case, any type level changes made by one aspect will be seen by other
aspects.  I don't know enough about the UserHandler type - but if it
ends up with an @LogMe on it I would say both aspects are going to
apply to some methods inside it.

Andy

On 17 December 2011 06:19, Mark <mark.kharitonov@xxxxxxxxx> wrote:
> I do not think it matters, but here is the code for the LoggerHolderAspect:
> ========================================================
> package com.shunra.poc.logging;
>
> import org.apache.log4j.LogManager;
> import org.apache.log4j.Logger;
>
> public aspect LoggerHolderAspect pertypewithin(@LogMe *) {
>  private Logger logger;
>  public void initLogger() {
>    logger = LogManager.getLogger(getWithinTypeName());
>  }
>  public Logger getLogger() {
>    return logger;
>  }
> }
> ========================================================
>
> Thank you very much in advance.
>
> --
> View this message in context: http://aspectj.2085585.n4.nabble.com/I-have-changed-my-logger-aspect-and-not-it-displays-some-messages-twice-how-come-tp4202008p4208357.html
> Sent from the AspectJ - users mailing list archive at Nabble.com.
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top