/** * {@inheritDoc} */ public void releaseInstance(Message m, Object o) { InjectionUtils.invokeLifeCycleMethod(o, preDestroyMethod); }
/** * {@inheritDoc} */ public void releaseInstance(Message m, Object o) { InjectionUtils.invokeLifeCycleMethod(o, preDestroyMethod); }
public void releaseInstance(Message m, Object o) { if (!isSingleton) { InjectionUtils.invokeLifeCycleMethod(o, preDestroyMethod); } }
public void releaseInstance(Message m, Object o) { if (!isSingleton()) { InjectionUtils.invokeLifeCycleMethod(o, preDestroyMethod); } }
/** * {@inheritDoc} */ public void releaseInstance(Message m, Object o) { if (doCallPreDestroy()) { InjectionUtils.invokeLifeCycleMethod(o, preDestroyMethod); } }
/** * {@inheritDoc} */ public void releaseInstance(Message m, Object o) { if (doCallPreDestroy()) { InjectionUtils.invokeLifeCycleMethod(o, preDestroyMethod); } }
protected void initInstance(Message m, Object instance) { if (isCallPostConstruct()) { InjectionUtils.invokeLifeCycleMethod(ClassHelper.getRealObject(instance), postConstructMethod); } }
protected void initInstance(Message m, Object instance) { if (isCallPostConstruct()) { InjectionUtils.invokeLifeCycleMethod(ClassHelper.getRealObject(instance), postConstructMethod); } }
public SingletonResourceProvider(Object o, boolean callPostConstruct) { resourceInstance = o; if (callPostConstruct) { InjectionUtils.invokeLifeCycleMethod(o, ResourceUtils.findPostConstructMethod(ClassHelper.getRealClass(o))); } }
@Override public void release() { // we can't give it to the injector so let's do it manually try { InjectionUtils.invokeLifeCycleMethod(instance, preDestroyMethod); } finally { if (injector != null) { injector.preDestroy(); } if (creationalContext != null) { creationalContext.release(); } } } }
protected void doInit() throws OpenEJBException { injector = new InjectionProcessor(instance, new ArrayList(injections), InjectionProcessor.unwrap(context)); instance = injector.createInstance(); final BeanManager bm = webbeansContext.getBeanManagerImpl(); creationalContext = bm.createCreationalContext(null); try { OWBInjector.inject(bm, instance, creationalContext); } catch (final Exception e) { // ignored } // injector.postConstruct(); // it doesn't know it InjectionUtils.invokeLifeCycleMethod(instance, postConstructMethod); }
public Object getInstance(Message m) { //TODO -- This is not the BP way. Object[] values = ResourceUtils.createConstructorArguments(c, m); //TODO Very springish... Object instance = values.length > 0 ? blueprintContainer.getComponentInstance(beanId) : blueprintContainer.getComponentInstance(beanId); if (!isSingleton || m == null) { InjectionUtils.invokeLifeCycleMethod(instance, postConstructMethod); } return instance; }
protected Object createInstance(Message m) { Object[] values = ResourceUtils.createConstructorArguments(c, m); try { Object instance = values.length > 0 ? c.newInstance(values) : c.newInstance(new Object[]{}); InjectionUtils.invokeLifeCycleMethod(instance, postConstructMethod); return instance; } catch (InstantiationException ex) { String msg = "Resource class " + c.getDeclaringClass().getName() + " can not be instantiated"; throw ExceptionUtils.toInternalServerErrorException(null, serverError(msg)); } catch (IllegalAccessException ex) { String msg = "Resource class " + c.getDeclaringClass().getName() + " can not be instantiated" + " due to IllegalAccessException"; throw ExceptionUtils.toInternalServerErrorException(null, serverError(msg)); } catch (InvocationTargetException ex) { Response r = JAXRSUtils.convertFaultToResponse(ex.getCause(), m); if (r != null) { m.getExchange().put(Response.class, r); throw new WebApplicationException(); } String msg = "Resource class " + c.getDeclaringClass().getName() + " can not be instantiated" + " due to InvocationTargetException"; throw ExceptionUtils.toInternalServerErrorException(null, serverError(msg)); } }
protected Object createInstance(Message m) { ProviderInfo<?> application = (ProviderInfo<?>)m.getExchange().getEndpoint().get(Application.class.getName()); Map<Class<?>, Object> mapValues = CastUtils.cast(application == null ? null : Collections.singletonMap(Application.class, application.getProvider())); Object[] values = ResourceUtils.createConstructorArguments(c, m, true, mapValues, params, anns, genericTypes); try { Object instance = values.length > 0 ? c.newInstance(values) : c.newInstance(new Object[]{}); InjectionUtils.invokeLifeCycleMethod(instance, postConstructMethod); return instance; } catch (InstantiationException ex) { String msg = "Resource class " + c.getDeclaringClass().getName() + " can not be instantiated"; throw ExceptionUtils.toInternalServerErrorException(null, serverError(msg)); } catch (IllegalAccessException ex) { String msg = "Resource class " + c.getDeclaringClass().getName() + " can not be instantiated" + " due to IllegalAccessException"; throw ExceptionUtils.toInternalServerErrorException(null, serverError(msg)); } catch (InvocationTargetException ex) { Response r = JAXRSUtils.convertFaultToResponse(ex.getCause(), m); if (r != null) { m.getExchange().put(Response.class, r); throw new WebApplicationException(); } String msg = "Resource class " + c.getDeclaringClass().getName() + " can not be instantiated" + " due to InvocationTargetException"; throw ExceptionUtils.toInternalServerErrorException(null, serverError(msg)); } }
public void init(Endpoint ep) { if (resourceInstance instanceof Constructor) { Constructor<?> c = (Constructor<?>)resourceInstance; Message m = new MessageImpl(); ExchangeImpl exchange = new ExchangeImpl(); exchange.put(Endpoint.class, ep); m.setExchange(exchange); Object[] values = ResourceUtils.createConstructorArguments(c, m, false, Collections.emptyMap()); try { resourceInstance = values.length > 0 ? c.newInstance(values) : c.newInstance(new Object[]{}); } catch (Exception ex) { throw new ServiceConstructionException(ex); } } if (callPostConstruct) { InjectionUtils.invokeLifeCycleMethod(resourceInstance, ResourceUtils.findPostConstructMethod(ClassHelper.getRealClass(resourceInstance))); } }
public Object getInstance(Message m) { //TODO -- This is not the BP way. ProviderInfo<?> application = m == null ? null : (ProviderInfo<?>)m.getExchange().getEndpoint().get(Application.class.getName()); Map<Class<?>, Object> mapValues = CastUtils.cast(application == null ? null : Collections.singletonMap(Application.class, application.getProvider())); Object[] values = ResourceUtils.createConstructorArguments(c, m, !isSingleton(), mapValues); //TODO Very springish... Object instance = values.length > 0 ? blueprintContainer.getComponentInstance(beanId) : blueprintContainer.getComponentInstance(beanId); if (!isSingleton() || m == null) { InjectionUtils.invokeLifeCycleMethod(instance, postConstructMethod); } return instance; }