本文整理汇总了Java中org.apache.deltaspike.cdise.api.CdiContainerLoader类的典型用法代码示例。如果您正苦于以下问题:Java CdiContainerLoader类的具体用法?Java CdiContainerLoader怎么用?Java CdiContainerLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CdiContainerLoader类属于org.apache.deltaspike.cdise.api包,在下文中一共展示了CdiContainerLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: applyBeforeFeatureConfig
import org.apache.deltaspike.cdise.api.CdiContainerLoader; //导入依赖的package包/类
void applyBeforeFeatureConfig(Class testClass) {
CdiContainer container = CdiContainerLoader.getCdiContainer();
if (!isContainerStarted()) {
container.boot(CdiTestSuiteRunner.getTestContainerConfig());
containerStarted = true;
bootExternalContainers(testClass);
}
List<Class<? extends Annotation>> restrictedScopes = new ArrayList<Class<? extends Annotation>>();
//controlled by the container and not supported by weld:
restrictedScopes.add(ApplicationScoped.class);
restrictedScopes.add(Singleton.class);
if (this.parent == null && this.testControl.getClass().equals(TestControlLiteral.class)) {
//skip scope-handling if @TestControl isn't used explicitly on the test-class -> TODO re-visit it
restrictedScopes.add(RequestScoped.class);
restrictedScopes.add(SessionScoped.class);
}
this.previousProjectStage = ProjectStageProducer.getInstance().getProjectStage();
ProjectStageProducer.setProjectStage(this.projectStage);
startScopes(container, testClass, null, restrictedScopes.toArray(new Class[restrictedScopes.size()]));
}
示例2: applyAfterFeatureConfig
import org.apache.deltaspike.cdise.api.CdiContainerLoader; //导入依赖的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;
}
}
}
示例3: main
import org.apache.deltaspike.cdise.api.CdiContainerLoader; //导入依赖的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);
}
}
示例4: shouldWork
import org.apache.deltaspike.cdise.api.CdiContainerLoader; //导入依赖的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();
}
示例5: applyAfterClassConfig
import org.apache.deltaspike.cdise.api.CdiContainerLoader; //导入依赖的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);
}
}
}
示例6: main
import org.apache.deltaspike.cdise.api.CdiContainerLoader; //导入依赖的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();
}
示例7: main
import org.apache.deltaspike.cdise.api.CdiContainerLoader; //导入依赖的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();
}
示例8: testBootRequest
import org.apache.deltaspike.cdise.api.CdiContainerLoader; //导入依赖的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
}
}
示例9: getRequestScopedBean
import org.apache.deltaspike.cdise.api.CdiContainerLoader; //导入依赖的package包/类
private RequestScopedBean getRequestScopedBean()
{
BeanManager beanManager = CdiContainerLoader.getCdiContainer().getBeanManager();
if (beanManager == null)
{
return null;
}
Set<Bean<?>> beans = beanManager.getBeans(RequestScopedBean.class);
Bean<RequestScopedBean> reqScpdBean = (Bean<RequestScopedBean>) beanManager.resolve(beans);
CreationalContext<RequestScopedBean> reqScpdCC =
beanManager.createCreationalContext(reqScpdBean);
RequestScopedBean instance = (RequestScopedBean)
beanManager.getReference(reqScpdBean, RequestScopedBean.class, reqScpdCC);
return instance;
}
示例10: testContainerBoot
import org.apache.deltaspike.cdise.api.CdiContainerLoader; //导入依赖的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();
}
示例11: basicInjection
import org.apache.deltaspike.cdise.api.CdiContainerLoader; //导入依赖的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();
}
}
示例12: doStart
import org.apache.deltaspike.cdise.api.CdiContainerLoader; //导入依赖的package包/类
protected void doStart() throws Exception {
CdiContainer container = CdiContainerLoader.getCdiContainer();
container.boot();
container.getContextControl().startContexts();
this.cdiContainer = container;
}
示例13: run
import org.apache.deltaspike.cdise.api.CdiContainerLoader; //导入依赖的package包/类
@Override
public void run(RunNotifier runNotifier)
{
CdiContainer container = CdiContainerLoader.getCdiContainer();
if (!containerStarted)
{
container.boot(CdiTestSuiteRunner.getTestContainerConfig());
containerStarted = true;
}
super.run(runNotifier);
}
示例14: start
import org.apache.deltaspike.cdise.api.CdiContainerLoader; //导入依赖的package包/类
public void start() {
CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
cdiContainer.boot();
cdiContainer.getContextControl().startContexts();
registerShutdownHook(cdiContainer);
CDI.current().getBeanManager().fireEvent(new ApplicationStartupEvent());
}
示例15: initCDI
import org.apache.deltaspike.cdise.api.CdiContainerLoader; //导入依赖的package包/类
@BeforeClass
public static void initCDI() {
cdiContainer = CdiContainerLoader.getCdiContainer();
cdiContainer.boot();
contextControl = cdiContainer.getContextControl();
contextControl.startContexts();
}