org.springframework.beans.PropertyValues Java Examples
The following examples show how to use
org.springframework.beans.PropertyValues.
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: JmsListenerContainerParser.java From java-technology-stack with MIT License | 6 votes |
@Override protected RootBeanDefinition createContainerFactory(String factoryId, Element containerEle, ParserContext parserContext, PropertyValues commonContainerProperties, PropertyValues specificContainerProperties) { RootBeanDefinition factoryDef = new RootBeanDefinition(); String containerType = containerEle.getAttribute(CONTAINER_TYPE_ATTRIBUTE); String containerClass = containerEle.getAttribute(CONTAINER_CLASS_ATTRIBUTE); if (!"".equals(containerClass)) { return null; // Not supported } else if ("".equals(containerType) || containerType.startsWith("default")) { factoryDef.setBeanClassName("org.springframework.jms.config.DefaultJmsListenerContainerFactory"); } else if (containerType.startsWith("simple")) { factoryDef.setBeanClassName("org.springframework.jms.config.SimpleJmsListenerContainerFactory"); } factoryDef.getPropertyValues().addPropertyValues(commonContainerProperties); factoryDef.getPropertyValues().addPropertyValues(specificContainerProperties); return factoryDef; }
Example #2
Source File: BeanComponentDefinition.java From spring4-understanding with Apache License 2.0 | 6 votes |
private void findInnerBeanDefinitionsAndBeanReferences(BeanDefinition beanDefinition) { List<BeanDefinition> innerBeans = new ArrayList<BeanDefinition>(); List<BeanReference> references = new ArrayList<BeanReference>(); PropertyValues propertyValues = beanDefinition.getPropertyValues(); for (int i = 0; i < propertyValues.getPropertyValues().length; i++) { PropertyValue propertyValue = propertyValues.getPropertyValues()[i]; Object value = propertyValue.getValue(); if (value instanceof BeanDefinitionHolder) { innerBeans.add(((BeanDefinitionHolder) value).getBeanDefinition()); } else if (value instanceof BeanDefinition) { innerBeans.add((BeanDefinition) value); } else if (value instanceof BeanReference) { references.add((BeanReference) value); } } this.innerBeanDefinitions = innerBeans.toArray(new BeanDefinition[innerBeans.size()]); this.beanReferences = references.toArray(new BeanReference[references.size()]); }
Example #3
Source File: CommonAnnotationBeanPostProcessor.java From spring-analysis-note with MIT License | 6 votes |
private InjectionMetadata findResourceMetadata(String beanName, final Class<?> clazz, @Nullable PropertyValues pvs) { // Fall back to class name as cache key, for backwards compatibility with custom callers. String cacheKey = (StringUtils.hasLength(beanName) ? beanName : clazz.getName()); // Quick check on the concurrent map first, with minimal locking. InjectionMetadata metadata = this.injectionMetadataCache.get(cacheKey); if (InjectionMetadata.needsRefresh(metadata, clazz)) { synchronized (this.injectionMetadataCache) { metadata = this.injectionMetadataCache.get(cacheKey); if (InjectionMetadata.needsRefresh(metadata, clazz)) { if (metadata != null) { metadata.clear(pvs); } metadata = buildResourceMetadata(clazz); this.injectionMetadataCache.put(cacheKey, metadata); } } } return metadata; }
Example #4
Source File: UifDictionaryIndex.java From rice with Educational Community License v2.0 | 6 votes |
/** * Performs additional indexing based on the view type associated with the view instance. The * {@code ViewTypeService} associated with the view type name on the instance is invoked to retrieve * the parameter key/value pairs from the configured property values, which are then used to build up an index * used to key the entry * * @param propertyValues - property values configured on the view bean definition * @param id - id (or bean name if id was not set) for the view */ protected void indexViewForType(PropertyValues propertyValues, String id) { String viewTypeName = ViewModelUtils.getStringValFromPVs(propertyValues, "viewTypeName"); if (StringUtils.isBlank(viewTypeName)) { return; } UifConstants.ViewType viewType = ViewType.valueOf(viewTypeName); ViewTypeService typeService = KRADServiceLocatorWeb.getViewService().getViewTypeService(viewType); if (typeService == null) { // don't do any further indexing return; } // invoke type service to retrieve it parameter name/value pairs Map<String, String> typeParameters = typeService.getParametersFromViewConfiguration(propertyValues); // build the index string from the parameters String index = buildTypeIndex(typeParameters); // get the index for the type and add the view entry ViewTypeDictionaryIndex typeIndex = getTypeIndex(viewType); typeIndex.put(index, id); }
Example #5
Source File: CommonAnnotationBeanPostProcessor.java From java-technology-stack with MIT License | 6 votes |
private InjectionMetadata findResourceMetadata(String beanName, final Class<?> clazz, @Nullable PropertyValues pvs) { // Fall back to class name as cache key, for backwards compatibility with custom callers. String cacheKey = (StringUtils.hasLength(beanName) ? beanName : clazz.getName()); // Quick check on the concurrent map first, with minimal locking. InjectionMetadata metadata = this.injectionMetadataCache.get(cacheKey); if (InjectionMetadata.needsRefresh(metadata, clazz)) { synchronized (this.injectionMetadataCache) { metadata = this.injectionMetadataCache.get(cacheKey); if (InjectionMetadata.needsRefresh(metadata, clazz)) { if (metadata != null) { metadata.clear(pvs); } metadata = buildResourceMetadata(clazz); this.injectionMetadataCache.put(cacheKey, metadata); } } } return metadata; }
Example #6
Source File: CommonAnnotationBeanPostProcessor.java From spring4-understanding with Apache License 2.0 | 6 votes |
private InjectionMetadata findResourceMetadata(String beanName, final Class<?> clazz, PropertyValues pvs) { // Fall back to class name as cache key, for backwards compatibility with custom callers. String cacheKey = (StringUtils.hasLength(beanName) ? beanName : clazz.getName()); // Quick check on the concurrent map first, with minimal locking. InjectionMetadata metadata = this.injectionMetadataCache.get(cacheKey); if (InjectionMetadata.needsRefresh(metadata, clazz)) { synchronized (this.injectionMetadataCache) { metadata = this.injectionMetadataCache.get(cacheKey); if (InjectionMetadata.needsRefresh(metadata, clazz)) { if (metadata != null) { metadata.clear(pvs); } try { metadata = buildResourceMetadata(clazz); this.injectionMetadataCache.put(cacheKey, metadata); } catch (NoClassDefFoundError err) { throw new IllegalStateException("Failed to introspect bean class [" + clazz.getName() + "] for resource metadata: could not find class that it depends on", err); } } } } return metadata; }
Example #7
Source File: AbstractAutowireCapableBeanFactory.java From java-technology-stack with MIT License | 6 votes |
/** * Perform a dependency check that all properties exposed have been set, * if desired. Dependency checks can be objects (collaborating beans), * simple (primitives and String), or all (both). * @param beanName the name of the bean * @param mbd the merged bean definition the bean was created with * @param pds the relevant property descriptors for the target bean * @param pvs the property values to be applied to the bean * @see #isExcludedFromDependencyCheck(java.beans.PropertyDescriptor) */ protected void checkDependencies( String beanName, AbstractBeanDefinition mbd, PropertyDescriptor[] pds, @Nullable PropertyValues pvs) throws UnsatisfiedDependencyException { int dependencyCheck = mbd.getDependencyCheck(); for (PropertyDescriptor pd : pds) { if (pd.getWriteMethod() != null && (pvs == null || !pvs.contains(pd.getName()))) { boolean isSimple = BeanUtils.isSimpleProperty(pd.getPropertyType()); boolean unsatisfied = (dependencyCheck == AbstractBeanDefinition.DEPENDENCY_CHECK_ALL) || (isSimple && dependencyCheck == AbstractBeanDefinition.DEPENDENCY_CHECK_SIMPLE) || (!isSimple && dependencyCheck == AbstractBeanDefinition.DEPENDENCY_CHECK_OBJECTS); if (unsatisfied) { throw new UnsatisfiedDependencyException(mbd.getResourceDescription(), beanName, pd.getName(), "Set this property value or disable dependency checking for this bean."); } } } }
Example #8
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 #9
Source File: JmsListenerContainerParser.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Override protected RootBeanDefinition createContainerFactory(String factoryId, Element containerEle, ParserContext parserContext, PropertyValues commonContainerProperties, PropertyValues specificContainerProperties) { RootBeanDefinition factoryDef = new RootBeanDefinition(); String containerType = containerEle.getAttribute(CONTAINER_TYPE_ATTRIBUTE); String containerClass = containerEle.getAttribute(CONTAINER_CLASS_ATTRIBUTE); if (!"".equals(containerClass)) { return null; // Not supported } else if ("".equals(containerType) || containerType.startsWith("default")) { factoryDef.setBeanClassName("org.springframework.jms.config.DefaultJmsListenerContainerFactory"); } else if (containerType.startsWith("simple")) { factoryDef.setBeanClassName("org.springframework.jms.config.SimpleJmsListenerContainerFactory"); } factoryDef.getPropertyValues().addPropertyValues(commonContainerProperties); factoryDef.getPropertyValues().addPropertyValues(specificContainerProperties); return factoryDef; }
Example #10
Source File: RequiredAnnotationBeanPostProcessor.java From lams with GNU General Public License v2.0 | 6 votes |
@Override public PropertyValues postProcessPropertyValues( PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException { if (!this.validatedBeanNames.contains(beanName)) { if (!shouldSkip(this.beanFactory, beanName)) { List<String> invalidProperties = new ArrayList<String>(); for (PropertyDescriptor pd : pds) { if (isRequiredProperty(pd) && !pvs.contains(pd.getName())) { invalidProperties.add(pd.getName()); } } if (!invalidProperties.isEmpty()) { throw new BeanInitializationException(buildExceptionMessage(invalidProperties, beanName)); } } this.validatedBeanNames.add(beanName); } return pvs; }
Example #11
Source File: InjectAnnotationBeanPostProcessor.java From spring-boot-starter-dubbo with Apache License 2.0 | 6 votes |
private InjectionMetadata findReferenceMetadata(String beanName, Class<?> clazz, PropertyValues pvs) { // Fall back to class name as cache key, for backwards compatibility with custom callers. String cacheKey = (StringUtils.hasLength(beanName) ? beanName : clazz.getName()); // Quick check on the concurrent map first, with minimal locking. InjectionMetadata metadata = this.injectionMetadataCache.get(cacheKey); if (InjectionMetadata.needsRefresh(metadata, clazz)) { synchronized (this.injectionMetadataCache) { metadata = this.injectionMetadataCache.get(cacheKey); if (InjectionMetadata.needsRefresh(metadata, clazz)) { if (metadata != null) { metadata.clear(pvs); } try { metadata = buildReferenceMetadata(clazz); this.injectionMetadataCache.put(cacheKey, metadata); } catch (NoClassDefFoundError err) { throw new IllegalStateException("Failed to introspect bean class [" + clazz.getName() + "] for reference metadata: could not find class that it depends on", err); } } } } return metadata; }
Example #12
Source File: CreateCacheAnnotationBeanPostProcessor.java From jetcache with Apache License 2.0 | 6 votes |
private InjectionMetadata findAutowiringMetadata(String beanName, Class<?> clazz, PropertyValues pvs) { // Fall back to class name as cache key, for backwards compatibility with custom callers. String cacheKey = (StringUtils.hasLength(beanName) ? beanName : clazz.getName()); // Quick check on the concurrent map first, with minimal locking. InjectionMetadata metadata = this.injectionMetadataCache.get(cacheKey); if (InjectionMetadata.needsRefresh(metadata, clazz)) { synchronized (this.injectionMetadataCache) { metadata = this.injectionMetadataCache.get(cacheKey); if (InjectionMetadata.needsRefresh(metadata, clazz)) { if (metadata != null) { clear(metadata, pvs); } try { metadata = buildAutowiringMetadata(clazz); this.injectionMetadataCache.put(cacheKey, metadata); } catch (NoClassDefFoundError err) { throw new IllegalStateException("Failed to introspect bean class [" + clazz.getName() + "] for autowiring metadata: could not find class that it depends on", err); } } } } return metadata; }
Example #13
Source File: JcaListenerContainerParser.java From spring-analysis-note with MIT License | 6 votes |
@Override protected RootBeanDefinition createContainer(Element containerEle, Element listenerEle, ParserContext parserContext, PropertyValues commonContainerProperties, PropertyValues specificContainerProperties) { RootBeanDefinition containerDef = new RootBeanDefinition(); containerDef.setSource(parserContext.extractSource(containerEle)); containerDef.setBeanClassName("org.springframework.jms.listener.endpoint.JmsMessageEndpointManager"); containerDef.getPropertyValues().addPropertyValues(specificContainerProperties); RootBeanDefinition configDef = new RootBeanDefinition(); configDef.setSource(parserContext.extractSource(containerEle)); configDef.setBeanClassName("org.springframework.jms.listener.endpoint.JmsActivationSpecConfig"); configDef.getPropertyValues().addPropertyValues(commonContainerProperties); parseListenerConfiguration(listenerEle, parserContext, configDef.getPropertyValues()); containerDef.getPropertyValues().add("activationSpecConfig", configDef); return containerDef; }
Example #14
Source File: AutowiredAnnotationBeanPostProcessor.java From spring4-understanding with Apache License 2.0 | 6 votes |
private InjectionMetadata findAutowiringMetadata(String beanName, Class<?> clazz, PropertyValues pvs) { // Fall back to class name as cache key, for backwards compatibility with custom callers. String cacheKey = (StringUtils.hasLength(beanName) ? beanName : clazz.getName()); // Quick check on the concurrent map first, with minimal locking. InjectionMetadata metadata = this.injectionMetadataCache.get(cacheKey); if (InjectionMetadata.needsRefresh(metadata, clazz)) { synchronized (this.injectionMetadataCache) { metadata = this.injectionMetadataCache.get(cacheKey); if (InjectionMetadata.needsRefresh(metadata, clazz)) { if (metadata != null) { metadata.clear(pvs); } try { metadata = buildAutowiringMetadata(clazz); this.injectionMetadataCache.put(cacheKey, metadata); } catch (NoClassDefFoundError err) { throw new IllegalStateException("Failed to introspect bean class [" + clazz.getName() + "] for autowiring metadata: could not find class that it depends on", err); } } } } return metadata; }
Example #15
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 #16
Source File: MaintenanceViewTypeServiceImpl.java From rice with Educational Community License v2.0 | 6 votes |
/** * @see org.kuali.rice.krad.uif.service.ViewTypeService#getParametersFromViewConfiguration(org.springframework.beans.PropertyValues) */ public Map<String, String> getParametersFromViewConfiguration(PropertyValues propertyValues) { Map<String, String> parameters = new HashMap<String, String>(); String viewName = ViewModelUtils.getStringValFromPVs(propertyValues, UifParameters.VIEW_NAME); String dataObjectClassName = ViewModelUtils.getStringValFromPVs(propertyValues, UifParameters.DATA_OBJECT_CLASS_NAME); String docTypeName = ViewModelUtils.getStringValFromPVs(propertyValues, UifParameters.DOC_TYPE_NAME); if (!StringUtils.isEmpty(docTypeName)) { parameters.put(UifParameters.DOC_TYPE_NAME, docTypeName); } else if (!StringUtils.isEmpty(dataObjectClassName)) { parameters.put(UifParameters.DATA_OBJECT_CLASS_NAME, dataObjectClassName); } else { throw new IllegalArgumentException("Document type name or bo class not given!"); } parameters.put(UifParameters.VIEW_NAME, viewName); return parameters; }
Example #17
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 #18
Source File: AutowiredAnnotationBeanPostProcessor.java From spring-analysis-note with MIT License | 6 votes |
private InjectionMetadata findAutowiringMetadata(String beanName, Class<?> clazz, @Nullable PropertyValues pvs) { // Fall back to class name as cache key, for backwards compatibility with custom callers. String cacheKey = (StringUtils.hasLength(beanName) ? beanName : clazz.getName()); // Quick check on the concurrent map first, with minimal locking. InjectionMetadata metadata = this.injectionMetadataCache.get(cacheKey); if (InjectionMetadata.needsRefresh(metadata, clazz)) { synchronized (this.injectionMetadataCache) { metadata = this.injectionMetadataCache.get(cacheKey); if (InjectionMetadata.needsRefresh(metadata, clazz)) { if (metadata != null) { metadata.clear(pvs); } metadata = buildAutowiringMetadata(clazz); this.injectionMetadataCache.put(cacheKey, metadata); } } } return metadata; }
Example #19
Source File: WebRequestDataBinderTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
/** * Must contain: forname=Tony surname=Blair age=50 */ protected void doTestTony(PropertyValues pvs) throws Exception { assertTrue("Contains 3", pvs.getPropertyValues().length == 3); assertTrue("Contains forname", pvs.contains("forname")); assertTrue("Contains surname", pvs.contains("surname")); assertTrue("Contains age", pvs.contains("age")); assertTrue("Doesn't contain tory", !pvs.contains("tory")); PropertyValue[] pvArray = pvs.getPropertyValues(); Map<String, String> m = new HashMap<String, String>(); m.put("forname", "Tony"); m.put("surname", "Blair"); m.put("age", "50"); for (PropertyValue pv : pvArray) { Object val = m.get(pv.getName()); assertTrue("Can't have unexpected value", val != null); assertTrue("Val i string", val instanceof String); assertTrue("val matches expected", val.equals(pv.getValue())); m.remove(pv.getName()); } assertTrue("Map size is 0", m.size() == 0); }
Example #20
Source File: JmsListenerContainerParser.java From spring-analysis-note with MIT License | 6 votes |
@Override protected RootBeanDefinition createContainerFactory(String factoryId, Element containerEle, ParserContext parserContext, PropertyValues commonContainerProperties, PropertyValues specificContainerProperties) { RootBeanDefinition factoryDef = new RootBeanDefinition(); String containerType = containerEle.getAttribute(CONTAINER_TYPE_ATTRIBUTE); String containerClass = containerEle.getAttribute(CONTAINER_CLASS_ATTRIBUTE); if (!"".equals(containerClass)) { return null; // Not supported } else if ("".equals(containerType) || containerType.startsWith("default")) { factoryDef.setBeanClassName("org.springframework.jms.config.DefaultJmsListenerContainerFactory"); } else if (containerType.startsWith("simple")) { factoryDef.setBeanClassName("org.springframework.jms.config.SimpleJmsListenerContainerFactory"); } factoryDef.getPropertyValues().addPropertyValues(commonContainerProperties); factoryDef.getPropertyValues().addPropertyValues(specificContainerProperties); return factoryDef; }
Example #21
Source File: PersistenceAnnotationBeanPostProcessor.java From spring4-understanding with Apache License 2.0 | 6 votes |
private InjectionMetadata findPersistenceMetadata(String beanName, final Class<?> clazz, PropertyValues pvs) { // Fall back to class name as cache key, for backwards compatibility with custom callers. String cacheKey = (StringUtils.hasLength(beanName) ? beanName : clazz.getName()); // Quick check on the concurrent map first, with minimal locking. InjectionMetadata metadata = this.injectionMetadataCache.get(cacheKey); if (InjectionMetadata.needsRefresh(metadata, clazz)) { synchronized (this.injectionMetadataCache) { metadata = this.injectionMetadataCache.get(cacheKey); if (InjectionMetadata.needsRefresh(metadata, clazz)) { if (metadata != null) { metadata.clear(pvs); } try { metadata = buildPersistenceMetadata(clazz); this.injectionMetadataCache.put(cacheKey, metadata); } catch (NoClassDefFoundError err) { throw new IllegalStateException("Failed to introspect bean class [" + clazz.getName() + "] for persistence metadata: could not find class that it depends on", err); } } } } return metadata; }
Example #22
Source File: HttpServletBean.java From java-technology-stack with MIT License | 6 votes |
/** * Map config parameters onto bean properties of this servlet, and * invoke subclass initialization. * @throws ServletException if bean properties are invalid (or required * properties are missing), or if subclass initialization fails. */ @Override public final void init() throws ServletException { // Set bean properties from init parameters. PropertyValues pvs = new ServletConfigPropertyValues(getServletConfig(), this.requiredProperties); if (!pvs.isEmpty()) { try { BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this); ResourceLoader resourceLoader = new ServletContextResourceLoader(getServletContext()); bw.registerCustomEditor(Resource.class, new ResourceEditor(resourceLoader, getEnvironment())); initBeanWrapper(bw); bw.setPropertyValues(pvs, true); } catch (BeansException ex) { if (logger.isErrorEnabled()) { logger.error("Failed to set bean properties on servlet '" + getServletName() + "'", ex); } throw ex; } } // Let subclasses do whatever initialization they like. initServletBean(); }
Example #23
Source File: AbstractAutowireCapableBeanFactory.java From blog_demos with Apache License 2.0 | 5 votes |
/** * Return an array of non-simple bean properties that are unsatisfied. * These are probably unsatisfied references to other beans in the * factory. Does not include simple properties like primitives or Strings. * @param mbd the merged bean definition the bean was created with * @param bw the BeanWrapper the bean was created with * @return an array of bean property names * @see BeanUtils#isSimpleProperty */ protected String[] unsatisfiedNonSimpleProperties(AbstractBeanDefinition mbd, BeanWrapper bw) { Set<String> result = new TreeSet<String>(); PropertyValues pvs = mbd.getPropertyValues(); PropertyDescriptor[] pds = bw.getPropertyDescriptors(); for (PropertyDescriptor pd : pds) { if (pd.getWriteMethod() != null && !isExcludedFromDependencyCheck(pd) && !pvs.contains(pd.getName()) && !BeanUtils.isSimpleProperty(pd.getPropertyType())) { result.add(pd.getName()); } } return StringUtils.toStringArray(result); }
Example #24
Source File: AbstractAutowireCapableBeanFactory.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Return an array of non-simple bean properties that are unsatisfied. * These are probably unsatisfied references to other beans in the * factory. Does not include simple properties like primitives or Strings. * @param mbd the merged bean definition the bean was created with * @param bw the BeanWrapper the bean was created with * @return an array of bean property names * @see org.springframework.beans.BeanUtils#isSimpleProperty */ protected String[] unsatisfiedNonSimpleProperties(AbstractBeanDefinition mbd, BeanWrapper bw) { Set<String> result = new TreeSet<String>(); PropertyValues pvs = mbd.getPropertyValues(); PropertyDescriptor[] pds = bw.getPropertyDescriptors(); for (PropertyDescriptor pd : pds) { // ��ȡ����дֵ�ķ��������� if (pd.getWriteMethod() != null && !isExcludedFromDependencyCheck(pd) && !pvs.contains(pd.getName()) && !BeanUtils.isSimpleProperty(pd.getPropertyType())) { result.add(pd.getName()); } } return StringUtils.toStringArray(result); }
Example #25
Source File: NacosUtils.java From nacos-spring-project with Apache License 2.0 | 5 votes |
public static PropertyValues resolvePropertyValues(Object bean, final String prefix, String dataId, String groupId, String content, String type) { final Properties configProperties = toProperties(dataId, groupId, content, type); final MutablePropertyValues propertyValues = new MutablePropertyValues(); ReflectionUtils.doWithFields(bean.getClass(), new ReflectionUtils.FieldCallback() { @Override public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException { String propertyName = NacosUtils.resolvePropertyName(field); propertyName = StringUtils.isEmpty(prefix) ? propertyName : prefix + "." + propertyName; if (hasText(propertyName)) { // If it is a map, the data will not be fetched // fix issue #91 if (Collection.class.isAssignableFrom(field.getType()) || Map.class.isAssignableFrom(field.getType())) { bindContainer(prefix, propertyName, configProperties, propertyValues); return; } if (configProperties.containsKey(propertyName)) { String propertyValue = configProperties .getProperty(propertyName); propertyValues.add(field.getName(), propertyValue); } } } }); return propertyValues; }
Example #26
Source File: JcaListenerContainerParser.java From java-technology-stack with MIT License | 5 votes |
@Override protected RootBeanDefinition createContainerFactory(String factoryId, Element containerEle, ParserContext parserContext, PropertyValues commonContainerProperties, PropertyValues specificContainerProperties) { RootBeanDefinition factoryDef = new RootBeanDefinition(); factoryDef.setBeanClassName("org.springframework.jms.config.DefaultJcaListenerContainerFactory"); factoryDef.getPropertyValues().addPropertyValues(commonContainerProperties); factoryDef.getPropertyValues().addPropertyValues(specificContainerProperties); return factoryDef; }
Example #27
Source File: InjectionMetadata.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Check whether this injector's property needs to be skipped due to * an explicit property value having been specified. Also marks the * affected property as processed for other processors to ignore it. */ protected boolean checkPropertySkipping(PropertyValues pvs) { if (this.skip != null) { return this.skip; } if (pvs == null) { this.skip = false; return false; } synchronized (pvs) { if (this.skip != null) { return this.skip; } if (this.pd != null) { if (pvs.contains(this.pd.getName())) { // Explicit value provided as part of the bean definition. this.skip = true; return true; } else if (pvs instanceof MutablePropertyValues) { ((MutablePropertyValues) pvs).registerProcessedProperty(this.pd.getName()); } } this.skip = false; return false; } }
Example #28
Source File: ConfigurationClassPostProcessor.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public PropertyValues postProcessPropertyValues( PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) { // Inject the BeanFactory before AutowiredAnnotationBeanPostProcessor's // postProcessPropertyValues method attempts to autowire other configuration beans. if (bean instanceof EnhancedConfiguration) { ((EnhancedConfiguration) bean).setBeanFactory(this.beanFactory); } return pvs; }
Example #29
Source File: CommonAnnotationBeanPostProcessor.java From java-technology-stack with MIT License | 5 votes |
@Deprecated @Override public PropertyValues postProcessPropertyValues( PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) { return postProcessProperties(pvs, bean, beanName); }
Example #30
Source File: HttpServletBean.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Map config parameters onto bean properties of this servlet, and * invoke subclass initialization. * @throws ServletException if bean properties are invalid (or required * properties are missing), or if subclass initialization fails. */ @Override public final void init() throws ServletException { if (logger.isDebugEnabled()) { logger.debug("Initializing servlet '" + getServletName() + "'"); } // Set bean properties from init parameters. PropertyValues pvs = new ServletConfigPropertyValues(getServletConfig(), this.requiredProperties); if (!pvs.isEmpty()) { try { BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this); ResourceLoader resourceLoader = new ServletContextResourceLoader(getServletContext()); bw.registerCustomEditor(Resource.class, new ResourceEditor(resourceLoader, getEnvironment())); initBeanWrapper(bw); bw.setPropertyValues(pvs, true); } catch (BeansException ex) { if (logger.isErrorEnabled()) { logger.error("Failed to set bean properties on servlet '" + getServletName() + "'", ex); } throw ex; } } // Let subclasses do whatever initialization they like. initServletBean(); if (logger.isDebugEnabled()) { logger.debug("Servlet '" + getServletName() + "' configured successfully"); } }