Java 类javax.enterprise.context.ConversationScoped 实例源码

项目:wicket-quickstart-cdi-async    文件:WorkflowBean.java   
/**
 * Does actually not work
 */
@Override
@Asynchronous
public void startAsynchronous(final IWorkflowListener listener)
{
    try
    {
        CdiContextAwareRunnable runnable = new CdiContextAwareRunnable(this.newWorkflowRunnable(listener));
        // runnable.addContext(RequestScoped.class);
        runnable.addContext(SessionScoped.class);
        // runnable.addContext(ApplicationScoped.class);
        runnable.addContext(ConversationScoped.class);

        runnable.run();
    }
    catch (WorkflowException e)
    {
        LOG.error(e.getMessage(), e);
    }
}
项目:tomee    文件:BeanContext.java   
public boolean isPassivatingScope() {
    final CdiEjbBean<?> bean = get(CdiEjbBean.class);
    if (bean == null) {
        return true;
    }

    if (ConversationScoped.class == bean.getScope()) {
        try {
            return !bean.getWebBeansContext().getConversationManager().getConversationBeanReference().isTransient();
        } catch (final RuntimeException re) { // conversation not found for instance so act as @RequestScoped
            return false;
        }
    }

    return true;
}
项目:tomee    文件:StatefulConversationScopedTOMEE1138Test.java   
@Before
public void startConversation() {
    final WebBeansContext webBeansContext = WebBeansContext.currentInstance();
    webBeansContext.registerService(ConversationService.class, new ConversationService() {
        @Override
        public String getConversationId() {
            return "conversation-test";
        }

        @Override
        public String generateConversationId() {
            return "cid_1";
        }
    });
    webBeansContext.getService(ContextsService.class).startContext(ConversationScoped.class, null);
}
项目:deltaspike    文件:ContextControlDecorator.java   
@Override
public void startContexts()
{
    wrapped.startContexts();

    if (isManualScopeHandling())
    {
        for (ExternalContainer externalContainer : CdiTestRunner.getActiveExternalContainers())
        {
            externalContainer.startScope(Singleton.class);
            externalContainer.startScope(ApplicationScoped.class);
            externalContainer.startScope(RequestScoped.class);
            externalContainer.startScope(SessionScoped.class);
            externalContainer.startScope(ConversationScoped.class);
        }
    }
}
项目:deltaspike    文件:ContextControlDecorator.java   
@Override
public void stopContexts()
{
    if (isManualScopeHandling())
    {
        for (ExternalContainer externalContainer : CdiTestRunner.getActiveExternalContainers())
        {
            externalContainer.stopScope(ConversationScoped.class);
            externalContainer.stopScope(SessionScoped.class);
            externalContainer.stopScope(RequestScoped.class);
            externalContainer.stopScope(ApplicationScoped.class);
            externalContainer.stopScope(Singleton.class);
        }
    }

    wrapped.stopContexts();
}
项目:deltaspike    文件:OpenWebBeansContextControl.java   
@Override
public void startContext(Class<? extends Annotation> scopeClass)
{
    if (scopeClass.isAssignableFrom(ApplicationScoped.class))
    {
        startApplicationScope();
    }
    else if (scopeClass.isAssignableFrom(SessionScoped.class))
    {
        startSessionScope();
    }
    else if (scopeClass.isAssignableFrom(RequestScoped.class))
    {
        startRequestScope();
    }
    else if (scopeClass.isAssignableFrom(ConversationScoped.class))
    {
        startConversationScope();
    }
}
项目:deltaspike    文件:OpenWebBeansContextControl.java   
public void stopContext(Class<? extends Annotation> scopeClass)
{
    if (scopeClass.isAssignableFrom(ApplicationScoped.class))
    {
        stopApplicationScope();
    }
    else if (scopeClass.isAssignableFrom(SessionScoped.class))
    {
        stopSessionScope();
    }
    else if (scopeClass.isAssignableFrom(RequestScoped.class))
    {
        stopRequestScope();
    }
    else if (scopeClass.isAssignableFrom(ConversationScoped.class))
    {
        stopConversationScope();
    }
}
项目:deltaspike    文件:WeldContextControl.java   
@Override
public void startContext(Class<? extends Annotation> scopeClass)
{
    if (scopeClass.isAssignableFrom(ApplicationScoped.class))
    {
        startApplicationScope();
    }
    else if (scopeClass.isAssignableFrom(SessionScoped.class))
    {
        startSessionScope();
    }
    else if (scopeClass.isAssignableFrom(RequestScoped.class))
    {
        startRequestScope();
    }
    else if (scopeClass.isAssignableFrom(ConversationScoped.class))
    {
        startConversationScope(null);
    }
}
项目:deltaspike    文件:WeldContextControl.java   
@Override
public void stopContext(Class<? extends Annotation> scopeClass)
{
    if (scopeClass.isAssignableFrom(ApplicationScoped.class))
    {
        stopApplicationScope();
    }
    else if (scopeClass.isAssignableFrom(SessionScoped.class))
    {
        stopSessionScope();
    }
    else if (scopeClass.isAssignableFrom(RequestScoped.class))
    {
        stopRequestScope();
    }
    else if (scopeClass.isAssignableFrom(ConversationScoped.class))
    {
        stopConversationScope();
    }
}
项目:microprofile-rest-client    文件:HasConversationScopeTest.java   
@Deployment
public static WebArchive createDeployment() {
    String url = SimpleGetApi.class.getName() + "/mp-rest/url=http://localhost:8080";
    String url2 = MyConversationScopedApi.class.getName() + "/mp-rest/url=http://localhost:8080";
    String scope = SimpleGetApi.class.getName() + "/mp-rest/scope=" + ConversationScoped.class.getName();
    JavaArchive jar = ShrinkWrap.create(JavaArchive.class)
        .addClasses(SimpleGetApi.class, MyConversationScopedApi.class)
        .addAsManifestResource(new StringAsset(url + "\n" + scope + "\n" + url2), "microprofile-config.properties")
        .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
    return ShrinkWrap.create(WebArchive.class)
        .addAsLibrary(jar)
        .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}
项目:joinfaces    文件:CdiScopeAnnotationsAutoConfiguration.java   
@Bean
@ConditionalOnProperty(value = "jsf.scope-configurer.cdi.enabled", havingValue = "true", matchIfMissing = true)
public static BeanFactoryPostProcessor cdiScopeAnnotationsConfigurer(Environment environment) {
    CustomScopeAnnotationConfigurer scopeAnnotationConfigurer = new CustomScopeAnnotationConfigurer();

    scopeAnnotationConfigurer.setOrder(environment.getProperty("jsf.scope-configurer.cdi.order", Integer.class, Ordered.LOWEST_PRECEDENCE));

    scopeAnnotationConfigurer.addMapping(RequestScoped.class, WebApplicationContext.SCOPE_REQUEST);
    scopeAnnotationConfigurer.addMapping(SessionScoped.class, WebApplicationContext.SCOPE_SESSION);
    scopeAnnotationConfigurer.addMapping(ConversationScoped.class, WebApplicationContext.SCOPE_SESSION);
    scopeAnnotationConfigurer.addMapping(ApplicationScoped.class, WebApplicationContext.SCOPE_APPLICATION);

    return scopeAnnotationConfigurer;
}
项目:parco    文件:EntityManagerProducer.java   
@ExtensionManaged
@Produces
@ConversationScoped
public EntityManager produce() 
{
     EntityManager entityManager = entityManagerFactory.createEntityManager();
     // .. do somthing with entity manager
     return entityManager;

}
项目:Tank    文件:EntityManagerProducer.java   
@Produces
@ConversationScoped
@PersistenceUnit
@Default
public EntityManagerFactory getEntityManagerFactory() {
    return emf;
}
项目:smartcommunication    文件:EntityManagerProducer.java   
@Produces
@Main
@ConversationScoped
public EntityManager create()
{
    return this.emfA.createEntityManager();
}
项目:actionbazaar    文件:ItemController.java   
/**
 * Produces the selected item for the current context
 * @return 
 */
@Produces @SelectedItem @Named("selectedItem") @ConversationScoped
public Item getCurrentItem() {
    if(item == null) {
        item = new Item();
    }
    return item;
}
项目:actionbazaar    文件:BidController.java   
/**
 * Returns the current bid
 * @return current bid
 */
@Produces @CurrentBid @Named("currentBid") @ConversationScoped
public Bid getCurrentBid() {
    Bid bid = new Bid();
    if(user instanceof BazaarAccount) {
        bid.setBidder((BazaarAccount)user);
    } 
    bid.setItem(item);
    return bid;
}
项目:actionbazaar    文件:ItemController.java   
/**
 * Produces the selected item for the current context
 * @return 
 */
@Produces @SelectedItem @Named("selectedItem") @ConversationScoped
public Item getCurrentItem() {
    if(item == null) {
        item = new Item();
    }
    return item;
}
项目:actionbazaar    文件:BidController.java   
/**
 * Returns the current bid
 * @return current bid
 */
@Produces @CurrentBid @Named("currentBid") @ConversationScoped
public Bid getCurrentBid() {
    Bid bid = new Bid();
    if(user instanceof BazaarAccount) {
        bid.setBidder((BazaarAccount)user);
    } 
    bid.setItem(item);
    return bid;
}
项目:actionbazaar    文件:ItemController.java   
/**
 * Produces the selected item for the current context
 * @return 
 */
@Produces @SelectedItem @Named("selectedItem") @ConversationScoped
public Item getCurrentItem() {
    if(item == null) {
        item = new Item();
    }
    return item;
}
项目:actionbazaar    文件:BidController.java   
/**
 * Returns the current bid
 * @return current bid
 */
@Produces @CurrentBid @Named("currentBid") @ConversationScoped
public Bid getCurrentBid() {
    Bid bid = new Bid();
    if(user instanceof BazaarAccount) {
        bid.setBidder((BazaarAccount)user);
    } 
    bid.setItem(item);
    return bid;
}
项目:wicket-quickstart-cdi-async    文件:CdiExecutorBean.java   
protected void submit(Runnable runnable)
{
    CdiContextAwareRunnable contextRunnable = new CdiContextAwareRunnable(runnable);
    contextRunnable.addContext(RequestScoped.class);
    contextRunnable.addContext(SessionScoped.class);
    contextRunnable.addContext(ConversationScoped.class);

    this.service.submit(contextRunnable);
}
项目:appformer    文件:SocialUserServicesExtendedBackEndImplTest.java   
@Test
public void cannotBeAManagedBeanBecauseOfWas() {
    assertNull(getAnnotation(ApplicationScoped.class));
    assertNull(getAnnotation(Dependent.class));
    assertNull(getAnnotation(SessionScoped.class));
    assertNull(getAnnotation(RequestScoped.class));
    assertNull(getAnnotation(ConversationScoped.class));
}
项目:tomee    文件:EmbeddedTomEEContainer.java   
private void startCdiContexts(final String name) {
    final WebBeansContext wbc = this.container.getAppContexts(name).getWebBeansContext();
    if (wbc != null && wbc.getBeanManagerImpl().isInUse()) {
        final MockHttpSession session = new MockHttpSession();
        wbc.getContextsService().startContext(RequestScoped.class, null);
        wbc.getContextsService().startContext(SessionScoped.class, session);
        wbc.getContextsService().startContext(ConversationScoped.class, null);

        SESSIONS.put(name, session);
    }
}
项目:tomee    文件:EmbeddedTomEEContainer.java   
private void stopCdiContexts(final String name) {
    try {
        final HttpSession session = SESSIONS.remove(name);
        if (session != null) {
            final WebBeansContext wbc = container.getAppContexts(container.getInfo(name).appId).getWebBeansContext();
            if (wbc != null && wbc.getBeanManagerImpl().isInUse()) {
                wbc.getContextsService().startContext(RequestScoped.class, null);
                wbc.getContextsService().startContext(SessionScoped.class, session);
                wbc.getContextsService().startContext(ConversationScoped.class, null);
            }
        }
    } catch (final Exception e) {
        // no-op
    }
}
项目:tomee    文件:ScopeHelper.java   
public static void stopContexts(final ContextsService contextsService, final ServletContext servletContext, final HttpSession session) throws Exception {
    contextsService.endContext(SessionScoped.class, session);
    contextsService.endContext(RequestScoped.class, null);
    contextsService.endContext(ConversationScoped.class, null);
    if (CdiAppContextsService.class.isInstance(contextsService)) {
        CdiAppContextsService.class.cast(contextsService).removeThreadLocals();
    }
}
项目:Mastering-Java-EE-Development-with-WildFly    文件:MethodScopedBean.java   
@ConversationScoped
public void setTextConversation(String textConversation) {
    this.textConversation = textConversation;
}
项目:microprofile-rest-client    文件:HasConversationScopeTest.java   
@Test
public void testHasConversationScoped() {
    Set<Bean<?>> beans = beanManager.getBeans(SimpleGetApi.class, RestClient.LITERAL);
    Bean<?> resolved = beanManager.resolve(beans);
    assertEquals(resolved.getScope(), ConversationScoped.class);
}
项目:microprofile-rest-client    文件:HasConversationScopeTest.java   
@Test
public void testHasConversationScopedWhenAnnotated() {
    Set<Bean<?>> beans = beanManager.getBeans(MyConversationScopedApi.class, RestClient.LITERAL);
    Bean<?> resolved = beanManager.resolve(beans);
    assertEquals(resolved.getScope(), ConversationScoped.class);
}
项目:HotswapAgentExamples    文件:EntityManagerProducer.java   
@Produces
@ConversationScoped
public EntityManager create() {
    return emf.createEntityManager();
}
项目:HotswapAgentExamples    文件:EntityManagerProducer.java   
@Produces
@ConversationScoped
public EntityManager create() {
    return emf.createEntityManager();
}
项目:ServisTakip    文件:DataRepositoryProducer.java   
@Produces
@DataRepository
@ConversationScoped
public EntityManager produceEntityManager() {
    return getEntityManagerFactory().createEntityManager();
}
项目:SimplePersistence    文件:EntityManagerProducer.java   
@Produces
@Default
@ConversationScoped
public EntityManager create() {
    return entityManagerFactory.createEntityManager();
}
项目:tomee    文件:ScopeHelper.java   
public static void startContexts(final ContextsService contextsService, final ServletContext servletContext, final HttpSession session) throws Exception {
    contextsService.startContext(SessionScoped.class, session);
    contextsService.startContext(RequestScoped.class, null);
    contextsService.startContext(ConversationScoped.class, null);
}
项目:tomee    文件:OpenEJBLifecycle.java   
@Override
public void stopApplication(final Object endObject) {
    logger.debug("OpenWebBeans Container is stopping.");

    try {
        // Fire shut down
        if (WebappBeanManager.class.isInstance(beanManager)) {
            WebappBeanManager.class.cast(beanManager).beforeStop();
        }

        webBeansContext.getContextsService().endContext(RequestScoped.class, endObject);
        webBeansContext.getContextsService().endContext(ConversationScoped.class, endObject);
        webBeansContext.getContextsService().endContext(SessionScoped.class, endObject);
        webBeansContext.getContextsService().endContext(ApplicationScoped.class, endObject);
        webBeansContext.getContextsService().endContext(Singleton.class, endObject);

        // clean up the EL caches after each request
        ELContextStore elStore = ELContextStore.getInstance(false);
        if (elStore != null)
        {
            elStore.destroyELContextStore();
        }

        this.beanManager.fireEvent(new BeforeShutdownImpl(), true);

        // this will now even destroy the ExtensionBeans and other internal stuff
        this.contextsService.destroy(endObject);

        //Unbind BeanManager
        if (jndiService != null) {
            jndiService.unbind(WebBeansConstants.WEB_BEANS_MANAGER_JNDI_NAME);
        }

        //Free all plugin resources
        ((CdiPlugin) webBeansContext.getPluginLoader().getEjbPlugin()).clearProxies();
        webBeansContext.getPluginLoader().shutDown();

        //Clear extensions
        webBeansContext.getExtensionLoader().clear();

        //Delete Resolutions Cache
        beanManager.getInjectionResolver().clearCaches();

        //Delete AnnotateTypeCache
        webBeansContext.getAnnotatedElementFactory().clear();

        //After Stop
        //Clear the resource injection service
        final ResourceInjectionService injectionServices = webBeansContext.getService(ResourceInjectionService.class);
        if (injectionServices != null) {
            injectionServices.clear();
        }

        //Comment out for commit OWB-502
        //ContextFactory.cleanUpContextFactory();

        CdiAppContextsService.class.cast(contextsService).removeThreadLocals();

        WebBeansFinder.clearInstances(WebBeansUtil.getCurrentClassLoader());

        // Clear BeanManager
        this.beanManager.clear();

        // Clear singleton list
        WebBeansFinder.clearInstances(WebBeansUtil.getCurrentClassLoader());

    } catch (final Exception e) {
        logger.error("An error occured while stopping the container.", e);
    }

}
项目:tomee    文件:StatefulConversationScopedTOMEE1138Test.java   
@After
public void stopConversation() {
    WebBeansContext.currentInstance().getService(ContextsService.class).endContext(ConversationScoped.class, null);
}
项目:deltaspike    文件:OpenWebBeansContextControl.java   
private void startConversationScope()
{
    ContextsService contextsService = getContextsService();

    contextsService.startContext(ConversationScoped.class, null);
}
项目:deltaspike    文件:OpenWebBeansContextControl.java   
private void stopConversationScope()
{
    ContextsService contextsService = getContextsService();

    contextsService.endContext(ConversationScoped.class, null);
}