protected void start(Weld weld) { try { if (weld == null) { weld = new Weld(); } containerInstance = weld.initialize(); } catch (IllegalArgumentException e) { throw new CucumberException(START_EXCEPTION_MESSAGE, e); } }
public static void main(String[] args) { try { System.out.println("\"Hello World\" Jersey Example Weld App"); final Weld weld = new Weld(); weld.initialize(); final ResourceConfig resourceConfig = createJaxRsApp(); final HttpServer server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, resourceConfig, false); Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { @Override public void run() { server.shutdownNow(); weld.shutdown(); } })); server.start(); System.out.println(String.format("Application started.\nTry out %s%s\nStop the application using CTRL+C", BASE_URI, ROOT_PATH)); Thread.currentThread().join(); } catch (IOException | InterruptedException ex) { Logger.getLogger(App.class.getName()).log(Level.SEVERE, null, ex); } }
protected static void start() { weld = new Weld(); weld.initialize(); server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, createJaxRsApp(), true); }
public class WebServiceBinder extends AbstractBinder { @Override protected void configure() { BeanManager bm = getBeanManager(); bind(getBean(bm, StudentRepository.class)) .to(StudentRepository.class); } private BeanManager getBeanManager() { // is there a better way to get the bean manager? return new Weld().getBeanManager(); } private <T> T getBean(BeanManager bm, Class<T> clazz) { Bean<T> bean = (Bean<T>) bm.getBeans(clazz).iterator().next(); CreationalContext<T> ctx = bm.createCreationalContext(bean); return (T) bm.getReference(bean, clazz, ctx); } }
public static void main(String[] args) throws Exception { Weld weld = new Weld(); final WeldContainer container = weld.initialize(); RequestContext requestContext= container.instance().select(RequestContext.class, UnboundLiteral.INSTANCE).get(); requestContext.activate(); final MyPojo pojo = container.instance().select(MyPojo.class).get(); Thread t = new Thread() { public void run() { RequestContext requestContext= container.instance().select(RequestContext.class, UnboundLiteral.INSTANCE).get(); requestContext.activate(); System.out.println("1" + pojo.ping()); } }; t.start(); t.join(); System.out.println("2" + pojo.ping()); weld.shutdown(); }
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(); }
private void startWeld() { logger.debug("Starting Weld for test class " + testClass.getCanonicalName()); weld = new Weld(testClass.getCanonicalName()); weldContainer = weld.initialize(); }
@Override public void init(IBatchConfig batchConfig) throws BatchContainerServiceException { weld = new Weld(); container = weld.initialize(); }
@Override protected void doStart() throws Exception { weld = new Weld(); delegate = weld.initialize(); }
@Override public synchronized void boot() { weld = new Weld(); weldContainer = weld.initialize(); }
@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.property(Weld.ARCHIVE_ISOLATION_SYSTEM_PROPERTY, false); weld.setClassLoader(CDIProvider.class.getClassLoader()); WeldContainer container = weld.initialize(); YggdrasilContext.registerObject(BeanManager.class.getName(), container.getBeanManager()); logger.info(CDIProvider.class.getSimpleName() + " initialized."); }
public static CliContext buildContext(InputReader input) { Weld weld = new Weld(); WeldContainer container = weld.initialize(); CliContext context = new CliContext(weld, container, input); return context; }
Weld weld = new Weld(); WeldContainer container = weld.initialize(); World helloWorld = container.instance().select(World.class).get(); System.out.println(helloWorld.helloWorld()); weld.shutdown();
public static void main(String[] args) { try { Weld weld = new Weld(); WeldContainer container = weld.initialize(); Fabric8MQ fabric8MQ = container.instance().select(Fabric8MQ.class).get(); fabric8MQ.start(); waitUntilStop(); } catch (Throwable e) { e.printStackTrace(); LOG.error("Failed to Start Fabric8-MQ", e); } }
public void setUp() throws Exception { // Bootstrap WELD container weld = new Weld(); WeldContainer weldContainer = weld.initialize(); beanManager = weldContainer.getBeanManager(); // Instantiate Paths used in tests for Path conversion paths = getReference(Paths.class); // Ensure URLs use the default:// scheme // fileSystemProvider.forceAsDefault(); }
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(); }
public WeldJUnit4Runner(final Class<Object> klass) throws InitializationError { super(klass); this.klass = klass; this.weld = new Weld(); this.container = weld.initialize(); }
/** * The returned {@link Weld} instance has: * <ul> * <li>automatic discovery disabled</li> * <li>concurrent deployment disabled</li> * </ul> * * @return a new {@link Weld} instance suitable for testing */ public static Weld createWeld() { return new Weld().disableDiscovery().property(ConfigurationKey.CONCURRENT_DEPLOYMENT.get(), false); }
// Initialize Weld Weld theWeld = new Weld(); WeldContainer theContainer = theWeld.initialize(); // Execute the run method theContainer.instance().select(Main.class).get().run(); // Shutting down Weld again theWeld.shutdown();
@Before public void setUp() { final Weld weld = new Weld(); container = weld.initialize(); bus = getBeanReference(Bus.class); }