List of usage examples for org.springframework.beans.factory.config RuntimeBeanReference RuntimeBeanReference
public RuntimeBeanReference(Class<?> beanType)
From source file:net.phoenix.thrift.xml.ProcessorBeanDefinitionParser.java
/** * TMultiplexedProcessor.registerProcessor(String serviceName, TProcessor * processor) ?processor ?MethodInvokingFactoryBean? * * @param serviceName/* w w w. j a va 2 s .c om*/ * @param processBeanName */ private String registerProcessor(ParserContext parserContext, String serviceName, String processBeanName) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(MethodInvokingBean.class); builder.addPropertyReference("targetObject", this.beanName); builder.addPropertyValue("targetMethod", "registerProcessor"); ManagedArray arguments = new ManagedArray(Object.class.getName(), 2); arguments.add(serviceName); arguments.add(new RuntimeBeanReference(processBeanName)); builder.addPropertyValue("arguments", arguments); String registerProcessorBeanName = processBeanName + "-registerProcessor"; parserContext.getRegistry().registerBeanDefinition(registerProcessorBeanName, builder.getBeanDefinition()); return registerProcessorBeanName; }
From source file:com.inspiresoftware.lib.dto.geda.config.AnnotationDrivenGeDABeanDefinitionParser.java
protected RuntimeBeanReference setupDtoSupport(final Element element, final String dtoSupportBeanName, final BeanDefinitionRegistry registry, final Object elementSource, final RuntimeBeanReference dtoFactoryRef, final RuntimeBeanReference dtoVcrRef, final RuntimeBeanReference dtoDslRef) { final RootBeanDefinition dtoSupportDef = new RootBeanDefinition(DTOSupportImpl.class); dtoSupportDef.setSource(elementSource); dtoSupportDef.setRole(BeanDefinition.ROLE_APPLICATION); final MutablePropertyValues valuesArgs = dtoSupportDef.getPropertyValues(); valuesArgs.addPropertyValue("beanFactory", dtoFactoryRef); if (dtoVcrRef != null) { valuesArgs.addPropertyValue("adaptersRegistrar", dtoVcrRef); }//from w w w. j a va 2 s . com if (dtoDslRef != null) { valuesArgs.addPropertyValue("dslRegistrar", dtoDslRef); } setupListenerProperty(valuesArgs, "onDtoAssembly", element.getAttribute(XSD_ATTR__ON_DTO_ASSEMBLY)); setupListenerProperty(valuesArgs, "onDtoAssembled", element.getAttribute(XSD_ATTR__ON_DTO_ASSEMBLED)); setupListenerProperty(valuesArgs, "onDtoFailed", element.getAttribute(XSD_ATTR__ON_DTO_FAILED)); setupListenerProperty(valuesArgs, "onEntityAssembly", element.getAttribute(XSD_ATTR__ON_ENTITY_ASSEMBLY)); setupListenerProperty(valuesArgs, "onEntityAssembled", element.getAttribute(XSD_ATTR__ON_ENTITY_ASSEMBLED)); setupListenerProperty(valuesArgs, "onEntityFailed", element.getAttribute(XSD_ATTR__ON_ENTITY_FAILED)); registry.registerBeanDefinition(dtoSupportBeanName, dtoSupportDef); return new RuntimeBeanReference(dtoSupportBeanName); }
From source file:org.jsr107.ri.annotations.spring.config.AnnotationDrivenJCacheBeanDefinitionParser.java
/** * Create {@link org.aopalliance.intercept.MethodInterceptor} that is applies the caching logic to advised methods. * * @return Reference to the {@link org.aopalliance.intercept.MethodInterceptor}. Should never be null. *//*from w w w. j a v a 2 s. com*/ protected RuntimeBeanReference setupInterceptor(Class<? extends AbstractCacheInterceptor<?>> interceptorClass, ParserContext parserContext, Object elementSource, RuntimeBeanReference cacheOperationSourceRuntimeReference) { final RootBeanDefinition interceptor = new RootBeanDefinition(interceptorClass); interceptor.setSource(elementSource); interceptor.setRole(BeanDefinition.ROLE_INFRASTRUCTURE); final ConstructorArgumentValues constructorArgumentValues = new ConstructorArgumentValues(); constructorArgumentValues.addIndexedArgumentValue(0, cacheOperationSourceRuntimeReference); interceptor.setConstructorArgumentValues(constructorArgumentValues); final XmlReaderContext readerContext = parserContext.getReaderContext(); final String interceptorBeanName = readerContext.registerWithGeneratedName(interceptor); return new RuntimeBeanReference(interceptorBeanName); }
From source file:com.weibo.api.motan.config.springsupport.MotanBeanDefinitionParser.java
@SuppressWarnings({ "unchecked", "rawtypes" }) private static void parseMultiRef(String property, String value, RootBeanDefinition beanDefinition, ParserContext parserContext) {/* w ww . ja v a2 s. co m*/ String[] values = value.split("\\s*[,]+\\s*"); ManagedList list = null; for (int i = 0; i < values.length; i++) { String v = values[i]; if (v != null && v.length() > 0) { if (list == null) { list = new ManagedList(); } list.add(new RuntimeBeanReference(v)); } } beanDefinition.getPropertyValues().addPropertyValue(property, list); }
From source file:org.springmodules.cache.config.CacheSetupStrategyParserTests.java
/** * Verifies that the method//from w w w . j ava 2 s.co m * <code>{@link AbstractCacheSetupStrategyParser#parse(Element, org.springframework.beans.factory.xml.ParserContext)}</code> * does not create a list of caching models if the XML element to parse does * not include any "cachingListener" subelement. */ public void testParseWithoutCachingListeners() { int modelCount = 2; registerCacheProviderFacadeDefinition(); elementBuilder.setDefaultCachingModelElementBuilders(modelCount); elementBuilder.setDefaultFlushingModelElementBuilders(modelCount); Map cachingModelMap = expectCachingModelParsing(); Map flushingModelMap = expectFlushingModelParsing(); Element element = elementBuilder.toXml(); CacheSetupStrategyPropertySource propertySource = new CacheSetupStrategyPropertySource(null, new RuntimeBeanReference(elementBuilder.cacheProviderId), null, cachingModelMap, flushingModelMap); strategyParser.parseCacheSetupStrategy(element, parserContext, propertySource); strategyParserControl.setMatcher(new CacheSetupStrategyPropertySourceMatcher()); replay(); // method to test strategyParser.parse(element, parserContext); verify(); }
From source file:de.acosix.alfresco.mtsupport.repo.beans.TenantLDAPAttributeMappingPostProcessor.java
/** * {@inheritDoc}/*from w w w . j a v a 2 s . com*/ */ @SuppressWarnings("unchecked") @Override public void postProcessBeanDefinitionRegistry(final BeanDefinitionRegistry registry) throws BeansException { if (this.isEnabled()) { final String enabledTenantsProperty = this.effectiveProperties .getProperty(this.enabledTenantPropertyKey); if (enabledTenantsProperty == null || enabledTenantsProperty.trim().isEmpty()) { LOGGER.debug("No tenants have been defined as enabled"); } else { final List<String> enabledTenants = Arrays.asList(enabledTenantsProperty.trim().split("\\s*,\\s*")); LOGGER.debug("Processing custom LDAP attribute mappings for property {} and enabled tenants {}", this.propertyName, enabledTenants); for (final String enabledTenant : enabledTenants) { final String tenantBasePrefix = this.mappingPropertyPrefix + "." + enabledTenant + "." + this.propertyName + "."; final String globalBasePrefix = this.mappingPropertyPrefix + "." + this.propertyName + "."; final String tenantMappingPropertiesKey = tenantBasePrefix + "customMappings"; final String globalMappingPropertiesKey = globalBasePrefix + "customMappings"; final String globalMappingsPropertyString = this.effectiveProperties .getProperty(globalMappingPropertiesKey); final String tenantMappingsPropertyString = this.effectiveProperties .getProperty(tenantMappingPropertiesKey, globalMappingsPropertyString); if (tenantMappingsPropertyString != null && !tenantMappingsPropertyString.trim().isEmpty()) { final BeanDefinition beanDefinition = TenantBeanUtils.getBeanDefinitionForTenant(registry, this.beanName, enabledTenant); Map<Object, Object> configuredMapping; final PropertyValue propertyValue = beanDefinition.getPropertyValues() .getPropertyValue(this.propertyName); if (propertyValue == null) { configuredMapping = new ManagedMap<>(); beanDefinition.getPropertyValues().add(this.propertyName, configuredMapping); } else { final Object value = propertyValue.getValue(); if (value instanceof Map<?, ?>) { configuredMapping = (Map<Object, Object>) value; } else { throw new IllegalStateException("Configured property value is not a map"); } } final String[] mappingProperties = tenantMappingsPropertyString.trim().split("\\s*,\\s*"); for (final String mappingProperty : mappingProperties) { final String globalMappingValuePropertyKey = globalBasePrefix + mappingProperty; final String tenantMappingValuePropertyKey = tenantBasePrefix + mappingProperty; final String globalMappingValue = this.effectiveProperties .getProperty(globalMappingValuePropertyKey); final String tenantMappingValue = this.effectiveProperties .getProperty(tenantMappingValuePropertyKey, globalMappingValue); final String trimmedMappingValue = tenantMappingValue != null ? tenantMappingValue.trim() : null; if (trimmedMappingValue != null && !trimmedMappingValue.isEmpty()) { if (this.beanReferences) { if (VALUE_NULL.equals(trimmedMappingValue)) { configuredMapping.remove(mappingProperty); } else { configuredMapping.put(mappingProperty, new RuntimeBeanReference(trimmedMappingValue)); } } else { if (VALUE_NULL.equals(trimmedMappingValue)) { configuredMapping.put(mappingProperty, null); } else { configuredMapping.put(mappingProperty, trimmedMappingValue); } } } } } } } } }
From source file:com.inspiresoftware.lib.dto.geda.config.AnnotationDrivenGeDABeanDefinitionParser.java
protected void setupListenerProperty(final MutablePropertyValues valuesArgs, final String property, final String listenerName) { if (StringUtils.hasLength(listenerName)) { valuesArgs.addPropertyValue(property, new RuntimeBeanReference(listenerName)); }/*from w w w. j a v a 2 s .c o m*/ }
From source file:org.solmix.runtime.support.spring.AbstractRootBeanDefinitionParser.java
protected static void parseMultiRef(String property, String value, RootBeanDefinition beanDefinition, ParserContext parserContext) {//from w ww .j a v a2 s . c o m String[] values = value.split("\\s*[,]+\\s*"); ManagedList<Object> list = null; for (int i = 0; i < values.length; i++) { String v = values[i]; if (v != null && v.length() > 0) { if (list == null) { list = new ManagedList<Object>(); } list.add(new RuntimeBeanReference(v)); } } beanDefinition.getPropertyValues().addPropertyValue(property, list); }
From source file:com.googlecode.ehcache.annotations.config.AnnotationDrivenEhCacheBeanDefinitionParser.java
/** * Setup the default cache interceptor /*from w ww .j ava 2 s . c o m*/ * * @return A reference to the default cache interceptor. */ protected RuntimeBeanReference setupDefaultCacheableInterceptor(Element element, ParserContext parserContext, Object elementSource) { //If the default cache resolver factory was specified simply return a bean reference for that final String defaultCacheableInterceptor = element.getAttribute(XSD_ATTR__DEFAULT_CACHEABLE_INTECEPTOR); if (StringUtils.hasLength(defaultCacheableInterceptor)) { return new RuntimeBeanReference(defaultCacheableInterceptor); } //Use no reference return null; }
From source file:org.springmodules.cache.config.MetadataAttributesParserTests.java
private void assertFlushingAdvisorIsRegistered() { Class advisorClass = FlushingAttributeSourceAdvisor.class; AbstractBeanDefinition definition = (AbstractBeanDefinition) registry .getBeanDefinition(advisorClass.getName()); ConfigAssert.assertBeanDefinitionWrapsClass(definition, advisorClass); RuntimeBeanReference expectedReference = new RuntimeBeanReference( MetadataFlushingInterceptor.class.getName()); ConfigAssert.assertBeanDefinitionHasConstructorArgument(expectedReference, definition.getConstructorArgumentValues(), 0, RuntimeBeanReference.class); }