Java Code Examples for javax.enterprise.inject.spi.Unmanaged#newInstance()
The following examples show how to use
javax.enterprise.inject.spi.Unmanaged#newInstance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultFallbackHandlerProvider.java From smallrye-fault-tolerance with Apache License 2.0 | 6 votes |
@Override public <T> FallbackHandler<T> get(FaultToleranceOperation operation) { if (operation.hasFallback()) { //noinspection Convert2Lambda return new FallbackHandler<T>() { @Override public T handle(ExecutionContext context) { Unmanaged<FallbackHandler<T>> unmanaged = new Unmanaged<>(beanManager, operation.getFallback().get(FallbackConfig.VALUE)); Unmanaged.UnmanagedInstance<FallbackHandler<T>> unmanagedInstance = unmanaged.newInstance(); FallbackHandler<T> handler = unmanagedInstance.produce().inject().postConstruct().get(); try { return handler.handle(context); } finally { // The instance exists to service a single invocation only unmanagedInstance.preDestroy().dispose(); } } }; } return null; }
Example 2
Source File: HealthExtension.java From thorntail with Apache License 2.0 | 6 votes |
public void afterDeploymentValidation(@Observes final AfterDeploymentValidation abd, BeanManager beanManager) { try { if (delegate != null) { Unmanaged<SmallRyeHealthReporter> unmanagedHealthCheck = new Unmanaged<>(beanManager, SmallRyeHealthReporter.class); reporterInstance = unmanagedHealthCheck.newInstance(); reporter = reporterInstance.produce().inject().postConstruct().get(); monitor.registerHealthReporter(reporter); // THORN-2195: Use the correct TCCL when health checks are obtained // In WildFly, the TCCL should always be set to the top-level deployment CL during extension notification monitor.registerContextClassLoader(Thread.currentThread().getContextClassLoader()); log.info(">> Added health reporter bean " + reporter); delegate = null; } } catch (Exception e) { throw new RuntimeException("Failed to register health reporter bean", e); } }