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


Java CdiContainer.getContextControl方法代码示例

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


在下文中一共展示了CdiContainer.getContextControl方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import org.apache.deltaspike.cdise.api.CdiContainer; //导入方法依赖的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: main

import org.apache.deltaspike.cdise.api.CdiContainer; //导入方法依赖的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

示例3: main

import org.apache.deltaspike.cdise.api.CdiContainer; //导入方法依赖的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

示例4: ContextControlWrapper

import org.apache.deltaspike.cdise.api.CdiContainer; //导入方法依赖的package包/类
private ContextControlWrapper() {
    final CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
    if (!isCdiContainerBooted(cdiContainer)) {
        LOG.info("booting cdi container");
        long start = System.currentTimeMillis();
        cdiContainer.boot();
        long end = System.currentTimeMillis();
        LOG.info("booting cdi container finished in " + (end - start) + " ms");
    }
    contextControl = cdiContainer.getContextControl();
}
 
开发者ID:guhilling,项目名称:cdi-test,代码行数:12,代码来源:ContextControlWrapper.java

示例5: startContainer

import org.apache.deltaspike.cdise.api.CdiContainer; //导入方法依赖的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

示例6: startScopes

import org.apache.deltaspike.cdise.api.CdiContainer; //导入方法依赖的package包/类
private void startScopes(CdiContainer container,
                         Class testClass,
                         Method testMethod,
                         Class<? extends Annotation>... restrictedScopes) {

    ContextControl contextControl = container.getContextControl();

    List<Class<? extends Annotation>> scopeClasses = new ArrayList<Class<? extends Annotation>>();

    Collections.addAll(scopeClasses, this.testControl.startScopes());

    if (scopeClasses.isEmpty()) {
        addScopesForDefaultBehavior(scopeClasses);
    } else {
        List<TestControlValidator> testControlValidatorList =
                ServiceUtils.loadServiceImplementations(TestControlValidator.class);

        for (TestControlValidator testControlValidator : testControlValidatorList) {
            if (testControlValidator instanceof TestAware) {
                if (testMethod != null) {
                    ((TestAware) testControlValidator).setTestMethod(testMethod);
                }
                ((TestAware) testControlValidator).setTestClass(testClass);
            }
            try {
                testControlValidator.validate(this.testControl);
            } finally {
                if (testControlValidator instanceof TestAware) {
                    ((TestAware) testControlValidator).setTestClass(null);
                    ((TestAware) testControlValidator).setTestMethod(null);
                }
            }
        }
    }

    for (Class<? extends Annotation> scopeAnnotation : scopeClasses) {
        if (this.parent != null && this.parent.isScopeStarted(scopeAnnotation)) {
            continue;
        }

        if (isRestrictedScope(scopeAnnotation, restrictedScopes)) {
            continue;
        }

        try {
            //force a clean context - TODO discuss onScopeStopped call
            contextControl.stopContext(scopeAnnotation);

            contextControl.startContext(scopeAnnotation);
            this.startedScopes.add(scopeAnnotation);

            onScopeStarted(scopeAnnotation);
        } catch (RuntimeException e) {
            Logger logger = Logger.getLogger(CdiCucumberTestRunner.class.getName());
            logger.setLevel(Level.SEVERE);
            logger.log(Level.SEVERE, "failed to start scope @" + scopeAnnotation.getName(), e);
        }
    }

}
 
开发者ID:database-rider,项目名称:database-rider,代码行数:61,代码来源:CdiCucumberTestRunner.java

示例7: requestDestroyed

import org.apache.deltaspike.cdise.api.CdiContainer; //导入方法依赖的package包/类
@Override
public void requestDestroyed(ServletRequestEvent servletRequestEvent) {
    CdiContainer container = CdiContainerLoader.getCdiContainer();
    ContextControl contextControl = container.getContextControl();
    contextControl.stopContext(RequestScoped.class);
}
 
开发者ID:johnament,项目名称:microservices-tutorial,代码行数:7,代码来源:CDIListener.java

示例8: requestInitialized

import org.apache.deltaspike.cdise.api.CdiContainer; //导入方法依赖的package包/类
@Override
public void requestInitialized(ServletRequestEvent servletRequestEvent) {
    CdiContainer container = CdiContainerLoader.getCdiContainer();
    ContextControl contextControl = container.getContextControl();
    contextControl.startContext(RequestScoped.class);
}
 
开发者ID:johnament,项目名称:microservices-tutorial,代码行数:7,代码来源:CDIListener.java

示例9: getContextControl

import org.apache.deltaspike.cdise.api.CdiContainer; //导入方法依赖的package包/类
private ContextControl getContextControl()
{
    CdiContainer container = CdiContainerLoader.getCdiContainer();
    return container.getContextControl();
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:6,代码来源:CdiServletRequestListener.java

示例10: testParallelThreadExecution

import org.apache.deltaspike.cdise.api.CdiContainer; //导入方法依赖的package包/类
@Test
public void testParallelThreadExecution() throws Exception
{
    final CdiContainer cc = CdiContainerLoader.getCdiContainer();
    Assert.assertNotNull(cc);

    cc.boot();
    cc.getContextControl().startContexts();

    final BeanManager bm = cc.getBeanManager();
    Assert.assertNotNull(bm);

    final AtomicInteger numErrors = new AtomicInteger(0);
    final ContextControl contextControl = cc.getContextControl();

    Runnable runnable = new Runnable()
    {
        @Override
        public void run()
        {
            try
            {
                contextControl.startContext(SessionScoped.class);
                contextControl.startContext(RequestScoped.class);


                Set<Bean<?>> beans = bm.getBeans(CarRepair.class);
                Bean<?> bean = bm.resolve(beans);

                CarRepair carRepair = (CarRepair)
                        bm.getReference(bean, CarRepair.class, bm.createCreationalContext(bean));
                Assert.assertNotNull(carRepair);

                for (int i = 0; i < 100000; i++)
                {
                    // we need the threads doing something ;)
                    Assert.assertNotNull(carRepair.getCar());
                    Assert.assertNotNull(carRepair.getCar().getUser());
                    Assert.assertNull(carRepair.getCar().getUser().getName());
                }
                contextControl.stopContext(RequestScoped.class);
                contextControl.stopContext(SessionScoped.class);
            }
            catch (Throwable e)
            {
                log.log(Level.SEVERE, "An exception happened on a new worker thread", e);
                numErrors.incrementAndGet();
            }
        }
    };


    Thread[] threads = new Thread[NUM_THREADS];
    for (int i = 0 ; i < NUM_THREADS; i++)
    {
        threads[i] = new Thread(runnable);
    }

    for (int i = 0 ; i < NUM_THREADS; i++)
    {
        threads[i].start();
    }

    for (int i = 0 ; i < NUM_THREADS; i++)
    {
        threads[i].join();
    }

    Assert.assertEquals("An error happened while executing parallel threads", 0, numErrors.get());


    cc.shutdown();
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:74,代码来源:ContainerCtrlTckTest.java


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