org.apache.cocoon.spring.configurator
Class ResourceUtils

java.lang.Object
  extended byorg.apache.cocoon.spring.configurator.ResourceUtils

public abstract class ResourceUtils
extends Object

Utility class for Spring resource handling.

Since:
1.0
Version:
$Id: ResourceUtils.java 588440 2007-10-26 00:26:05Z vgritsenko $

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 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, 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,
                                  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.
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.


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