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


Java CdiContainer.shutdown方法代码示例

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


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

示例1: applyAfterFeatureConfig

import org.apache.deltaspike.cdise.api.CdiContainer; //导入方法依赖的package包/类
void applyAfterFeatureConfig() {
    ProjectStageProducer.setProjectStage(previousProjectStage);
    previousProjectStage = null;

    CdiContainer container = CdiContainerLoader.getCdiContainer();

    stopStartedScopes(container);

    if (this.containerStarted) {
        if (isStopContainerAllowed()) {
            shutdownExternalContainers();

            container.shutdown(); //stop the container on the same level which started it
            containerStarted = false;
        }
    }
}
 
开发者ID:database-rider,项目名称:database-rider,代码行数:18,代码来源:CdiCucumberTestRunner.java

示例2: 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

示例3: shouldWork

import org.apache.deltaspike.cdise.api.CdiContainer; //导入方法依赖的package包/类
@Test
public void shouldWork() {
    // this will give you a CdiContainer for Weld or OWB, depending on the jar you added
    CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();

// now we gonna boot the CDI container. This will trigger the classpath scan, etc
    cdiContainer.boot();

    // and finally we like to start all built-in contexts
    cdiContainer.getContextControl().startContexts();

    // No specific JBoss Weld or Open Web Beans included in the test code

    // finally we gonna stop the container
    cdiContainer.shutdown();
}
 
开发者ID:peterpilgrim,项目名称:javaee7-developer-handbook,代码行数:17,代码来源:ExampleCdiContainerTest.java

示例4: applyAfterClassConfig

import org.apache.deltaspike.cdise.api.CdiContainer; //导入方法依赖的package包/类
void applyAfterClassConfig()
{
    CdiContainer container = CdiContainerLoader.getCdiContainer();

    stopStartedScopes(container);

    if (this.containerStarted)
    {
        if (CdiTestSuiteRunner.isStopContainerAllowed())
        {
            shutdownExternalContainers();

            container.shutdown(); //stop the container on the same level which started it
            CdiTestSuiteRunner.setContainerStarted(false);
        }
    }
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:18,代码来源:CdiTestRunner.java

示例5: 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

示例6: 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

示例7: testBootRequest

import org.apache.deltaspike.cdise.api.CdiContainer; //导入方法依赖的package包/类
@Test
public void testBootRequest() throws Exception
{
    CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
    cdiContainer.boot();
    cdiContainer.getContextControl().startContexts();
    int port = createServer();
    testRead(port);

    try
    {
        shutdown();
    }
    finally
    {
        cdiContainer.shutdown(); //also calls #stopContexts
    }
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:19,代码来源:EmbeddedServletContainer.java

示例8: testContainerBoot

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

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

    BeanManager bm = cc.getBeanManager();
    Assert.assertNotNull(bm);
    
    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);

    Assert.assertNotNull(carRepair.getCar());
    Assert.assertNotNull(carRepair.getCar().getUser());

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

示例9: basicInjection

import org.apache.deltaspike.cdise.api.CdiContainer; //导入方法依赖的package包/类
@Test
public void basicInjection() // useless because of tcks but nice to have when working on this specific container
{
    final CdiContainer container = CdiContainerLoader.getCdiContainer();
    container.boot();

    try
    {
        final BeanManager beanManager = container.getBeanManager();
        assertEquals("foo", Foo.class.cast(beanManager.getReference(beanManager.resolve(beanManager.getBeans(Foo.class)), Foo.class, null)).name());
    }
    finally
    {
        container.shutdown();
    }
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:17,代码来源:OpenEJbContainerControlConfigurationTest.java

示例10: run

import org.apache.deltaspike.cdise.api.CdiContainer; //导入方法依赖的package包/类
@Override
public void run(RunNotifier notifier)
{
    if (this.testSuiteClass == null)
    {
        throw new IllegalStateException("no test-suite class found");
    }

    CdiContainer container = CdiContainerLoader.getCdiContainer();

    if (!containerStarted)
    {
        container.boot(getTestContainerConfig());
        containerStarted = true;
    }

    notifier.addListener(new LogRunListener());

    try
    {
        super.run(notifier);
    }
    finally
    {
        if (STOP_CONTAINER)
        {
            container.shutdown();
            containerStarted = false;
        }
    }
}
 
开发者ID:apache,项目名称:deltaspike,代码行数:32,代码来源:CdiTestSuiteRunner.java

示例11: destroy

import org.apache.deltaspike.cdise.api.CdiContainer; //导入方法依赖的package包/类
static void destroy(CdiContainer cdiContainer) {
    cdiContainer.getContextControl().stopContext(ApplicationScoped.class);
    cdiContainer.shutdown();
}
 
开发者ID:shamoh,项目名称:standalone-javax-mvc,代码行数:5,代码来源:Main.java

示例12: main

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

   cdiContainer.shutdown();
}
 
开发者ID:apache,项目名称:activemq-artemis,代码行数:7,代码来源:CDIExample.java

示例13: stop

import org.apache.deltaspike.cdise.api.CdiContainer; //导入方法依赖的package包/类
@Override
public void stop(final CdiContainer cdiContainer) {
    cdiContainer.getContextControl().stopContexts();
    cdiContainer.shutdown();
}
 
开发者ID:apache,项目名称:incubator-batchee,代码行数:6,代码来源:CdiCtrlLifecycle.java

示例14: 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

示例15: testRestartContexts

import org.apache.deltaspike.cdise.api.CdiContainer; //导入方法依赖的package包/类
/**
 * Stops and starts: application-, session- and request-scope.
 * <p/>
 * application-scoped instance has a ref to
 * request-scoped instance which has a ref to
 * session-scoped instance.
 * <p/>
 * If the deepest ref has the expected value, all levels in between were resetted correctly.
 */
@Test
public void testRestartContexts()
{
    CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
    Assert.assertNotNull(cdiContainer);

    cdiContainer.boot();
    cdiContainer.getContextControl().startContexts();

    BeanManager beanManager = cdiContainer.getBeanManager();
    Assert.assertNotNull(beanManager);

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

    CarRepair carRepair = (CarRepair)
        beanManager.getReference(bean, CarRepair.class, beanManager.createCreationalContext(bean));

    Assert.assertNotNull(carRepair);

    Car car = carRepair.getCar();

    Assert.assertNotNull(car);
    Assert.assertNotNull(car.getUser());


    carRepair.getCar().getUser().setName("tester");
    Assert.assertEquals("tester", car.getUser().getName());

    Assert.assertFalse(CarRepair.isPreDestroyCalled());
    Assert.assertFalse(Car.isPreDestroyCalled());
    Assert.assertFalse(TestUser.isPreDestroyCalled());

    cdiContainer.getContextControl().stopContexts();

    Assert.assertTrue(CarRepair.isPreDestroyCalled());
    Assert.assertTrue(Car.isPreDestroyCalled());
    Assert.assertTrue(TestUser.isPreDestroyCalled());

    try
    {
        car.getUser();

        // accessing the car should have triggered a ContextNotActiveException
        Assert.fail();
    }
    catch (ContextNotActiveException e)
    {
        //do nothing - exception expected
    }

    cdiContainer.getContextControl().startContexts();

    carRepair = (CarRepair)
        beanManager.getReference(bean, CarRepair.class, beanManager.createCreationalContext(bean));

    Assert.assertNotNull(carRepair.getCar());
    Assert.assertNotNull(carRepair.getCar().getUser());
    Assert.assertNull(carRepair.getCar().getUser().getName());

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


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