List of usage examples for org.springframework.beans.factory.config BeanDefinition getPropertyValues
MutablePropertyValues getPropertyValues();
From source file:org.bigtester.ate.xmlschema.HomepageBeanDefinitionParser.java
/** * {@inheritDoc}/*from w w w. j av a2 s .c om*/ */ @Override protected AbstractBeanDefinition parseInternal(@Nullable Element element, @Nullable ParserContext parserContext) { // Here we parse the Spring elements such as < property> if (parserContext == null || element == null) throw GlobalUtils.createNotInitializedException("element and parserContext"); // Here we parse the Spring elements such as < property> BeanDefinitionHolder holder = parserContext.getDelegate().parseBeanDefinitionElement(element); BeanDefinition bDef = holder.getBeanDefinition(); bDef.setBeanClassName(Homepage.class.getName()); String homeUrl = element.getAttribute(XsdElementConstants.ATTR_HOMEPAGE_HOMEURL); bDef.getConstructorArgumentValues().addGenericArgumentValue(homeUrl); String dataFile = element.getAttribute(XsdElementConstants.ATTR_BASEPAGEOBJECT_DATAFILE); if (StringUtils.hasText(dataFile)) bDef.getPropertyValues().addPropertyValue(XsdElementConstants.ATTR_BASEPAGEOBJECT_DATAFILE, dataFile); bDef.setParentName(XsdElementConstants.ELEMENT_ID_MYBASEPAGEOBJECT); String idstring = element.getAttribute("id"); parserContext.getRegistry().registerBeanDefinition(idstring, bDef); return (AbstractBeanDefinition) bDef; }
From source file:com.wavemaker.runtime.data.cloudfoundry.CloudFoundryDataServiceBeanFactoryPostProcessor.java
/** * @param beanFactory//w w w . java 2s.c om */ private void processHibernateProperties(DefaultListableBeanFactory beanFactory) { String[] sessionFactoryBeanNames = beanFactory .getBeanNamesForType(ConfigurationAndSessionFactoryBean.class); for (String sfBean : sessionFactoryBeanNames) { BeanDefinition beanDefinition = getBeanDefinition(beanFactory, sfBean); if (sfBean.contains(DataServiceConstants.AUX_BEAN_SUFFIX)) { beanDefinition.setLazyInit(false); } else { beanDefinition.setLazyInit(true); } MutablePropertyValues propertyValues = beanDefinition.getPropertyValues(); PropertyValue hibernateProperties = propertyValues.getPropertyValue("hibernateProperties"); ManagedProperties hibernatePropsPropertyValue = null; if (hibernateProperties != null) { Object value = hibernateProperties.getValue(); if (value instanceof ManagedProperties) { hibernatePropsPropertyValue = (ManagedProperties) hibernateProperties.getValue(); TypedStringValue dialect = (TypedStringValue) hibernatePropsPropertyValue .get(new TypedStringValue(DataServiceConstants.HIBERNATE_DIALECT_PROPERTY)); if (dialect != null && dialect .equals(new TypedStringValue("com.wavemaker.runtime.data.dialect.MySQLDialect"))) { hibernatePropsPropertyValue.put( new TypedStringValue(DataServiceConstants.HIBERNATE_DIALECT_PROPERTY), new TypedStringValue("org.hibernate.dialect.MySQLDialect")); } } } else { hibernatePropsPropertyValue = new ManagedProperties(); } } }
From source file:org.bigtester.ate.xmlschema.BaseElementFinderBeanDefinitionParser.java
/** * {@inheritDoc}/*from w w w .j a v a2 s .co m*/ */ @Override protected @Nullable AbstractBeanDefinition parseInternal(@Nullable Element element, @Nullable ParserContext parserContext) { if (parserContext == null || element == null) throw GlobalUtils.createNotInitializedException("element and parserContext"); BeanDefinitionHolder holder = parserContext.getDelegate().parseBeanDefinitionElement(element); BeanDefinition bDef = holder.getBeanDefinition(); String findbyValue = element.getAttribute(XsdElementConstants.ATTR_GENERICELEMENTFIND_FINDBYVALUE); if (StringUtils.hasText(findbyValue)) bDef.getConstructorArgumentValues().addGenericArgumentValue(findbyValue); String strIndex = element.getAttribute(XsdElementConstants.ATTR_GENERICELEMENTFIND_INDEXOFSAMEELEMENTS); if (StringUtils.hasText(strIndex)) { bDef.getPropertyValues().addPropertyValue( XsdElementConstants.ATTR_GENERICELEMENTFIND_INDEXOFSAMEELEMENTS, new RuntimeBeanReference(strIndex)); } bDef.setAttribute("id", element.getAttribute("id")); return (AbstractBeanDefinition) bDef; }
From source file:com.clican.pluto.dataprocess.spring.parser.ForProcessorParser.java
@SuppressWarnings("unchecked") public void customiseBeanDefinition(BeanDefinition beanDef, Element element, ParserContext parserContext) { this.setBeanDefinitionStringProperty("elementName", beanDef, element); this.setBeanDefinitionStringProperty("step", beanDef, element); this.setBeanDefinitionStringProperty("start", beanDef, element); this.setBeanDefinitionStringProperty("end", beanDef, element); String commit = element.getAttribute("stepCommit"); if (StringUtils.isNotEmpty(commit)) { beanDef.getPropertyValues().addPropertyValue("stepCommit", Boolean.parseBoolean(commit)); }//from w w w . j av a 2s .c o m String iteratorProcessors = element.getAttribute("iteratorProcessors"); List iteratorProcessorList = new ManagedList(); for (String nextDataProcess : iteratorProcessors.split(",")) { nextDataProcess = nextDataProcess.trim(); iteratorProcessorList.add(new RuntimeBeanReference(nextDataProcess)); } beanDef.getPropertyValues().addPropertyValue("iteratorProcessors", iteratorProcessorList); }
From source file:net.nan21.dnet.core.presenter.descriptor.DsDefinitions.java
/** * Helper method to create the definition for a single given data-source. * /*from w w w. j a va 2 s . co m*/ * @param name * @param factory * @return * @throws Exception */ private DsDefinition createDefinition(String name, ConfigurableListableBeanFactory factory) throws Exception { BeanDefinition beanDef = factory.getBeanDefinition(name); DsDefinition definition = new DsDefinition(); definition.setName(name); String modelClass = null; String filterClass = null; String paramClass = null; String readOnly = null; MutablePropertyValues mpv = beanDef.getPropertyValues(); // model class modelClass = ((TypedStringValue) mpv.getPropertyValue("modelClass").getValue()).getValue(); definition.setModelClass(this.applicationContext.getClassLoader().loadClass(modelClass)); // filter class if (mpv.getPropertyValue("filterClass") != null) { filterClass = ((TypedStringValue) mpv.getPropertyValue("filterClass").getValue()).getValue(); definition.setFilterClass(this.applicationContext.getClassLoader().loadClass(filterClass)); } else { definition.setFilterClass(this.applicationContext.getClassLoader().loadClass(modelClass)); } // param-class if (mpv.getPropertyValue("paramClass") != null) { paramClass = ((TypedStringValue) mpv.getPropertyValue("paramClass").getValue()).getValue(); definition.setParamClass(this.applicationContext.getClassLoader().loadClass(paramClass)); } // other attributes if (mpv.contains("readOnly")) { readOnly = ((TypedStringValue) mpv.getPropertyValue("readOnly").getValue()).getValue(); definition.setReadOnly(Boolean.getBoolean(readOnly)); } // RPC methods if (mpv.contains("rpcData")) { @SuppressWarnings("unchecked") ManagedMap<TypedStringValue, Object> rpcData = (ManagedMap<TypedStringValue, Object>) mpv .getPropertyValue("rpcData").getValue(); List<String> services = new ArrayList<String>(); for (TypedStringValue tsv : rpcData.keySet()) { services.add(tsv.getValue()); } definition.setServiceMethods(services); } if (mpv.contains("rpcFilter")) { @SuppressWarnings("unchecked") ManagedMap<TypedStringValue, Object> rpcFilter = (ManagedMap<TypedStringValue, Object>) mpv .getPropertyValue("rpcFilter").getValue(); List<String> services = new ArrayList<String>(); for (TypedStringValue tsv : rpcFilter.keySet()) { services.add(tsv.getValue()); } definition.setServiceMethods(services); } return definition; }
From source file:com.apporiented.spring.override.ListMergeProcessor.java
@SuppressWarnings({ "rawtypes", "unchecked" }) public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { BeanDefinition bd = beanFactory.getBeanDefinition(ref); if (property == null) { //Assert.state(ListFactoryBean.class.getName().equals(bd.getBeanClassName()), // "Bean [" + ref + "] must be a ListFactoryBean"); property = "sourceList"; }/*from ww w . j a v a 2s .c om*/ log.debug("Adding " + values.size() + " items to " + ref + "." + property + ": " + values); PropertyValue pv = bd.getPropertyValues().getPropertyValue(property); if (pv == null) { // No list set on the target bean, create a new one ... ManagedList list = new ManagedList(); list.addAll(values); bd.getPropertyValues().addPropertyValue(property, list); } else { Object value = pv.getValue(); if (value instanceof RuntimeBeanReference) { RuntimeBeanReference ref = (RuntimeBeanReference) value; value = beanFactory.getBean(ref.getBeanName()); } else if (value instanceof TypedStringValue) { TypedStringValue tsv = (TypedStringValue) value; ManagedList list = new ManagedList(); list.addAll(values); list.add(tsv.getValue()); bd.getPropertyValues().addPropertyValue(property, list); return; } Assert.isInstanceOf(List.class, value); List list = (List) value; if (append) { list.addAll(values); } else { for (int i = values.size() - 1; i >= 0; i--) { list.add(0, values.get(i)); } } } }
From source file:org.solmix.runtime.support.spring.SpringBeanProvider.java
public boolean hasConfiguredPropertyValue(String beanName, String propertyName, String searchValue) { if (context.containsBean(beanName) && !passThroughs.contains(beanName)) { ConfigurableApplicationContext ctxt = (ConfigurableApplicationContext) context; BeanDefinition def = ctxt.getBeanFactory().getBeanDefinition(beanName); if (!ctxt.getBeanFactory().isSingleton(beanName) || def.isAbstract()) { return false; }//from w w w .j av a 2s. co m Collection<?> ids = null; PropertyValue pv = def.getPropertyValues().getPropertyValue(propertyName); if (pv != null) { Object value = pv.getValue(); if (!(value instanceof Collection)) { throw new RuntimeException("The property " + propertyName + " must be a collection!"); } if (value instanceof Mergeable) { if (!((Mergeable) value).isMergeEnabled()) { ids = (Collection<?>) value; } } else { ids = (Collection<?>) value; } } if (ids != null) { for (Iterator<?> itr = ids.iterator(); itr.hasNext();) { Object o = itr.next(); if (o instanceof TypedStringValue) { if (searchValue.equals(((TypedStringValue) o).getValue())) { return true; } } else { if (searchValue.equals(o)) { return true; } } } } } return false; // return orig.hasConfiguredPropertyValue(beanName, propertyName, searchValue); }
From source file:de.acosix.alfresco.mtsupport.repo.beans.TenantLDAPAttributeMappingPostProcessor.java
/** * {@inheritDoc}/* ww w . jav a2 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.clican.pluto.dataprocess.spring.parser.DplExecProcessorParser.java
@SuppressWarnings("unchecked") public void customiseBeanDefinition(BeanDefinition beanDef, Element element, ParserContext parserContext) { this.setBeanDefinitionStringProperty("resultName", beanDef, element); String dplStatement = element.getAttribute("dplStatement"); if (StringUtils.isEmpty(dplStatement)) { dplStatement = "dplStatement"; }//ww w . j a v a 2 s .c o m String clazz = element.getAttribute("clazz"); if (StringUtils.isNotEmpty(clazz)) { try { Class c = Class.forName(clazz); beanDef.getPropertyValues().addPropertyValue("clazz", c); } catch (Exception e) { throw new RuntimeException(e); } } String singleRow = element.getAttribute("singleRow"); if (StringUtils.isNotEmpty(singleRow)) { beanDef.getPropertyValues().addPropertyValue("singleRow", Boolean.parseBoolean(singleRow)); } String traces = element.getAttribute("traces"); if (StringUtils.isNotEmpty(traces)) { List<String> traceList = new ArrayList<String>(); for (String trace : traces.split(",")) { traceList.add(trace.trim()); } beanDef.getPropertyValues().addPropertyValue("traces", traceList); } beanDef.getPropertyValues().addPropertyValue("dplStatement", new RuntimeBeanReference(dplStatement)); beanDef.getPropertyValues().addPropertyValue("dpl", element.getTextContent().trim()); }
From source file:com.clican.pluto.dataprocess.spring.parser.JGroupPartitionProcessorParser.java
@SuppressWarnings("unchecked") public void customiseBeanDefinition(BeanDefinition beanDef, Element element, ParserContext parserContext) { ((RootBeanDefinition) beanDef).setInitMethodName("init"); String partition = element.getAttribute("partition"); if (StringUtils.isEmpty(partition)) { partition = "partition"; }//from w w w .j a v a 2 s. c o m String partitionListName = element.getAttribute("partitionListName"); if (StringUtils.isNotEmpty(element.getAttribute("inputVarName"))) { String[] inputVarName = element.getAttribute("inputVarName").split(","); beanDef.getPropertyValues().addPropertyValue("inputVarName", inputVarName); } if (StringUtils.isNotEmpty(element.getAttribute("outputVarName"))) { String[] outputVarName = element.getAttribute("outputVarName").split(","); beanDef.getPropertyValues().addPropertyValue("outputVarName", outputVarName); } String serviceName = element.getAttribute("serviceName"); beanDef.getPropertyValues().addPropertyValue("partitionListName", partitionListName); beanDef.getPropertyValues().addPropertyValue("serviceName", serviceName); try { beanDef.getPropertyValues().addPropertyValue("partition", new RuntimeBeanReference(partition)); } catch (Throwable e) { } String[] partitionProcessors = element.getAttribute("partitionProcessors").split(","); List partitionProcessorList = new ManagedList(); for (String partitionProcessor : partitionProcessors) { partitionProcessorList.add(new RuntimeBeanReference(partitionProcessor.trim())); } beanDef.getPropertyValues().addPropertyValue("partitionProcessors", partitionProcessorList); }