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();