Using @PostConstruct, interceptors and Seam 2.2.1.CR2
kragoth Oct 19, 2010 12:27 AMOK, let me preface this by saying the code I am about to put in this post worked FINE in Seam 2.0.1 - CR1.
My problem is this. I have an interceptor that intercepts all my Seam beans on the @PostConstruct event. See Code below.
@Interceptor(stateless = true) public class GekkoSeamLifecycleInterceptor extends AbstractInterceptor { @PostConstruct public void postConstruct(InvocationContext invocation) throws Exception { //NOPMD Logger log = LogManager.getLogger(this.getClass().getSimpleName() + "." + getLogCategory(invocation.getTarget())); if (invocation.getTarget() instanceof AbstractSeamComponent) { AbstractSeamComponent abstractSeamComponent = ((AbstractSeamComponent)invocation.getTarget()); abstractSeamComponent.setConversationId( Conversation.instance().getId()); } log.debug("Seam Bean of type: " + invocation.getTarget().getClass().getCanonicalName() + " has been created. In conversation: " + Conversation.instance().getId()); } @Override public Object aroundInvoke(InvocationContext ic) throws Exception { //NOPMD return ic.proceed(); } @Override public boolean isInterceptorEnabled() { return true; } ...other bits and pieces that are not relevant. }
Today I tried to update to Seam 2.2.1.CR2 and things have not gone well. The PostConstruct method does not work anymore! Why doesn't the PostConstruct annotated method get invoked? I've been trying for the best part of a day using google and just trying random combinations of changes to get something to happen but, no luck.
I'll just show how I use the interceptor and hope that someone else has had this problem and solved it.
I have my own annotation:
@Target(TYPE) @Retention(RUNTIME) @Inherited @Interceptors(GekkoSeamLifecycleInterceptor.class) public @interface LifecycleInterceptor {}
which is used the superclass of all my Seam beans.
@SpringAutowirable @ExceptionInterceptor @LifecycleInterceptor public class AbstractSeamComponent implements Serializable {
This was working perfectly fine in Seam 2.0.1. If anyone knows how to get this going again that would be great. Or, is it a known issue with this version of Seam?