Example usage for org.springframework.core.io UrlResource getURL

List of usage examples for org.springframework.core.io UrlResource getURL

Introduction

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

Prototype

@Override
public URL getURL() 

Source Link

Document

This implementation returns the underlying URL reference.

Usage

From source file:com.francetelecom.clara.cloud.commons.JndiAwarePropertyPlaceholderConfigurer.java

/**
 * Takes an array or Resources and for any of type UrlResource, resolves any
 * properties in the URL. Note that as we haven't loaded the property fiels
 * at this stage we are resolving properties against the system and jndi
 * sets (if any)//from   w w w  . jav a 2s.c o m
 * 
 * @param locations
 */
@SuppressWarnings("unchecked")
private void processLocationValues(Resource[] locations) {
    if (locations != null) {
        Properties props = new Properties();
        HashSet visitedPlaceholders = new HashSet();
        for (int i = 0; i < locations.length; i++) {
            if (locations[i] instanceof UrlResource) {
                UrlResource file = (UrlResource) locations[i];
                String path;
                try {
                    path = file.getURL().toString();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                String value = parseStringValue(path, props, visitedPlaceholders);
                if (!StringUtils.equals(path, value)) {
                    UrlResource newFile;
                    try {
                        newFile = new UrlResource(value);
                    } catch (MalformedURLException e) {
                        throw new RuntimeException(e);
                    }
                    locations[i] = newFile;
                }
            }
        }
    }
}