Skip to main content

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

I don't know Tapestry, and perhaps your pointcut doesn't map exactly the
doFilter method which is executed.
Try with a more generic pointcut like :


	pointcut interceptor : execution(*
org.apache.tapestry5.TapestryFilter.doFilter(..) );

	void around() : interceptor {

System.out.println("============> TapestryFilterInterceptor.aj test aspectj
...");
// eventually getArgs and handle them
// proceed();
	}
 
 
Jean-Louis Pasturel


-----Message d'origine-----
De : aspectj-users-bounces@xxxxxxxxxxx
[mailto:aspectj-users-bounces@xxxxxxxxxxx] De la part de neo anderson
Envoyé : jeudi 3 septembre 2009 04:16
À : aspectj-users@xxxxxxxxxxx
Objet : [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.

_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users



*********************************
This message and any attachments (the "message") are confidential and intended solely for the addressees. 
Any unauthorised use or dissemination is prohibited.
Messages are susceptible to alteration. 
France Telecom Group shall not be liable for the message if altered, changed or falsified.
If you are not the intended addressee of this message, please cancel it immediately and inform the sender.
********************************


Back to the top