Skip to main content

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 16:24
Eclipse UserFriend
Originally posted by:

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:

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?



public aspect HttpServletMonitor {

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

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

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

public HttpServletMonitor(){ }




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

<aspect name="HttpServletMonitor"/>


<weaver options="-verbose -XlazyTjp">

<include within="HWServlet"/>


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

Current Time: Sun Jun 24 09:38:01 GMT 2018

Powered by FUDForum. Page generated in 0.01949 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top