javax.enterprise.inject.se.SeContainerInitializer Java Examples

The following examples show how to use javax.enterprise.inject.se.SeContainerInitializer. 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: Task.java    From Java-EE-8-and-Angular with MIT License 6 votes vote down vote up
public static void main(String... args) {
    try (SeContainer container = SeContainerInitializer
            .newInstance().initialize()) {
        Task appInstance = container
                .select(Task.class)
                .get();
        //Test normal CDI
        appInstance.useInjected();
        
        //Test programmatic approach using RequestContextController
        //For each of below requests a new LoginBean is injected
        appInstance.doWorkInRequest("programmatic");            
        appInstance.doWorkInRequest("programmatic");
        
        //Test annotation approach using @ActivateRequestContext
        //For each of below requests a new LoginBean is injected
        appInstance.doWorkInRequest();
        appInstance.doWorkInRequest();
    }
}
 
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: 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 #5
Source File: TestDynamicQualifier.java    From Java-EE-8-and-Angular with MIT License 5 votes vote down vote up
public static void main(String[] args) {
    try (SeContainer container = SeContainerInitializer
            .newInstance().initialize()) {
        Test appInstance = container
                .select(Test.class)
                .get();

        appInstance.doWork();
    }
}
 
Example #6
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 #7
Source File: App.java    From Java-EE-8-and-Angular with MIT License 5 votes vote down vote up
public static void main(String[] args) {
    try (SeContainer container = SeContainerInitializer
            .newInstance().initialize()) {
        App appInstance = container
                .select(App.class)
                .get();
        appInstance.doCRUD();
    }
}
 
Example #8
Source File: CdiTest.java    From Java-EE-8-and-Angular with MIT License 5 votes vote down vote up
@Test
public void injection_test() {
    try (SeContainer container = SeContainerInitializer.newInstance().initialize()) {
        CdiTest appInstance = container.select(CdiTest.class).get();
        String msg = appInstance.doSomething();

        assertNotNull(msg);
    }
}
 
Example #9
Source File: AccountService.java    From Java-EE-8-and-Angular with MIT License 5 votes vote down vote up
public static void main(String[] args) {
    try (SeContainer container = SeContainerInitializer
            .newInstance().initialize()) {
        AccountService appInstance = container
                .select(AccountService.class)
                .get();
        
        appInstance.login(1,"AG007");
        appInstance.login(2,"AG007");
        //3rd event should lock account and then send SMS
        appInstance.login(3,"AG007");
    }
}
 
Example #10
Source File: Test.java    From Java-EE-8-and-Angular with MIT License 5 votes vote down vote up
public static void main(String... args) {
    try (SeContainer container = SeContainerInitializer
            .newInstance().initialize()) {
        Test appInstance = container
                .select(Test.class)
                .get();
        //Invoke action which raises an event that an observer listens to
        appInstance.doSomething();
    }
}
 
Example #11
Source File: BootCDI.java    From Java-EE-8-and-Angular with MIT License 5 votes vote down vote up
public static void main(String... args) {
    //Use try-with-resources for closing the SeContainer instance
    try (SeContainer container = SeContainerInitializer
            .newInstance().initialize()) {
        //Lookup the BootCDI instance by its type.
        BootCDI appInstance = container
                .select(BootCDI.class)
                .get();
        //Once BootCDI instance is obtained we can invoke its methods
        appInstance.doSomething();
    }
}
 
Example #12
Source File: Test.java    From Java-EE-8-and-Angular with MIT License 5 votes vote down vote up
public static void main(String[] args) {
    try (SeContainer container = SeContainerInitializer
            .newInstance().initialize()) {
        Test appInstance = container
                .select(Test.class)
                .get();

        appInstance.doWork();
    }
}
 
Example #13
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 #14
Source File: MeecrowaveSeContainerInitializerTest.java    From openwebbeans-meecrowave with Apache License 2.0 5 votes vote down vote up
@Test
public void run() {
    try (final SeContainer container = SeContainerInitializer.newInstance()
            .addProperty("httpPort", new Meecrowave.Builder().randomHttpPort().getHttpPort())
            .disableDiscovery()
            .addBeanClasses(Configured.class)
            .initialize()) {
        final Client client = ClientBuilder.newClient();
        assertNotNull(container.select(Meecrowave.class).get());
        assertEquals("configured", client
                .target(String.format("http://localhost:%d/configured", container.select(Meecrowave.Builder.class).get().getHttpPort()))
                .request(TEXT_PLAIN_TYPE)
                .get(String.class));
    }
}
 
Example #15
Source File: OrderedObserver.java    From javaee8-cookbook with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
    SeContainer container = SeContainerInitializer.newInstance().initialize();
    container.getBeanManager().fireEvent(new MyEvent("event -> " + System.currentTimeMillis()));
}
 
Example #16
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 #17
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 #18
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!"));
    }
}
 
Example #19
Source File: Weld3Bootstrapper.java    From hammock with Apache License 2.0 4 votes vote down vote up
public SeContainerInitializer getSeContainerInitializer() {
    return seContainerInitializer;
}
 
Example #20
Source File: MeecrowaveSeContainerSelector.java    From openwebbeans-meecrowave with Apache License 2.0 4 votes vote down vote up
@Override
public SeContainerInitializer find() {
    return new MeecrowaveSeContainerInitializer();
}
 
Example #21
Source File: HammockSeContainerSelector.java    From hammock with Apache License 2.0 4 votes vote down vote up
@Override
public SeContainerInitializer find() {
    return new HammockInitializer();
}
 
Example #22
Source File: OWBBootstrapper.java    From hammock with Apache License 2.0 4 votes vote down vote up
public OWBBootstrapper() {
    seContainerInitializer = SeContainerInitializer.newInstance();
}
 
Example #23
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 #24
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) {
    SeContainer container = SeContainerInitializer.newInstance().initialize();
    container.getBeanManager().createInstance().select(BeanUsingAnEmitter.class).get().periodicallySendMessage();
}
 
Example #25
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) {
    SeContainer container = SeContainerInitializer.newInstance().initialize();

    container.getBeanManager().createInstance().select(BeanUsingAnEmitter.class).get().periodicallySendMessage();
}
 
Example #26
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) {
    SeContainer container = SeContainerInitializer.newInstance().initialize();
    container.getBeanManager().createInstance().select(BeanUsingAnEmitter.class).get().periodicallySendMessage();
}
 
Example #27
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) {
    SeContainer container = SeContainerInitializer.newInstance().initialize();

    container.getBeanManager().createInstance().select(BeanUsingAnEmitter.class).get().periodicallySendMessage();
}
 
Example #28
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) {
    SeContainer container = SeContainerInitializer.newInstance().initialize();

    container.getBeanManager().createInstance().select(BeanUsingAnEmitter.class).get().periodicallySendMessageToKafka();
}
 
Example #29
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) {
    SeContainer container = SeContainerInitializer.newInstance().initialize();

    container.getBeanManager().createInstance().select(BeanUsingAnEmitter.class).get().periodicallySendMqttMessage();
}
 
Example #30
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) {
    SeContainerInitializer.newInstance().initialize();
}