org.apache.cocoon.spring.configurator
Class ResourceUtils

java.lang.Object
  extended by org.apache.cocoon.spring.configurator.ResourceUtils

public abstract class ResourceUtils
extends Object

Utility class for Spring resource handling.

Since:
1.0
Version:
$Id: ResourceUtils.java 677626 2008-07-17 16:06:10Z gkossakowski $

Nested Class Summary
protected static class ResourceUtils.ResourceComparator
          Class implementing a simple resource comparator as described here: getResourceComparator().
 
Constructor Summary
ResourceUtils()
           
 
Method Summary
protected static String correctUri(String uri)
           
static Resource[] filterResources(Resource[] resources, ResourceFilter filter)
           
static Properties getPOMProperties(String groupId, String artifactId)
          Return the properties added by Maven.
static Comparator getResourceComparator()
          Return a resource comparator.
static String getUri(Resource resource)
          Get the uri of a resource.
static boolean isClasspathUri(String uri)
           
static void readProperties(String propertiesPath, Properties properties, ResourceLoader resourceLoader, ResourceFilter resourceFilter, Log logger)
          Read all property files from the given directory and apply them to the supplied properties.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ResourceUtils

public ResourceUtils()
Method Detail

getUri

public static String getUri(Resource resource)
                     throws IOException
Get the uri of a resource. This method corrects the uri in the case of the file protocol on windows.

Parameters:
resource - The resource.
Returns:
The uri.
Throws:
IOException

correctUri

protected static String correctUri(String uri)

isClasspathUri

public static boolean isClasspathUri(String uri)

readProperties

public static void readProperties(String propertiesPath,
                                  Properties properties,
                                  ResourceLoader resourceLoader,
                                  ResourceFilter resourceFilter,
                                  Log logger)
Read all property files from the given directory and apply them to the supplied properties.

Parameters:
propertiesPath - The directory path.
properties - The properties object where all the read properties are applied to.
resourceLoader - The resource loader to load the property files.
resourceFilter - The resource filter used to filter read property files, if null no filtering is being applied.
logger - Optional logger for debugging.

getResourceComparator

public static Comparator getResourceComparator()
Return a resource comparator. This comparator compares the file name of two resources. In addition all resources contained in a directory named WEB-INF/classes/cocoon are sorted (in alphabetical) order after all other files.

Returns:
A new comparator for resources.

getPOMProperties

public static Properties getPOMProperties(String groupId,
                                          String artifactId)
Return the properties added by Maven.

Parameters:
groupId - The group identifier of the artifact.
artifactId - The artifact identifier.
Returns:
Returns a properties object or null if the properties can't be found/read.

filterResources

public static Resource[] filterResources(Resource[] resources,
                                         ResourceFilter filter)
Parameters:
resources - The array of resources need to be filtered
filter - The instance of the filter itself
Returns:
the array of resources that has been filtered


Copyright © 1999-2009 The Apache Software Foundation. All Rights Reserved.