List of usage examples for org.springframework.beans.factory.config TypedStringValue getTargetTypeName
@Nullable
public String getTargetTypeName()
From source file:me.springframework.di.spring.SpringConfigurationLoader.java
/** * Constructs a {@link MutableSource} from a source based on a literal * representation of a value./*from w w w . j ava2s. c o m*/ * * @param sink * The {@link Sink} configured to receive the value produced by * the source. * @param value * Spring's representation of that value. * @return The {@link Source} representation of the object producing that * value. */ private static MutableSource load(Sink sink, TypedStringValue value) { return new MutableStringValueSource(sink, value.getValue(), value.getTargetTypeName()); }
From source file:com.arondor.common.reflection.parser.spring.BeanPropertyParser.java
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 {//from w w w .ja v a 2 s . co m 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() + ")"); } }
From source file:com.arondor.common.reflection.parser.spring.BeanPropertyParser.java
private ObjectConfiguration getEnumObjectConfiguration(TypedStringValue stringValue) { ObjectConfiguration enumObjectConfiguration = objectConfigurationFactory.createObjectConfiguration(); enumObjectConfiguration.setClassName(hashHelper.hashClassName(stringValue.getTargetTypeName())); enumObjectConfiguration.setConstructorArguments(new ArrayList<ElementConfiguration>()); PrimitiveConfiguration enumFieldConfiguration = objectConfigurationFactory .createPrimitiveConfiguration(stringValue.getValue()); enumObjectConfiguration.getConstructorArguments().add(enumFieldConfiguration); return enumObjectConfiguration; }