[jboss-user] [JBoss AOP] - jboss as and aop

Moslem do-not-reply at jboss.com
Sun Nov 16 09:18:37 EST 2008


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 ! 




View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4189669#4189669

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4189669



More information about the jboss-user mailing list