aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes EJB 3.0 - Interceptors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "EJB 3.0 - Interceptors" Watch "EJB 3.0 - Interceptors" New topic
Author

EJB 3.0 - Interceptors

Fabian Gutierrez
Greenhorn

Joined: Aug 15, 2004
Posts: 22
The core ejb 3.0 spec in section 12.3.1, reads:

"If an interceptor class itself has superclasses, the interceptor methods defined by the interceptor class�s superclasses are invoked before the interceptor method defined by the interceptor class, most general superclass first."

However, if i have this classes:

public class FatherInterceptor {
@PostConstruct
public void after1(InvocationContext contexto) {
System.out.println("Father:created...");
}
}

public class SonInterceptor extends FatherInterceptor {
@PostConstruct
public void after2(InvocationContext contexto) {
System.out.println("Son:created...");
}
}

@Interceptors(SonInterceptor.class)
public class MyBean implements MyBeanInterface{
...
}

I excepted an output like this:
Father:created...
Son:created...

but it only prints
Father:created...

So...is this the expected behaviour?

ps
i'm using Sun Aplication Server 9


Best regards..

Fabian


SCJP 1.4, SCWCD 1.4, SCBCD 5, SCJD 5
Fabian Gutierrez
Greenhorn

Joined: Aug 15, 2004
Posts: 22
Well, basically, the problem originated because i didn't call the proceed mthod on the InvocationContext, which also works like a chain..

public class FatherInterceptor {
@PostConstruct
public void after1(InvocationContext contexto) {
System.out.println("Father:created...");
try {
contexto.proceed();
} catch (Exception ex) {
...
}
}

}

Best reagards..
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: EJB 3.0 - Interceptors