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


Java WeldContainer类代码示例

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


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

示例1: initWeldContainer

import org.jboss.weld.environment.se.WeldContainer; //导入依赖的package包/类
protected WeldContainer initWeldContainer(Weld weld) {
    // Register mock injection services if needed
    if (!resources.isEmpty()) {
        weld.addServices(new MockResourceInjectionServices(resources));
    }
    if (ejbFactory != null) {
        weld.addServices(new MockEjbInjectionServices(ejbFactory));
    }
    if (persistenceContextFactory != null || persistenceUnitFactory != null) {
        weld.addServices(new MockJpaInjectionServices(persistenceUnitFactory, persistenceContextFactory));
    }
    // Init the container
    container = weld.initialize();
    injectInstances();
    if (extension != null) {
        extension.activateContexts();
    }
    return container;
}
 
开发者ID:weld,项目名称:weld-junit,代码行数:20,代码来源:AbstractWeldInitiator.java

示例2: testCommandDecorator

import org.jboss.weld.environment.se.WeldContainer; //导入依赖的package包/类
@Test
public void testCommandDecorator() {

    try (WeldContainer container = new Weld()
            // Disable discovery completely
            .disableDiscovery()
            // Add command context implementation, decorator is enabled globally/automatically
            .packages(CommandContext.class)
            // Add bean classes manually
            .beanClasses(DummyService.class, IdService.class, TestCommand.class)
            // Add command extension manually so that we don't need to create META-INF/...
            .addExtension(new CommandExtension())
            .initialize()) {

        // Command is a bean - cotext is activated/deactivated by decorator
        container.select(TestCommand.class).get().execute();
    }

}
 
开发者ID:weld,项目名称:command-context-example,代码行数:20,代码来源:CommandDecoratorTest.java

示例3: testCommandDecorator

import org.jboss.weld.environment.se.WeldContainer; //导入依赖的package包/类
@Test
public void testCommandDecorator() {

    try (WeldContainer container = new Weld()
            // Disable discovery completely
            .disableDiscovery()
            // Add command context implementation, decorator is enabled globally/automatically
            .packages(CommandContext.class)
            // Add bean classes manually
            .beanClasses(DummyService.class, IdService.class, TestCommand.class)
            // Add command extension manually so that we don't need to create META-INF/...
            .addExtension(new CommandExtension()).initialize()) {

        // Execute non-CDI bean command - context is activated/deactivated by executor
        CommandExecutor executor = container.select(CommandExecutor.class).get();
        executor.execute(() -> {
            assertEquals(container.select(IdService.class).get().getId(), container.select(IdService.class).get().getId());
        });
    }

}
 
开发者ID:weld,项目名称:command-context-example,代码行数:22,代码来源:CommandExecutorTest.java

示例4: apply

import org.jboss.weld.environment.se.WeldContainer; //导入依赖的package包/类
@Override
public Statement apply(final Statement base, Description description) {
    return new Statement() {

        @Override
        public void evaluate() throws Throwable {
            WeldContainer container = weld.initialize();
            context.setBeanManager(container.getBeanManager());
            try {
                base.evaluate();
            } finally {
                container.shutdown();
                context.unsetBeanManager();
            }
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:CamelCdiDeployment.java

示例5: start

import org.jboss.weld.environment.se.WeldContainer; //导入依赖的package包/类
@Override
public void start(Stage initStage) throws Exception {
    final Stage primaryStage = new Stage(StageStyle.DECORATED);
    Task<ObservableValue<Stage>> mainStageTask = new Task<ObservableValue<Stage>>() {
        @Override
        protected ObservableValue<Stage> call() throws Exception {
            Weld weld = new Weld();
            WeldContainer container = weld.initialize(); // Initialize Weld CDI
            primaryStage.setTitle("StudyGuide");
            primaryStage.setOnCloseRequest(event -> {
                logger.debug("Closing down Weld.");
                weld.shutdown();
            });
            primaryStage.getIcons().add(new Image(StudyGuideApplication.class.getResourceAsStream(logoResource)));
            container.event().select(Stage.class, new AnnotationLiteral<StartupStage>() {
            }).fire(primaryStage);
            return new ReadOnlyObjectWrapper<>(primaryStage);
        }
    };
    mainStageTask.exceptionProperty().addListener((observable, oldValue, newValue) -> {
        Platform.runLater(() -> {
            throw new IllegalStateException("Main stage loading failed.", newValue);
        });
    });
    showSplashScreen(initStage, mainStageTask);
}
 
开发者ID:oskopek,项目名称:StudyGuide,代码行数:27,代码来源:StudyGuideApplication.java

示例6: createNestedInjector

import org.jboss.weld.environment.se.WeldContainer; //导入依赖的package包/类
@Nonnull
@Override
public Injector<WeldContainer> createNestedInjector(final @Nonnull String name, @Nonnull Iterable<Binding<?>> bindings) {
    requireNonBlank(name, "Argument 'name' cannot be blank");
    requireNonNull(bindings, "Argument 'bindings' cannot be null");

    if (isClosed()) {
        throw new ClosedInjectorException(this);
    }

    /*
    final InjectorProvider injectorProvider = new InjectorProvider();
    WeldInjector injector = new WeldInjector(delegate.createChildInjector(moduleFromBindings(bindings), new AbstractModule() {
        @Override
        protected void configure() {
            bind(Injector.class)
                .annotatedWith(new NamedImpl(name))
                .toProvider(guicify(injectorProvider));
        }
    }));
    injectorProvider.setInjector(injector);
    return injector;
    */
    return null;
}
 
开发者ID:aalmiray,项目名称:griffon2,代码行数:26,代码来源:WeldInjector.java

示例7: main

import org.jboss.weld.environment.se.WeldContainer; //导入依赖的package包/类
public static void main(String[] args) {
        disableLogging();
        SystemAccess system = new RealSystemAccess();
        new MigrationTool(new ExternalMigrationService(system),
                          new ToolConfig.DefaultFactory(),
                          system,
                          () -> {
                            /*
                             * Work around log4j-api message printed from missing configuration.
                             */
                            PrintStream err = System.err;
//                            System.setErr(new PrintStream(new NullOutputStream()));
                            try {
                                WeldContainer container = new Weld().initialize();
                                return container;
                            } finally {
                                System.setErr(err);
                            }
                        }).run(args);
    }
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:21,代码来源:MigrationTool.java

示例8: migrateAndExit

import org.jboss.weld.environment.se.WeldContainer; //导入依赖的package包/类
private void migrateAndExit(Path niogitDir) {
    int exitStatus = 0;
    WeldContainer container = null;
    try {
        container = containerFactory.get();
        InternalMigrationService internalService = loadInternalService(container);
        internalService.migrateAllProjects(niogitDir);
    } catch (Throwable t) {
        exitStatus = 1;
        t.printStackTrace(system.err());
    } finally {
        if (container != null && container.isRunning()) {
            quietShutdown(container);
        }
    }

    system.exit(exitStatus);
}
 
开发者ID:kiegroup,项目名称:kie-wb-common,代码行数:19,代码来源:MigrationTool.java

示例9: initWeld

import org.jboss.weld.environment.se.WeldContainer; //导入依赖的package包/类
WeldContainer initWeld(Object testInstance) {
    Weld weld = WeldInitiator.this.weld;
    if (weld == null) {
        weld = createWeld().addPackage(false, testInstance.getClass());
    }
    // this ensures the test instance is always an InjectionTarget
    instancesToInject.add(createToInject(testInstance));

    return initWeldContainer(weld);
}
 
开发者ID:weld,项目名称:weld-junit,代码行数:11,代码来源:WeldInitiator.java

示例10: first

import org.jboss.weld.environment.se.WeldContainer; //导入依赖的package包/类
@Test
public void first() {
    if (containerId == null) {
        containerId = WeldContainer.current().getId();
    } else {
        Assertions.assertEquals(containerId, WeldContainer.current().getId());
    }
}
 
开发者ID:weld,项目名称:weld-junit,代码行数:9,代码来源:PerClassLifecycleTest.java

示例11: second

import org.jboss.weld.environment.se.WeldContainer; //导入依赖的package包/类
@Test
public void second() {
    if (containerId == null) {
        containerId = WeldContainer.current().getId();
    } else {
        Assertions.assertEquals(containerId, WeldContainer.current().getId());
    }
}
 
开发者ID:weld,项目名称:weld-junit,代码行数:9,代码来源:PerClassLifecycleTest.java

示例12: main

import org.jboss.weld.environment.se.WeldContainer; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
    Weld weld = new Weld();
    WeldContainer container = weld.initialize();

    TextUI textUI = container.instance().select(TextUI.class).get();
    printBanner();
    textUI.start();
}
 
开发者ID:redhat-italy,项目名称:hacep,代码行数:9,代码来源:Main.java

示例13: bootstrapWeldContainer

import org.jboss.weld.environment.se.WeldContainer; //导入依赖的package包/类
@Test
public void bootstrapWeldContainer() {
    Weld weld = new Weld();

    try (WeldContainer container = weld.initialize()) {
        Greeter greeter = container.select(Greeter.class).get();
        assertTrue(greeter != null);
    }
}
 
开发者ID:hantsy,项目名称:ee8-sandbox,代码行数:10,代码来源:GreeterTest.java

示例14: bootWeldSeContainer

import org.jboss.weld.environment.se.WeldContainer; //导入依赖的package包/类
@Test(expected = UnsatisfiedResolutionException.class)
public void bootWeldSeContainer() {
    Extension testExtension = ContainerLifecycleObserver.extensionBuilder()
        .add(afterBeanDiscovery((e) -> System.out.println("Bean discovery completed!")))
        .add(processAnnotatedType().notify((e) -> {
            if (e.getAnnotatedType().getJavaClass().getName().startsWith("com.hantsylab")) {
                e.veto();
            }
        })).build();
    try (WeldContainer container = new Weld().addExtension(testExtension).initialize()) {
        Greeter greeter = container.select(Greeter.class).get();
        //assertTrue(greeter == null);
    }

}
 
开发者ID:hantsy,项目名称:ee8-sandbox,代码行数:16,代码来源:GreeterTest.java

示例15: testCommandContextActivatedManually

import org.jboss.weld.environment.se.WeldContainer; //导入依赖的package包/类
@Test
public void testCommandContextActivatedManually() {

    try (WeldContainer container = new Weld()
            // Disable discovery completely
            .disableDiscovery()
            // Add command context implementation, decorator is enabled globally/automatically
            .packages(CommandContext.class)
            // Add bean classes manually
            .beanClasses(DummyService.class, IdService.class, TestCommand.class)
            // Add command extension manually so that we don't need to create META-INF/...
            .addExtension(new CommandExtension()).initialize()) {

        // Command cotext is activated/deactivated manually
        CommandContext ctx = container.select(CommandContext.class).get();

        try {
            ctx.activate();
            // Note that we actually don't even need to execute any command...

            // Use programmatic lookup to simulate @Inject IdService
            String id1 = container.select(IdService.class).get().getId();
            String id2 = container.select(IdService.class).get().getId();
            assertEquals(id1, id2);
        } finally {
            ctx.deactivate();
        }
    }

}
 
开发者ID:weld,项目名称:command-context-example,代码行数:31,代码来源:CommandContextBeanTest.java


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