aQute.lib.osgi
Class Analyzer

java.lang.Object
  extended by aQute.lib.osgi.Processor
      extended by aQute.lib.osgi.Analyzer
All Implemented Interfaces:
aQute.lib.reporter.Reporter
Direct Known Subclasses:
Builder

public class Analyzer
extends Processor


Field Summary
static java.lang.String BND_LASTMODIFIED
           
static java.lang.String BUNDLE_ACTIVATOR
           
static java.lang.String BUNDLE_CLASSPATH
           
static java.lang.String BUNDLE_CONTACTADDRESS
           
static java.lang.String BUNDLE_COPYRIGHT
           
static java.lang.String BUNDLE_DESCRIPTION
           
static java.lang.String BUNDLE_DOCURL
           
static java.lang.String BUNDLE_LICENSE
           
static java.lang.String BUNDLE_LOCALIZATION
           
static java.lang.String BUNDLE_MANIFESTVERSION
           
static java.lang.String BUNDLE_NAME
           
static java.lang.String BUNDLE_NATIVECODE
           
static java.lang.String BUNDLE_REQUIREDEXECUTIONENVIRONMENT
           
static java.lang.String BUNDLE_SYMBOLICNAME
           
static java.lang.String BUNDLE_VENDOR
           
static java.lang.String BUNDLE_VERSION
           
static java.lang.String CLASSPATH
           
static java.lang.String[] componentDirectives
           
static java.lang.String CONDITIONAL_PACKAGE
           
static java.lang.String CREATED_BY
           
static java.lang.String[] directives
           
static java.lang.String DONOTCOPY
           
static java.lang.String DYNAMICIMPORT_PACKAGE
           
static java.lang.String EXPORT_CONTENTS
           
static java.lang.String EXPORT_PACKAGE
           
static java.lang.String EXPORT_SERVICE
           
static java.lang.String FAIL_OK
           
static java.lang.String FRAGMENT_HOST
           
static java.lang.String[] headers
           
static java.lang.String IGNORE_PACKAGE
           
static java.lang.String IMPORT_PACKAGE
           
static java.lang.String IMPORT_SERVICE
           
static java.lang.String INCLUDE
           
static java.lang.String INCLUDE_RESOURCE
           
static java.lang.String NO_IMPORT_DIRECTIVE
           
static java.lang.String NOEXTRAHEADERS
           
static java.lang.String NOUSES
           
static java.lang.String[] options
           
static java.lang.String PEDANTIC
           
static java.lang.String POM
           
static java.lang.String PRIVATE_PACKAGE
           
static java.lang.String REMOVE_HEADERS
           
static java.lang.String REQUIRE_BUNDLE
           
static java.lang.String SERVICE_COMPONENT
           
static java.lang.String SOURCES
           
static java.lang.String SPLIT_PACKAGE_DIRECTIVE
           
static java.lang.String TOOL
           
 
Fields inherited from class aQute.lib.osgi.Processor
DEFAULT_BAR_EXTENSION, DEFAULT_BND_EXTENSION, DEFAULT_JAR_EXTENSION, DEFAULT_PLUGINS
 
Constructor Summary
Analyzer()
           
 
Method Summary
 java.lang.String _findname(java.lang.String[] args)
           
 java.lang.String _findpath(java.lang.String[] args)
          Findpath looks through the contents of the JAR and finds paths that end with the given regular expression ${findpath (; reg-expr (; replacement)? )? }
 void analyze()
          Calcualtes the data structures for generating a manifest.
 java.util.jar.Manifest calcManifest()
          One of the main workhorses of this class.
 java.lang.String calculateExportsFromContents(Jar bundle)
          Calculate an export header solely based on the contents of a JAR file
 void close()
           
 java.util.Map doServiceComponent(java.lang.String serviceComponent)
          Check if a service component header is actually referring to a class.
 long getBndLastModified()
           
 void getBndManifest()
           
 java.util.Map getBundleClasspath()
           
 java.util.List getClasspath()
           
 java.util.Map getContained()
           
 java.util.Map getExports()
           
 java.util.Map getImports()
           
 Jar getJar()
           
static java.util.Properties getManifest(java.io.File dirOrJar)
          Specifically for Maven
 java.util.Properties getProperties()
           
 java.lang.String getProperty(java.lang.String headerName)
           
 java.lang.String getProperty(java.lang.String headerName, java.lang.String deflt)
          Get a property with a proper default
 java.util.Map getReferred()
           
 java.util.Set getUnreachable()
          Return the set of unreachable code depending on exports and the bundle activator.
 java.util.Map getUses()
           
 java.lang.String getVersion()
          Get the version from the manifest, a lot of work!
 long lastModified()
           
 void mergeManifest(java.util.jar.Manifest manifest)
          Merge the existing manifest with the instructions.
 void mergeProperties(java.io.File file, boolean override)
           
 void mergeProperties(java.util.Properties properties, boolean override)
           
 java.lang.String printClauses(java.util.Map exports, java.lang.String allowedDirectives)
          Print a standard Map based OSGi header.
 void putAll(java.util.Map additional, boolean force)
           
 void setBase(java.io.File file)
           
 void setClasspath(java.io.File[] classpath)
          Set the classpath for this analyzer by file.
 void setClasspath(Jar[] classpath)
           
 void setClasspath(java.lang.String[] classpath)
           
 Jar setJar(java.io.File jar)
          Set the JAR file we are going to work in.
 Jar setJar(Jar jar)
          Set the JAR directly we are going to work on.
 void setProperties(java.io.File propertiesFile)
          Set the properties by file.
 void setProperties(java.util.Properties properties)
           
 void setProperty(java.lang.String key, java.lang.String value)
          Add or override a new property.
 void unsetProperty(java.lang.String string)
           
 void updateModified(long time)
           
 
Methods inherited from class aQute.lib.osgi.Processor
add, analyzeBundleClasspath, error, error, format, getErrors, getFile, getInfo, getPackage, getWarnings, isPedantic, parseHeader, parseHeader, progress, report, setPedantic, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUNDLE_CLASSPATH

public static final java.lang.String BUNDLE_CLASSPATH
See Also:
Constant Field Values

BUNDLE_COPYRIGHT

public static final java.lang.String BUNDLE_COPYRIGHT
See Also:
Constant Field Values

BUNDLE_DESCRIPTION

public static final java.lang.String BUNDLE_DESCRIPTION
See Also:
Constant Field Values

BUNDLE_NAME

public static final java.lang.String BUNDLE_NAME
See Also:
Constant Field Values

BUNDLE_NATIVECODE

public static final java.lang.String BUNDLE_NATIVECODE
See Also:
Constant Field Values

EXPORT_PACKAGE

public static final java.lang.String EXPORT_PACKAGE
See Also:
Constant Field Values

EXPORT_SERVICE

public static final java.lang.String EXPORT_SERVICE
See Also:
Constant Field Values

IMPORT_PACKAGE

public static final java.lang.String IMPORT_PACKAGE
See Also:
Constant Field Values

DYNAMICIMPORT_PACKAGE

public static final java.lang.String DYNAMICIMPORT_PACKAGE
See Also:
Constant Field Values

IMPORT_SERVICE

public static final java.lang.String IMPORT_SERVICE
See Also:
Constant Field Values

BUNDLE_VENDOR

public static final java.lang.String BUNDLE_VENDOR
See Also:
Constant Field Values

BUNDLE_VERSION

public static final java.lang.String BUNDLE_VERSION
See Also:
Constant Field Values

BUNDLE_DOCURL

public static final java.lang.String BUNDLE_DOCURL
See Also:
Constant Field Values

BUNDLE_CONTACTADDRESS

public static final java.lang.String BUNDLE_CONTACTADDRESS
See Also:
Constant Field Values

BUNDLE_ACTIVATOR

public static final java.lang.String BUNDLE_ACTIVATOR
See Also:
Constant Field Values

BUNDLE_REQUIREDEXECUTIONENVIRONMENT

public static final java.lang.String BUNDLE_REQUIREDEXECUTIONENVIRONMENT
See Also:
Constant Field Values

BUNDLE_SYMBOLICNAME

public static final java.lang.String BUNDLE_SYMBOLICNAME
See Also:
Constant Field Values

BUNDLE_LOCALIZATION

public static final java.lang.String BUNDLE_LOCALIZATION
See Also:
Constant Field Values

REQUIRE_BUNDLE

public static final java.lang.String REQUIRE_BUNDLE
See Also:
Constant Field Values

FRAGMENT_HOST

public static final java.lang.String FRAGMENT_HOST
See Also:
Constant Field Values

BUNDLE_MANIFESTVERSION

public static final java.lang.String BUNDLE_MANIFESTVERSION
See Also:
Constant Field Values

SERVICE_COMPONENT

public static final java.lang.String SERVICE_COMPONENT
See Also:
Constant Field Values

BUNDLE_LICENSE

public static final java.lang.String BUNDLE_LICENSE
See Also:
Constant Field Values

PRIVATE_PACKAGE

public static final java.lang.String PRIVATE_PACKAGE
See Also:
Constant Field Values

IGNORE_PACKAGE

public static final java.lang.String IGNORE_PACKAGE
See Also:
Constant Field Values

INCLUDE_RESOURCE

public static final java.lang.String INCLUDE_RESOURCE
See Also:
Constant Field Values

CONDITIONAL_PACKAGE

public static final java.lang.String CONDITIONAL_PACKAGE
See Also:
Constant Field Values

BND_LASTMODIFIED

public static final java.lang.String BND_LASTMODIFIED
See Also:
Constant Field Values

CREATED_BY

public static final java.lang.String CREATED_BY
See Also:
Constant Field Values

TOOL

public static final java.lang.String TOOL
See Also:
Constant Field Values

headers

public static final java.lang.String[] headers

REMOVE_HEADERS

public static final java.lang.String REMOVE_HEADERS
See Also:
Constant Field Values

SOURCES

public static final java.lang.String SOURCES
See Also:
Constant Field Values

FAIL_OK

public static final java.lang.String FAIL_OK
See Also:
Constant Field Values

DONOTCOPY

public static final java.lang.String DONOTCOPY
See Also:
Constant Field Values

EXPORT_CONTENTS

public static final java.lang.String EXPORT_CONTENTS
See Also:
Constant Field Values

CLASSPATH

public static final java.lang.String CLASSPATH
See Also:
Constant Field Values

PEDANTIC

public static final java.lang.String PEDANTIC
See Also:
Constant Field Values

NOEXTRAHEADERS

public static final java.lang.String NOEXTRAHEADERS
See Also:
Constant Field Values

POM

public static final java.lang.String POM
See Also:
Constant Field Values

INCLUDE

public static final java.lang.String INCLUDE
See Also:
Constant Field Values

NOUSES

public static final java.lang.String NOUSES
See Also:
Constant Field Values

options

public static final java.lang.String[] options

SPLIT_PACKAGE_DIRECTIVE

public static final java.lang.String SPLIT_PACKAGE_DIRECTIVE
See Also:
Constant Field Values

NO_IMPORT_DIRECTIVE

public static final java.lang.String NO_IMPORT_DIRECTIVE
See Also:
Constant Field Values

directives

public static final java.lang.String[] directives

componentDirectives

public static final java.lang.String[] componentDirectives
Constructor Detail

Analyzer

public Analyzer()
Method Detail

getManifest

public static java.util.Properties getManifest(java.io.File dirOrJar)
                                        throws java.io.IOException
Specifically for Maven

Parameters:
properties - the properties
Throws:
java.io.IOException

analyze

public void analyze()
             throws java.io.IOException
Calcualtes the data structures for generating a manifest.

Throws:
java.io.IOException

calcManifest

public java.util.jar.Manifest calcManifest()
                                    throws java.io.IOException
One of the main workhorses of this class. This will analyze the current setp and calculate a new manifest according to this setup. This method will also set the manifest on the main jar dot

Returns:
Throws:
java.io.IOException

calculateExportsFromContents

public java.lang.String calculateExportsFromContents(Jar bundle)
Calculate an export header solely based on the contents of a JAR file

Parameters:
bundle - The jar file to analyze
Returns:

doServiceComponent

public java.util.Map doServiceComponent(java.lang.String serviceComponent)
                                 throws java.io.IOException
Check if a service component header is actually referring to a class. If so, replace the reference with an XML file reference. This makes it easier to create and use components.

Throws:
java.io.UnsupportedEncodingException
java.io.IOException

getBundleClasspath

public java.util.Map getBundleClasspath()

getContained

public java.util.Map getContained()

getExports

public java.util.Map getExports()

getImports

public java.util.Map getImports()

getJar

public Jar getJar()

getProperties

public java.util.Properties getProperties()

getProperty

public java.lang.String getProperty(java.lang.String headerName)

getReferred

public java.util.Map getReferred()

getUnreachable

public java.util.Set getUnreachable()
Return the set of unreachable code depending on exports and the bundle activator.

Returns:

getUses

public java.util.Map getUses()

getVersion

public java.lang.String getVersion()
Get the version from the manifest, a lot of work!

Returns:
version or unknown.

getBndLastModified

public long getBndLastModified()

getBndManifest

public void getBndManifest()

mergeManifest

public void mergeManifest(java.util.jar.Manifest manifest)
                   throws java.io.IOException
Merge the existing manifest with the instructions.

Parameters:
manifest - The manifest to merge with
Throws:
java.io.IOException

setBase

public void setBase(java.io.File file)

setClasspath

public void setClasspath(java.io.File[] classpath)
                  throws java.io.IOException
Set the classpath for this analyzer by file.

Parameters:
classpath -
Throws:
java.io.IOException

setClasspath

public void setClasspath(Jar[] classpath)

setClasspath

public void setClasspath(java.lang.String[] classpath)

setJar

public Jar setJar(java.io.File jar)
           throws java.io.IOException
Set the JAR file we are going to work in. This will read the JAR in memory.

Parameters:
jar -
Returns:
Throws:
java.io.IOException

setJar

public Jar setJar(Jar jar)
Set the JAR directly we are going to work on.

Parameters:
jar -
Returns:

setProperties

public void setProperties(java.io.File propertiesFile)
                   throws java.io.FileNotFoundException,
                          java.io.IOException
Set the properties by file. Setting the properties this way will also set the base for this analyzer. After reading the properties, this will call setProperties(Properties) which will handle the includes.

Parameters:
propertiesFile -
Throws:
java.io.FileNotFoundException
java.io.IOException

mergeProperties

public void mergeProperties(java.io.File file,
                            boolean override)

mergeProperties

public void mergeProperties(java.util.Properties properties,
                            boolean override)

setProperties

public void setProperties(java.util.Properties properties)

setProperty

public void setProperty(java.lang.String key,
                        java.lang.String value)
Add or override a new property.

Parameters:
key -
value -

unsetProperty

public void unsetProperty(java.lang.String string)

getProperty

public java.lang.String getProperty(java.lang.String headerName,
                                    java.lang.String deflt)
Get a property with a proper default

Overrides:
getProperty in class Processor
Parameters:
headerName -
deflt -
Returns:

printClauses

public java.lang.String printClauses(java.util.Map exports,
                                     java.lang.String allowedDirectives)
Print a standard Map based OSGi header.

Parameters:
exports - map { name => Map { attribute|directive => value } }
Returns:
the clauses

close

public void close()

_findpath

public java.lang.String _findpath(java.lang.String[] args)
Findpath looks through the contents of the JAR and finds paths that end with the given regular expression ${findpath (; reg-expr (; replacement)? )? }

Parameters:
args -
Returns:

_findname

public java.lang.String _findname(java.lang.String[] args)

updateModified

public void updateModified(long time)

lastModified

public long lastModified()

putAll

public void putAll(java.util.Map additional,
                   boolean force)

getClasspath

public java.util.List getClasspath()