use of org.apache.deltaspike.cdise.api.CdiContainer in project HotswapAgent by HotswapProjects.
the class HAAbstractUnitTest method startContainer.
protected void startContainer() {
CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
cdiContainer.boot();
ContextControl contextControl = cdiContainer.getContextControl();
contextControl.startContext(ApplicationScoped.class);
contextControl.startContext(SessionScoped.class);
contextControl.startContext(RequestScoped.class);
}
use of org.apache.deltaspike.cdise.api.CdiContainer in project camel by apache.
the class Main method doStart.
@Override
protected void doStart() throws Exception {
// TODO: Use standard CDI Java SE support when CDI 2.0 becomes a prerequisite
CdiContainer container = getCdiContainer();
container.boot();
container.getContextControl().startContexts();
cdiContainer = container;
super.doStart();
postProcessContext();
warnIfNoCamelFound();
}
use of org.apache.deltaspike.cdise.api.CdiContainer in project deltaspike by apache.
the class SimpleSchedulerExample method main.
public static void main(String[] args) throws InterruptedException {
CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
cdiContainer.boot();
ContextControl contextControl = cdiContainer.getContextControl();
contextControl.startContext(ApplicationScoped.class);
GlobalResultHolder globalResultHolder = BeanProvider.getContextualReference(GlobalResultHolder.class);
while (globalResultHolder.getCount() < 100) {
Thread.sleep(500);
LOG.info("current count: " + globalResultHolder.getCount());
}
LOG.info("completed!");
contextControl.stopContext(ApplicationScoped.class);
cdiContainer.shutdown();
}
use of org.apache.deltaspike.cdise.api.CdiContainer in project deltaspike by apache.
the class ConfigExample method main.
public static void main(String[] args) {
CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
cdiContainer.boot();
ContextControl contextControl = cdiContainer.getContextControl();
contextControl.startContext(ApplicationScoped.class);
SettingsBean settingsBean = BeanProvider.getContextualReference(SettingsBean.class, false);
LOG.info("configured int-value #1: " + settingsBean.getIntProperty1());
LOG.info("configured long-value #2: " + settingsBean.getProperty2());
LOG.info("configured inverse-value #2: " + settingsBean.getInverseProperty());
LOG.info("configured location (custom config): " + settingsBean.getLocationId().name());
cdiContainer.shutdown();
}
use of org.apache.deltaspike.cdise.api.CdiContainer in project deltaspike by apache.
the class SimpleBeanLookupExample method main.
/**
* Entry point
*
* @param args currently not used
*/
public static void main(String[] args) {
CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer();
cdiContainer.boot();
ContextControl contextControl = cdiContainer.getContextControl();
contextControl.startContext(ApplicationScoped.class);
//containerControl.startContexts();
//or:
//cdiContainer.start();
List<EchoService> echoServiceList = BeanProvider.getContextualReferences(EchoService.class, false);
for (EchoService echoService : echoServiceList) {
LOG.info(echoService.echo("Hello CDI bean!"));
}
LOG.info("---");
echoServiceList = BeanProvider.getContextualReferences(EchoService.class, false, false);
for (EchoService echoService : echoServiceList) {
LOG.info(echoService.echo("Hello non dependent CDI scoped bean!"));
}
LOG.info("---");
EchoService defaultEchoService = BeanProvider.getContextualReference(DefaultEchoService.class, false);
LOG.info(defaultEchoService.echo("Hello explicitly resolved CDI bean!"));
defaultEchoService = BeanProvider.getContextualReference("defaultEchoService", false, EchoService.class);
LOG.info(defaultEchoService.echo("Hello CDI bean resolved by name!"));
OptionalService optionalService = BeanProvider.getContextualReference(OptionalService.class, true);
if (optionalService == null) {
LOG.info("No (optional) implementation found for " + OptionalService.class.getName());
} else {
LOG.severe("Unexpected implementation found: " + optionalService.getClass().getName());
}
contextControl.stopContext(ApplicationScoped.class);
cdiContainer.shutdown();
//or:
//containerControl.stopContexts();
//cdiContainer.shutdownContainer();
//cdiContainer.stopContext(ApplicationScoped.class); //doesn't work with weld right now - see WELD-1072
}
Aggregations