public class JarFileResourceStore extends java.lang.Object implements ResourceStore
JarFileResourceStore
knows how to read and write
resources from (to respectively) a Jar File.Constructor and Description |
---|
JarFileResourceStore(java.util.jar.JarFile source,
java.io.File target)
Construct a
JarFileResourceStore wrapping the given original bundle,
and configured to output in the given target file. |
Modifier and Type | Method and Description |
---|---|
void |
accept(ResourceVisitor visitor)
Browse all resources available in this store.
|
void |
close()
Close the store: no methods will be called anymore on this instance.
|
void |
open()
Notify the store that resource will be written.
|
byte[] |
read(java.lang.String path)
Return the bytecode of the given class name.
|
void |
setClassLoader(java.lang.ClassLoader classLoader) |
void |
setManifest(java.util.jar.Manifest manifest) |
void |
setManifestBuilder(ManifestBuilder manifestBuilder) |
void |
setResourceMapper(ResourceMapper mapper) |
static byte[] |
toByteArray(java.net.URL url) |
void |
write(java.lang.String resourcePath,
byte[] resource)
Notify the builder that a new resource has been built and should
be stored in the resulting bundle.
|
void |
writeMetadata(org.apache.felix.ipojo.metadata.Element metadata)
Writes the given Element into this store.
|
public JarFileResourceStore(java.util.jar.JarFile source, java.io.File target) throws java.io.IOException
JarFileResourceStore
wrapping the given original bundle,
and configured to output in the given target file.source
- original Bundletarget
- File where the updated Bundle will be outputtedjava.io.IOException
- if there is an error retrieving the Manifest from the original JarFilepublic void setResourceMapper(ResourceMapper mapper)
public void setManifestBuilder(ManifestBuilder manifestBuilder)
public void setManifest(java.util.jar.Manifest manifest)
public void setClassLoader(java.lang.ClassLoader classLoader)
public byte[] read(java.lang.String path) throws java.io.IOException
ResourceStore
read
in interface ResourceStore
path
- normalized resource path (format: org/objectweb/asm/Visitor.class)java.io.IOException
- if resource was not foundpublic static byte[] toByteArray(java.net.URL url) throws java.io.IOException
java.io.IOException
public void accept(ResourceVisitor visitor)
ResourceStore
accept
in interface ResourceStore
visitor
- is called for each available resourcepublic void open() throws java.io.IOException
ResourceStore
open
in interface ResourceStore
java.io.IOException
- if there was an errorpublic void writeMetadata(org.apache.felix.ipojo.metadata.Element metadata)
ResourceStore
writeMetadata
in interface ResourceStore
metadata
- Element metadata to be insertedpublic void write(java.lang.String resourcePath, byte[] resource) throws java.io.IOException
ResourceStore
write
in interface ResourceStore
resourcePath
- resource name of the class (format: org/objectweb/asm/Visitor.class)resource
- content of the resourcejava.io.IOException
- if there was an error storing the resourcepublic void close() throws java.io.IOException
ResourceStore
close
in interface ResourceStore
java.io.IOException
- if close failedCopyright © 2006-2014 The Apache Software Foundation. All Rights Reserved.