Examples of WeldContainer


Examples of org.jboss.weld.environment.se.WeldContainer

            @Override
            protected Deployment createDeployment(ResourceLoader resourceLoader, CDI11Bootstrap bootstrap) {
                return super.createDeployment(loader, bootstrap);
            }
        };
        final WeldContainer container = this.weld.initialize();
        beanManagerProducer.set(container.getBeanManager());
        return new ProtocolMetaData();
    }
View Full Code Here

Examples of org.jboss.weld.environment.se.WeldContainer

public class SingletonContextTest {

    @Test
    public void testSingletonBeanLifecycle() {
        Weld weld = new Weld();
        WeldContainer container = weld.initialize();
        assertEquals("bar", container.instance().select(Translator.class).get().translate("hello"));
        assertTrue(Translator.isInitCallbackInvoked);
        assertTrue(Dictionary.isInitCallbackInvoked);
        weld.shutdown();
        assertTrue(Translator.isDestroyCallbackInvoked);
        assertTrue(Dictionary.isDestroyCallbackInvoked);
View Full Code Here

Examples of org.jboss.weld.environment.se.WeldContainer

    @Test
    public void testContainerIsolation() {

        Weld weld1 = new Weld("1");
        WeldContainer weldContainer1 = weld1.initialize();
        Foo foo1 = weldContainer1.instance().select(Foo.class).get();

        Weld weld2 = new Weld("2");
        WeldContainer weldContainer2 = weld2.initialize();
        Foo foo2 = weldContainer2.instance().select(Foo.class).get();

        foo1.setValue(1);
        foo2.setValue(2);

        Assert.assertEquals(1, foo1.getValue());
View Full Code Here

Examples of org.jboss.weld.environment.se.WeldContainer

public class SimpleInstanceTest {
    @Test
    public void testSelect() throws Exception {
        Weld weld = new Weld();
        try {
            WeldContainer wc = weld.initialize();
            Assert.assertNotNull(wc.instance().select(KPT.class).select(new KPQLiteral()).get());
            Assert.assertNotNull(wc.instance().select(KPT.class, new KPQLiteral()).get());
        } finally {
            weld.shutdown();
        }
    }
View Full Code Here

Examples of org.jboss.weld.environment.se.WeldContainer

    Weld weld = new Weld();
    try {

      Plant.postConstructCalled = false;
      WeldContainer weldContainer = weld.initialize();
      weldContainer.instance().select(Tree.class).get();
      assertTrue(Plant.postConstructCalled);

    } finally {
      weld.shutdown();
    }
View Full Code Here

Examples of org.jboss.weld.environment.se.WeldContainer

               };
            }
            else
            {
               final Weld weld = new ModularWeld(scanResult);
               WeldContainer container;
               container = weld.initialize();

               final BeanManager manager = container.getBeanManager();
               Assert.notNull(manager, "BeanManager was null");

               AddonRepositoryProducer repositoryProducer = BeanManagerUtils.getContextualInstance(manager,
                        AddonRepositoryProducer.class);
               repositoryProducer.setRepository(addon.getRepository());
View Full Code Here

Examples of org.jboss.weld.environment.se.WeldContainer

               // FIXME this plugin loading scheme causes classloading issues w/weld because weld cannot load classes
               // from its own classloaders before plugins are loaded and pollute the classpath.
               // We can work around it by loading weld before we load plugins, then restarting weld, but this is SLOW.
               try {
                  WeldContainer container = weld.initialize();
                  manager = container.getBeanManager();
                  weld.shutdown();
               }
               catch (Exception e) {}

               try {
                  // TODO verify plugin API versions. only activate compatible plugins.
                  loadPlugins();
                  WeldContainer container = weld.initialize();
                  manager = container.getBeanManager();
               }
               catch (Throwable e) {
                  // Boot up with external plugins disabled.
                  System.out
                           .println("Plugin system disabled due to failure while loading one or more plugins; try removing offending plugins with \"forge remove-plugin <TAB>\".");
                  e.printStackTrace();

                  Thread.currentThread().setContextClassLoader(mainClassLoader);

                  initLogging();
                  WeldContainer container = weld.initialize();
                  manager = container.getBeanManager();
               }

               manager.fireEvent(new PreStartup());
               manager.fireEvent(new Startup(workingDir, restarting));
               manager.fireEvent(new PostStartup());
View Full Code Here

Examples of org.jboss.weld.environment.se.WeldContainer

               boolean restarting = restartRequested;
               restartRequested = false;

               initLogging();
               Weld weld = new Weld();
               WeldContainer container = weld.initialize();
               BeanManager manager = container.getBeanManager();
               manager.fireEvent(new PreStartup());
               manager.fireEvent(new Startup(workingDir, restarting));
               manager.fireEvent(new PostStartup());
               manager.fireEvent(new AcceptUserInput());
               weld.shutdown();
View Full Code Here

Examples of org.jboss.weld.environment.se.WeldContainer

    public void setUp() throws Exception {
        SimpleNamingContextBuilder builder = new SimpleNamingContextBuilder();
        builder.activate();

        StartMain sm = new StartMain(new String[0]);
        WeldContainer weldContainer = sm.go();
        builder.bind(CdiObjectFactory.CDI_JNDIKEY_BEANMANAGER_COMP, weldContainer.getBeanManager());
    }
View Full Code Here

Examples of org.jboss.weld.environment.se.WeldContainer

    @Test
    public void testObservers() {
        InitObserverTestBean.reset();
        ObserverTestBean.reset();

        WeldContainer container = startMain.go();
        BeanManager manager = container.getBeanManager();
        manager.fireEvent(new CustomEvent());

        assertTrue(ObserverTestBean.isBuiltInObserved());
        assertTrue(ObserverTestBean.isCustomObserved());
        assertTrue(ObserverTestBean.isInitObserved());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.