Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AJDT » load time weaving with existing servlet
load time weaving with existing servlet [message #590300] Wed, 05 October 2005 12:24
Eclipse User
Originally posted by: drinkevich.hotmail.com

I am trying to add an aspect to an existing servlet; where the servlet does
not know about the aspect in advance (i.e. it's already deployed) (Note: I
was able to make this work if I created an eclipse project and put them in
the same project prior to building my war file)

I created a simple Hello World servlet (hwservlet) and deployed that war
file to Tomcat. (5.5 using 1.5)

I then created an aspect HttpServletMonitor to listen to the doGet method.
(code below)

I placed
- HttpServletMonitor.class file in hwservlet\web-inf\classes
- aop.xml in hwservlet\META-INF (file below)
- Added aspectj.jar and aspectjweaver.jar to Tomcat's classpath
-Dclasspath=c:\aspectj1.5\lib\aspectjrt.jar;c:\aspectj1.5\li b\aspectweaver.jar
Added the javaagent parameter to tomcat:
-Djavaagent=c:\aspect1.5\lib\aspectjweaver.jar

I restart Tomcat ... the HelloWorld servlet still works just file but the
aspect is not executed. If I run Tomcat through Eclipse in debug mode, I can
hit a breakpoint in the servlet, but not the aspect.

What have I missed?

Thanks
Debbie

*****

public aspect HttpServletMonitor {

/** Execution of any 'do' Servlet request methods. */
public pointcut monitoredOperation(Object operation) :
execution(void HttpServlet.do*(..)) && this(operation);

/** Advice that records statistics for each monitored operation. */
void around(Object operation) : monitoredOperation(operation) {
String threadId = Thread.currentThread().getName();
proceed(operation);
}

private void writeLog(){
// write a temp file to disk
}

public HttpServletMonitor(){ }
}

***

<aspectj>


<aspects>

<!-- declare existing aspects to the weaver -->

<aspect name="HttpServletMonitor"/>


</aspects>

<weaver options="-verbose -XlazyTjp">

<include within="HWServlet"/>

</weaver>


</aspectj>
Previous Topic:AspectJ project dependent on normal java project
Next Topic:load time weaving with existing servlet
Goto Forum:
  


Current Time: Fri Apr 18 14:28:32 EDT 2014

Powered by FUDForum. Page generated in 0.01633 seconds