Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Why would one ever want to use Load Time Weaving?

I know I must be testing your patience here. I have this simple aspect, which
purpose is to customize the toString() output of a type belong to a third
party library:
===========================
package com.shunra.poc;

import javax.ws.rs.core.Response;

import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

@Aspect
public class ResponseToStringAspect {
  @Pointcut("!within(com.shunra.poc.ResponseToStringAspect) &&
!within(com.shunra.poc.logging.LoggerAspect) &&"
      + " call(public String toString()) && target(o)")
  void toString(Response o) {
  }

  @Around("toString(o)")
  public String responseToString(Response o) {
    Object entity = o.getEntity();
    return entity == null ? "null" : entity.toString();
  }
}
===========================

I am trying to understand, how to replace this compile-time aspect, which
replaces Response.toString() invocations issued from my own code to an
equivalent load-time aspect, which would instrument the method itself,
rather than calls to it. 

Specifically, what are the steps to do it in Eclipse?

Thank you very much.

--
View this message in context: http://aspectj.2085585.n4.nabble.com/Why-would-one-ever-want-to-use-Load-Time-Weaving-tp4181328p4194579.html
Sent from the AspectJ - users mailing list archive at Nabble.com.


Back to the top