Search in sources :

Example 1 with MutableBoundRequest

use of org.jboss.weld.context.bound.MutableBoundRequest in project deltaspike by apache.

the class WeldContextControl method startConversationScope.

void startConversationScope(String cid) {
    RequestContextHolder rcHolder = requestContexts.get();
    if (rcHolder == null) {
        startRequestScope();
        rcHolder = requestContexts.get();
    }
    conversationContext.associate(new MutableBoundRequest(rcHolder.requestMap, sessionMaps.get()));
    conversationContext.activate(cid);
}
Also used : MutableBoundRequest(org.jboss.weld.context.bound.MutableBoundRequest)

Example 2 with MutableBoundRequest

use of org.jboss.weld.context.bound.MutableBoundRequest in project deltaspike by apache.

the class WeldContextControl method stopConversationScope.

void stopConversationScope() {
    RequestContextHolder rcHolder = requestContexts.get();
    if (rcHolder == null) {
        startRequestScope();
        rcHolder = requestContexts.get();
    }
    if (conversationContext.isActive()) {
        conversationContext.invalidate();
        conversationContext.deactivate();
        conversationContext.dissociate(new MutableBoundRequest(rcHolder.getRequestMap(), sessionMaps.get()));
    }
}
Also used : MutableBoundRequest(org.jboss.weld.context.bound.MutableBoundRequest)

Example 3 with MutableBoundRequest

use of org.jboss.weld.context.bound.MutableBoundRequest in project wildfly by wildfly.

the class WeldContextSetup method setup.

@SuppressWarnings("unchecked")
public void setup(Map<String, Object> properties) {
    try {
        final BeanManager manager = (BeanManager) new InitialContext().lookup(STANDARD_BEAN_MANAGER_JNDI_NAME);
        if (manager != null && Container.available()) {
            final Bean<BoundSessionContext> sessionContextBean = (Bean<BoundSessionContext>) manager.resolve(manager.getBeans(BoundSessionContext.class, BoundLiteral.INSTANCE));
            CreationalContext<?> ctx = manager.createCreationalContext(sessionContextBean);
            final BoundSessionContext sessionContext = (BoundSessionContext) manager.getReference(sessionContextBean, BoundSessionContext.class, ctx);
            sessionContext.associate(sessionContexts.get());
            sessionContext.activate();
            final Bean<BoundRequestContext> requestContextBean = (Bean<BoundRequestContext>) manager.resolve(manager.getBeans(BoundRequestContext.class, BoundLiteral.INSTANCE));
            ctx = manager.createCreationalContext(requestContextBean);
            final BoundRequestContext requestContext = (BoundRequestContext) manager.getReference(requestContextBean, BoundRequestContext.class, ctx);
            requestContext.associate(requestContexts.get());
            requestContext.activate();
            final Bean<BoundConversationContext> conversationContextBean = (Bean<BoundConversationContext>) manager.resolve(manager.getBeans(BoundConversationContext.class, BoundLiteral.INSTANCE));
            ctx = manager.createCreationalContext(conversationContextBean);
            final BoundConversationContext conversationContext = (BoundConversationContext) manager.getReference(conversationContextBean, BoundConversationContext.class, ctx);
            BoundRequest request = new MutableBoundRequest(requestContexts.get(), sessionContexts.get());
            boundRequests.set(request);
            conversationContext.associate(request);
            conversationContext.activate();
        }
    } catch (NamingException e) {
        WeldLogger.ROOT_LOGGER.failedToSetupWeldContexts(e);
    }
}
Also used : MutableBoundRequest(org.jboss.weld.context.bound.MutableBoundRequest) BoundSessionContext(org.jboss.weld.context.bound.BoundSessionContext) BoundConversationContext(org.jboss.weld.context.bound.BoundConversationContext) InitialContext(javax.naming.InitialContext) Bean(javax.enterprise.inject.spi.Bean) BoundRequestContext(org.jboss.weld.context.bound.BoundRequestContext) BoundRequest(org.jboss.weld.context.bound.BoundRequest) MutableBoundRequest(org.jboss.weld.context.bound.MutableBoundRequest) NamingException(javax.naming.NamingException) BeanManager(javax.enterprise.inject.spi.BeanManager)

Aggregations

MutableBoundRequest (org.jboss.weld.context.bound.MutableBoundRequest)3 Bean (javax.enterprise.inject.spi.Bean)1 BeanManager (javax.enterprise.inject.spi.BeanManager)1 InitialContext (javax.naming.InitialContext)1 NamingException (javax.naming.NamingException)1 BoundConversationContext (org.jboss.weld.context.bound.BoundConversationContext)1 BoundRequest (org.jboss.weld.context.bound.BoundRequest)1 BoundRequestContext (org.jboss.weld.context.bound.BoundRequestContext)1 BoundSessionContext (org.jboss.weld.context.bound.BoundSessionContext)1