Java Code Examples for javax.enterprise.inject.se.SeContainerInitializer#newInstance()

The following examples show how to use javax.enterprise.inject.se.SeContainerInitializer#newInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WeldTestBase.java    From smallrye-reactive-messaging with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
    initializer = SeContainerInitializer.newInstance();

    initializer.addBeanClasses(MediatorFactory.class,
            MediatorManager.class,
            WorkerPoolRegistry.class,
            ExecutionHolder.class,
            InternalChannelRegistry.class,
            ChannelProducer.class,
            ConfiguredChannelFactory.class,
            LegacyConfiguredChannelFactory.class,
            MetricDecorator.class,

            // In memory connector
            InMemoryConnector.class,

            // SmallRye config
            io.smallrye.config.inject.ConfigProducer.class);

    List<Class<?>> beans = getBeans();
    initializer.addBeanClasses(beans.toArray(new Class<?>[0]));
    initializer.disableDiscovery();
    initializer.addExtensions(new ReactiveMessagingExtension());
}
 
Example 2
Source File: WeldTestBaseWithoutTails.java    From smallrye-reactive-messaging with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() {
    initializer = SeContainerInitializer.newInstance();

    initializer.addBeanClasses(MediatorFactory.class,
            ExecutionHolder.class,
            MediatorManager.class,
            WorkerPoolRegistry.class,
            InternalChannelRegistry.class,
            ChannelProducer.class,
            ConfiguredChannelFactory.class,
            LegacyConfiguredChannelFactory.class,
            MetricDecorator.class,
            // Messaging provider
            MyDummyConnector.class,

            // SmallRye config
            io.smallrye.config.inject.ConfigProducer.class);

    List<Class<?>> beans = getBeans();
    initializer.addBeanClasses(beans.toArray(new Class<?>[0]));
    initializer.disableDiscovery();
    initializer.addExtensions(new ReactiveMessagingExtension());
}
 
Example 3
Source File: DemoApplication.java    From Sentinel with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) {
    SeContainerInitializer containerInit = SeContainerInitializer.newInstance();
    SeContainer container = containerInit.initialize();

    TestService testService = container.select(TestService.class).get();

    testService.test();

    System.out.println(testService.hello(-1));
    System.out.println(testService.hello(1));

    System.out.println(testService.helloAnother("bad"));

    try {
        System.out.println(testService.helloAnother("foo"));
    } catch (IllegalStateException e) {
        System.err.println(e.getMessage());
    }

    System.out.println(testService.helloAnother("weld"));

    container.close();
    System.exit(0);
}
 
Example 4
Source File: AccountApplication.java    From cdi with Apache License 2.0 5 votes vote down vote up
public static void main(final String[] args) {
    SeContainerInitializer initializer = SeContainerInitializer.newInstance();

    try (SeContainer container = initializer.initialize()) {
        container.select(AccountApplication.class).get().run();
    }
}
 
Example 5
Source File: GreeterTest.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
@Test
public void bootBasicContainer() {
    SeContainerInitializer initializer = SeContainerInitializer.newInstance();
    try (SeContainer container = initializer.initialize()) {
        assertTrue(container.isRunning());
        Set<Bean<?>> greeters = container.getBeanManager().getBeans("greeter");
        assertTrue(greeters.size() == 1);
    }
}
 
Example 6
Source File: Main.java    From smallrye-reactive-messaging with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws InterruptedException {
    SeContainerInitializer instance = SeContainerInitializer.newInstance();
    instance.initialize();

    Thread.sleep(10000);
}
 
Example 7
Source File: SentinelAnnotationInterceptorIntegrationTest.java    From Sentinel with Apache License 2.0 4 votes vote down vote up
@BeforeClass
public static void init() {
    SeContainerInitializer containerInit = SeContainerInitializer.newInstance();
    container = containerInit.initialize();
}
 
Example 8
Source File: OWBBootstrapper.java    From hammock with Apache License 2.0 4 votes vote down vote up
public OWBBootstrapper() {
    seContainerInitializer = SeContainerInitializer.newInstance();
}
 
Example 9
Source File: Weld3Bootstrapper.java    From hammock with Apache License 2.0 4 votes vote down vote up
public Weld3Bootstrapper() {
    seContainerInitializer = SeContainerInitializer.newInstance();
    config = ConfigProvider.getConfig();
}
 
Example 10
Source File: MainApp.java    From tutorials with MIT License 4 votes vote down vote up
public static void main(String[] args) {
    SeContainerInitializer initializer = SeContainerInitializer.newInstance();
    try (SeContainer container = initializer.initialize()) {
    }
}
 
Example 11
Source File: BootstrappingApplication.java    From tutorials with MIT License 4 votes vote down vote up
public static void main(String... args) {
    SeContainerInitializer containerInitializer = SeContainerInitializer.newInstance();
    try (SeContainer container = containerInitializer.initialize()) {
        container.getBeanManager().fireEvent(new ExampleEvent("Welcome to Baeldung!"));
    }
}