In a project I'm using the demoiselle-scheduler-quartz component. 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 execution of the task, and deactivates 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 to class org.jboss.weld.context.AbstractManagedContext
:
public abstract class AbstractManagedContext extends AbstractContext implements ManagedContext {
private final ThreadLocal<Boolean> active;
...
}
I do not know if the implementation was intentional or a bug, but is there any way to make RequestContext
thread-safe?
I tried to implement a @Alternative RequestContext
, but it is always injected to br.gov.frameworkdemoiselle.internal.context.TemporaryRequestContextImpl
.
I also tried setting a @Produces RequestContext
method, but it did not work either.