0
In one project I am using the component "Demoiselle-Scheduler-Quartz". In this project several threads are fired and executed concurrently. The "Demoiselle-Scheduler-Quartz" component injects the Demoiselle contexts (Requestcontext, Sessioncontext, Viewcontext, Conversationcontext), activates them, invokes the task execution, and disables them. But sporadically occurs Contextnotactiveexception.
Looking at the Demoiselle source code I noticed the class br.gov.frameworkdemoiselle.internal.context.AbstractCustomContext
:
public abstract class AbstractCustomContext implements CustomContext {
private boolean active;
...
}
and compared with the class org.jboss.weld.context.AbstractManagedContext
:
public abstract class AbstractManagedContext extends AbstractContext implements ManagedContext {
private final ThreadLocal<Boolean> active;
...
}
I don’t know if the implementation was intentional or a bug, but is there any way to make the RequestContext
thread-safe?
I tried to implement a @Alternative RequestContext
, but is always injected with br.gov.frameworkdemoiselle.internal.context.TemporaryRequestContextImpl
.
I also tried to define a method @Produces RequestContext
, but it didn’t work either.
I had already declared my implementation in Beans.xml as you suggested, but it still doesn’t work. I believe that the way Demoiselle-core was implemented prevents the injection of context "alternatives". See:
br.gov.frameworkdemoiselle.internal.context.CustomContextProducer
andbr.gov.frameworkdemoiselle.internal.bootstrap.CustomContextBootstrap
– eugenioflima