Java Code Examples for org.springframework.beans.factory.config.BeanDefinitionVisitor

Following code examples demonstrate how to use org.springframework.beans.factory.config.BeanDefinitionVisitorfrom spring-framework. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.springframework.beans.factory.config.BeanDefinitionVisitorand various code implementation of this class.

                public String resolveStringValue(String strVal) {


                    if (strVal.contains("shit")) {

                        System.out.println("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");

                        return "shit*****";
                    }
                    return strVal;
                } 


					public String resolveStringValue(String strVal) {
						if(isObscene(strVal)){
							return "****";
						}
						return strVal;
					} 

    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {


        String[] beanNames = beanFactory.getBeanDefinitionNames();
        for (String beanName : beanNames) {
            BeanDefinition bd = beanFactory.getBeanDefinition(beanName);
            BeanDefinitionVisitor visitor = new BeanDefinitionVisitor(valueResolver);
            visitor.visitBeanDefinition(bd);
        }

    } 

                public String resolveStringValue(String strVal) {
                    if(strVal.toLowerCase().startsWith("hello")) {
                        return "bye ";
                    }
                    return strVal;
                } 

    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        String [] beanNames = beanFactory.getBeanDefinitionNames();
        for(String beanName: beanNames){
            BeanDefinition beanDefinition = beanFactory.getBeanDefinition(beanName);
            BeanDefinitionVisitor visitor = new BeanDefinitionVisitor(str->{
                if(str.equals("宇宙")){
                    return "aaaaa";
                }else{
                    return str;
                }
            }
            );
            visitor.visitBeanDefinition(beanDefinition);
        }
    } 

                public String resolveStringValue(String strVal) {
                    if (isObscene(strVal)) {
                        return "*******";
                    } else {
                        return strVal;
                    }
                } 

				public String resolveStringValue(String strVal) {
					if(isObscene(strVal)) return "*********";
					return strVal;
				} 

Advertisement
Javadoc
Visitor class for traversing BeanDefinition objects, in particular the property values and construct

or argument values contained in them, resolving bean metadata values.

Used by PropertyPlaceholderConfigurer to parse all String values contained in a BeanDefinition, resolving any placeholders found. @author Juergen Hoeller @author Sam Brannen @since 1.2 @see BeanDefinition @see BeanDefinition#getPropertyValues @see BeanDefinition#getConstructorArgumentValues @see PropertyPlaceholderConfigurer

Read More
Advertisement