org.shept.util
Class JarUtils

java.lang.Object
  extended by org.shept.util.JarUtils

public abstract class JarUtils
extends Object

Version:
$$Id: JarUtils.java 94 2010-12-22 15:12:29Z aha $$
Author:
Andi

Field Summary
private static Set<? super String> alreadyCopied
           
protected static org.apache.commons.logging.Log logger
          Logger that is available to subclasses
 
Constructor Summary
JarUtils()
           
 
Method Summary
static void copyResources(org.springframework.core.io.ClassPathResource cpr, String webAppDestPath)
          Copy resources from a classPath, typically within a jar file to a specified destination, typically a resource directory in the projects webApp directory (images, sounds, e.t.c.
static void copyResources(String[] resources, org.springframework.core.io.ClassPathResource cpr, String webAppDestPath)
          Copy resources from a classPath, typically within a jar file to a specified destination, typically a resource directory in the projects webApp directory (images, sounds, e.t.c.
static void copyResourcesOnce(org.springframework.core.io.ClassPathResource cpr, String destPath)
           
static void copyResourcesOnce(org.springframework.core.io.ClassPathResource cpr, String destPath, String resName)
          Init this controllers ressources by copying them into the web container (subpath of WEB-INF).
static Set<? super String> getAlreadyCopied()
           
static String jarPathInternal(URL jarPathUrl)
          Extract the URL-String for the internal resource path from the given URL (which points to a resource in a jar file).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

alreadyCopied

private static Set<? super String> alreadyCopied

logger

protected static final org.apache.commons.logging.Log logger
Logger that is available to subclasses

Constructor Detail

JarUtils

public JarUtils()
Method Detail

copyResourcesOnce

public static void copyResourcesOnce(org.springframework.core.io.ClassPathResource cpr,
                                     String destPath,
                                     String resName)
Init this controllers ressources by copying them into the web container (subpath of WEB-INF). This is useful for resources as pictures, sounds for access by plain HTML This would not work if they stay just in the jar. (Well actually it would work with Mozilla browsers because they support url naming convention specifying resources inside a .jar-file. This isn't true for Internet Explorer).

Resource copying is done only if there are no resources in the destination path so you can easily provide other than the default resources.

Note that changing the names for destination directory in the servlet context requires that you need to specify an imagePath for the taglibs. Alternatively you can also copy the taglibs into your WEB-INF/tags directory and modify for a different behavior or look and feel. In this case you need to specify your own (shept).tld file (copy implicit.tld from shept META-INF).


copyResourcesOnce

public static void copyResourcesOnce(org.springframework.core.io.ClassPathResource cpr,
                                     String destPath)

copyResources

public static void copyResources(org.springframework.core.io.ClassPathResource cpr,
                                 String webAppDestPath)
                          throws IOException,
                                 URISyntaxException
Copy resources from a classPath, typically within a jar file to a specified destination, typically a resource directory in the projects webApp directory (images, sounds, e.t.c. ) Copies resources only if the destination file does not exist and the specified resource is available. The ClassPathResource will be scanned for all resources in the path specified by the resource. For example a path like: new ClassPathResource("resource/images/pager/", SheptBaseController.class); takes all the resources in the path 'resource/images/pager' (but not in sub-path) from the specified clazz 'SheptBaseController'

Parameters:
cpr - ClassPathResource specifying the source location on the classPath (maybe within a jar)
webAppDestPath - Full path String to the fileSystem destination directory
Throws:
IOException - when copying on copy error
URISyntaxException

copyResources

public static void copyResources(String[] resources,
                                 org.springframework.core.io.ClassPathResource cpr,
                                 String webAppDestPath)
                          throws IOException
Copy resources from a classPath, typically within a jar file to a specified destination, typically a resource directory in the projects webApp directory (images, sounds, e.t.c. ) Copies resources only if the destination file does not exist and the specified resource is available.

Parameters:
resources - Array of String resources (filenames) to be copied
cpr - ClassPathResource specifying the source location on the classPath (maybe within a jar)
webAppDestPath - Full path String to the fileSystem destination directory
Throws:
IOException - when copying on copy error

jarPathInternal

public static String jarPathInternal(URL jarPathUrl)
Extract the URL-String for the internal resource path from the given URL (which points to a resource in a jar file). This methods complements ResourceUtils.extractJarFileURL(URL)

Parameters:
jarPathUrl -
Returns:
empty String if no such internal jar path is found

getAlreadyCopied

public static Set<? super String> getAlreadyCopied()
Returns:
the alreadyCopied


Copyright © 2011. All Rights Reserved.