|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.jar.Manifest
org.knopflerfish.framework.AutoManifest
public class AutoManifest
Manifest subclass which modifies some of the attributes automatically. This can be used to add or remove manifest headers to any loaded bundle. For example, adding package import/export headers.
To enable automatic manifest generation, set the system property
org.knopflerfish.framework.automanifest=true
The automatic manifest config can be specified as an URL using the system property:
org.knopflerfish.framework.automanifest.config=[URL]
Default is "!!/automanifest.props"
The "!!"
part is used to refer
to a resource on the system classloader, but any URL can be used.
The configuration file for automatic manifest generation is on java property file format with any number of sections as:
[id].match.filter=[ldap filter] [id].export.filter=[ldap filter] [id].export.file.filter=[ldap filter] [id].header.[header-name]=[header-value] [id].header.[header-name]=[header-value] [id].header.[header-name]=[header-value] ...
The default config file only has one section, setting all installed bundles to automatically export all of their packages, and dynamically install every class. This is implemented by a single section:
1.match.filter=(location=*) 1.export.filter=(pkg=*) 1.export.file.filter=(file=*.class) 1.header.DynamicImport-Package=* 1.header.Import-Package=[remove] 1.header.Export-Package=[autoexport]
[id]
is any string. The [id]
is also used for sorting the sections. Matching is
done is this sort order.
match.filter
value is an LDAP filter expression used to select
which bundles the section applies to. Only the first matching section is applied to
a bundle. All original bundle manifest attributes can be used in the matching, plus the
special key "location" which represents the bundle location string.
The export.filter
value is an LDAP filter expression which selects
which resources are valid for automatic package export. The special
key "pkg" represents the export candidate. E.g. a filter of "(pkg=*)"
exports all packages.
The export.file.filter
value is an optional LDAP filter expression which selects
which files are considered for auto package generation. The special key
key "file" represents the file candidate. E.g. a filter of "(name=*)"
considers all files. Default is "(file=*.class)
The [header-name]
values are stored directly in the generated
manifest. Any number of header names can be specified.
Two special header values can be used:
"[remove]" - Removes the header completely from the manifest "[autoexport]" - Uses the generated package names as value. Package names are only present if the passes the export.filter
Note 1: An extra attribute
"Bundle-AutoManifest-config"
is always added to the manifest. The value is the URL of the config file
Note 2: Debug output of automatic manifest can be enabled by setting the system property
org.knopflerfish.framework.debug.automanifest=true
Constructor Summary | |
---|---|
AutoManifest(java.util.jar.Manifest mf,
java.lang.String location)
Create an AutoManifest instance based on an orginal manifest and a bundle location. |
Method Summary | |
---|---|
void |
addFile(java.io.File file)
Add a File for automatic package export consideration. |
void |
addFile(java.lang.String prefix,
java.io.File file)
Add a File for automatic package export consideration. |
void |
addFileName(java.lang.String f)
Add a string file name for automatic package export consideration. |
void |
addZipFile(java.util.zip.ZipFile jar)
Add contents of a ZipFile for automatic package export consideration. |
void |
clear()
Delegate to original manifest. |
boolean |
equals(java.lang.Object obj)
AutoManifests are equal if both the original manifest and the bundle location are equal. |
java.util.jar.Attributes |
getAttributes(java.lang.String name)
Delegate to original manifest. |
java.util.Map |
getEntries()
Delegate to original manifest. |
java.lang.String |
getLocation()
Get the bundle location |
java.util.jar.Attributes |
getMainAttributes()
Get the main manifest attributes, possibly modified. |
java.util.jar.Manifest |
getManifest()
Get the original manifest |
int |
hashCode()
Hash code base on original manifest and loation |
boolean |
isAuto()
Check if manifest generation is enabled for this instance. |
void |
read(java.io.InputStream is)
Delegate to original manifest. |
void |
write(java.io.OutputStream out)
Delegate to original manifest. |
Methods inherited from class java.util.jar.Manifest |
---|
clone |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AutoManifest(java.util.jar.Manifest mf, java.lang.String location)
An AutoManifest instance is a proxy to the original manifest except in the case of getting the main attributes. In this case the result may be modified according the auto manifest configuration file.
Note: The first time an AutoManifest instance is created, the configuration file is read.
mf
- original manifest. Must not be null.location
- bundle location. Must not be null.Method Detail |
---|
public boolean isAuto()
public void clear()
clear
in class java.util.jar.Manifest
public java.util.jar.Attributes getAttributes(java.lang.String name)
getAttributes
in class java.util.jar.Manifest
public java.util.Map getEntries()
getEntries
in class java.util.jar.Manifest
public void read(java.io.InputStream is) throws java.io.IOException
read
in class java.util.jar.Manifest
java.io.IOException
public void write(java.io.OutputStream out) throws java.io.IOException
write
in class java.util.jar.Manifest
java.io.IOException
public java.util.jar.Manifest getManifest()
public java.lang.String getLocation()
public boolean equals(java.lang.Object obj)
equals
in class java.util.jar.Manifest
public int hashCode()
hashCode
in class java.util.jar.Manifest
public java.util.jar.Attributes getMainAttributes()
getMainAttributes
in class java.util.jar.Manifest
public void addFile(java.io.File file) throws java.io.IOException
java.io.IOException
public void addFile(java.lang.String prefix, java.io.File file) throws java.io.IOException
java.io.IOException
public void addZipFile(java.util.zip.ZipFile jar)
public void addFileName(java.lang.String f)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |