Class JarContent
- java.lang.Object
-
- org.apache.felix.framework.cache.JarContent
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
JarContent.DevNullRunnable
private static class
JarContent.EntriesEnumeration
-
Field Summary
Fields Modifier and Type Field Description private static int
BUFSIZE
private static java.lang.String
EMBEDDED_DIRECTORY
private static java.lang.String
LIBRARY_DIRECTORY
private java.util.Map
m_configMap
private java.io.File
m_file
private boolean
m_isZipFileOwner
private Logger
m_logger
private java.util.Map
m_nativeLibMap
private java.lang.Object
m_revisionLock
private java.io.File
m_rootDir
private WeakZipFileFactory
m_zipFactory
private WeakZipFileFactory.WeakZipFile
m_zipFile
-
Constructor Summary
Constructors Constructor Description JarContent(Logger logger, java.util.Map configMap, WeakZipFileFactory zipFactory, java.lang.Object revisionLock, java.io.File rootDir, java.io.File file, WeakZipFileFactory.WeakZipFile zipFile)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
This method must be called when the content is no longer needed so that any resourses being used (e.g., open files) can be closed.private void
extractEmbeddedJar(java.lang.String jarPath)
This method extracts an embedded JAR file from the bundle's JAR file.protected void
finalize()
java.util.Enumeration<java.lang.String>
getEntries()
Returns an enumeration of entry names as String objects.byte[]
getEntryAsBytes(java.lang.String name)
This method returns the named entry as an array of bytes.Content
getEntryAsContent(java.lang.String entryName)
This method returns the named entry as an IContent Typically, this method only makes sense for entries that correspond to some form of aggregated resource (e.g., an embedded JAR file or directory), but implementations are free to interpret this however makes sense.java.lang.String
getEntryAsNativeLibrary(java.lang.String entryName)
This method returns the named entry as a file in the file system for use as a native library.java.io.InputStream
getEntryAsStream(java.lang.String name)
This method returns the named entry as an input stream.java.net.URL
getEntryAsURL(java.lang.String name)
This method allows retrieving an entry as a local URL.java.io.File
getFile()
boolean
hasEntry(java.lang.String name)
This method determines if the specified named entry is contained in the associated content.java.lang.String
toString()
-
-
-
Field Detail
-
BUFSIZE
private static final int BUFSIZE
- See Also:
- Constant Field Values
-
EMBEDDED_DIRECTORY
private static final transient java.lang.String EMBEDDED_DIRECTORY
- See Also:
- Constant Field Values
-
LIBRARY_DIRECTORY
private static final transient java.lang.String LIBRARY_DIRECTORY
- See Also:
- Constant Field Values
-
m_logger
private final Logger m_logger
-
m_configMap
private final java.util.Map m_configMap
-
m_zipFactory
private final WeakZipFileFactory m_zipFactory
-
m_revisionLock
private final java.lang.Object m_revisionLock
-
m_rootDir
private final java.io.File m_rootDir
-
m_file
private final java.io.File m_file
-
m_zipFile
private final WeakZipFileFactory.WeakZipFile m_zipFile
-
m_isZipFileOwner
private final boolean m_isZipFileOwner
-
m_nativeLibMap
private java.util.Map m_nativeLibMap
-
-
Constructor Detail
-
JarContent
public JarContent(Logger logger, java.util.Map configMap, WeakZipFileFactory zipFactory, java.lang.Object revisionLock, java.io.File rootDir, java.io.File file, WeakZipFileFactory.WeakZipFile zipFile)
-
-
Method Detail
-
finalize
protected void finalize()
- Overrides:
finalize
in classjava.lang.Object
-
close
public void close()
Description copied from interface:Content
This method must be called when the content is no longer needed so that any resourses being used (e.g., open files) can be closed. Once this method is called, the content is no longer usable. If the content is already closed, then calls on this method should have no effect.
-
hasEntry
public boolean hasEntry(java.lang.String name) throws java.lang.IllegalStateException
Description copied from interface:Content
This method determines if the specified named entry is contained in the associated content. The entry name is a relative path with '/' separators.
-
getEntries
public java.util.Enumeration<java.lang.String> getEntries()
Description copied from interface:Content
Returns an enumeration of entry names as String objects. An entry name is a path constructed with '/' as path element separators and is relative to the root of the content. Entry names for entries that represent directories should end with the '/' character.
- Specified by:
getEntries
in interfaceContent
-
getEntryAsBytes
public byte[] getEntryAsBytes(java.lang.String name) throws java.lang.IllegalStateException
Description copied from interface:Content
This method returns the named entry as an array of bytes.
- Specified by:
getEntryAsBytes
in interfaceContent
- Parameters:
name
- The name of the entry to retrieve as a byte array.- Returns:
- An array of bytes if the corresponding entry was found, null otherwise.
- Throws:
java.lang.IllegalStateException
-
getEntryAsStream
public java.io.InputStream getEntryAsStream(java.lang.String name) throws java.lang.IllegalStateException, java.io.IOException
Description copied from interface:Content
This method returns the named entry as an input stream.
- Specified by:
getEntryAsStream
in interfaceContent
- Parameters:
name
- The name of the entry to retrieve as an input stream.- Returns:
- An input stream if the corresponding entry was found, null otherwise.
- Throws:
java.lang.IllegalStateException
java.io.IOException
-
getEntryAsURL
public java.net.URL getEntryAsURL(java.lang.String name)
Description copied from interface:Content
This method allows retrieving an entry as a local URL.
- Specified by:
getEntryAsURL
in interfaceContent
- Parameters:
name
- The name of the entry to retrieve as a URL- Returns:
- A URL using a local protocol such as file, jar or null if not possible.
-
getEntryAsContent
public Content getEntryAsContent(java.lang.String entryName)
Description copied from interface:Content
This method returns the named entry as an IContent Typically, this method only makes sense for entries that correspond to some form of aggregated resource (e.g., an embedded JAR file or directory), but implementations are free to interpret this however makes sense. This method should return a new IContent instance for every invocation and the caller is responsible for opening and closing the returned content object.
- Specified by:
getEntryAsContent
in interfaceContent
- Parameters:
entryName
- The name of the entry to retrieve as an IContent.- Returns:
- An IContent instance if a corresponding entry was found, null otherwise.
-
getEntryAsNativeLibrary
public java.lang.String getEntryAsNativeLibrary(java.lang.String entryName)
Description copied from interface:Content
This method returns the named entry as a file in the file system for use as a native library. It may not be possible for all content implementations (e.g., memory only) to implement this method, in which case it is acceptable to return null. Since native libraries can only be associated with a single class loader, this method should return a unique file per request.
- Specified by:
getEntryAsNativeLibrary
in interfaceContent
- Parameters:
entryName
- The name of the entry to retrieve as a file.- Returns:
- A string corresponding to the absolute path of the file if a corresponding entry was found, null otherwise.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getFile
public java.io.File getFile()
-
extractEmbeddedJar
private void extractEmbeddedJar(java.lang.String jarPath) throws java.lang.Exception
This method extracts an embedded JAR file from the bundle's JAR file.- Parameters:
id
- the identifier of the bundle that owns the embedded JAR file.jarPath
- the path to the embedded JAR file inside the bundle JAR file.- Throws:
java.lang.Exception
-
-