javax.enterprise.inject.spi.Unmanaged Java Examples
The following examples show how to use
javax.enterprise.inject.spi.Unmanaged.
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); } }
Example #3
Source File: HammockInstanceManager.java From hammock with Apache License 2.0 | 5 votes |
@Override public Object newInstance(Class<?> clazz) throws IllegalAccessException, InvocationTargetException, NamingException, InstantiationException { try { Unmanaged.UnmanagedInstance<?> instance = new Unmanaged<>(beanManager, clazz).newInstance(); instance.produce().inject().postConstruct(); Object o = instance.get(); instanceMap.put(o, instance); return o; } catch (Exception e) { return clazz.newInstance(); } }
Example #4
Source File: HammockInstanceManager.java From hammock with Apache License 2.0 | 5 votes |
@Override public void destroyInstance(Object o) throws IllegalAccessException, InvocationTargetException { Unmanaged.UnmanagedInstance remove = instanceMap.remove(o); if (remove != null) { remove.preDestroy(); remove.dispose(); } }
Example #5
Source File: HammockInstanceFactory.java From hammock with Apache License 2.0 | 5 votes |
@Override public InstanceHandle<T> createInstance() { try { return new HammockInstanceHandle<>(new Unmanaged<>(beanManager, clazz).newInstance()); } catch (Exception e) { try { return new BasicInstanceFactory<T>(clazz.newInstance()); } catch (Exception ex) { throw new RuntimeException("Unable to instantiate "+clazz, ex); } } }
Example #6
Source File: HammockInstanceHandle.java From hammock with Apache License 2.0 | 4 votes |
HammockInstanceHandle(Unmanaged.UnmanagedInstance<T> instance) { this.instance = instance; instance.produce().inject().postConstruct(); }
Example #7
Source File: Unmanageable.java From hammock with Apache License 2.0 | 4 votes |
public Unmanageable(Class<T> clazz) { this.instance = new Unmanaged<T>(clazz).newInstance(); this.instance.produce().inject().postConstruct(); }