List of usage examples for org.springframework.beans.factory.support RootBeanDefinition getPropertyValues
@Override
public MutablePropertyValues getPropertyValues()
From source file:com.googlecode.ehcache.annotations.config.AnnotationDrivenEhCacheBeanDefinitionParser.java
/** * Utility API used to setup each of the default {@link CacheKeyGenerator} implementations. Requires * that the class has a static String field named DEFAULT_BEAN_NAME declared that is used for the bean * name. //from w w w. j a v a 2s .c o m */ protected final void setupDefaultCacheKeyGenerator( Class<? extends CacheKeyGenerator<? extends Serializable>> generatorClass, ParserContext parserContext, Object elementSource) { final String generatorName; try { final Field field = generatorClass.getField("DEFAULT_BEAN_NAME"); generatorName = (String) field.get(null); } catch (Exception e) { throw new IllegalArgumentException("Could not access static field 'DEFAULT_BEAN_NAME' on " + generatorClass + ". This field is required to be setup as a default CacheKeyGenerator", e); } final RootBeanDefinition defaultKeyGenerator = new RootBeanDefinition(generatorClass); defaultKeyGenerator.setSource(elementSource); defaultKeyGenerator.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); if (ReflectionHelperAware.class.isAssignableFrom(generatorClass)) { final RuntimeBeanReference cacheManagerReference = new RuntimeBeanReference( CACHING_REFLECTION_HELPER_BEAN_NAME); final MutablePropertyValues propertyValues = defaultKeyGenerator.getPropertyValues(); propertyValues.addPropertyValue("reflectionHelper", cacheManagerReference); } final BeanDefinitionRegistry registry = parserContext.getRegistry(); registry.registerBeanDefinition(generatorName, defaultKeyGenerator); }
From source file:com.codestd.spring.cxf.config.schema.AnnotationBeanDefinitionParser.java
@Override public BeanDefinition parse(Element element, ParserContext parserContext) { RootBeanDefinition beanDefinition = new RootBeanDefinition(); beanDefinition.setBeanClass(beanClass); beanDefinition.setLazyInit(false);//from w w w . jav a 2 s . c o m String id = element.getAttribute("id"); if (id == null || id.length() == 0) { String name = element.getAttribute("name"); if (!StringUtils.isEmpty(name)) id = name; else id = beanClass.getName(); } if (parserContext.getRegistry().containsBeanDefinition(id)) { throw new IllegalStateException("Duplicate spring bean id " + id); } parserContext.getRegistry().registerBeanDefinition(id, beanDefinition); String annotationPackage = element.getAttribute("package"); if (!StringUtils.isEmpty(annotationPackage)) beanDefinition.getPropertyValues().add("annotationPackage", annotationPackage); return beanDefinition; }
From source file:org.hdiv.config.xml.ConfigBeanDefinitionParser.java
private RootBeanDefinition createDefaultEditableParametersValidations(Element element, Object source) { RootBeanDefinition bean = new RootBeanDefinition(HDIVValidations.class); bean.setSource(source);//from w w w . j a v a2s .co m bean.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); bean.setInitMethodName("init"); Map map = new Hashtable(); bean.getPropertyValues().addPropertyValue("rawUrls", map); return bean; }
From source file:com.bfd.harpc.config.spring.HarpcBeanDefinitionParser.java
/** * {@link#parse}/*from ww w . j a va2 s .co m*/ * <p> * * @param element * @param parserContext * @param clazz * @return {@link BeanDefinition} */ private BeanDefinition parse(Element element, ParserContext parserContext, Class<?> clazz) { RootBeanDefinition beanDefinition = new RootBeanDefinition(); beanDefinition.setBeanClass(clazz); Method[] methods = clazz.getMethods(); String id = StringUtils.EMPTY; for (Method method : methods) { if (method.getName().length() > 3 && method.getName().startsWith("set") && method.getParameterTypes().length == 1) { String attribute = method.getName().substring(3); char ch = attribute.charAt(0); attribute = Character.toLowerCase(ch) + attribute.substring(1); String value = element.getAttribute(attribute); if (StringUtils.isNotEmpty(value)) { Type type = method.getParameterTypes()[0]; if (type == boolean.class) { beanDefinition.getPropertyValues().addPropertyValue(attribute, Boolean.valueOf(value)); } else { if ("ref".equals(attribute) && parserContext.getRegistry().containsBeanDefinition(value)) { beanDefinition.getPropertyValues().addPropertyValue(attribute, new RuntimeBeanReference(value)); } else { beanDefinition.getPropertyValues().addPropertyValue(attribute, value); if ("id".equals(attribute)) { id = value; } } } } } } parserContext.getRegistry().registerBeanDefinition(id, beanDefinition); return beanDefinition; }
From source file:org.solmix.runtime.support.spring.AbstractRootBeanDefinitionParser.java
/**?ID?*/ protected String checkId(Element element, ParserContext parserContext, RootBeanDefinition beanDefinition) { String id = element.getAttribute("id"); if (id == null || id.length() == 0) { String name = element.getAttribute("name"); if (name != null && name.length() != 0) { id = name;//from w w w . jav a2s .c om } else { id = type.getSimpleName() + "-" + Integer.toString(Math.abs(this.hashCode())); } } if (id != null && id.length() > 0) { if (parserContext.getRegistry().containsBeanDefinition(id)) { throw new IllegalStateException("Duplicate spring bean id " + id); } parserContext.getRegistry().registerBeanDefinition(id, beanDefinition); beanDefinition.getPropertyValues().addPropertyValue("id", id); } return id; }
From source file:eap.config.ConfigBeanDefinitionParser.java
/** * Create a {@link RootBeanDefinition} for the advisor described in the supplied. Does <strong>not</strong> * parse any associated '{@code pointcut}' or '{@code pointcut-ref}' attributes. *//* w ww . ja v a 2s . c o m*/ private AbstractBeanDefinition createAdvisorBeanDefinition(Element advisorElement, ParserContext parserContext) { RootBeanDefinition advisorDefinition = new RootBeanDefinition(DefaultBeanFactoryPointcutAdvisor.class); advisorDefinition.setSource(parserContext.extractSource(advisorElement)); String adviceRef = advisorElement.getAttribute(ADVICE_REF); if (!StringUtils.hasText(adviceRef)) { parserContext.getReaderContext().error("'advice-ref' attribute contains empty value.", advisorElement, this.parseState.snapshot()); } else { advisorDefinition.getPropertyValues().add(ADVICE_BEAN_NAME, new RuntimeBeanNameReference(adviceRef)); } if (advisorElement.hasAttribute(ORDER_PROPERTY)) { advisorDefinition.getPropertyValues().add(ORDER_PROPERTY, advisorElement.getAttribute(ORDER_PROPERTY)); } return advisorDefinition; }
From source file:com.inspiresoftware.lib.dto.geda.config.AnnotationDrivenGeDABeanDefinitionParser.java
protected RuntimeBeanReference setupPointcut(final ParserContext parserContext, final Object elementSource, final RuntimeBeanReference resolver, final String[] pointcutMatchRegex, final String[] pointcutNoMatchRegex) { final RootBeanDefinition pointcut; if (pointcutMatchRegex.length == 0 && pointcutNoMatchRegex.length == 0) { pointcut = new RootBeanDefinition(GeDAMethodMatcherPointcut.class); final ConstructorArgumentValues constructorArgs = pointcut.getConstructorArgumentValues(); constructorArgs.addGenericArgumentValue(resolver); } else {//from w w w. j a v a 2 s. com pointcut = new RootBeanDefinition(GeDAMethodRegExMatcherPointcut.class); final ConstructorArgumentValues constructorArgs = pointcut.getConstructorArgumentValues(); constructorArgs.addGenericArgumentValue(resolver); final MutablePropertyValues propertyValues = pointcut.getPropertyValues(); if (pointcutMatchRegex.length > 0) { propertyValues.addPropertyValue("patterns", pointcutMatchRegex); } if (pointcutNoMatchRegex.length > 0) { propertyValues.addPropertyValue("excludedPatterns", pointcutNoMatchRegex); } } pointcut.setSource(elementSource); pointcut.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); final XmlReaderContext readerContext = parserContext.getReaderContext(); final String pointcutBeanName = readerContext.registerWithGeneratedName(pointcut); return new RuntimeBeanReference(pointcutBeanName); }
From source file:org.hdiv.config.xml.ConfigBeanDefinitionParser.java
private RootBeanDefinition createStateCache(Element element, Object source) { RootBeanDefinition bean = new RootBeanDefinition(StateCache.class); bean.setSource(source);//from w ww. ja va 2 s . c om bean.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); bean.setScope(BeanDefinition.SCOPE_PROTOTYPE); bean.setInitMethodName("init"); String maxSize = element.getAttribute("maxPagesPerSession"); if (StringUtils.hasText(maxSize)) { bean.getPropertyValues().addPropertyValue("maxSize", maxSize); } return bean; }
From source file:org.hdiv.config.xml.ConfigBeanDefinitionParser.java
private void processStartPages(Node node, RootBeanDefinition bean) { String method = null;/* w w w.j a v a 2s . c o m*/ if (node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) node; method = element.getAttribute("method"); } String value = node.getTextContent(); List patterns = this.convertToList(value); for (int i = 0; i < patterns.size(); i++) { String pattern = (String) patterns.get(i); StartPage startPage = new StartPage(method, pattern); this.startPages.add(startPage); } bean.getPropertyValues().addPropertyValue("userStartPages", this.startPages); }
From source file:org.devefx.httpmapper.spring.config.ListenersBeanDefinitionParser.java
public BeanDefinition parse(Element element, ParserContext parserContext) { CompositeComponentDefinition compDefinition = new CompositeComponentDefinition(element.getTagName(), parserContext.extractSource(element)); parserContext.pushContainingComponent(compDefinition); RuntimeBeanReference pathMatcherRef = null; if (element.hasAttribute("path-matcher")) { pathMatcherRef = new RuntimeBeanReference(element.getAttribute("path-matcher")); }/* w ww . j av a 2s . co m*/ List<Element> listeners = DomUtils.getChildElementsByTagName(element, "bean", "ref", "listener"); for (Element listener : listeners) { RootBeanDefinition mappedListenerDef = new RootBeanDefinition(MappedListener.class); mappedListenerDef.setSource(parserContext.extractSource(listener)); mappedListenerDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); ManagedList<String> includePatterns = null; ManagedList<String> excludePatterns = null; Object listenerBean; if ("listener".equals(listener.getLocalName())) { includePatterns = getIncludePatterns(listener, "mapping"); excludePatterns = getIncludePatterns(listener, "exclude-mapping"); Element beanElem = DomUtils.getChildElementsByTagName(listener, "bean", "ref").get(0); listenerBean = parserContext.getDelegate().parsePropertySubElement(beanElem, null); } else { listenerBean = parserContext.getDelegate().parsePropertySubElement(listener, null); } mappedListenerDef.getConstructorArgumentValues().addIndexedArgumentValue(0, includePatterns); mappedListenerDef.getConstructorArgumentValues().addIndexedArgumentValue(1, excludePatterns); mappedListenerDef.getConstructorArgumentValues().addIndexedArgumentValue(2, listenerBean); if (pathMatcherRef != null) { mappedListenerDef.getPropertyValues().add("pathMatcher", pathMatcherRef); } String beanName = parserContext.getReaderContext().registerWithGeneratedName(mappedListenerDef); parserContext.registerComponent(new BeanComponentDefinition(mappedListenerDef, beanName)); } parserContext.popAndRegisterContainingComponent(); return null; }