List of usage examples for org.springframework.beans.factory.support AbstractBeanDefinition getPropertyValues
@Override
public MutablePropertyValues getPropertyValues()
From source file:uk.org.ponder.rsac.support.BeanDefUtil.java
static RSACBeanInfo convertBeanDef(BeanDefinition origdef, String beanname, ConfigurableListableBeanFactory factory, MethodAnalyser abdAnalyser, BeanDefConverter converter) { RSACBeanInfo rbi = new RSACBeanInfo(); AbstractBeanDefinition def = getMergedBeanDefinition(factory, beanname, origdef); MutablePropertyValues pvs = def.getPropertyValues(); PropertyValue[] values = pvs.getPropertyValues(); for (int j = 0; j < values.length; ++j) { PropertyValue thispv = values[j]; Object beannames = BeanDefUtil.propertyValueToBeanName(thispv.getValue(), converter); boolean skip = false; // skip recording the dependency if it was unresolvable (some // unrecognised // type) or was a single-valued type referring to a static dependency. // NB - we now record ALL dependencies - bean-copying strategy // discontinued. if (beannames == null // || beannames instanceof String // && !blankcontext.containsBean((String) beannames) ) {//from w w w. ja v a 2s .c om skip = true; } if (!skip) { rbi.recordDependency(thispv.getName(), beannames); } } // NB - illegal cast here is unavoidable. // Bit of a problem here with Spring flow - apparently the bean class // will NOT be set for a "factory-method" bean UNTIL it has been // instantiated // via the logic in AbstractAutowireCapableBeanFactory l.376: // protected BeanWrapper instantiateUsingFactoryMethod( AbstractBeanDefinition abd = def; rbi.factorybean = abd.getFactoryBeanName(); rbi.factorymethod = abd.getFactoryMethodName(); rbi.initmethod = abd.getInitMethodName(); rbi.destroymethod = abd.getDestroyMethodName(); rbi.islazyinit = abd.isLazyInit(); rbi.dependson = abd.getDependsOn(); rbi.issingleton = abd.isSingleton(); rbi.isabstract = abd.isAbstract(); rbi.aliases = factory.containsBeanDefinition(beanname) ? factory.getAliases(beanname) : StringArrayParser.EMPTY_STRINGL; if (abd.hasConstructorArgumentValues()) { ConstructorArgumentValues cav = abd.getConstructorArgumentValues(); boolean hasgeneric = !cav.getGenericArgumentValues().isEmpty(); boolean hasindexed = !cav.getIndexedArgumentValues().isEmpty(); if (hasgeneric && hasindexed) { throw new UnsupportedOperationException("RSAC Bean " + beanname + " has both indexed and generic constructor arguments, which is not supported"); } if (hasgeneric) { List cvalues = cav.getGenericArgumentValues(); rbi.constructorargvals = new ConstructorArgumentValues.ValueHolder[cvalues.size()]; for (int i = 0; i < cvalues.size(); ++i) { rbi.constructorargvals[i] = (ConstructorArgumentValues.ValueHolder) cvalues.get(i); } } else if (hasindexed) { Map cvalues = cav.getIndexedArgumentValues(); rbi.constructorargvals = new ConstructorArgumentValues.ValueHolder[cvalues.size()]; for (int i = 0; i < cvalues.size(); ++i) { rbi.constructorargvals[i] = (ConstructorArgumentValues.ValueHolder) cvalues.get(new Integer(i)); } } } if (rbi.factorymethod == null) { // Core Spring change at 2.0M5 - ALL bean classes are now irrevocably // lazy!! // Package org.springframework.beans // introduced lazy loading (and lazy validation) of bean classes in // standard bean factories and bean definition readers AccessMethod bcnaccess = abdAnalyser.getAccessMethod("beanClassName"); if (bcnaccess != null) { String bcn = (String) bcnaccess.getChildObject(abd); if (bcn != null) { rbi.beanclass = ClassGetter.forName(bcn); if (rbi.beanclass == null) { throw new IllegalArgumentException("Class name " + bcn + " for bean definition with name " + beanname + " cannot be resolved"); } } } else { // all right then BE like that! We'll work out the class later. // NB - beandef.getBeanClass() was eliminated around 1.2, we must // use the downcast even earlier now. rbi.beanclass = abd.getBeanClass(); } } return rbi; }
From source file:com.bstek.dorado.spring.ClassTypeListShortCutDecorator.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) { AbstractBeanDefinition beanDef = (AbstractBeanDefinition) definition.getBeanDefinition(); MutablePropertyValues propertyValues = (beanDef.getPropertyValues() == null) ? new MutablePropertyValues() : beanDef.getPropertyValues(); ManagedList list = null;/*from ww w . j a v a 2 s . c om*/ boolean firstPropertyValue = propertyValues.getPropertyValue(IMPL_TYPES) == null; if (!firstPropertyValue) { list = (ManagedList) (propertyValues.getPropertyValue(IMPL_TYPES).getValue()); } else { list = new ManagedList(); list.setSource(node); list.setMergeEnabled(true); propertyValues.addPropertyValue(IMPL_TYPES, list); beanDef.setPropertyValues(propertyValues); } Element el = (Element) node; String className = el.getAttribute("name"); try { list.add(Class.forName(className)); } catch (ClassNotFoundException e) { logger.warn(e, e); } return definition; }
From source file:com.bstek.dorado.spring.MapEntryShortCutDecorator.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) { AbstractBeanDefinition beanDef = (AbstractBeanDefinition) definition.getBeanDefinition(); MutablePropertyValues propertyValues = (beanDef.getPropertyValues() == null) ? new MutablePropertyValues() : beanDef.getPropertyValues(); ManagedMap map = null;/* ww w . ja v a2s .c o m*/ boolean firstPropertyValue = propertyValues.getPropertyValue(property) == null; if (!firstPropertyValue) { map = (ManagedMap) (propertyValues.getPropertyValue(property).getValue()); } else { map = new ManagedMap(); map.setSource(node); map.setMergeEnabled(true); propertyValues.addPropertyValue(property, map); beanDef.setPropertyValues(propertyValues); } Element el = (Element) node; String key = el.getAttribute("key"); String value = el.getAttribute("value"); String valueRef = el.getAttribute("value-ref"); Object entryValue = null; if (StringUtils.isNotEmpty(value)) { entryValue = value; } else if (StringUtils.isNotEmpty(valueRef)) { RuntimeBeanReference ref = new RuntimeBeanReference(valueRef); ref.setSource(parserContext.getReaderContext().extractSource(el)); entryValue = ref; } else { Element beanEl = DomUtils.getChildElementByTagName(el, "bean"); if (beanEl != null) { entryValue = parserContext.getDelegate().parseBeanDefinitionElement(beanEl); } } if (supportsMultiKey && StringUtils.isNotEmpty(key)) { for (String k : StringUtils.split(key, KEY_DELIM)) { map.put(k, entryValue); } } else { map.put(key, entryValue); } return definition; }
From source file:org.activiti.spring.components.config.xml.ActivitiAnnotationDrivenBeanDefinitionParser.java
private void configureProcessEngine(AbstractBeanDefinition abstractBeanDefinition, Element element) { String procEngineRef = element.getAttribute(processEngineAttribute); if (StringUtils.hasText(procEngineRef)) abstractBeanDefinition.getPropertyValues().add( Conventions.attributeNameToPropertyName(processEngineAttribute), new RuntimeBeanReference(procEngineRef)); }
From source file:org.springmodules.cache.config.MethodMapInterceptorsParserTests.java
public void testParseCacheSetupStrategy() { parser.parseCacheSetupStrategy(config.toXml(), parserContext, propertySource); // verify the properties of the caching interceptor. AbstractBeanDefinition cachingInterceptor = (AbstractBeanDefinition) registry .getBeanDefinition(config.cachingInterceptorId); MutablePropertyValues cachingProperties = cachingInterceptor.getPropertyValues(); assertSame(propertySource.cacheKeyGenerator, cachingProperties.getPropertyValue("cacheKeyGenerator").getValue()); assertSame(propertySource.cacheProviderFacadeReference, cachingProperties.getPropertyValue("cacheProviderFacade").getValue()); assertSame(propertySource.cachingListeners, cachingProperties.getPropertyValue("cachingListeners").getValue()); assertSame(propertySource.cachingModelMap, cachingProperties.getPropertyValue("cachingModels").getValue()); // verify the properties of the flushing interceptor. AbstractBeanDefinition flushingInterceptor = (AbstractBeanDefinition) registry .getBeanDefinition(config.flushingInterceptorId); MutablePropertyValues flushingProperties = flushingInterceptor.getPropertyValues(); assertSame(propertySource.cacheProviderFacadeReference, flushingProperties.getPropertyValue("cacheProviderFacade").getValue()); assertSame(propertySource.flushingModelMap, flushingProperties.getPropertyValue("flushingModels").getValue()); }
From source file:org.echocat.jomon.spring.BeanPostConfigurer.java
@Nonnull protected MutablePropertyValues getPropertyValues(@Nonnull AbstractBeanDefinition beanDefinition) { MutablePropertyValues propertyValues = beanDefinition.getPropertyValues(); if (propertyValues == null) { propertyValues = new MutablePropertyValues(); beanDefinition.setPropertyValues(propertyValues); }//w w w. j a v a 2 s. co m return propertyValues; }
From source file:net.phoenix.thrift.xml.ArgBeanDefinitionParser.java
/** * ?arg/* w w w.j av a 2s.co m*/ */ @Override protected void postParse(Element element, ParserContext parserContext, AbstractBeanDefinition current) { Object argument = parserContext.getDelegate().parsePropertyValue(element, current, "argument"); if (argument == null) throw new BeanCreationException( "Could not found value for arg '" + element.getAttribute("name") + "'."); current.getPropertyValues().add("argument", argument); // register the definition; if (parserContext.isNested()) { this.registerBeanDefinition(element, parserContext, current); } }
From source file:de.acosix.alfresco.mtsupport.repo.beans.TemplatedTenantBeanEmitter.java
protected void shallowCloneManagedCollections(final AbstractBeanDefinition cloneBeanDefinition) { // clone is not a deep clone - managed lists / maps are by-reference which is problematic for placeholder resolution final MutablePropertyValues propertyValues = cloneBeanDefinition.getPropertyValues(); for (final PropertyValue pv : propertyValues.getPropertyValues()) { final Object value = pv.getValue(); if (value instanceof ManagedList<?>) { final ManagedList<Object> newList = new ManagedList<>(); newList.setSource(((ManagedList<?>) value).getSource()); newList.setElementTypeName(((ManagedList<?>) value).getElementTypeName()); newList.addAll((ManagedList<?>) value); propertyValues.add(pv.getName(), newList); } else if (value instanceof ManagedSet<?>) { final ManagedSet<Object> newSet = new ManagedSet<>(); newSet.setSource(((ManagedSet<?>) value).getSource()); newSet.setElementTypeName(((ManagedSet<?>) value).getElementTypeName()); newSet.addAll((ManagedSet<?>) value); propertyValues.add(pv.getName(), newSet); } else if (value instanceof ManagedMap<?, ?>) { final ManagedMap<Object, Object> newMap = new ManagedMap<>(); newMap.setSource(((ManagedMap<?, ?>) value).getSource()); newMap.setKeyTypeName(((ManagedMap<?, ?>) value).getKeyTypeName()); newMap.setValueTypeName(((ManagedMap<?, ?>) value).getValueTypeName()); newMap.putAll((ManagedMap<?, ?>) value); propertyValues.add(pv.getName(), newMap); }/*from ww w . j av a2s. c o m*/ } }
From source file:grails.plugin.cache.CacheBeanPostProcessor.java
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) { log.info("postProcessBeanDefinitionRegistry start"); AbstractBeanDefinition beanDef = findBeanDefinition(registry); if (beanDef == null) { log.error("Unable to find the AnnotationCacheOperationSource bean definition"); return;//from w w w .j ava 2s . co m } // change the class to the plugin's subclass beanDef.setBeanClass(GrailsAnnotationCacheOperationSource.class); // wire in the dependency for the grailsApplication MutablePropertyValues props = beanDef.getPropertyValues(); if (props == null) { props = new MutablePropertyValues(); beanDef.setPropertyValues(props); } props.addPropertyValue("grailsApplication", new RuntimeBeanReference("grailsApplication", true)); log.debug("updated {}", beanDef); }
From source file:eap.config.ConfigBeanDefinitionParser.java
/** * Parses the supplied {@code <advisor>} element and registers the resulting * {@link org.springframework.aop.Advisor} and any resulting {@link org.springframework.aop.Pointcut} * with the supplied {@link BeanDefinitionRegistry}. *//*from www .j av a2 s . c o m*/ private void parseAdvisor(Element advisorElement, ParserContext parserContext) { AbstractBeanDefinition advisorDef = createAdvisorBeanDefinition(advisorElement, parserContext); String id = advisorElement.getAttribute(ID); try { this.parseState.push(new AdvisorEntry(id)); String advisorBeanName = id; if (StringUtils.hasText(advisorBeanName)) { parserContext.getRegistry().registerBeanDefinition(advisorBeanName, advisorDef); } else { advisorBeanName = parserContext.getReaderContext().registerWithGeneratedName(advisorDef); } Object pointcut = parsePointcutProperty(advisorElement, parserContext); if (pointcut instanceof BeanDefinition) { advisorDef.getPropertyValues().add(POINTCUT, pointcut); parserContext.registerComponent( new AdvisorComponentDefinition(advisorBeanName, advisorDef, (BeanDefinition) pointcut)); } else if (pointcut instanceof String) { advisorDef.getPropertyValues().add(POINTCUT, new RuntimeBeanReference((String) pointcut)); parserContext.registerComponent(new AdvisorComponentDefinition(advisorBeanName, advisorDef)); } } finally { this.parseState.pop(); } }