Package org.jboss.weld.environment.se

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


public class PostConstructInheritanceTest {

  @Test
  public void testPostConstructInherited() {

    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


                  }
               };
            }
            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());

               ForgeProducer forgeProducer = BeanManagerUtils.getContextualInstance(manager, ForgeProducer.class);
               forgeProducer.setForge(forge);

               AddonProducer addonProducer = BeanManagerUtils.getContextualInstance(manager, AddonProducer.class);
               addonProducer.setAddon(addon);

               AddonRegistryProducer addonRegistryProducer = BeanManagerUtils.getContextualInstance(manager,
                        AddonRegistryProducer.class);
               addonRegistryProducer.setRegistry(forge.getAddonRegistry());

               ContainerServiceExtension extension = BeanManagerUtils.getContextualInstance(manager,
                        ContainerServiceExtension.class);
               ServiceRegistryProducer serviceRegistryProducer = BeanManagerUtils.getContextualInstance(manager,
                        ServiceRegistryProducer.class);
               serviceRegistryProducer.setServiceRegistry(new ServiceRegistryImpl(forge.getLockManager(), addon,
                        manager, extension));

               ServiceRegistry registry = BeanManagerUtils.getContextualInstance(manager, ServiceRegistry.class);
               Assert.notNull(registry, "Service registry was null.");
               addon.setServiceRegistry(registry);

               logger.info("Services loaded from addon [" + addon.getId() + "] -  " + registry.getServices());

               shutdownCallback = new Callable<Object>()
               {
                  @Override
                  public Object call() throws Exception
                  {
                     try
                     {
                        manager.fireEvent(new PreShutdown());
                     }
                     catch (Exception e)
                     {
                        logger.log(Level.SEVERE, "Failed to execute pre-Shutdown event.", e);
                     }
                     finally
                     {
                        addon.setStatus(AddonStatus.LOADED);
                        if (operation != null)
                           operation.cancel(true);
                     }

                     weld.shutdown();
                     return null;
                  }
               };

               postStartupTask = new Callable<Void>()
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

            {
               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();
            }
         });

         currentShell.start();
         try
View Full Code Here

        } catch (IllegalStateException e) {
        }

        // initialise CDI environment
        weld = new Weld();
        container = weld.initialize();

        cleanJNDI();

View Full Code Here

        } catch (IllegalStateException e) {
        }

        // initialise CDI environment
        weld = new Weld();
        container = weld.initialize();

        cleanJNDI();

View Full Code Here

    protected WeldContainer container;

    @Before
    public void init() {
        weld = new Weld();
        container = weld.initialize();
    }
View Full Code Here

     * Test the alternate API for booting WeldContainer from an SE app.
     */
    @Test
    public void testInitialize() {

        Weld weld = new Weld();
        WeldContainer container = weld.initialize();

        MainTestBean mainTestBean = container.instance().select(MainTestBean.class).get();
        assertNotNull(mainTestBean);

        ParametersTestBean paramsBean = mainTestBean.getParametersTestBean();
        assertNotNull(paramsBean);
        assertNotNull(paramsBean.getParameters());

        weld.shutdown();
    }
View Full Code Here

    public void testObservers() {

        InitObserverTestBean.reset();
        ObserverTestBean.reset();

        Weld weld = new Weld();
        WeldContainer container = weld.initialize();

        container.event().select(CustomEvent.class).fire(new CustomEvent());

        assertTrue(ObserverTestBean.isBuiltInObserved());
        assertTrue(ObserverTestBean.isCustomObserved());
        assertTrue(ObserverTestBean.isInitializedObserved());
        assertFalse(ObserverTestBean.isDestroyedObserved());

        // moved as per WELD-949
        assertTrue(ObserverTestBean.isInitObserved());
        assertTrue(InitObserverTestBean.isInitObserved());

        weld.shutdown();
        assertTrue(ObserverTestBean.isDestroyedObserved());
    }
View Full Code Here

*/
public final class SEArtifactFactory extends AbstractArtifactFactory {
    private final BeanManager beanManager;

    public SEArtifactFactory() {
        WeldContainer weldContainer = new Weld().initialize();
        beanManager = weldContainer.getBeanManager();
    }
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.