本文整理了Java中org.jboss.weld.environment.se.Weld.initialize()
方法的一些代码示例,展示了Weld.initialize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Weld.initialize()
方法的具体详情如下:
包路径:org.jboss.weld.environment.se.Weld
类名称:Weld
方法名:initialize
[英]Bootstraps a new Weld SE container with the current container id (generated value if not set through #containerId(String)).
The container must be shut down properly when an application is stopped. Applications are encouraged to use the try-with-resources statement or invoke WeldContainer#shutdown() explicitly.
However, a shutdown hook is also registered during initialization so that all running containers are shut down automatically when a program exits or VM is terminated. This means that it's not necessary to implement the shutdown logic in a class where a main method is used to start the container.
[中]用当前容器id引导一个新的Weld SE容器(如果未通过#containerId(字符串)设置,则生成值)。
当应用程序停止时,容器必须正确关闭。建议应用程序使用try with resources语句或显式调用WeldContainer#shutdown()。
但是,在初始化期间也会注册一个关闭钩子,以便在程序退出或VM终止时自动关闭所有正在运行的容器。这意味着,在使用main方法启动容器的类中,不必实现关闭逻辑。
代码示例来源:origin: cucumber/cucumber-jvm
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);
}
}
代码示例来源:origin: jersey/jersey
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);
}
}
代码示例来源:origin: jersey/jersey
protected static void start() {
weld = new Weld();
weld.initialize();
server = GrizzlyHttpServerFactory.createHttpServer(BASE_URI, createJaxRsApp(), true);
}
代码示例来源:origin: stackoverflow.com
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();
}
代码示例来源:origin: stackoverflow.com
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();
}
代码示例来源:origin: org.jbehave/jbehave-weld
@Override
public WeldContainer initialize() {
weld = super.initialize();
return weld;
}
代码示例来源:origin: org.guvnor/guvnor-test-utils
private void startWeld() {
logger.debug("Starting Weld for test class " + testClass.getCanonicalName());
weld = new Weld(testClass.getCanonicalName());
weldContainer = weld.initialize();
}
代码示例来源:origin: CDISource/cdisource
@Override
protected void doStart() throws Exception {
weld = new Weld();
delegate = weld.initialize();
}
代码示例来源:origin: org.wamblee/wamblee-test-enterprise
/**
* Must be called to initialize the bean manager.
*/
public void initialize() {
weld = new Weld();
container = weld.initialize();
beanManager = container.getBeanManager();
}
代码示例来源:origin: br.com.caelum.vraptor/vraptor-test
public void start() {
if (weld == null) {
weld = new Weld();
}
if (weldContainer == null) {
weldContainer = weld.initialize();
}
if (contexts == null) {
contexts = getContexts();
}
}
代码示例来源:origin: stackoverflow.com
Weld weld = new Weld();
WeldContainer container = weld.initialize();
World helloWorld = container.instance().select(World.class).get();
System.out.println(helloWorld.helloWorld());
weld.shutdown();
代码示例来源:origin: io.fabric8.ipaas.apps/fabric8mq
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);
}
}
代码示例来源:origin: io.fabric8.ipaas.apps/amqbroker
public static void main(String[] args) {
try {
Weld weld = new Weld();
WeldContainer container = weld.initialize();
AMQBroker amqBroker = container.instance().select(AMQBroker.class).get();
amqBroker.start();
waitUntilStop();
} catch (Throwable e) {
e.printStackTrace();
LOG.error("Failed to Start AMQ_Broker", e);
}
}
代码示例来源:origin: org.uberfire/uberfire-test-utils
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();
}
代码示例来源:origin: org.jbpm/jbpm-human-task-services
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();
}
代码示例来源:origin: liimaorg/liima
public WeldJUnit4Runner(final Class<Object> klass)
throws InitializationError {
super(klass);
this.klass = klass;
this.weld = new Weld();
this.container = weld.initialize();
}
代码示例来源:origin: stackoverflow.com
// 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();
代码示例来源:origin: IanDarwin/javasrc
public static void main(String[] args) {
final Instance<Object> weldInstance = new Weld().initialize().instance();
weldInstance.select(ConsoleViewer.class).get().displayMessage();
}
}
代码示例来源:origin: org.drools/drools-cdi
@BeforeClass
public static void beforeClass() {
CDITestRunner.setUp();
CDITestRunner.weld = CDITestRunner.createWeld( KieServicesInjectionTest.class.getName() );
CDITestRunner.container = CDITestRunner.weld.initialize();
}
代码示例来源:origin: apache/cxf
@Before
public void setUp() {
final Weld weld = new Weld();
container = weld.initialize();
bus = getBeanReference(Bus.class);
}
内容来源于网络,如有侵权,请联系作者删除!