@Test public void testInit() { Company company = new Company(); BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(company); bw.setPropertyValue("name", "Some Company Inc."); PropertyValue value = new PropertyValue("name", "Some Company Inc1."); bw.setPropertyValue(value); Employee employee = new Employee(); BeanWrapper jim = PropertyAccessorFactory.forBeanPropertyAccess(employee); PropertyValue name = new PropertyValue("name", "Some Employee Inc1."); List<PropertyValue> list = new ArrayList<>(); list.add(name); PropertyValues propertyValues = new MutablePropertyValues(list); jim.setPropertyValues(propertyValues, true); jim.setPropertyValue("salary", 1L); bw.setPropertyValue("managingDirector", jim.getWrappedInstance()); Float salary = (Float) bw.getPropertyValue("managingDirector.salary"); assertEquals(salary, Float.parseFloat("1.0")); }
@Override public final void init(FilterConfig filterConfig) throws ServletException { Assert.notNull(filterConfig, "FilterConfig must not be null"); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Initializing filter '" + filterConfig.getFilterName() + "'"); } initPlaceHolderConfigure(filterConfig); try { PropertyValues pvs = new JndiSupportFilterConfigPropertyValues(filterConfig, this.requiredProperties); BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this); ResourceLoader resourceLoader = new ServletContextResourceLoader(filterConfig.getServletContext()); ServletContextPropertySource servletContextPropertySource = new ServletContextPropertySource(NAME + "_ServletContextPropertySource", filterConfig.getServletContext()); MutablePropertySources propertySources = new MutablePropertySources(); propertySources.addFirst(servletContextPropertySource); PropertySourcesPropertyResolver propertySourcesPropertyResolver = new PropertySourcesPropertyResolver(propertySources); bw.registerCustomEditor(Resource.class, new ResourceEditor(resourceLoader, propertySourcesPropertyResolver)); bw.setPropertyValues(pvs, true); } catch (BeansException ex) { String msg = "Failed to set bean properties on filter '" + filterConfig.getFilterName() + "': " + ex.getMessage(); LOGGER.error(msg, ex); throw new NestedServletException(msg, ex); } doInit(filterConfig); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Filter '" + filterConfig.getFilterName() + "' configured successfully"); } }
JndiSupportFilter implements Filter { @Override public final void init(FilterConfig filterConfig) throws ServletException { Assert.notNull(filterConfig, "FilterConfig must not be null"); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Initializing filter '" + filterConfig.getFilterName() + "'"); } initPlaceHolderConfigure(filterConfig); try { PropertyValues pvs = new JndiSupportFilterConfigPropertyValues(filterConfig, this.requiredProperties); BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this); ResourceLoader resourceLoader = new ServletContextResourceLoader(filterConfig.getServletContext()); ServletContextPropertySource servletContextPropertySource = new ServletContextPropertySource(NAME + "_ServletContextPropertySource", filterConfig.getServletContext()); MutablePropertySources propertySources = new MutablePropertySources(); propertySources.addFirst(servletContextPropertySource); PropertySourcesPropertyResolver propertySourcesPropertyResolver = new PropertySourcesPropertyResolver(propertySources); bw.registerCustomEditor(Resource.class, new ResourceEditor(resourceLoader, propertySourcesPropertyResolver)); bw.setPropertyValues(pvs, true); } catch (BeansException ex) { String msg = "Failed to set bean properties on filter '" + filterConfig.getFilterName() + "': " + ex.getMessage(); LOGGER.error(msg, ex); throw new NestedServletException(msg, ex); } doInit(filterConfig); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Filter '" + filterConfig.getFilterName() + "' configured successfully"); } } }
JndiSupportFilter implements Filter { @Override public final void init(FilterConfig filterConfig) throws ServletException { Assert.notNull(filterConfig, "FilterConfig must not be null"); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Initializing filter '" + filterConfig.getFilterName() + "'"); } initPlaceHolderConfigure(filterConfig); try { PropertyValues pvs = new JndiSupportFilterConfigPropertyValues(filterConfig, this.requiredProperties); BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this); ResourceLoader resourceLoader = new ServletContextResourceLoader(filterConfig.getServletContext()); ServletContextPropertySource servletContextPropertySource = new ServletContextPropertySource(NAME + "_ServletContextPropertySource", filterConfig.getServletContext()); MutablePropertySources propertySources = new MutablePropertySources(); propertySources.addFirst(servletContextPropertySource); PropertySourcesPropertyResolver propertySourcesPropertyResolver = new PropertySourcesPropertyResolver(propertySources); bw.registerCustomEditor(Resource.class, new ResourceEditor(resourceLoader, propertySourcesPropertyResolver)); bw.setPropertyValues(pvs, true); } catch (BeansException ex) { String msg = "Failed to set bean properties on filter '" + filterConfig.getFilterName() + "': " + ex.getMessage(); LOGGER.error(msg, ex); throw new NestedServletException(msg, ex); } doInit(filterConfig); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Filter '" + filterConfig.getFilterName() + "' configured successfully"); } }  }
JndiSupportFilter implements Filter { @Override public final void init(FilterConfig filterConfig) throws ServletException { Assert.notNull(filterConfig, "FilterConfig must not be null"); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Initializing filter '" + filterConfig.getFilterName() + "'"); } initPlaceHolderConfigure(filterConfig); try { PropertyValues pvs = new JndiSupportFilterConfigPropertyValues(filterConfig, this.requiredProperties); BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this); ResourceLoader resourceLoader = new ServletContextResourceLoader(filterConfig.getServletContext()); ServletContextPropertySource servletContextPropertySource = new ServletContextPropertySource(NAME + "_ServletContextPropertySource", filterConfig.getServletContext()); MutablePropertySources propertySources = new MutablePropertySources(); propertySources.addFirst(servletContextPropertySource); PropertySourcesPropertyResolver propertySourcesPropertyResolver = new PropertySourcesPropertyResolver(propertySources); bw.registerCustomEditor(Resource.class, new ResourceEditor(resourceLoader, propertySourcesPropertyResolver)); bw.setPropertyValues(pvs, true); } catch (BeansException ex) { String msg = "Failed to set bean properties on filter '" + filterConfig.getFilterName() + "': " + ex.getMessage(); LOGGER.error(msg, ex); throw new NestedServletException(msg, ex); } doInit(filterConfig); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Filter '" + filterConfig.getFilterName() + "' configured successfully"); } }  @Override final void init(FilterConfig filterConfig); @Override void destroy(); }
JndiSupportFilter implements Filter { @Override public final void init(FilterConfig filterConfig) throws ServletException { Assert.notNull(filterConfig, "FilterConfig must not be null"); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Initializing filter '" + filterConfig.getFilterName() + "'"); } initPlaceHolderConfigure(filterConfig); try { PropertyValues pvs = new JndiSupportFilterConfigPropertyValues(filterConfig, this.requiredProperties); BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this); ResourceLoader resourceLoader = new ServletContextResourceLoader(filterConfig.getServletContext()); ServletContextPropertySource servletContextPropertySource = new ServletContextPropertySource(NAME + "_ServletContextPropertySource", filterConfig.getServletContext()); MutablePropertySources propertySources = new MutablePropertySources(); propertySources.addFirst(servletContextPropertySource); PropertySourcesPropertyResolver propertySourcesPropertyResolver = new PropertySourcesPropertyResolver(propertySources); bw.registerCustomEditor(Resource.class, new ResourceEditor(resourceLoader, propertySourcesPropertyResolver)); bw.setPropertyValues(pvs, true); } catch (BeansException ex) { String msg = "Failed to set bean properties on filter '" + filterConfig.getFilterName() + "': " + ex.getMessage(); LOGGER.error(msg, ex); throw new NestedServletException(msg, ex); } doInit(filterConfig); if (LOGGER.isDebugEnabled()) { LOGGER.debug("Filter '" + filterConfig.getFilterName() + "' configured successfully"); } }  @Override final void init(FilterConfig filterConfig); @Override void destroy(); static final String JNDI_PROPERTY_PREFIX; static final String NAME; }