Example usage for org.springframework.core.io ResourceEditor ResourceEditor

List of usage examples for org.springframework.core.io ResourceEditor ResourceEditor

Introduction

In this page you can find the example usage for org.springframework.core.io ResourceEditor ResourceEditor.

Prototype

public ResourceEditor(ResourceLoader resourceLoader, @Nullable PropertyResolver propertyResolver) 

Source Link

Document

Create a new instance of the ResourceEditor class using the given ResourceLoader and PropertyResolver .

Usage

From source file:org.jasig.springframework.web.portlet.filter.GenericPortletFilterBean.java

@Override
public void init(FilterConfig filterConfig) throws PortletException {
    Assert.notNull(filterConfig, "FilterConfig must not be null");
    if (logger.isDebugEnabled()) {
        logger.debug("Initializing filter '" + filterConfig.getFilterName() + "'");
    }/* ww w . ja va 2  s.  com*/

    this.filterConfig = filterConfig;

    // Set bean properties from init parameters.
    try {
        PropertyValues pvs = new FilterConfigPropertyValues(filterConfig, this.requiredProperties);
        BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this);
        ResourceLoader resourceLoader = new PortletContextResourceLoader(filterConfig.getPortletContext());
        bw.registerCustomEditor(Resource.class, new ResourceEditor(resourceLoader, this.environment));
        initBeanWrapper(bw);
        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 PortletException(msg, ex);
    }

    // Let subclasses do whatever initialization they like.
    initFilterBean();

    if (logger.isDebugEnabled()) {
        logger.debug("Filter '" + filterConfig.getFilterName() + "' configured successfully");
    }
}

From source file:org.springframework.web.filter.GenericFilterBean.java

/**
 * Standard way of initializing this filter.
 * Map config parameters onto bean properties of this filter, and
 * invoke subclass initialization./*w ww.ja v  a  2 s . c  o  m*/
 * @param filterConfig the configuration for this filter
 * @throws ServletException if bean properties are invalid (or required
 * properties are missing), or if subclass initialization fails.
 * @see #initFilterBean
 */
@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() + "'");
    }

    this.filterConfig = filterConfig;

    // Set bean properties from init parameters.
    PropertyValues pvs = new FilterConfigPropertyValues(filterConfig, this.requiredProperties);
    if (!pvs.isEmpty()) {
        try {
            BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this);
            ResourceLoader resourceLoader = new ServletContextResourceLoader(filterConfig.getServletContext());
            Environment env = this.environment;
            if (env == null) {
                env = new StandardServletEnvironment();
            }
            bw.registerCustomEditor(Resource.class, new ResourceEditor(resourceLoader, env));
            initBeanWrapper(bw);
            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);
        }
    }

    // Let subclasses do whatever initialization they like.
    initFilterBean();

    if (logger.isDebugEnabled()) {
        logger.debug("Filter '" + filterConfig.getFilterName() + "' configured successfully");
    }
}

From source file:org.springframework.web.portlet.GenericPortletBean.java

/**
 * Map config parameters onto bean properties of this portlet, and
 * invoke subclass initialization.// w w  w  .j a  va2  s  .c  om
 * @throws PortletException if bean properties are invalid (or required
 * properties are missing), or if subclass initialization fails.
 */
@Override
public final void init() throws PortletException {
    if (logger.isInfoEnabled()) {
        logger.info("Initializing portlet '" + getPortletName() + "'");
    }

    // Set bean properties from init parameters.
    try {
        PropertyValues pvs = new PortletConfigPropertyValues(getPortletConfig(), this.requiredProperties);
        BeanWrapper bw = PropertyAccessorFactory.forBeanPropertyAccess(this);
        ResourceLoader resourceLoader = new PortletContextResourceLoader(getPortletContext());
        bw.registerCustomEditor(Resource.class, new ResourceEditor(resourceLoader, getEnvironment()));
        initBeanWrapper(bw);
        bw.setPropertyValues(pvs, true);
    } catch (BeansException ex) {
        logger.error("Failed to set bean properties on portlet '" + getPortletName() + "'", ex);
        throw ex;
    }

    // let subclasses do whatever initialization they like
    initPortletBean();

    if (logger.isInfoEnabled()) {
        logger.info("Portlet '" + getPortletName() + "' configured successfully");
    }
}

From source file:org.springframework.web.servlet.HttpServletBean.java

/**
 * Map config parameters onto bean properties of this servlet, and
 * invoke subclass initialization./* w ww  .  j av a2  s. co m*/
 * @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");
    }
}