This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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..
 
Don't get me started about those stupid light bulbs.
 
subject: EJB 3.0 - Interceptors
 
Similar Threads
Interceptors invocation sequence?
Life-Cycle Event Interceptor Method Skipped
Exceptions in lifecycle callback methods (II)
Lifecycle callback interceptor
EJB3 mock questions available now! (Section 2)