-
1. Re: Intercepting Seam components/Support for AspectJ
jacob.orshalick Nov 20, 2007 2:31 PM (in response to b.reeve)Maybe it was snipped from the code but I do not see the RetentionPolicy. Try the following:
@Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Interceptors(LoggingInterceptor.class) public @interface Logging {}
-
2. Re: Intercepting Seam components/Support for AspectJ
b.reeve Nov 20, 2007 6:31 PM (in response to b.reeve)Hi Jacob,
Thanks for the reply. I tried it that way and it worked.
I had few doubts too.
1. Is there a way to intercept just the methods and not the class.
2. Is there any way to collectively configure a set of classes or pattern in the interceptor as we do with Spring. (So that we dont have to modify the seam component at all)
Thanks in advance... -
3. Re: Intercepting Seam components/Support for AspectJ
jacob.orshalick Nov 20, 2007 8:05 PM (in response to b.reeve)"b.reeve" wrote:
1. Is there a way to intercept just the methods and not the class.
Seam does not support method level interceptors, but you can always place the interceptor at the class level and use a method-level annotation to define the method(s) that should be intercepted. I provide an example of this on my blog (in the second half of the posting):
http://solutionsfit.com/blog/2007/11/09/thoughts-on-webbeans-and-stereotypes/
If this is not appealing you could use regexes on the InvocationContext to achieve the same results (i.e. if method being invoked matches pattern, run interceptor code)."b.reeve" wrote:
2. Is there any way to collectively configure a set of classes or pattern in the interceptor as we do with Spring. (So that we dont have to modify the seam component at all)
You can do this type of thing through an EJB interceptor and configure it in your ejb-jar.xml, but to my knowledge pattern matching is not directly supported by Seam interceptors. The direction of Web Beans (http://jcp.org/en/jsr/detail?id=299 submitted based on Seam) covers this case through the use of stereotypes. In the blog-posting above I describe how to achieve stereotypes with Seam which is an option for collective configuration. Hope that helps. -
4. Re: Intercepting Seam components/Support for AspectJ
b.reeve Nov 26, 2007 4:02 PM (in response to b.reeve)Thank you Jacob for the solution.
I tired implementing the method-level annotation as explained in your blog. It totally works.
But still it needs to be configured from the component perspective.
I dont have EJB's in my application. So using the EJB interceptor for configuring the pattern matching interception is not viable for me. I will look more into Stereotypes.
InvocationContext regex seems to be a good option. Could you please point me to some sample code for implementing the regex on InvocationContext.
Thanks ! -
5. Re: Intercepting Seam components/Support for AspectJ
jacob.orshalick Nov 26, 2007 8:24 PM (in response to b.reeve)You can retrieve the method name by calling getMethod() on the InvocationContext. The method name can be used for pattern matching. Pattern and Matcher provided by the java.util.regex library will do the trick. This library is provided with your Java distribution. There are a variety of available tutorials on this library. Hope that helps.
-
6. Re: Intercepting Seam components/Support for AspectJ
b.reeve Nov 28, 2007 1:27 PM (in response to b.reeve)Thank you for the briefing... it really helped.
Is it possible to annotate just the super interface and its concrete implementations will be intercepted. (I dont want to annotate all my classes for logging interception)
Is there any drawbacks in using this kind of interception for logging purpose? ( i think that AspectJ would have been a best choice if Seam had any support for it)
Would there be any performance hit in using seam interception as opposed to normal logging.
Thanks!