[jboss-user] [EJB3] - Problem with @Interceptors on generic bean methods, JBAS7

Christoph Albrecht do-not-reply at jboss.com
Sat May 12 05:19:30 EDT 2012


Christoph Albrecht [https://community.jboss.org/people/calb] created the discussion

"Problem with @Interceptors on generic bean methods, JBAS7"

To view the discussion, visit: https://community.jboss.org/message/735187#735187

--------------------------------------------------------------
Hello all,

Migrating my application from JBoss 4.2.3-GA to JBoss 7.1.1-Final I stumpled upon following issue. 
What is working fine for me with JB-4.2.3 does not with JB-7.1.1.

I want an interceptor be triggered on a stateless session bean method that is an implementation of a generic superinterface method declaration.

@Stateless
@Remote(TestBeanService.class)
public class TestBean implements TestBeanService {
    
 
    @Interceptors(TestInterceptor.class)
    public void simpleFoo() {
        System.out.println("doing simple foo");
    }
 
 
    @Override
    @Interceptors(TestInterceptor.class)
    public void genericFoo(SomeClass entity) {
        System.out.println("doing generic foo");
    }
 
}
 
 
//====================================================
 
public interface TestBeanService extends GenericService<SomeClass> {
    
    public void simpleFoo();
    
}
 
 
//====================================================
 
public interface GenericService<T> {
 
    public void genericFoo(T entity);
}
 
//====================================================
 
 
public class TestInterceptor {
 
    @AroundInvoke
    public Object intercept(InvocationContext invocation) throws Exception {
 
        try {
            System.out.println("intercepting method invocation: " + invocation.getMethod());
            Object object = invocation.proceed();
            return object;
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
}


If the genericFoo() method is called from a client the invocation is not being intercepted on JB-7.1.1 (on JB-4.2.3 it is). The simpleFoo() method invocation is intercepted without problems.

The only way I found making genericFoo() be intercepted on JB-7.1.1 is either to declare the @Interceptors(TestInterceptor.class) annotation on top of the bean class (on the cost of making every method in the bean class be intercepted):

@Stateless
@Remote(TestBeanService.class)
@Interceptors(TestInterceptor.class) 
public class TestBean implements TestBeanService {
 //...
}


The other way around is to add an extra genericFoo() method declaration in the TestBeanService interface, what I was expecting should be unnecessary:

public interface TestBeanService extends GenericService<SomeClass> {
    
    public void simpleFoo();
 
    public void genericFoo(SomeClass entity);
    
}


Don't know, is this an known/new issue with JBoss (EJB) or am I missing something?

 https://issues.jboss.org/browse/EJBTHREE-2231 https://issues.jboss.org/browse/EJBTHREE-2231

 https://issues.jboss.org/browse/EJBTHREE-471 https://issues.jboss.org/browse/EJBTHREE-471

 https://community.jboss.org/message/557649#557649 https://community.jboss.org/message/557649#557649

Regards
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/735187#735187]

Start a new discussion in EJB3 at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2029]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120512/b52b8e5e/attachment-0001.html 


More information about the jboss-user mailing list