org.eclipse.gemini.blueprint.test.internal.util.jar
Class JarCreator

java.lang.Object
  extended by org.eclipse.gemini.blueprint.test.internal.util.jar.JarCreator

public class JarCreator
extends Object

Helper class for creating Jar files. Note that this class is stateful and the same instance should not be reused.

Author:
Costin Leau

Field Summary
static String EVERYTHING_PATTERN
           
 
Constructor Summary
JarCreator()
           
 
Method Summary
protected  int addJarContent(Manifest manifest, Map entries)
          Actual jar creation.
 org.springframework.core.io.Resource createJar(Manifest manifest)
          Create a jar using the current settings and return a Resource pointing to the jar.
 org.springframework.core.io.Resource createJar(Manifest manifest, Map content)
          Create a jar using the current settings and return a Resource pointing to the jar.
 String determineRootPath()
          Resources' root path (the root path does not become part of the jar).
 Collection getContainedPackages()
           
 String[] getContentPattern()
           
 org.springframework.core.io.support.ResourcePatternResolver getPatternResolver()
           
 String getRootPath()
           
 Storage getStorage()
           
 boolean isAddFolders()
           
 Map resolveContent()
          Resolve the jar content based on its path.
 void setAddFolders(boolean addFolders)
          Whether the folders in which the files reside, should be added to the archive.
 void setContentPattern(String[] contentPattern)
          Pattern for content matching.
 void setPatternResolver(org.springframework.core.io.support.ResourcePatternResolver patternResolver)
           
 void setRootPath(String rootPath)
           
 void setStorage(Storage jarStorage)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EVERYTHING_PATTERN

public static final String EVERYTHING_PATTERN
See Also:
Constant Field Values
Constructor Detail

JarCreator

public JarCreator()
Method Detail

determineRootPath

public String determineRootPath()
Resources' root path (the root path does not become part of the jar).

Returns:
the root path

addJarContent

protected int addJarContent(Manifest manifest,
                            Map entries)
                     throws IOException
Actual jar creation.

Parameters:
manifest - to use
entries - array of resource to include in the jar
Returns:
the number of bytes written to the underlying stream.
Throws:
IOException

createJar

public org.springframework.core.io.Resource createJar(Manifest manifest)
Create a jar using the current settings and return a Resource pointing to the jar.

Parameters:
manifest -

createJar

public org.springframework.core.io.Resource createJar(Manifest manifest,
                                                      Map content)
Create a jar using the current settings and return a Resource pointing to the jar.

Parameters:
manifest -

resolveContent

public Map resolveContent()
Resolve the jar content based on its path. Will return a map containing the entries relative to the jar root path as keys and Spring Resource pointing to the actual resources as values. It will also determine the packages contained by this package.

Returns:

getContainedPackages

public Collection getContainedPackages()

getContentPattern

public String[] getContentPattern()
Returns:
Returns the contentPattern.

setContentPattern

public void setContentPattern(String[] contentPattern)
Pattern for content matching. Note that using EVERYTHING_PATTERN can become problematic on windows due to file system locking.

Parameters:
contentPattern - The contentPattern to set.

getPatternResolver

public org.springframework.core.io.support.ResourcePatternResolver getPatternResolver()
Returns:
Returns the patternResolver.

setPatternResolver

public void setPatternResolver(org.springframework.core.io.support.ResourcePatternResolver patternResolver)
Parameters:
patternResolver - The patternResolver to set.

getStorage

public Storage getStorage()
Returns:
Returns the jarStorage.

setStorage

public void setStorage(Storage jarStorage)
Parameters:
jarStorage - The jarStorage to set.

getRootPath

public String getRootPath()
Parameters:
-

setRootPath

public void setRootPath(String rootPath)
Parameters:
rootPath - The rootPath to set.

isAddFolders

public boolean isAddFolders()
Returns:
Returns the addFolders.

setAddFolders

public void setAddFolders(boolean addFolders)
Whether the folders in which the files reside, should be added to the archive. Default is true since otherwise, the archive will contains only files and no folders.

Parameters:
addFolders - The addFolders to set.


Copyright © 2006-2012. All Rights Reserved.