return beanArchive;
}
};
WeldBootstrap bootstrap = new WeldBootstrap();
bootstrap.startContainer(Environments.SE, deployment, new ConcurrentHashMapBeanStore())
.startInitialization()
.deployBeans()
.validateBeans()
.endInitialization();
WeldManager manager = bootstrap.getManager(beanArchive);
// start the session lifecycle
manager.getServices().get(ContextLifecycle.class).restoreSession(manager.getId(), new ConcurrentHashMapBeanStore());
WELD_MANAGER.set(
new WeldHolder(
bootstrap,
manager));
// TODO: replace with a before/after invoke interceptor ?
return new LocalMethodExecutor() {
@Override
public TestResult invoke(TestMethodExecutor testMethodExecutor)
{
WeldManager manager = WELD_MANAGER.get().getManager();
String requestId = UUID.randomUUID().toString();
try
{
// start the request lifecycle
manager.getServices().get(ContextLifecycle.class).beginRequest(requestId, new ConcurrentHashMapBeanStore());
return super.invoke(testMethodExecutor);
}
finally
{
// end the request lifecycle
manager.getServices().get(ContextLifecycle.class).endRequest(requestId, new ConcurrentHashMapBeanStore());
}
}
};
}