1 Reply Latest reply on Nov 19, 2008 11:03 AM by flavia.rainone

    jboss as and aop

    moslem

      Hi all!
      i developed a java servlet and i tried to triger an aspect when executing it .

      the proposed servlet is very simple it just print a "hello world" messege .
      The aspect should write on a file a string
      i am using jboss as and all the depolyemnt steps are done seccessufly

      The servlet shows the message but the aspect is not trigred.

      ***servlet***

      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>");
      }
      }

      ****aspect****
      import org.jboss.aop.joinpoint.Invocation;
      import java.io.*;

      public class Trial{

      public Object affiche (Invocation invocation)
      throws Throwable {

      try
      {
      FileWriter fw =new FileWriter("C:\\Users\\Moslem\\test\\a.txt");
      BufferedWriter bw= new BufferedWriter(fw);
      PrintWriter pw= new PrintWriter(bw);
      pw.print("sdqsdqsdqsqdqdqsdq");
      pw.close();
      }
      catch(IOException e){
      }


      return invocation.invokeNext();

      }
      }

      ***** jBoss_aop.xml****
      <?xml version="1.0" encoding="UTF-8" standalone="yes"?>








      ***annotation****

      package aspe.src.an;

      public @interface Anno {

      }


      i hope someone can help me , thx !