I have just developed an Interceptor that will log @WebMethod calls on a 
@WebService annotated @Stateless EJB. I have noticed that if I don't implement 
a @Remote interface on my @Stateless session bean, the interceptor is not 
invoked on any of the @WebMethods. But I can still call the webservice 
correctly. If I do implement the @Remote interface, the interceptor works 
correctly with the webservice interface.

Why?

Here are some short class samples (taken from the O'Reilly EJB3.0 book):

@WebService(name = "TravelAgent", serviceName="TravelAgentService")
@Stateless
@SOAPBinding(style=Style.RPC)

// ***
// Comment the following line out and the calls to the
// TravelAgentInterceptor.class in the @Interceptors list
// are never invoked and no failure message is reported
// There is no difference in the behaviour between @Remote
// or "implements TravelAgentRemote" either.
// ***

// @Remote(TravelAgentRemote.class)  

public class TravelAgentBean
{
    @PersistenceContext(unitName="titan") private EntityManager manager;
        
    @Interceptors(TravelAgentInterceptor.class)
    @WebMethod
    public void createCabin(@WebParam(name="Cabin")Cabin cabin)
    {
        manager.persist(cabin);
    }
}


@Remote
public interface TravelAgentRemote
{
    public void createCabin(Cabin cabin);
}

public class TravelAgentInterceptor
{
        @AroundInvoke
        public Object intercept(InvocationContext invocationContext) throws 
Exception
        {
                System.out.println(invocationContext.getMethod().getName() + " 
called.");
                return invocationContext.proceed();
        }
}

Any help would be much appreciated. I am hoping to avoid having to define 
Remote interfaces that are exact copies of the methods on my stateless 
webservice session beans. The @WebService annotation provides an "endpoint 
interface" so that I don't have to implement the @Remote interface? Is that 
correct?

Thanks!


View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3953595#3953595

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3953595

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to