@Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { context.addPropertyAccessor(new BeanFactoryAccessor()); context.setBeanResolver(new BeanFactoryResolver(applicationContext)); context.setRootObject(applicationContext); }
public ConsumerBeanAutoConfiguration() { this.expressionParser = new SpelExpressionParser(); this.expressionPropertyAccessors = new ArrayList<PropertyAccessor>(); this.expressionPropertyAccessors.add(new EnvironmentAccessor()); this.expressionPropertyAccessors.add(new BeanFactoryAccessor()); this.expressionPropertyAccessors.add(new ReflectivePropertyAccessor()); this.expressionPropertyAccessors.add(new DirectFieldAccessPropertyAccessor()); }
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { context.addPropertyAccessor(new BeanFactoryAccessor()); context.setBeanResolver(new BeanFactoryResolver(applicationContext)); context.setRootObject(applicationContext); }
public ElementConfiguration parseProperty(Object value) { LOGGER.debug("value : " + value); if (value instanceof TypedStringValue) { TypedStringValue stringValue = (TypedStringValue) value; if (stringValue.getTargetTypeName() != null) { return getEnumObjectConfiguration(stringValue); } else { PrimitiveConfiguration primitiveConfiguration = objectConfigurationFactory .createPrimitiveConfiguration(); if (useSPEL(stringValue)) { ExpressionParser parser = new SpelExpressionParser(); String expAsStringWithToken = stringValue.getValue().trim(); String expAsString = expAsStringWithToken.substring(2, expAsStringWithToken.length() - 1).trim(); LOGGER.trace("This property is a SPEL expression: " + expAsString); // String regex = "systemProperties\\['([^\\s]+)'\\]"; Expression exp = parser.parseExpression(expAsString); StandardEvaluationContext sec = null; if (sec == null) { sec = new StandardEvaluationContext(); sec.addPropertyAccessor(new EnvironmentAccessor()); sec.addPropertyAccessor(new BeanExpressionContextAccessor()); sec.addPropertyAccessor(new BeanFactoryAccessor()); sec.addPropertyAccessor(new MapAccessor()); } primitiveConfiguration.setValue(String.valueOf(exp.getValue())); } else { LOGGER.trace("This property is NOT a SPEL expression: " + stringValue.getValue()); primitiveConfiguration.setValue(stringValue.getValue()); } return primitiveConfiguration; } } else if (value instanceof RuntimeBeanReference) { RuntimeBeanReference beanReference = (RuntimeBeanReference) value; ReferenceConfiguration referenceConfiguration = objectConfigurationFactory.createReferenceConfiguration(); referenceConfiguration.setReferenceName(beanReference.getBeanName()); return referenceConfiguration; } else if (value instanceof ManagedList<?>) { return parseValueList((ManagedList<?>) value); } else if (value instanceof ManagedMap<?, ?>) { return parseValueMap((ManagedMap<?, ?>) value); } else if (value instanceof BeanDefinitionHolder) { BeanDefinitionHolder beanDefinitionHolder = (BeanDefinitionHolder) value; return parseBeanDefinition(beanDefinitionHolder.getBeanDefinition()); } else { throw new UnsupportedOperationException("The type of property value is not suppported : " + value + " (class : " + value.getClass().getName() + ")"); } }