org.springframework.beans.factory.config.TypedStringValue Java Examples
The following examples show how to use
org.springframework.beans.factory.config.TypedStringValue.
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: BeanDefinitionParserDelegate.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Parse a props element. */ public Properties parsePropsElement(Element propsEle) { ManagedProperties props = new ManagedProperties(); props.setSource(extractSource(propsEle)); props.setMergeEnabled(parseMergeAttribute(propsEle)); List<Element> propEles = DomUtils.getChildElementsByTagName(propsEle, PROP_ELEMENT); for (Element propEle : propEles) { String key = propEle.getAttribute(KEY_ATTRIBUTE); // Trim the text value to avoid unwanted whitespace // caused by typical XML formatting. String value = DomUtils.getTextValue(propEle).trim(); TypedStringValue keyHolder = new TypedStringValue(key); keyHolder.setSource(extractSource(propEle)); TypedStringValue valueHolder = new TypedStringValue(value); valueHolder.setSource(extractSource(propEle)); props.put(keyHolder, valueHolder); } return props; }
Example #2
Source File: BeanDefinitionParserDelegate.java From spring-analysis-note with MIT License | 6 votes |
/** * Return a typed String value Object for the given value element. */ public Object parseValueElement(Element ele, @Nullable String defaultTypeName) { // It's a literal value. String value = DomUtils.getTextValue(ele); String specifiedTypeName = ele.getAttribute(TYPE_ATTRIBUTE); String typeName = specifiedTypeName; if (!StringUtils.hasText(typeName)) { typeName = defaultTypeName; } try { TypedStringValue typedValue = buildTypedStringValue(value, typeName); typedValue.setSource(extractSource(ele)); typedValue.setSpecifiedTypeName(specifiedTypeName); return typedValue; } catch (ClassNotFoundException ex) { error("Type class [" + typeName + "] not found for <value> element", ele, ex); return value; } }
Example #3
Source File: ViewModelUtils.java From rice with Educational Community License v2.0 | 6 votes |
/** * Helper method for getting the string value of a property from a {@link PropertyValues} * * @param propertyValues property values instance to pull from * @param propertyName name of property whose value should be retrieved * @return String value for property or null if property was not found */ public static String getStringValFromPVs(PropertyValues propertyValues, String propertyName) { String propertyValue = null; if ((propertyValues != null) && propertyValues.contains(propertyName)) { Object pvValue = propertyValues.getPropertyValue(propertyName).getValue(); if (pvValue instanceof TypedStringValue) { TypedStringValue typedStringValue = (TypedStringValue) pvValue; propertyValue = typedStringValue.getValue(); } else if (pvValue instanceof String) { propertyValue = (String) pvValue; } } return propertyValue; }
Example #4
Source File: BeanDefinitionParserDelegate.java From spring-analysis-note with MIT License | 6 votes |
/** * Parse a props element. */ public Properties parsePropsElement(Element propsEle) { ManagedProperties props = new ManagedProperties(); props.setSource(extractSource(propsEle)); props.setMergeEnabled(parseMergeAttribute(propsEle)); List<Element> propEles = DomUtils.getChildElementsByTagName(propsEle, PROP_ELEMENT); for (Element propEle : propEles) { String key = propEle.getAttribute(KEY_ATTRIBUTE); // Trim the text value to avoid unwanted whitespace // caused by typical XML formatting. String value = DomUtils.getTextValue(propEle).trim(); TypedStringValue keyHolder = new TypedStringValue(key); keyHolder.setSource(extractSource(propEle)); TypedStringValue valueHolder = new TypedStringValue(value); valueHolder.setSource(extractSource(propEle)); props.put(keyHolder, valueHolder); } return props; }
Example #5
Source File: BeanDefinitionWriterServiceImpl.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { ManagedMap<?, ?> map = (ManagedMap<?, ?>) source; for (Map.Entry<?, ?> entry : map.entrySet()) { writer.startNode("entry"); writer.startNode("key"); if (entry.getKey().getClass().equals(TypedStringValue.class)) { writer.startNode("value"); writer.setValue(((TypedStringValue) entry.getKey()).getValue()); writer.endNode(); } else { writeItem(entry.getKey(), context, writer); } writer.endNode(); if (entry.getValue().getClass().equals(TypedStringValue.class)) { writer.startNode("value"); writer.setValue(((TypedStringValue) entry.getValue()).getValue()); writer.endNode(); } else { writeItem(entry.getValue(), context, writer); } writer.endNode(); } }
Example #6
Source File: BeanDefinitionWriterServiceImpl.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { BeanDefinitionHolder holder = (BeanDefinitionHolder) source; BeanDefinition definition = holder.getBeanDefinition(); writer.addAttribute("class", definition.getBeanClassName()); writer.addAttribute("name", holder.getBeanName()); for (PropertyValue property : definition.getPropertyValues().getPropertyValueList()) { writer.startNode("property"); writer.addAttribute("name", property.getName()); if (property.getValue().getClass().equals(TypedStringValue.class)) { context.convertAnother(property.getValue()); } else { writeItem(property.getValue(), context, writer); } writer.endNode(); } }
Example #7
Source File: MapperScannerConfigurer.java From Mapper with MIT License | 6 votes |
private String updatePropertyValue(String propertyName, PropertyValues values) { PropertyValue property = values.getPropertyValue(propertyName); if (property == null) { return null; } Object value = property.getValue(); if (value == null) { return null; } else if (value instanceof String) { return value.toString(); } else if (value instanceof TypedStringValue) { return ((TypedStringValue) value).getValue(); } else { return null; } }
Example #8
Source File: BeanFactoryGenericsTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void parameterizedInstanceFactoryMethodWithWrappedClassName() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(); rbd.setBeanClassName(Mockito.class.getName()); rbd.setFactoryMethodName("mock"); // TypedStringValue used to be equivalent to an XML-defined argument String rbd.getConstructorArgumentValues().addGenericArgumentValue(new TypedStringValue(Runnable.class.getName())); bf.registerBeanDefinition("mock", rbd); assertTrue(bf.isTypeMatch("mock", Runnable.class)); assertTrue(bf.isTypeMatch("mock", Runnable.class)); assertEquals(Runnable.class, bf.getType("mock")); assertEquals(Runnable.class, bf.getType("mock")); Map<String, Runnable> beans = bf.getBeansOfType(Runnable.class); assertEquals(1, beans.size()); }
Example #9
Source File: ZebraMapperScannerConfigurer.java From Zebra with Apache License 2.0 | 6 votes |
private String updatePropertyValue(String propertyName, PropertyValues values) { PropertyValue property = values.getPropertyValue(propertyName); if (property == null) { return null; } Object value = property.getValue(); if (value == null) { return null; } else if (value instanceof String) { return value.toString(); } else if (value instanceof TypedStringValue) { return ((TypedStringValue) value).getValue(); } else { return null; } }
Example #10
Source File: AspectJAutoProxyBeanDefinitionParser.java From java-technology-stack with MIT License | 6 votes |
private void addIncludePatterns(Element element, ParserContext parserContext, BeanDefinition beanDef) { ManagedList<TypedStringValue> includePatterns = new ManagedList<>(); NodeList childNodes = element.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node node = childNodes.item(i); if (node instanceof Element) { Element includeElement = (Element) node; TypedStringValue valueHolder = new TypedStringValue(includeElement.getAttribute("name")); valueHolder.setSource(parserContext.extractSource(includeElement)); includePatterns.add(valueHolder); } } if (!includePatterns.isEmpty()) { includePatterns.setSource(parserContext.extractSource(element)); beanDef.getPropertyValues().add("includePatterns", includePatterns); } }
Example #11
Source File: BeanDefinitionParserDelegate.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Parse a props element. */ public Properties parsePropsElement(Element propsEle) { ManagedProperties props = new ManagedProperties(); props.setSource(extractSource(propsEle)); props.setMergeEnabled(parseMergeAttribute(propsEle)); List<Element> propEles = DomUtils.getChildElementsByTagName(propsEle, PROP_ELEMENT); for (Element propEle : propEles) { String key = propEle.getAttribute(KEY_ATTRIBUTE); // Trim the text value to avoid unwanted whitespace // caused by typical XML formatting. String value = DomUtils.getTextValue(propEle).trim(); TypedStringValue keyHolder = new TypedStringValue(key); keyHolder.setSource(extractSource(propEle)); TypedStringValue valueHolder = new TypedStringValue(value); valueHolder.setSource(extractSource(propEle)); props.put(keyHolder, valueHolder); } return props; }
Example #12
Source File: BeanDefinitionParserDelegate.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Return a typed String value Object for the given value element. */ public Object parseValueElement(Element ele, String defaultTypeName) { // It's a literal value. String value = DomUtils.getTextValue(ele); String specifiedTypeName = ele.getAttribute(TYPE_ATTRIBUTE); String typeName = specifiedTypeName; if (!StringUtils.hasText(typeName)) { typeName = defaultTypeName; } try { TypedStringValue typedValue = buildTypedStringValue(value, typeName); typedValue.setSource(extractSource(ele)); typedValue.setSpecifiedTypeName(specifiedTypeName); return typedValue; } catch (ClassNotFoundException ex) { error("Type class [" + typeName + "] not found for <value> element", ele, ex); return value; } }
Example #13
Source File: BeanDefinitionParserDelegate.java From java-technology-stack with MIT License | 6 votes |
/** * Parse a props element. */ public Properties parsePropsElement(Element propsEle) { ManagedProperties props = new ManagedProperties(); props.setSource(extractSource(propsEle)); props.setMergeEnabled(parseMergeAttribute(propsEle)); List<Element> propEles = DomUtils.getChildElementsByTagName(propsEle, PROP_ELEMENT); for (Element propEle : propEles) { String key = propEle.getAttribute(KEY_ATTRIBUTE); // Trim the text value to avoid unwanted whitespace // caused by typical XML formatting. String value = DomUtils.getTextValue(propEle).trim(); TypedStringValue keyHolder = new TypedStringValue(key); keyHolder.setSource(extractSource(propEle)); TypedStringValue valueHolder = new TypedStringValue(value); valueHolder.setSource(extractSource(propEle)); props.put(keyHolder, valueHolder); } return props; }
Example #14
Source File: BeanDefinitionParserDelegate.java From java-technology-stack with MIT License | 6 votes |
/** * Return a typed String value Object for the given value element. */ public Object parseValueElement(Element ele, @Nullable String defaultTypeName) { // It's a literal value. String value = DomUtils.getTextValue(ele); String specifiedTypeName = ele.getAttribute(TYPE_ATTRIBUTE); String typeName = specifiedTypeName; if (!StringUtils.hasText(typeName)) { typeName = defaultTypeName; } try { TypedStringValue typedValue = buildTypedStringValue(value, typeName); typedValue.setSource(extractSource(ele)); typedValue.setSpecifiedTypeName(specifiedTypeName); return typedValue; } catch (ClassNotFoundException ex) { error("Type class [" + typeName + "] not found for <value> element", ele, ex); return value; } }
Example #15
Source File: BeanFactoryGenericsTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void parameterizedInstanceFactoryMethodWithWrappedClassName() { DefaultListableBeanFactory bf = new DefaultListableBeanFactory(); RootBeanDefinition rbd = new RootBeanDefinition(); rbd.setBeanClassName(Mockito.class.getName()); rbd.setFactoryMethodName("mock"); // TypedStringValue used to be equivalent to an XML-defined argument String rbd.getConstructorArgumentValues().addGenericArgumentValue(new TypedStringValue(Runnable.class.getName())); bf.registerBeanDefinition("mock", rbd); assertTrue(bf.isTypeMatch("mock", Runnable.class)); assertTrue(bf.isTypeMatch("mock", Runnable.class)); assertEquals(Runnable.class, bf.getType("mock")); assertEquals(Runnable.class, bf.getType("mock")); Map<String, Runnable> beans = bf.getBeansOfType(Runnable.class); assertEquals(1, beans.size()); }
Example #16
Source File: AspectJAutoProxyBeanDefinitionParser.java From spring4-understanding with Apache License 2.0 | 6 votes |
private void addIncludePatterns(Element element, ParserContext parserContext, BeanDefinition beanDef) { ManagedList<TypedStringValue> includePatterns = new ManagedList<TypedStringValue>(); NodeList childNodes = element.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node node = childNodes.item(i); if (node instanceof Element) { Element includeElement = (Element) node; TypedStringValue valueHolder = new TypedStringValue(includeElement.getAttribute("name")); valueHolder.setSource(parserContext.extractSource(includeElement)); includePatterns.add(valueHolder); } } if (!includePatterns.isEmpty()) { includePatterns.setSource(parserContext.extractSource(element)); beanDef.getPropertyValues().add("includePatterns", includePatterns); } }
Example #17
Source File: BeanDefinitionParserDelegate.java From blog_demos with Apache License 2.0 | 6 votes |
/** * Parse a props element. */ public Properties parsePropsElement(Element propsEle) { ManagedProperties props = new ManagedProperties(); props.setSource(extractSource(propsEle)); props.setMergeEnabled(parseMergeAttribute(propsEle)); List<Element> propEles = DomUtils.getChildElementsByTagName(propsEle, PROP_ELEMENT); for (Element propEle : propEles) { String key = propEle.getAttribute(KEY_ATTRIBUTE); // Trim the text value to avoid unwanted whitespace // caused by typical XML formatting. String value = DomUtils.getTextValue(propEle).trim(); TypedStringValue keyHolder = new TypedStringValue(key); keyHolder.setSource(extractSource(propEle)); TypedStringValue valueHolder = new TypedStringValue(value); valueHolder.setSource(extractSource(propEle)); props.put(keyHolder, valueHolder); } return props; }
Example #18
Source File: BeanDefinitionParserDelegate.java From blog_demos with Apache License 2.0 | 6 votes |
/** * Return a typed String value Object for the given value element. */ public Object parseValueElement(Element ele, String defaultTypeName) { // It's a literal value. String value = DomUtils.getTextValue(ele); String specifiedTypeName = ele.getAttribute(TYPE_ATTRIBUTE); String typeName = specifiedTypeName; if (!StringUtils.hasText(typeName)) { typeName = defaultTypeName; } try { TypedStringValue typedValue = buildTypedStringValue(value, typeName); typedValue.setSource(extractSource(ele)); typedValue.setSpecifiedTypeName(specifiedTypeName); return typedValue; } catch (ClassNotFoundException ex) { error("Type class [" + typeName + "] not found for <value> element", ele, ex); return value; } }
Example #19
Source File: AspectJAutoProxyBeanDefinitionParser.java From spring-analysis-note with MIT License | 6 votes |
private void addIncludePatterns(Element element, ParserContext parserContext, BeanDefinition beanDef) { ManagedList<TypedStringValue> includePatterns = new ManagedList<>(); NodeList childNodes = element.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node node = childNodes.item(i); if (node instanceof Element) { Element includeElement = (Element) node; TypedStringValue valueHolder = new TypedStringValue(includeElement.getAttribute("name")); valueHolder.setSource(parserContext.extractSource(includeElement)); includePatterns.add(valueHolder); } } if (!includePatterns.isEmpty()) { includePatterns.setSource(parserContext.extractSource(element)); beanDef.getPropertyValues().add("includePatterns", includePatterns); } }
Example #20
Source File: AspectJAutoProxyBeanDefinitionParser.java From lams with GNU General Public License v2.0 | 6 votes |
private void addIncludePatterns(Element element, ParserContext parserContext, BeanDefinition beanDef) { ManagedList<TypedStringValue> includePatterns = new ManagedList<TypedStringValue>(); NodeList childNodes = element.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node node = childNodes.item(i); if (node instanceof Element) { Element includeElement = (Element) node; TypedStringValue valueHolder = new TypedStringValue(includeElement.getAttribute("name")); valueHolder.setSource(parserContext.extractSource(includeElement)); includePatterns.add(valueHolder); } } if (!includePatterns.isEmpty()) { includePatterns.setSource(parserContext.extractSource(element)); beanDef.getPropertyValues().add("includePatterns", includePatterns); } }
Example #21
Source File: BeanDefinitionParserDelegate.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Return a typed String value Object for the given value element. */ public Object parseValueElement(Element ele, String defaultTypeName) { // It's a literal value. String value = DomUtils.getTextValue(ele); String specifiedTypeName = ele.getAttribute(TYPE_ATTRIBUTE); String typeName = specifiedTypeName; if (!StringUtils.hasText(typeName)) { typeName = defaultTypeName; } try { TypedStringValue typedValue = buildTypedStringValue(value, typeName); typedValue.setSource(extractSource(ele)); typedValue.setSpecifiedTypeName(specifiedTypeName); return typedValue; } catch (ClassNotFoundException ex) { error("Type class [" + typeName + "] not found for <value> element", ele, ex); return value; } }
Example #22
Source File: EventPublicationTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void beanEventReceived() throws Exception { ComponentDefinition componentDefinition1 = this.eventListener.getComponentDefinition("testBean"); assertTrue(componentDefinition1 instanceof BeanComponentDefinition); assertEquals(1, componentDefinition1.getBeanDefinitions().length); BeanDefinition beanDefinition1 = componentDefinition1.getBeanDefinitions()[0]; assertEquals(new TypedStringValue("Rob Harrop"), beanDefinition1.getConstructorArgumentValues().getGenericArgumentValue(String.class).getValue()); assertEquals(1, componentDefinition1.getBeanReferences().length); assertEquals("testBean2", componentDefinition1.getBeanReferences()[0].getBeanName()); assertEquals(1, componentDefinition1.getInnerBeanDefinitions().length); BeanDefinition innerBd1 = componentDefinition1.getInnerBeanDefinitions()[0]; assertEquals(new TypedStringValue("ACME"), innerBd1.getConstructorArgumentValues().getGenericArgumentValue(String.class).getValue()); assertTrue(componentDefinition1.getSource() instanceof Element); ComponentDefinition componentDefinition2 = this.eventListener.getComponentDefinition("testBean2"); assertTrue(componentDefinition2 instanceof BeanComponentDefinition); assertEquals(1, componentDefinition1.getBeanDefinitions().length); BeanDefinition beanDefinition2 = componentDefinition2.getBeanDefinitions()[0]; assertEquals(new TypedStringValue("Juergen Hoeller"), beanDefinition2.getPropertyValues().getPropertyValue("name").getValue()); assertEquals(0, componentDefinition2.getBeanReferences().length); assertEquals(1, componentDefinition2.getInnerBeanDefinitions().length); BeanDefinition innerBd2 = componentDefinition2.getInnerBeanDefinitions()[0]; assertEquals(new TypedStringValue("Eva Schallmeiner"), innerBd2.getPropertyValues().getPropertyValue("name").getValue()); assertTrue(componentDefinition2.getSource() instanceof Element); }
Example #23
Source File: ScriptingDefaultsParser.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public BeanDefinition parse(Element element, ParserContext parserContext) { BeanDefinition bd = LangNamespaceUtils.registerScriptFactoryPostProcessorIfNecessary(parserContext.getRegistry()); String refreshCheckDelay = element.getAttribute(REFRESH_CHECK_DELAY_ATTRIBUTE); if (StringUtils.hasText(refreshCheckDelay)) { bd.getPropertyValues().add("defaultRefreshCheckDelay", new Long(refreshCheckDelay)); } String proxyTargetClass = element.getAttribute(PROXY_TARGET_CLASS_ATTRIBUTE); if (StringUtils.hasText(proxyTargetClass)) { bd.getPropertyValues().add("defaultProxyTargetClass", new TypedStringValue(proxyTargetClass, Boolean.class)); } return null; }
Example #24
Source File: DictionaryBeanFactoryPostProcessor.java From rice with Educational Community License v2.0 | 5 votes |
/** * Indicate whether the given value is a string or holds a string * * @param value value to test * @return boolean true if the value is a string, false if not */ protected boolean isStringValue(Object value) { boolean isString = false; if (value instanceof TypedStringValue || (value instanceof String)) { isString = true; } return isString; }
Example #25
Source File: SpringValueDefinitionProcessor.java From apollo with Apache License 2.0 | 5 votes |
private void processPropertyValues(BeanDefinitionRegistry beanRegistry) { if (!PROPERTY_VALUES_PROCESSED_BEAN_FACTORIES.add(beanRegistry)) { // already initialized return; } if (!beanName2SpringValueDefinitions.containsKey(beanRegistry)) { beanName2SpringValueDefinitions.put(beanRegistry, LinkedListMultimap.<String, SpringValueDefinition>create()); } Multimap<String, SpringValueDefinition> springValueDefinitions = beanName2SpringValueDefinitions.get(beanRegistry); String[] beanNames = beanRegistry.getBeanDefinitionNames(); for (String beanName : beanNames) { BeanDefinition beanDefinition = beanRegistry.getBeanDefinition(beanName); MutablePropertyValues mutablePropertyValues = beanDefinition.getPropertyValues(); List<PropertyValue> propertyValues = mutablePropertyValues.getPropertyValueList(); for (PropertyValue propertyValue : propertyValues) { Object value = propertyValue.getValue(); if (!(value instanceof TypedStringValue)) { continue; } String placeholder = ((TypedStringValue) value).getValue(); Set<String> keys = placeholderHelper.extractPlaceholderKeys(placeholder); if (keys.isEmpty()) { continue; } for (String key : keys) { springValueDefinitions.put(beanName, new SpringValueDefinition(key, placeholder, propertyValue.getName())); } } } }
Example #26
Source File: DictionaryBeanFactoryPostProcessor.java From rice with Educational Community License v2.0 | 5 votes |
/** * Determines whether the given value is of String type and if so returns the string value * * @param value object value to check * @return String string value for object or null if object is not a string type */ protected String getString(Object value) { String stringValue = null; if (value instanceof TypedStringValue || (value instanceof String)) { if (value instanceof TypedStringValue) { TypedStringValue typedStringValue = (TypedStringValue) value; stringValue = typedStringValue.getValue(); } else { stringValue = (String) value; } } return stringValue; }
Example #27
Source File: BeanDefinitionParserDelegate.java From blog_demos with Apache License 2.0 | 5 votes |
/** * Build a typed String value Object for the given raw value. * @see org.springframework.beans.factory.config.TypedStringValue */ protected final Object buildTypedStringValueForMap(String value, String defaultTypeName, Element entryEle) { try { TypedStringValue typedValue = buildTypedStringValue(value, defaultTypeName); typedValue.setSource(extractSource(entryEle)); return typedValue; } catch (ClassNotFoundException ex) { error("Type class [" + defaultTypeName + "] not found for Map key/value type", entryEle, ex); return value; } }
Example #28
Source File: DictionaryBeanProcessorBase.java From rice with Educational Community License v2.0 | 5 votes |
/** * Determines whether the given value is of String type and if so returns the string value * * @param value object value to check * @return String string value for object or null if object is not a string type */ protected String getStringValue(Object value) { if (value instanceof TypedStringValue) { TypedStringValue typedStringValue = (TypedStringValue) value; return typedStringValue.getValue(); } else if (value instanceof String) { return (String) value; } return null; }
Example #29
Source File: BeanDefinitionValueResolver.java From blog_demos with Apache License 2.0 | 5 votes |
/** * Evaluate the given value as an expression, if necessary. * @param value the candidate value (may be an expression) * @return the resolved value */ protected Object evaluate(TypedStringValue value) { Object result = this.beanFactory.evaluateBeanDefinitionString(value.getValue(), this.beanDefinition); if (!ObjectUtils.nullSafeEquals(result, value.getValue())) { value.setDynamic(); } return result; }
Example #30
Source File: BeanDefinitionWriterServiceImpl.java From geomajas-project-server with GNU Affero General Public License v3.0 | 5 votes |
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { BeanDefinition definition = (BeanDefinition) source; writer.addAttribute("class", definition.getBeanClassName()); for (PropertyValue property : definition.getPropertyValues().getPropertyValueList()) { writer.startNode("property"); writer.addAttribute("name", property.getName()); if (property.getValue().getClass().equals(TypedStringValue.class)) { context.convertAnother(property.getValue()); } else { writeItem(property.getValue(), context, writer); } writer.endNode(); } }