CamelBeanInjectionTarget(InjectionTarget<T> delegate, BeanManager manager) { super(delegate); this.delegate = delegate; this.processor = new CdiCamelBeanPostProcessor(manager); }
@Override public void inject(T instance, CreationalContext<T> ctx) { super.inject(instance, ctx); try { // TODO: see how to retrieve the bean name processor.postProcessBeforeInitialization(instance, instance.getClass().getName()); processor.postProcessAfterInitialization(instance, instance.getClass().getName()); } catch (Exception cause) { throw new InjectionException("Camel annotations post processing of [" + delegate + "] failed!", cause); } } }
if (propertyInject != null) { try { injectFieldProperty(field, propertyInject.value(), propertyInject.defaultValue(), propertyInject.context(), bean, beanName); } catch (Exception cause) { throw new InjectionException("Injection of [" + propertyInject + "] for field [" + field + "] failed!", cause); if (beanInject != null && getPostProcessorHelper().matchContext(beanInject.context())) { try { injectFieldBean(field, beanInject.value(), bean, beanName); } catch (Exception cause) { throw new InjectionException("Injection of [" + beanInject + "] for field [" + field + "] failed!", cause); if (endpointInject != null) { try { injectField(field, endpointInject.uri(), endpointInject.ref(), endpointInject.property(), endpointInject.context(), bean, beanName); } catch (Exception cause) { throw new InjectionException("Injection of [" + endpointInject + "] for field [" + field + "] failed!", cause); if (produce != null) { try { injectField(field, produce.uri(), produce.ref(), produce.property(), produce.context(), bean, beanName); } catch (Exception cause) { throw new InjectionException("Injection of [" + produce + "] for field [" + field + "] failed!", cause);
private void injectField(Field field, String uri, String ref, String property, String context, Object bean, String beanName) { ReflectionHelper.setField(field, bean, getPostProcessorHelper(context).getInjectionValue(field.getType(), uri, ref, property, field.getName(), bean, beanName)); }
private CamelPostProcessorHelper getPostProcessorHelper(String contextName) { return postProcessorHelpers.computeIfAbsent(contextName, k -> new CamelPostProcessorHelper(getOrLookupCamelContext(k))); }
private void injectFieldProperty(Field field, String property, String defaultValue, String context, Object bean, String beanName) { ReflectionHelper.setField(field, bean, getPostProcessorHelper(context).getInjectionPropertyValue(field.getType(), property, defaultValue, field.getName(), bean, beanName)); }