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
Methods inherited from class org.jboss.virtual.plugins.context.AbstractVFSContext |
addTempInfo, cleanupTempInfo, createNewOptions, equals, getChild, getChildURL, getFurthestParentTemp, getOption, getOption, getOption, getOptions, getPeerContext, getRootPeer, getRootURI, getTempInfo, getTempInfos, getVFS, hashCode, setExceptionHandler, setOption, setOptionsToURL, setRootPeer, toString, visit, visit |
ZipEntryContext
public ZipEntryContext(URL rootURL)
throws URISyntaxException,
IOException
- Create a new ZipEntryContext
- Parameters:
rootURL
- - file or jar:file url
- Throws:
URISyntaxException
- for any URI error
IOException
- for any error
ZipEntryContext
public ZipEntryContext(URL rootURL,
boolean autoClean)
throws URISyntaxException,
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:
URISyntaxException
- for any URI error
IOException
- for any error
ZipEntryContext
public ZipEntryContext(URL rootURL,
VirtualFileHandler peer,
URL localRootUrl)
throws URISyntaxException,
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:
URISyntaxException
- for any URI error
IOException
- for any error
ZipEntryContext
public ZipEntryContext(URL rootURL,
VirtualFileHandler peer,
URL localRootUrl,
boolean autoClean)
throws URISyntaxException,
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:
URISyntaxException
- for any URI error
IOException
- for any error
ZipEntryContext
public ZipEntryContext(URL rootURL,
VirtualFileHandler peer,
org.jboss.virtual.plugins.context.zip.ZipWrapper zipWrapper,
boolean autoClean)
throws URISyntaxException,
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:
URISyntaxException
- for any URI error
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(String rootPath)
throws IOException
- Create zip source.
- Parameters:
rootPath
- the root path
- Returns:
- zip entry wrapper
- Throws:
IOException
- for any error
findEntry
protected org.jboss.virtual.plugins.context.zip.ZipWrapper findEntry(InputStream is,
String relative,
org.jboss.virtual.plugins.context.zip.ZipEntryContext.RealURLInfo urlInfo)
throws IOException
- Find exact entry.
Use recursion on relative path.
- Parameters:
is
- the input streamrelative
- relative pathurlInfo
- url info
- Returns:
- zip wrapper instance
- Throws:
IOException
- for any error
getConstraints
public 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 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 String getPath(VFSContext peer,
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,
String name,
File file)
throws IOException,
URISyntaxException
- Mount ZipEntryContext created around extracted nested archive
- Parameters:
parent
- the parentname
- the namefile
- the file
- Returns:
- mounted delegate
- Throws:
IOException
- for any error
URISyntaxException
- for any URI syntax error
mountZipStream
protected DelegatingHandler mountZipStream(VirtualFileHandler parent,
String name,
InputStream zipStream)
throws IOException,
URISyntaxException
- Mount ZipEntryContext created around ZipStreamWrapper
- Parameters:
parent
- the parentname
- the namezipStream
- the zip stream
- Returns:
- mounted delegate
- Throws:
IOException
- for any error
URISyntaxException
- for any URI syntax error
getRoot
public VirtualFileHandler getRoot()
- Returns this context's root
- Returns:
- root handler
getChildren
public List<VirtualFileHandler> getChildren(VirtualFileHandler parent,
boolean ignoreErrors)
throws 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:
IOException
- for any error
finalize
protected void finalize()
throws Throwable
- Properly release held resources
- Overrides:
finalize
in class Object
- Throws:
Throwable
splitParentChild
public static String[] splitParentChild(String pathName)
- Break to path + name
- Parameters:
pathName
- the path name
- Returns:
- path tokens
Copyright © 2011 JBoss, A division of Red Hat, Inc. All Rights Reserved.