public class OsgiHeaderUtil extends Object
| Constructor and Description |
|---|
OsgiHeaderUtil() |
| Modifier and Type | Method and Description |
|---|---|
static String |
buildHeader(Map<String,Map<String,String>> values)
Builds the header string from a map
|
static String |
buildHeader(String key,
Map<String,String> attrs)
Builds the header string from a map
|
static PluginInformation |
extractOsgiPluginInformation(Manifest manifest,
boolean requireVersion)
Extract a PluginInformation from the Manifest of a jar containing an OSGi bundle.
|
static Set<String> |
findReferredPackageNames(Collection<Class<?>> classes)
Finds all referred packages for the specified set of classes/interfaces by scanning their bytecode.
|
static Map<String,String> |
findReferredPackageVersions(List<HostComponentRegistration> registrations,
Map<String,String> packageVersions)
Finds all referred packages for host component registrations by scanning their declared interfaces' bytecode.
|
static String |
generatePackageVersionString(Map<String,String> packages)
Generate package version string such as "com.abc;version=1.2,com.atlassian".
|
static String |
getAttributeWithoutValidation(Manifest manifest,
String key)
Extract the attribute from manifest(no-validations)
|
static Manifest |
getManifest(PluginArtifact pluginArtifact)
Extract the manifest of a PluginArtifact.
|
static String |
getNonEmptyAttribute(Manifest manifest,
String key)
Extract the attribute from manifest and validate if it's not empty
|
static String |
getPluginKey(org.osgi.framework.Bundle bundle)
Gets the plugin key from the bundle
WARNING: shamelessly copied at
PluginBundleUtils, which can't use
this class due to creating a cyclic build dependency. |
static String |
getPluginKey(File file)
Obtain the plugin key for a bundle in the given File.
|
static String |
getPluginKey(Manifest mf)
Gets the plugin key from the jar manifest
|
static String |
getValidatedAttribute(Manifest manifest,
String key)
Extract the attribute from manifest and validate it's not null and not empty
|
static Map<String,Map<String,String>> |
moveStarPackageToEnd(Map<String,Map<String,String>> packages,
String pluginKey)
Reorder any Import-Package or Export-Package or Private-Package value passed, so that packages containing a
star-value i.e.
|
static Map<String,Map<String,String>> |
parseHeader(String header)
Parses an OSGi header line into a map structure
|
static Map<String,Map<String,String>> |
stripDuplicatePackages(Map<String,Map<String,String>> packages,
String pluginKey,
String action)
Remove any duplicate Import-Package or Export-Package or Private-Package value passed.
|
public static Set<String> findReferredPackageNames(Collection<Class<?>> classes) throws IOException
classes - The set of classes/interfaces to scanIOException - If there are any problems scanning bytecodepublic static Map<String,String> findReferredPackageVersions(List<HostComponentRegistration> registrations, Map<String,String> packageVersions) throws IOException
registrations - A list of host component registrationsIOException - If there are any problems scanning bytecodepublic static Map<String,Map<String,String>> parseHeader(String header)
header - The header linepublic static String buildHeader(Map<String,Map<String,String>> values)
values - The header valuespublic static String buildHeader(String key, Map<String,String> attrs)
key - The header valueattrs - The map of attributespublic static String getPluginKey(org.osgi.framework.Bundle bundle)
PluginBundleUtils, which can't use
this class due to creating a cyclic build dependency. Ensure these two implementations are in sync.
This method shouldn't be used directly. Instead consider consuming the PluginRetrievalService.bundle - The plugin bundlepublic static String getPluginKey(File file)
file - the file containing the bundle.public static String getPluginKey(Manifest mf)
mf - The plugin jar manifestpublic static String generatePackageVersionString(Map<String,String> packages)
packages - map of packagename -&t; version.public static String getValidatedAttribute(Manifest manifest, String key)
NullPointerException - if attribute value is nullIllegalArgumentException - if attribute is emptypublic static String getNonEmptyAttribute(Manifest manifest, String key)
IllegalArgumentException - if attribute value is emptypublic static String getAttributeWithoutValidation(Manifest manifest, String key)
@Internal public static PluginInformation extractOsgiPluginInformation(Manifest manifest, boolean requireVersion)
manifest - the manifest to parse.public static Manifest getManifest(PluginArtifact pluginArtifact)
pluginArtifact - the plugin artifact who manifest is required.public static Map<String,Map<String,String>> moveStarPackageToEnd(Map<String,Map<String,String>> packages, String pluginKey)
Note that any reordered packages will be logged at debug level.
packages - map of package declarations, keyed by package namepluginKey - only used for debug loggingpublic static Map<String,Map<String,String>> stripDuplicatePackages(Map<String,Map<String,String>> packages, String pluginKey, String action)
Note that any removed packages will be logged at warning level.
packages - map of package declarations, keyed by package namepluginKey - only used for debug loggingaction - only used for debug logging - "import", "export" etc.Copyright © 2019 Atlassian. All rights reserved.