當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。