[jboss-user] [JBoss Seam] - Intercepting Seam components/Support for AspectJ
b.reeve
do-not-reply at jboss.com
Tue Nov 20 12:27:50 EST 2007
I am working on a Seam project with Facelets and Spring on Tomcat. Enviroment is Seam 2.0.0.CR2, Tomcat 6.0.10, Facelets 1.2, Spring 2.0.
Could anyone please tell me if there is a way to do intercepting on Seam components using AspectJ just as we do with Spring beans? Is there a way to create custom Seam interceptors and configure them for intercepting the Seam components. I dont have EJBs in my project.
Here is what I tried to do
| public class LoggingInterceptor {
| @Logger
| private Log log;
|
| @AroundInvoke
| public Object componentLog(InvocationContext invocation) throws Exception{
| log.info("Logging for component " + invocation.getTarget().getClass().getCanonicalName());
| Object returnType = invocation.proceed();
| log.info("Logging for component " + invocation.getTarget().getClass().getCanonicalName());
| return returnType;
| }
|
| }
|
| @Interceptors(LoggingInterceptor.class)
| public @interface Logging {}
|
|
| @Name("loginBean")
| @Scope(ScopeType.SESSION)
| @Logging
| public class LoginBean {
|
| private String username;
| private String password;
|
| public String login() {
| return loginAction.login(username, password);
| }
|
| public String getUsername() {
| return username;
| }
| public void setUsername(String username) {
| this.username = username;
| }
| public String getPassword() {
| return password;
| }
| public void setPassword(String password) {
| this.password = password;
| }
| }
|
I dont see the interceptor class being called. How do I make the method login() being intercepted? Where do I configure the interceptor class to be instantiated? Is there any sample code that I can refer to.
Thanks in Advance...
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4106492#4106492
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4106492
More information about the jboss-user
mailing list