org.jboss.virtual.plugins.context.zip
Class ZipEntryContext
java.lang.Object
org.jboss.virtual.plugins.context.AbstractVFSContext
org.jboss.virtual.plugins.context.zip.ZipEntryContext
- All Implemented Interfaces:
- VFSContext
public class ZipEntryContext
- extends AbstractVFSContext
ZipEntryContext implements a VFSContext
that exposes a zip archive as a virtual file system.
Zip archive can be in a form of a file or a stream.
Nested archives are processed through this same class.
By default nested archives are cached in memory and mounted as new
instances of ZipEntryContext with ZipStreamWrapper as a source.
If system property jboss.vfs.forceCopy=true is specified,
or URL query parameter forceCopy=true is present,
nested archives are extracted into a temp directory before being
mounted as new instances of ZipEntryContext.
In-memory nested archives may consume a lot of memory. To reduce memory footprint
at the expense of performance, system property jboss.vfs.optimizeForMemory=true
can be set.
This context implementation has two modes of releasing file locks.
Asynchronous mode is the default one since it is better performant.
To switch this to synchronous mode a system property
jboss.vfs.forceNoReaper=true can be specified or URL query parameter
noReaper=true can be included in context URL.
This context implementation is a replacement for
JarContext
.
- Version:
- $Revision: 1.0 $
- Author:
- Marko Strukelj, Ales Justin, David M. Lloyd
Constructor Summary |
ZipEntryContext(java.net.URL rootURL)
Create a new ZipEntryContext |
ZipEntryContext(java.net.URL rootURL,
boolean autoClean)
Create a new ZipEntryContext |
ZipEntryContext(java.net.URL rootURL,
VirtualFileHandler peer,
java.net.URL localRootUrl)
Create a new ZipEntryContext to be mounted into another context |
ZipEntryContext(java.net.URL rootURL,
VirtualFileHandler peer,
java.net.URL localRootUrl,
boolean autoClean)
Create a new ZipEntryContext to be mounted into another context |
ZipEntryContext(java.net.URL rootURL,
VirtualFileHandler peer,
org.jboss.virtual.plugins.context.zip.ZipWrapper zipWrapper,
boolean autoClean)
Create a new ZipEntryContext to be mounted into another context |
Methods inherited from class org.jboss.virtual.plugins.context.AbstractVFSContext |
addTempInfo, cleanup, cleanupTempInfo, createNewOptions, equals, getChild, getChildURL, getFurthestParentTemp, getOption, getOption, getOption, getOptions, getPeerContext, getRootPeer, getRootURI, getTempInfo, getTempInfos, getTempStore, getVFS, hashCode, setExceptionHandler, setOption, setOptionsToURL, setRootPeer, setTempStore, toString, visit, visit |
Methods inherited from class java.lang.Object |
clone, getClass, notify, notifyAll, wait, wait, wait |
ZipEntryContext
public ZipEntryContext(java.net.URL rootURL)
throws java.net.URISyntaxException,
java.io.IOException
- Create a new ZipEntryContext
- Parameters:
rootURL
- - file or jar:file url
- Throws:
java.net.URISyntaxException
- for any URI error
java.io.IOException
- for any error
ZipEntryContext
public ZipEntryContext(java.net.URL rootURL,
boolean autoClean)
throws java.net.URISyntaxException,
java.io.IOException
- Create a new ZipEntryContext
- Parameters:
rootURL
- - file or jar:file urlautoClean
- - true if file represented by rootURL should be deleted after this context is closed
- Throws:
java.net.URISyntaxException
- for any URI error
java.io.IOException
- for any error
ZipEntryContext
public ZipEntryContext(java.net.URL rootURL,
VirtualFileHandler peer,
java.net.URL localRootUrl)
throws java.net.URISyntaxException,
java.io.IOException
- Create a new ZipEntryContext to be mounted into another context
- Parameters:
rootURL
- - url representing this context within another contextpeer
- - file handler in another context through which this context is being mountedlocalRootUrl
- - file or jar:file url
- Throws:
java.net.URISyntaxException
- for any URI error
java.io.IOException
- for any error
ZipEntryContext
public ZipEntryContext(java.net.URL rootURL,
VirtualFileHandler peer,
java.net.URL localRootUrl,
boolean autoClean)
throws java.net.URISyntaxException,
java.io.IOException
- Create a new ZipEntryContext to be mounted into another context
- Parameters:
rootURL
- - url representing this context within another contextpeer
- - file handler in another context through which this context is being mountedlocalRootUrl
- - file or jar:file urlautoClean
- - true if file represented by localRootURL should be deleted after this context is closed
- Throws:
java.net.URISyntaxException
- for any URI error
java.io.IOException
- for any error
ZipEntryContext
public ZipEntryContext(java.net.URL rootURL,
VirtualFileHandler peer,
org.jboss.virtual.plugins.context.zip.ZipWrapper zipWrapper,
boolean autoClean)
throws java.net.URISyntaxException,
java.io.IOException
- Create a new ZipEntryContext to be mounted into another context
- Parameters:
rootURL
- - url representing this context within another contextpeer
- - file handler in another context through which this context is being mountedzipWrapper
- - abstracted zip archive sourceautoClean
- - true if file represented by localRootURL should be deleted after this context is closed
- Throws:
java.net.URISyntaxException
- for any URI error
java.io.IOException
- for any error
getZipSource
protected org.jboss.virtual.plugins.context.zip.ZipWrapper getZipSource()
- Get zip source.
Lazy init.
- Returns:
- the zip source
getAggregatedOptions
public Options getAggregatedOptions()
- Returns aggregated options.
If peer exists, it uses peer context's options as a basis,
and overrides them with this context's options.
- Returns:
- map containing aggregated options
getExceptionHandler
public ExceptionHandler getExceptionHandler()
- Description copied from interface:
VFSContext
- Get the exception handler.
- Specified by:
getExceptionHandler
in interface VFSContext
- Overrides:
getExceptionHandler
in class AbstractVFSContext
- Returns:
- the exception handler
createZipSource
protected org.jboss.virtual.plugins.context.zip.ZipWrapper createZipSource(java.lang.String rootPath)
throws java.lang.Exception
- Create zip source.
- Parameters:
rootPath
- the root path
- Returns:
- zip entry wrapper
- Throws:
java.lang.Exception
- for any error
findEntry
protected org.jboss.virtual.plugins.context.zip.ZipWrapper findEntry(java.io.InputStream is,
java.lang.String relative,
org.jboss.virtual.plugins.context.zip.ZipEntryContext.RealURLInfo urlInfo)
throws java.io.IOException
- Find exact entry.
Use recursion on relative path.
- Parameters:
is
- the input streamrelative
- relative pathurlInfo
- url info
- Returns:
- zip wrapper instance
- Throws:
java.io.IOException
- for any error
getConstraints
public java.util.Set<VFSContextConstraints> getConstraints()
- Description copied from interface:
VFSContext
- Get context's constraints.
- Specified by:
getConstraints
in interface VFSContext
- Overrides:
getConstraints
in class AbstractVFSContext
- Returns:
- the constraints
getName
public java.lang.String getName()
- Returns archive file name - if this is a top-level ZipEntryContext.
Otherwise it returns the last component of URL.
- Returns:
- name
getPath
protected java.lang.String getPath(VFSContext peer,
java.lang.String entryName)
- Get temp path.
- Parameters:
peer
- the peer vfs contextentryName
- the zip entry name
- Returns:
- full temp path
mountZipFile
protected DelegatingHandler mountZipFile(VirtualFileHandler parent,
java.lang.String name,
java.io.File file)
throws java.io.IOException,
java.net.URISyntaxException
- Mount ZipEntryContext created around extracted nested archive
- Parameters:
parent
- the parentname
- the namefile
- the file
- Returns:
- mounted delegate
- Throws:
java.io.IOException
- for any error
java.net.URISyntaxException
- for any URI syntax error
mountZipStream
protected DelegatingHandler mountZipStream(VirtualFileHandler parent,
java.lang.String name,
java.io.InputStream zipStream)
throws java.io.IOException,
java.net.URISyntaxException
- Mount ZipEntryContext created around ZipStreamWrapper
- Parameters:
parent
- the parentname
- the namezipStream
- the zip stream
- Returns:
- mounted delegate
- Throws:
java.io.IOException
- for any error
java.net.URISyntaxException
- for any URI syntax error
getRoot
public VirtualFileHandler getRoot()
- Returns this context's root
- Returns:
- root handler
getChildren
public java.util.List<VirtualFileHandler> getChildren(VirtualFileHandler parent,
boolean ignoreErrors)
throws java.io.IOException
- Returns a list of children for a given parent
- Specified by:
getChildren
in interface VFSContext
- Overrides:
getChildren
in class AbstractVFSContext
- Parameters:
parent
- parent handlerignoreErrors
- true if errors should be silently ignored
- Returns:
- list of handlers representing children of the given parent
- Throws:
java.io.IOException
- for any error
finalize
protected void finalize()
throws java.lang.Throwable
- Properly release held resources
- Overrides:
finalize
in class java.lang.Object
- Throws:
java.lang.Throwable
splitParentChild
public static java.lang.String[] splitParentChild(java.lang.String pathName)
- Break to path + name
- Parameters:
pathName
- the path name
- Returns:
- path tokens