当前位置: 首页>>代码示例>>Java>>正文


Java ContextControl类代码示例

本文整理汇总了Java中org.apache.deltaspike.cdise.api.ContextControl的典型用法代码示例。如果您正苦于以下问题:Java ContextControl类的具体用法?Java ContextControl怎么用?Java ContextControl使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ContextControl类属于org.apache.deltaspike.cdise.api包,在下文中一共展示了ContextControl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.apache.deltaspike.cdise.api.ContextControl; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
	final CdiContainer container = CdiContainerLoader.getCdiContainer();
	try {
		container.boot();

        ContextControl contextControl = container.getContextControl();
        contextControl.startContext(ApplicationScoped.class);

		Quickstart quickstart = CDI.current().select(Quickstart.class).get();
		quickstart.run();
	} catch (Exception e) {
		e.printStackTrace();
	} finally {
		container.shutdown();
		System.out.println("Shutting down...");
		System.exit(0);
	}
}
 
开发者ID:kamaladafrica,项目名称:axon-cdi-quickstart,代码行数:19,代码来源:Main.java

示例2: startRequestScope

import org.apache.deltaspike.cdise.api.ContextControl; //导入依赖的package包/类
@AroundInvoke
public Object startRequestScope(final InvocationContext ctx) throws Exception {
    Object result = null;
    ContextControl contextControl = null;
    if(!isRequestScopeActive()) {
        contextControl = CDI.current().select(ContextControl.class).get();
        contextControl.startContext(RequestScoped.class);
    }
    try {
        result = ctx.proceed();
    }
    finally {
        if(contextControl != null) {
            contextControl.stopContext(RequestScoped.class);
        }
    }
    return result;
}
 
开发者ID:johnament,项目名称:restful-and-beyond-tut2184,代码行数:19,代码来源:RequestScopeInterceptor.java

示例3: testRequestScopedBeanPerformance

import org.apache.deltaspike.cdise.api.ContextControl; //导入依赖的package包/类
@Test(priority = 3)
public void testRequestScopedBeanPerformance() throws InterruptedException
{
    final SimpleRequestScopedBeanWithoutInterceptor underTest = getInstance(cdiContainer.getBeanManager(), SimpleRequestScopedBeanWithoutInterceptor.class);
    final ContextControl contextControl = cdiContainer.getContextControl();
    contextControl.startContext(RequestScoped.class);
    Assert.assertEquals(underTest.theMeaningOfLife(), 42);
    contextControl.stopContext(RequestScoped.class);

    executeInParallel("invocation on @RequestScoped bean", new Runnable()
    {

        @Override
        public void run()
        {
            contextControl.startContext(RequestScoped.class);
            for (int i = 0; i < NUM_ITERATION; i++)
            {
                // this line does the actual bean invocation.
                underTest.theMeaningOfLife();
            }
            contextControl.stopContext(RequestScoped.class);
        }
    });
}
 
开发者ID:struberg,项目名称:cdi-performance,代码行数:26,代码来源:CdiPerformanceTest.java

示例4: setUp

import org.apache.deltaspike.cdise.api.ContextControl; //导入依赖的package包/类
@Before
public final void setUp() throws Exception {
    System.out.printf("AbstractCdiContainerTest#setUp() containerRefCount=%d, cdiContainer=%s\n", containerRefCount.get(), cdiContainer );

    if ( cdiContainer != null ) {
        containerRefCount.incrementAndGet();

        final ContextControl ctxCtrl = BeanProvider.getContextualReference(ContextControl.class);

        //stop the RequestContext to dispose of the @RequestScoped EntityManager
        ctxCtrl.stopContext(RequestScoped.class);

        //immediately restart the context again
        ctxCtrl.startContext(RequestScoped.class);

        // perform injection into the very own test class
        final BeanManager beanManager = cdiContainer.getBeanManager();
        final CreationalContext creationalContext = beanManager.createCreationalContext(null);

        final AnnotatedType annotatedType = beanManager.createAnnotatedType(this.getClass());
        final InjectionTarget injectionTarget = beanManager.createInjectionTarget(annotatedType);
        injectionTarget.inject(this, creationalContext);
    }
}
 
开发者ID:peterpilgrim,项目名称:javaee7-developer-handbook,代码行数:25,代码来源:AbstractCdiContainerTest.java

示例5: tearDown

import org.apache.deltaspike.cdise.api.ContextControl; //导入依赖的package包/类
@After
    public final void tearDown() throws Exception {
        System.out.printf("AbstractCdiContainerTest#tearDown() containerRefCount=%d, cdiContainer=%s\n", containerRefCount.get(), cdiContainer );
        if (cdiContainer != null) {
            final ContextControl ctxCtrl = BeanProvider.getContextualReference(ContextControl.class);

            //stop the RequestContext to dispose of the @RequestScoped EntityManager
            ctxCtrl.stopContext(RequestScoped.class);

            //immediately restart the context again
            ctxCtrl.startContext(RequestScoped.class);

//            cdiContainer.getContextControl().stopContext(RequestScoped.class);
//            cdiContainer.getContextControl().startContext(RequestScoped.class);
            containerRefCount.decrementAndGet();
        }
    }
 
开发者ID:peterpilgrim,项目名称:javaee7-developer-handbook,代码行数:18,代码来源:AbstractCdiContainerTest.java

示例6: main

import org.apache.deltaspike.cdise.api.ContextControl; //导入依赖的package包/类
public static void main(String[] args) throws InterruptedException
{
    CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
    cdiContainer.boot();

    ContextControl contextControl = cdiContainer.getContextControl();
    contextControl.startContext(ApplicationScoped.class);

    GlobalResultHolder globalResultHolder =
        BeanProvider.getContextualReference(GlobalResultHolder.class);

    while (globalResultHolder.getCount() < 100)
    {
        Thread.sleep(500);
        LOG.info("current count: " + globalResultHolder.getCount());
    }
    LOG.info("completed!");

    contextControl.stopContext(ApplicationScoped.class);
    cdiContainer.shutdown();
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:22,代码来源:SimpleSchedulerExample.java

示例7: main

import org.apache.deltaspike.cdise.api.ContextControl; //导入依赖的package包/类
public static void main(String[] args)
{
    CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
    cdiContainer.boot();

    ContextControl contextControl = cdiContainer.getContextControl();
    contextControl.startContext(ApplicationScoped.class);

    SettingsBean settingsBean = BeanProvider.getContextualReference(SettingsBean.class, false);

    LOG.info("configured int-value #1: " + settingsBean.getIntProperty1());
    LOG.info("configured long-value #2: " + settingsBean.getProperty2());
    LOG.info("configured inverse-value #2: " + settingsBean.getInverseProperty());
    LOG.info("configured location (custom config): " + settingsBean.getLocationId().name());
    
    cdiContainer.shutdown();
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:18,代码来源:ConfigExample.java

示例8: requestInitialized

import org.apache.deltaspike.cdise.api.ContextControl; //导入依赖的package包/类
@Override
public void requestInitialized(ServletRequestEvent servletRequestEvent)
{
    LOG.log(Level.FINER,"Incoming request.");
    ContextControl contextControl = getContextControl();
    servletRequestEvent.getServletRequest().setAttribute(CDI_REQ_CONTEXT, contextControl);
    contextControl.startContext(RequestScoped.class);
}
 
开发者ID:johnament,项目名称:restful-and-beyond-tut2184,代码行数:9,代码来源:RequestScopedServletRequestListener.java

示例9: testCreateEmployee

import org.apache.deltaspike.cdise.api.ContextControl; //导入依赖的package包/类
@Test
public void testCreateEmployee() {
    ContextControl contextControl = CDI.current().select(ContextControl.class).get();
    contextControl.startContext(RequestScoped.class);
    Employees e = new Employees();
    e.setFirstName("Bob");
    e.setLastName("Hope");
    EntityManager em = CDI.current().select(EntityManager.class).get();
    Employees e2 = em.merge(e);
    System.out.println("Employee id :"+e2.getId());
    contextControl.stopContext(RequestScoped.class);
}
 
开发者ID:johnament,项目名称:restful-and-beyond-tut2184,代码行数:13,代码来源:JPALongTest.java

示例10: postStart

import org.apache.deltaspike.cdise.api.ContextControl; //导入依赖的package包/类
@Override
public void postStart() {
    final ContextControl contextControl = this.container.getContextControl();
    contextControl.startContext(ApplicationScoped.class);
    contextControl.startContext(SessionScoped.class);
    contextControl.startContext(RequestScoped.class);
}
 
开发者ID:qjafcunuas,项目名称:jbromo,代码行数:8,代码来源:DeltaSpikeCdiContainer.java

示例11: preStop

import org.apache.deltaspike.cdise.api.ContextControl; //导入依赖的package包/类
@Override
public void preStop() {
    final ContextControl contextControl = this.container.getContextControl();
    contextControl.stopContext(RequestScoped.class);
    contextControl.stopContext(SessionScoped.class);
    contextControl.stopContext(ApplicationScoped.class);
}
 
开发者ID:qjafcunuas,项目名称:jbromo,代码行数:8,代码来源:DeltaSpikeCdiContainer.java

示例12: startContainer

import org.apache.deltaspike.cdise.api.ContextControl; //导入依赖的package包/类
protected void startContainer()
{
    CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
    cdiContainer.boot();
    ContextControl contextControl = cdiContainer.getContextControl();
    contextControl.startContext(ApplicationScoped.class);
    contextControl.startContext(SessionScoped.class);
    contextControl.startContext(RequestScoped.class);
}
 
开发者ID:HotswapProjects,项目名称:HotswapAgent,代码行数:10,代码来源:HAAbstractUnitTest.java

示例13: startContexts

import org.apache.deltaspike.cdise.api.ContextControl; //导入依赖的package包/类
public void startContexts(Scheduled scheduled)
{
    Collections.addAll(this.scopes, scheduled.startScopes());

    if (!this.scopes.isEmpty())
    {
        this.contextControl = BeanProvider.getDependent(ContextControl.class);

        for (Class<? extends Annotation> scopeAnnotation : this.scopes)
        {
            contextControl.get().startContext(scopeAnnotation);
        }
    }
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:15,代码来源:AbstractQuartzScheduler.java

示例14: getContextControlForDeployment

import org.apache.deltaspike.cdise.api.ContextControl; //导入依赖的package包/类
public static JavaArchive getContextControlForDeployment()
{
    JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "cdi-control.jar")
            .addClass(ContextControl.class);

    if (CdiContainerUnderTest.is("owb"))
    {
        jar.addPackage("org.apache.deltaspike.cdise.owb");
    }
    return jar;
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:12,代码来源:ArchiveUtils.java

示例15: requestDestroyed

import org.apache.deltaspike.cdise.api.ContextControl; //导入依赖的package包/类
@Override
public void requestDestroyed(ServletRequestEvent servletRequestEvent)
{
    LOG.log(Level.FINER,"Request done.");
    ContextControl contextControl = (ContextControl)servletRequestEvent.getServletRequest()
            .getAttribute(CDI_REQ_CONTEXT);
    contextControl.stopContext(RequestScoped.class);
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:9,代码来源:CdiServletRequestListener.java


注:本文中的org.apache.deltaspike.cdise.api.ContextControl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。