Package org.jboss.weld.environment.se

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


    }

    public void startUp() {
        System.setProperty( "org.uberfire.nio.git.daemon.enabled", "false" );
        System.setProperty( "org.uberfire.nio.git.ssh.enabled", "false" );
        weld = new Weld();
        weldContainer = weld.initialize();
        migrater = weldContainer.instance().select( Jcr2VfsMigrater.class ).get();
    }
View Full Code Here


               + " To enable the Weld Integration please define an WeldContainerHelper");
         }
      }
      else
      {
         Weld weld = new Weld();
         weld.addExtension(new WeldExtension());
         WeldContainerHelper helper = super.getComponentInstanceOfType(WeldContainerHelper.class);
         List<Extension> extensions = helper.getExtensions();
         if (extensions != null)
         {
            for (Extension e : extensions)
            {
               weld.addExtension(e);
            }
         }
         this.helper = helper;
         this.container = weld.initialize();
         // This is an ugly hack to make sure that the BeanManagerProxy is initialized with the right Container
         // This is needed especially when we intend to initialize several weld containers within the same instance
         container.getBeanManager().getBeans(org.jboss.weld.environment.se.WeldContainer.class);
         this.weldContainer = org.jboss.weld.Container.instance();
         this.weld = weld;
View Full Code Here

    @Override
    public void initialize() {
        super.initialize();

        // Deploy the weld container...
        _weld = new Weld() {
            @Override
            protected Deployment createDeployment(final ResourceLoader resourceLoader, Bootstrap bootstrap) {
                ResourceLoader filterLoader = new ResourceLoader() {
                    public void cleanup() {
                        resourceLoader.cleanup();
View Full Code Here


    @Override
    public synchronized void boot()
    {
        weld = new Weld();
        weldContainer = weld.initialize();
    }
View Full Code Here

               initLogging();

               boolean restarting = restartRequested;
               restartRequested = false;

               Weld weld = new ModularWeld();
               BeanManager manager = null;

               // 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());
               manager.fireEvent(new AcceptUserInput());
               weld.shutdown();
            }
         });

         currentShell.start();
         try
View Full Code Here

    @Test
    public void testBootstrapNotNeeded() throws Exception {

        // First boostrap Weld SE
        Weld weld = new Weld();
        WeldContainer container = weld.initialize();
        TestBean testBean = container.instance().select(TestBean.class).get();
        assertNotNull(testBean);

        // Then start Jetty
        Server server = new Server(InetSocketAddress.createUnresolved("localhost", 8080));
        ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
        context.setContextPath("/");
        server.setHandler(context);
        context.addServlet(TestServlet.class, "/test");
        context.setAttribute(WeldServletLifecycle.BEAN_MANAGER_ATTRIBUTE_NAME, container.getBeanManager());
        context.addEventListener(new Listener());
        server.start();

        // Finally verify the test bean
        try {
            WebClient webClient = new WebClient();
            webClient.setThrowExceptionOnFailingStatusCode(true);
            Page page = webClient.getPage("http://localhost:8080/test");
            assertEquals(testBean.getId(), page.getWebResponse().getContentAsString().trim());
        } finally {
            server.stop();
            weld.shutdown();
        }
    }
View Full Code Here

                return Collections.enumeration(urls);
            }
        };
        final ResourceLoader loader = new ClassLoaderResourceLoader(classLoader);

        this.weld = new Weld() {
            @Override
            protected Deployment createDeployment(ResourceLoader resourceLoader, CDI11Bootstrap bootstrap) {
                return super.createDeployment(loader, bootstrap);
            }
        };
View Full Code Here

*/
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

public class ContainerIsolationTest {

    @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());
        Assert.assertEquals(2, foo2.getValue());

        weld1.shutdown();

        Assert.assertEquals(2, foo2.getValue());
        weld2.shutdown();
    }
View Full Code Here

* @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a>
*/
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

TOP

Related Classes of org.jboss.weld.environment.se.Weld

Copyright © 2018 www.massapicom. 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.