Class BundleInfo
java.lang.Object
de.uni_hildesheim.sse.easy.loader.framework.BundleInfo
Maintains information about an OSGi bundle. In addition, bundle information object support tagging,
i.e., additional information such as a loading stage may be attached and retrieved.
- Author:
- Holger Eichelberger
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Stringprivate Stringprivate String[]private booleanprivate String[]private Stringprivate String[]private String[]private ClassLoaderprivate Stringprivate String[]private BundleInfo[]private Fileprivate Stringprivate booleanprivate Objectprivate Versionprivate static final DocumentBuilderFactory -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateBundleInfo(File file, Manifest manifest) Creates a bundle information object from a given JARmanifest.privateBundleInfo(String name, EasyDependency versionRestriction) Creates an unresolved bundle information object from the given symbolicname. -
Method Summary
Modifier and TypeMethodDescriptionAnalyzes this bundle for cyclic dependencies.private voidanalyzeForCyclicDependencies(Set<BundleInfo> known, List<String> messages, String path) Analyzes this bundle for cyclic dependencies.static BundleInfocreateInstance(File file) Creates an bundle information instance from a JAR file.static BundleInfocreateInstance(String name, EasyDependency versionSpec) Creates an bundle information instance.Returns those paths in the bundle that shall be excluded from a Jar.Returns the activation policy.Returns the activator class name.(package private) static AttributesgetAttributes(Manifest manifest) Returns the attributes of the manifest to be considered.Returns the responsible class loader.getClasspathEntry(int index) Returns the specified classpath entry.intReturns the number of classpath entries in this bundle.getDsClass(int index) Returns the specified DS class.String[]Returns (a copy of) the DS class names.intReturns the number of DS classes to be loaded by this bundle.Returns the path to the DS specification within the JAR file.getName()Returns the symbolic name of the bundle.getRequiredBundle(int index) Returns the specified required bundle.intReturns the number of bundles required by this bundle.Returns the underlying JAR file.Returns the sample class of this bundle.static StringgetSampleClass(JarFile jarFile) Returns the name of a representative class in the given JAR file.getTag()Returns the tag of this bundle information object.Returns the version of the represented bundle.booleanReturns whether the represented bundle is a singleton.private BundleInfo[]parseBundleList(Attributes attributes, String key) Parses a bundle list fromattributes.private static String[]parseClasspath(Attributes attributes) Parses the bundle classpath.private static booleanparseDoBundleClassPath(Attributes attributes) Parses the the EASy-specific flag whether the class path shall be bundled.(package private) voidParses a DS specification into class names to be loaded and instantiated.private static String[]parsePackageList(Attributes attributes, String key) Parses a package list from the given Manifest attributes.private static booleanparseSingleton(Attributes attributes) Parses the attributes whether the current bundle is a singleton.(package private) static StringparseSymbolicName(Attributes attributes) Parses the symbolic name and the singleton attribute.(package private) static VersionparseVersion(Attributes attributes) Parses the bundle version from theattributes.voidResolves this bundle.voidsetClassloader(ClassLoader loader) Returns the class loader being responsible for loading this bundle.private voidsetSampleClass(String sampleClass) Changes the sample class.splitBundleList(String text) Splits a bundle list specificiation into bundle names with version information etc.voidTags this bundle information object with an arbitrary tag object.toString()
-
Field Details
-
XML_FACTORY
-
resolved
-
name
-
singleton
private boolean singleton -
version
-
activator
-
activationPolicy
-
dsSpec
-
dsClasses
-
requiredBundles
-
importPackages
-
exportPackages
-
tag
-
sampleClass
-
loader
-
doBundleClassPath
private boolean doBundleClassPath -
classpath
-
origClasspath
-
-
Constructor Details
-
BundleInfo
Creates a bundle information object from a given JARmanifest. Please note that the DS specification must be loaded viaparseDsSpec(InputStream).- Parameters:
file- the JAR file resolving this bundlemanifest- the JAR manifest to analyze- Throws:
BundleException- if a non-OSGi manifest shall be analyzed, i.e., information in missing (or if the bundle shall be ignored)
-
BundleInfo
Creates an unresolved bundle information object from the given symbolicname.- Parameters:
name- the name of the bundleversionRestriction- the version restriction specification- Throws:
BundleException- in case that the name is illegal (or if the bundle shall be ignored)
-
-
Method Details
-
createInstance
public static BundleInfo createInstance(String name, EasyDependency versionSpec) throws BundleException Creates an bundle information instance. Successfully created instances are automatically registered in theBundleRegistry.- Parameters:
name- the name of the bundleversionSpec- the version or version specification to be fulfilled- Returns:
- the corresponding bundle information object (or null)
- Throws:
BundleException- in case that relevant information is missing
-
createInstance
Creates an bundle information instance from a JAR file. Successfully created instances are automatically registered in theBundleRegistry.- Parameters:
file- the file to be analyzed- Returns:
- the corresponding bundle information object (or null)
- Throws:
BundleException- in case that reading the bundle manifest fails
-
getSampleClass
Returns the name of a representative class in the given JAR file.- Parameters:
jarFile- the JAR file- Returns:
- the name of the representative class (just the first identified one)
-
getAttributes
Returns the attributes of the manifest to be considered.- Parameters:
manifest- the manifest to be analyzed- Returns:
- the attributes to be considered
-
parseVersion
Parses the bundle version from theattributes.- Parameters:
attributes- the attributes to parse from- Returns:
- the bundle version or null if none is given
- Throws:
BundleException- in case that the version number cannot be parsed
-
parsePackageList
Parses a package list from the given Manifest attributes.- Parameters:
attributes- the attributes to be consideredkey- the attribute key- Returns:
- the parsed package list, may be null
-
parseClasspath
Parses the bundle classpath.- Parameters:
attributes- the attributes to be considered- Returns:
- the bundle classpath (may be null)
-
splitBundleList
Splits a bundle list specificiation into bundle names with version information etc.- Parameters:
text- the text to be splitted- Returns:
- the bundle lists
-
parseBundleList
Parses a bundle list fromattributes.- Parameters:
attributes- the attributes to be consideredkey- the attribute key- Returns:
- the parsed bundle list, may be null
- Throws:
BundleException- in case that the bundle information object cannot be created due to missing or illegal information
-
parseSymbolicName
Parses the symbolic name and the singleton attribute.- Parameters:
attributes- the Manifest attributes to be analyzed- Returns:
- the symbolic name
- Throws:
BundleException- in case that the analysis fails, in particular if no symbolic name is given
-
parseSingleton
Parses the attributes whether the current bundle is a singleton.- Parameters:
attributes- the Manifest attributes to be analyzed- Returns:
trueif this bundle is a singleton,falseelse- Throws:
BundleException- in case that the analysis fails, in particular if no symbolic name is given
-
getName
Returns the symbolic name of the bundle.- Returns:
- the symbolic name
-
isSingleton
public boolean isSingleton()Returns whether the represented bundle is a singleton.- Returns:
trueif it is a singleton,falseelse
-
getVersion
Returns the version of the represented bundle.- Returns:
- the version, may be null
-
getActivatorClassName
Returns the activator class name.- Returns:
- the class name of the activator, may be null if not present
-
getActivationPolicy
Returns the activation policy.- Returns:
- the activation policy, may be null if not stated
-
getDsSpec
Returns the path to the DS specification within the JAR file.- Returns:
- the path to the DS specification, may be null if not present
-
getResolvedJar
Returns the underlying JAR file.- Returns:
- the underlying JAR file if this bundle is actually resolved, null else
-
tag
Tags this bundle information object with an arbitrary tag object.- Parameters:
tag- the tag (may be null)
-
getTag
Returns the tag of this bundle information object.- Returns:
- the tag (may be null)
-
setClassloader
Returns the class loader being responsible for loading this bundle.- Parameters:
loader- the responsible class loader
-
getClassloader
Returns the responsible class loader.- Returns:
- the class loader (may be null)
-
resolve
Resolves this bundle.- Parameters:
file- the JAR file resolving this bundlemanifest- the manifest containing the bundle information- Throws:
BundleException- in case that analyzing the manifest fails
-
excludeFromJar
Returns those paths in the bundle that shall be excluded from a Jar.- Returns:
- the paths to be excluded, null if all shall be included
-
parseDoBundleClassPath
Parses the the EASy-specific flag whether the class path shall be bundled.- Parameters:
attributes- the attributes- Returns:
trueif the classpath shall be bundled
-
getRequiredBundlesCount
public int getRequiredBundlesCount()Returns the number of bundles required by this bundle.- Returns:
- the number of required bundles
-
getRequiredBundle
Returns the specified required bundle.- Parameters:
index- the 0-based index of the required bundle- Returns:
- the specified bundle
- Throws:
IndexOutOfBoundsException- ifindex < 0 || index >=getRequiredBundlesCount()
-
getDsClassesCount
public int getDsClassesCount()Returns the number of DS classes to be loaded by this bundle.- Returns:
- the number of required bundles
-
getDsClass
Returns the specified DS class.- Parameters:
index- the 0-based index of the required bundle- Returns:
- the specified DS class name
- Throws:
IndexOutOfBoundsException- ifindex < 0 || index >=getDsClassesCount()
-
getClasspathEntryCount
public int getClasspathEntryCount()Returns the number of classpath entries in this bundle.- Returns:
- the number of classpath entries
-
getClasspathEntry
Returns the specified classpath entry.- Parameters:
index- the 0-based index of the required bundle- Returns:
- the specified classpath entry
- Throws:
IndexOutOfBoundsException- ifindex < 0 || index >=getClasspathEntryCount()
-
getDsClasses
Returns (a copy of) the DS class names.- Returns:
- the DS class names (may be null)
-
parseDsSpec
Parses a DS specification into class names to be loaded and instantiated. Currently, we ignore the more sophisticated capabilities of DS and rely on the implementation element only.- Parameters:
is- the input stream to load (will not be closed by this method)- Throws:
IOException- in case that loading or parsing fails
-
analyzeForCyclicDependencies
Analyzes this bundle for cyclic dependencies.- Returns:
- messages pointing to cyclic dependencies
-
analyzeForCyclicDependencies
private void analyzeForCyclicDependencies(Set<BundleInfo> known, List<String> messages, String path) Analyzes this bundle for cyclic dependencies.- Parameters:
known- already visited and known bundlesmessages- messages collected so farpath- the dependency path to this bundle visited so far
-
getSampleClass
Returns the sample class of this bundle.- Returns:
- the sample class, i.e., one of the classes defined by this bundle (may be null)
-
setSampleClass
Changes the sample class.- Parameters:
sampleClass- the new sample class
-
toString
-