Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Intercept filter method

I am new to aspectj and enounter a problem when trying to apply aspectj to
the web environment. My problem is that I need to use TapestryFilter and
want to add some more behaviour whilst tomcat execute doFilter method.
However, I notice that TapestryFilter.doFilter is marked as final so there
is no way to extend/ subclass it. Therefore, I try to use around()  advice
to bypass the method as the suggestion in
http://www.nabble.com/How-to-delete-a-method-td22550934.html

void around() : execution(* MyClass.finalize()) {
  ... no proceed() here
}

So I create a class where it contains the following code:

	pointcut interceptor(ServletRequest request, ServletResponse response,
FilterChain filterChain) : execution(*
org.apache.tapestry5.TapestryFilter.doFilter(ServletRequest,
ServletResponse, FilterChain) throws IOException, ServletException) &&
args(request, response, filterChain);

	void around(ServletRequest request, ServletResponse response, FilterChain
filterChain) : interceptor(request, response, filterChain) {

System.out.println("============> TapestryFilterInterceptor.aj test aspectj
...");
// proceed();
	}


What I expect is when filter gets called in the web environment (client
accesses the url from browser), the log should print information e.g.
TapestryFilterInterceptor.java test aspectj ...

Unfortunately, it seems the log doesn't show anything related to this
message. 

So my question is - is this the right way to use advice if I want to add
more code in the doFilter() method using aspectj? Or what is the right way
to do such task?

Thanks in advice.

I appreciate any suggestion.




-- 
View this message in context: http://www.nabble.com/Intercept-filter-method-tp25268794p25268794.html
Sent from the AspectJ - users mailing list archive at Nabble.com.



Back to the top