Refine search
public static void main(String[] args) throws IOException { Weld weld = new Weld(); WeldContainer container = weld.initialize(); Application application = container.instance().select(Application.class).get(); application.run(); weld.shutdown(); }
@Override public <T> T getInstance(Class<T> type) { return containerInstance.select(type) .get(); }
private TaskServiceModule() { weld = new Weld(); this.container = weld.initialize(); this.taskService = this.container.instance().select(TaskServiceEntryPointImpl.class).get(); //Singleton.. that we need to instantiate this.container.instance().select(TaskLifeCycleEventListener.class).get(); }
/** * Must be called to initialize the bean manager. */ public void initialize() { weld = new Weld(); container = weld.initialize(); beanManager = container.getBeanManager(); }
log.info("Hello from CDI microservice provider!"); final String weldName = String.valueOf(context.getProperties().get(Context.WELD_NAME)); final Weld weld = new Weld(weldName); final MicroservicesCDIExtension microservicesCDIExtension = new MicroservicesCDIExtension(this.context); weld.property("org.jboss.weld.se.archive.isolation", "false"); weld.addExtension(microservicesCDIExtension); final WeldContainer container = weld.initialize(); this.context.getProperties().put(BEAN_MANAGER, container.getBeanManager()); this.context.getProperties().put(CDI_CONTAINER, container); this.context.getProperties().put(Storage.STORAGE, new HashMap<String, Object>()); this.beanManager = container.getBeanManager(); this.deployed = true; container.event().select(MicroservicesInitEvent.class).fire(new MicroservicesInitEvent(this.context, container.getBeanManager(), container)); container.event().select(MicroservicesStartedEvent.class).fire(new MicroservicesStartedEvent(this.context, container.getBeanManager(), container));
@Override public void provide(YggdrasilConfiguration configuration) throws YggdrasilException { logger.info("Initializing Weld container..."); System.setProperty("org.jboss.logging.provider", "slf4j"); Weld weld = new Weld(); weld.setClassLoader(CDIProvider.class.getClassLoader()); WeldContainer container = weld.initialize(); YggdrasilContext.registerObject(BeanManager.class.getName(), container.getBeanManager()); logger.info(CDIProvider.class.getSimpleName() + " initialized."); }
MigrationSetup.configureProperties(system, niogitDir); weldContainer = new Weld().initialize(); migrationServicesCDIWrapper = weldContainer.instance().select(MigrationServicesCDIWrapper.class).get(); formMigrationServicesCDIWrapper = weldContainer.instance().select(FormsMigrationServicesCDIWrapper.class).get(); WorkspaceProjectService service = weldContainer.instance().select(WorkspaceProjectService.class).get(); try { migrationServicesCDIWrapper = null; weldContainer.close(); } catch (Exception ex) {
@Test public void testConsumers() throws InterruptedException { try (WeldContainer weld = new Weld().disableDiscovery().addExtension(new VertxExtension()).addPackage(false, RegisterConsumersAfterBootstrapTest.class) .initialize()) { Vertx vertx = Vertx.vertx(); try { weld.select(VertxExtension.class).get().registerConsumers(vertx, weld.event()); vertx.eventBus().send(HelloObserver.HELLO_ADDRESS, "hello"); assertEquals("hello", SYNCHRONIZER.poll(Timeouts.DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS)); } finally { vertx.close(); } } }
@Before public void setUp() throws Exception { // disable git and ssh daemons as they are not needed for the tests System.setProperty("org.uberfire.nio.git.daemon.enabled", "false"); System.setProperty("org.uberfire.nio.git.ssh.enabled", "false"); System.setProperty("org.uberfire.sys.repo.monitor.disabled", "true"); //Bootstrap WELD container weldContainer = new Weld().initialize(); dataModelService = weldContainer.select(DataModelerService.class).get(); moduleService = weldContainer.select(KieModuleService.class).get(); //Ensure URLs use the default:// scheme fs.forceAsDefault(); }
@Override public void evaluate() throws Throwable { WeldContainer container = weld.initialize(); context.setBeanManager(container.getBeanManager()); try { base.evaluate(); } finally { container.shutdown(); context.unsetBeanManager(); } } };
/** * Get the CDI {@link BeanManager}. * @return The CDI {@link BeanManager}. */ public BeanManager getBeanManager() { return _weldContainer.getBeanManager(); }
@Override public void run() { for (String id : getRunningContainerIds()) { WeldContainer container = instance(id); if (container != null) { container.shutdown(); // At this time the logger service may not be available - print some basic info to the standard output System.out.println(String.format("Weld SE container %s shut down by shutdown hook", id)); } } } }
_weldContainer = _weld.initialize(); _weldContainer.event().select(ContainerInitialized.class).fire(new ContainerInitialized());
@Override public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException { // we did our checks in supportsParameter() method, now we can do simple resolution if (getContainerFromStore(extensionContext) != null) { List<Annotation> qualifiers = resolveQualifiers(parameterContext, getContainerFromStore(extensionContext).getBeanManager()); return getContainerFromStore(extensionContext) .select(parameterContext.getParameter().getType(), qualifiers.toArray(new Annotation[qualifiers.size()])).get(); } return null; }
public void registerWeldSEContexts(@Observes AfterBeanDiscovery event, BeanManager manager) { if (ignoreEvent(event)) { return; } final String contextId = BeanManagerProxy.unwrap(manager).getContextId(); this.threadContext = new ThreadContext(contextId); event.addContext(threadContext); // Register WeldContainer as a singleton event.addBean().addType(WeldContainer.class).addQualifier(Default.Literal.INSTANCE).scope(Singleton.class) .produceWith((i) -> WeldContainer.instance(contextId)); }
public static void main(final String[] args) throws Exception { weldContainer.instance().select(Workbench.class).get().init(); }
/** * Note that any container-based operation will result in {@link IllegalStateException} after shutdown. */ @Override public void shutdown() { container.shutdown(); }