[jboss-user] [JBoss AOP] - problem with jboss loadtime weaving
Moslem
do-not-reply at jboss.com
Tue May 20 06:17:55 EDT 2008
Hello !
i am trying to do an example of aspect oriented application on jboss 4 , i wrot a servlet called HelloWorldServlet.java , an aspect Trial.java witch access and write on a file when the service mathode of the servelt is called, Anno.java wich is the annotation that i used to do the weaving
here are the source codes:
Anno.java:
package aspe.src.an;
public @interface Anno {
}
Trial.java:
import org.jboss.aop.joinpoint.Invocation;
import java.io.*;
public class Trial{
public Object affiche (Invocation invocation)
throws Throwable {
try
{
FileWriter fw =new FileWriter("a.txt");
BufferedWriter bw= new BufferedWriter(fw);
PrintWriter pw= new PrintWriter(bw);
pw.print("hellloooooo");
pw.close();
}
catch(IOException e){
}
return invocation.invokeNext();
}
}
HelloWorldServlet.java:
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class HelloWorldServlet extends HttpServlet
{
@aspe.src.an.Anno protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
ServletOutputStream out = response.getOutputStream();
out.println("<h1>Hello World!</h1>");
}
}
then i v puted trial.class and Anno.class on a jar file aspect.jar
and i v created
jboss-aop.xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
aop
aspect class="Trial"
scope="PER_VM"/
bind pointcut="call(* *->@aspe.src.an.Anno(..))"
advice name="filew"
aspect="Trial"/>
/bind
/aop
i puted aspect.jar and jboss-aop.xml on the deploy folder
then i lunched the servlet , hello world apear on my browser but the file a.txt stay empty so the weaving did not happend i forgot to say that i seted the enableloadtimeweaving atribute to true but as i saed nothing happend only the servlet works so please helpe me i am waiting for ur
respons
thank u in advance.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4151948#4151948
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4151948
More information about the jboss-user
mailing list