aQute.lib.osgi
Class Analyzer

java.lang.Object
  extended by aQute.lib.osgi.Processor
      extended by aQute.lib.osgi.Analyzer
All Implemented Interfaces:
Registry, Constants, Reporter, Closeable
Direct Known Subclasses:
Builder, Verifier

public class Analyzer
extends Processor


Field Summary
 
Fields inherited from class aQute.lib.osgi.Processor
LIST_SPLITTER
 
Fields inherited from interface aQute.lib.osgi.Constants
BLUEPRINT_TIMEOUT_ATTRIBUTE, BLUEPRINT_WAIT_FOR_DEPENDENCIES_ATTRIBUTE, BND_ADDXMLTOTEST, BND_LASTMODIFIED, BUILDFILES, BUILDPACKAGES, BUILDPATH, BUMPPOLICY, BUNDLE_ACTIVATIONPOLICY, BUNDLE_ACTIVATOR, BUNDLE_BLUEPRINT, BUNDLE_CATEGORY, BUNDLE_CLASSPATH, BUNDLE_CONTACTADDRESS, BUNDLE_COPYRIGHT, BUNDLE_DESCRIPTION, BUNDLE_DOCURL, BUNDLE_ICON, BUNDLE_LICENSE, BUNDLE_LOCALIZATION, BUNDLE_MANIFESTVERSION, BUNDLE_NAME, BUNDLE_NATIVECODE, BUNDLE_REQUIREDEXECUTIONENVIRONMENT, BUNDLE_SPECIFIC_HEADERS, BUNDLE_SYMBOLIC_NAME_ATTRIBUTE, BUNDLE_SYMBOLICNAME, BUNDLE_UPDATELOCATION, BUNDLE_VENDOR, BUNDLE_VERSION, BUNDLE_VERSION_ATTRIBUTE, CLASSPATH, COMMAND_DIRECTIVE, COMPILER_SOURCE, COMPILER_TARGET, COMPONENT_ACTIVATE, COMPONENT_CONFIGURATION_POLICY, COMPONENT_DEACTIVATE, COMPONENT_DESCRIPTORS, COMPONENT_DESIGNATE, COMPONENT_DESIGNATEFACTORY, COMPONENT_DYNAMIC, COMPONENT_ENABLED, COMPONENT_FACTORY, COMPONENT_IMMEDIATE, COMPONENT_IMPLEMENTATION, COMPONENT_MODIFIED, COMPONENT_MULTIPLE, COMPONENT_NAME, COMPONENT_OPTIONAL, COMPONENT_PROPERTIES, COMPONENT_PROVIDE, COMPONENT_SERVICEFACTORY, COMPONENT_VERSION, componentDirectives, CONDITIONAL_PACKAGE, CONDUIT, CONSUMER_POLICY, CREATED_BY, CURRENT_PACKAGE, CURRENT_USES, CURRENT_VERSION, DEBUG, DEFAULT_BAR_EXTENSION, DEFAULT_BND_EXTENSION, DEFAULT_BNDRUN_EXTENSION, DEFAULT_CHARSET, DEFAULT_DO_NOT_COPY, DEFAULT_JAR_EXTENSION, DEFAULT_LAUNCHER_BSN, DEFAULT_TESTER_BSN, DEPENDSON, DEPLOY, DEPLOYREPO, DESCRIPTION_ATTRIBUTE, directives, DONOTCOPY, DUPLICATE_MARKER, DYNAMICIMPORT_PACKAGE, EMBEDDED_REPO, EMPTY, EMPTY_HEADER, EXCLUDE_DIRECTIVE, EXPORT_CONTENTS, EXPORT_PACKAGE, EXPORT_SERVICE, EXTENSION_DIRECTIVE, FAIL_OK, FRAGMENT_ATTACHMENT_DIRECTIVE, FRAGMENT_HOST, FROM_DIRECTIVE, headers, IGNORE_PACKAGE, IMPORT_DIRECTIVE, IMPORT_PACKAGE, IMPORT_PRIVATE, IMPORT_REFERENCE, IMPORT_SERVICE, importDirectives, INCLUDE, INCLUDE_DIRECTIVE, INCLUDE_RESOURCE, INCLUDERESOURCE, JIDENTIFIER, KEYSTORE_LOCATION_DIRECTIVE, KEYSTORE_PASSWORD_DIRECTIVE, KEYSTORE_PROVIDER_DIRECTIVE, LANGUAGE_ATTRIBUTE, LAUNCHER_PLUGIN, LIB_DIRECTIVE, LINK_ATTRIBUTE, MAKE, MANDATORY_DIRECTIVE, MANIFEST, METAPACKAGES, METATYPE, NAME_ATTRIBUTE, NAMESECTION, NAMESPACE_STEM, NO_IMPORT_DIRECTIVE, NOANNOTATIONS, NOBUNDLES, NODEFAULTVERSION, NOEXTRAHEADERS, NOMANIFEST, NONE, NOPE, NOUSES, options, OSNAME_ATTRIBUTE, OSVERSION_ATTRIBUTE, PATH_DIRECTIVE, PEDANTIC, PLUGIN, POM, PRESENCE_DIRECTIVE, PRIVATE_DIRECTIVE, PRIVATE_PACKAGE, PROCESSOR_ATTRIBUTE, PROVIDE_DIRECTIVE, PROVIDER_POLICY, RELEASEREPO, REMOVE_ATTRIBUTE_DIRECTIVE, REMOVEHEADERS, REPORTNEWER, REQUIRE_BND, REQUIRE_BUNDLE, RESOLUTION_DIRECTIVE, RESOURCEONLY, RUNBUILDS, RUNBUNDLES, RUNFRAMEWORK, RUNFRAMEWORK_NONE, RUNFRAMEWORK_SERVICES, RUNPATH, RUNPATH_LAUNCHER_DIRECTIVE, RUNPATH_MAIN_DIRECTIVE, RUNPROPERTIES, RUNSTORAGE, RUNSYSTEMPACKAGES, RUNTIMEOUT, RUNTRACE, RUNVM, SAVEMANIFEST, SELECTION_FILTER_ATTRIBUTE, SERVICE_COMPONENT, SET_COMPONENT_DIRECTIVES, SET_COMPONENT_DIRECTIVES_1_1, SIGN, SIGN_PASSWORD_DIRECTIVE, SIGNATURE_TEST, SINGLETON_DIRECTIVE, SIZE_ATTRIBUTE, SNAPSHOT, SOURCEPATH, SOURCES, SPECIFICATION_VERSION, SPLIT_PACKAGE_DIRECTIVE, SUB, TESTCASES, TESTCONTINUOUS, TESTER_PLUGIN, TESTPACKAGES, TESTPATH, TESTREPORT, TOOL, UNDERTEST, USES_DIRECTIVE, USES_USES, VALID_PROPERTY_TYPES, VERBOSE, VERSION_ATTRIBUTE, VERSION_FILTER, VERSIONPOLICY, VERSIONPOLICY_IMPL, VERSIONPOLICY_USES, VISIBILITY_DIRECTIVE, WAB, WABLIB
 
Constructor Summary
Analyzer()
           
Analyzer(Processor parent)
           
 
Method Summary
 String _bsn(String[] args)
           
 String _classes(String... args)
           
 String _exporters(String[] args)
          Get the exporter of a package ...
 String _findname(String[] args)
           
 String _findpath(String[] args)
          Findpath looks through the contents of the JAR and finds paths that end with the given regular expression ${findpath (; reg-expr (; replacement)? )? }
 String _md5(String[] args)
           
 String _sha1(String[] args)
           
 void addClasspath(File cp)
           
 void addClasspath(Jar jar)
           
 void analyze()
          Calculates the data structures for generating a manifest.
protected  Map<String,Clazz> analyzeBundleClasspath(Jar dot, Map<String,Map<String,String>> bundleClasspath, Map<String,Map<String,String>> contained, Map<String,Map<String,String>> referred, Map<String,Set<String>> uses)
           
protected  void begin()
           
 Manifest calcManifest()
          One of the main workhorses of this class.
 String calculateExportsFromContents(Jar bundle)
          Calculate an export header solely based on the contents of a JAR file
 boolean checkClass(String interfaceName)
          Check if the given class or interface name is contained in the jar.
static String cleanupVersion(String version)
           
 void clear()
           
 void close()
           
protected  void doUses(String packageName, Map<String,Map<String,String>> exports, Map<String,Set<String>> uses, Map<String,Map<String,String>> imports)
           
 Clazz findClass(String path)
          Find a clazz on the class path.
 Resource findResource(String path)
          Locate a resource on the class path.
 String getBndInfo(String key, String defaultValue)
           
 long getBndLastModified()
           
 String getBndVersion()
          Get the version for this bnd
 String getBsn()
          Clear the key part of a header.
 Map<String,Map<String,String>> getBundleClasspath()
           
 Collection<Clazz> getClasses(String... args)
           
 List<Jar> getClasspath()
           
 Map<String,Clazz> getClassspace()
           
 Map<String,Map<String,String>> getContained()
           
 Map<String,Map<String,String>> getExports()
           
 MultiMap<Set<String>,String> getGroups()
          Calculate the groups inside the bundle.
protected  String getImportPackages()
          Analyzer has an empty default but the builder has a * as default.
 Map<String,Map<String,String>> getImports()
           
 Jar getJar()
           
static Properties getManifest(File dirOrJar)
          Specifically for Maven
 String getPackage(String clazz)
           
 Map<String,Map<String,String>> getReferred()
           
 Jar getTarget()
           
 Set<String> getUnreachable()
          Return the set of unreachable code depending on exports and the bundle activator.
 Map<String,Set<String>> getUses()
           
 String getVersion()
          Answer the bundle version.
 String getVersionPolicy(boolean implemented)
           
 boolean isNoBundle()
           
 void mergeManifest(Manifest manifest)
          Merge the existing manifest with the instructions.
 void putAll(Map<String,String> additional, boolean force)
           
 boolean referred(String packageName)
           
 void referTo(String impl)
           
 void setBase(File file)
           
 void setClasspath(File[] classpath)
          Set the classpath for this analyzer by file.
 void setClasspath(Jar[] classpath)
           
 void setClasspath(String[] classpath)
           
 Jar setJar(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.
 
Methods inherited from class aQute.lib.osgi.Processor
_basedir, _random, addBasicPlugin, addClose, addIncluded, addProperties, append, appendPath, beginHandleErrors, customize, doAttrbutes, doIncludeFile, endHandleErrors, error, error, exists, forceRefresh, formatArrays, getBase, getClass, getDuration, getErrors, getExecutor, getFile, getFile, getFlattenedProperties, getInfo, getInfo, getMacroDomains, getManifestAsProperties, getParent, getPlugin, getPlugins, getPlugins, getProperties, getPropertiesFile, getProperty, getProperty, getReplacer, getTop, getWarnings, isDuplicate, isExceptions, isFailOk, isMissingPlugin, isOk, isPedantic, isPerfect, isTrace, isTrue, join, join, join, join, join, lastModified, loadPlugins, loadProperties, makePrintable, merge, merge, mergeProperties, mergeProperties, newHashMap, newList, newList, newMap, newMap, newSet, newSet, normalize, normalize, parseHeader, parseHeader, printClause, printClauses, printClauses, progress, propertiesChanged, read, refresh, removeBasicPlugin, removeDuplicateMarker, replaceAll, setExceptions, setFileMustExist, setForceLocal, setParent, setPedantic, setProperties, setProperties, setProperties, setProperty, setTrace, setTypeSpecificPlugins, signal, split, split, split, trace, unsetProperty, updateModified, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Analyzer

public Analyzer(Processor parent)

Analyzer

public Analyzer()
Method Detail

getManifest

public static Properties getManifest(File dirOrJar)
                              throws Exception
Specifically for Maven

Parameters:
properties - the properties
Throws:
Exception

analyze

public void analyze()
             throws Exception
Calculates the data structures for generating a manifest.

Throws:
IOException
Exception

getImportPackages

protected String getImportPackages()
Analyzer has an empty default but the builder has a * as default.

Returns:

calcManifest

public Manifest calcManifest()
                      throws Exception
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:
IOException
Exception

getBsn

public String getBsn()
Clear the key part of a header. I.e. remove everything from the first ';'

Parameters:
value -
Returns:

_bsn

public String _bsn(String[] args)

calculateExportsFromContents

public 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:

getBundleClasspath

public Map<String,Map<String,String>> getBundleClasspath()

getContained

public Map<String,Map<String,String>> getContained()

getExports

public Map<String,Map<String,String>> getExports()

getImports

public Map<String,Map<String,String>> getImports()

getJar

public Jar getJar()

getReferred

public Map<String,Map<String,String>> getReferred()

getUnreachable

public Set<String> getUnreachable()
Return the set of unreachable code depending on exports and the bundle activator.

Returns:

getUses

public Map<String,Set<String>> getUses()

getBndVersion

public String getBndVersion()
Get the version for this bnd

Returns:
version or unknown.

getBndLastModified

public long getBndLastModified()

getBndInfo

public String getBndInfo(String key,
                         String defaultValue)

mergeManifest

public void mergeManifest(Manifest manifest)
                   throws IOException
Merge the existing manifest with the instructions.

Parameters:
manifest - The manifest to merge with
Throws:
IOException

setBase

public void setBase(File file)
Overrides:
setBase in class Processor

setClasspath

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

Parameters:
classpath -
Throws:
IOException

setClasspath

public void setClasspath(Jar[] classpath)

setClasspath

public void setClasspath(String[] classpath)

setJar

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

Parameters:
jar -
Returns:
Throws:
IOException

setJar

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

Parameters:
jar -
Returns:

begin

protected void begin()
Overrides:
begin in class Processor

checkClass

public boolean checkClass(String interfaceName)
Check if the given class or interface name is contained in the jar.

Parameters:
interfaceName -
Returns:

referred

public boolean referred(String packageName)

doUses

protected void doUses(String packageName,
                      Map<String,Map<String,String>> exports,
                      Map<String,Set<String>> uses,
                      Map<String,Map<String,String>> imports)
Parameters:
packageName -
exports -
uses -
imports -

close

public void close()
Specified by:
close in interface Closeable
Overrides:
close in class Processor

_findpath

public String _findpath(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 String _findname(String[] args)

putAll

public void putAll(Map<String,String> additional,
                   boolean force)

getClasspath

public List<Jar> getClasspath()

addClasspath

public void addClasspath(Jar jar)

addClasspath

public void addClasspath(File cp)
                  throws IOException
Throws:
IOException

clear

public void clear()
Overrides:
clear in class Processor

getTarget

public Jar getTarget()

analyzeBundleClasspath

protected Map<String,Clazz> analyzeBundleClasspath(Jar dot,
                                                   Map<String,Map<String,String>> bundleClasspath,
                                                   Map<String,Map<String,String>> contained,
                                                   Map<String,Map<String,String>> referred,
                                                   Map<String,Set<String>> uses)
                                            throws Exception
Throws:
Exception

cleanupVersion

public static String cleanupVersion(String version)

getPackage

public String getPackage(String clazz)

getVersionPolicy

public String getVersionPolicy(boolean implemented)

_classes

public String _classes(String... args)
                throws Exception
Throws:
Exception

getClasses

public Collection<Clazz> getClasses(String... args)
                             throws Exception
Throws:
Exception

_exporters

public String _exporters(String[] args)
                  throws Exception
Get the exporter of a package ...

Throws:
Exception

getClassspace

public Map<String,Clazz> getClassspace()

findResource

public Resource findResource(String path)
Locate a resource on the class path.

Parameters:
path - Path of the reosurce
Returns:
A resource or null

findClass

public Clazz findClass(String path)
                throws Exception
Find a clazz on the class path. This class has been parsed.

Parameters:
path -
Returns:
Throws:
Exception

getVersion

public String getVersion()
Answer the bundle version.

Returns:

isNoBundle

public boolean isNoBundle()

referTo

public void referTo(String impl)

getGroups

public MultiMap<Set<String>,String> getGroups()
Calculate the groups inside the bundle. A group consists of packages that have a reference to each other.


_md5

public String _md5(String[] args)
            throws Exception
Throws:
Exception

_sha1

public String _sha1(String[] args)
             throws Exception
Throws:
Exception


Copyright © 2012 aQute SARL. All Rights Reserved.