public class

OsgiHeaderUtil

extends Object
java.lang.Object
   ↳ com.atlassian.plugin.osgi.util.OsgiHeaderUtil

Class Overview

Utilities to help create OSGi headers

Summary

Public Constructors
OsgiHeaderUtil()
Public Methods
static String buildHeader(Map<StringMap<StringString>> values)
Builds the header string from a map
static String buildHeader(String key, Map<StringString> attrs)
Builds the header string from a map
static Set<String> findReferredPackageNames(List<HostComponentRegistration> registrations)
Finds all referred packages for host component registrations by scanning their declared interfaces' bytecode.
static Map<StringString> findReferredPackageVersions(List<HostComponentRegistration> registrations, Map<StringString> packageVersions)
Finds all referred packages for host component registrations by scanning their declared interfaces' bytecode.
static String findReferredPackages(List<HostComponentRegistration> registrations, Map<StringString> packageVersions)
This method is deprecated. Since 2.7.0, use findReferredPackageVersions(java.util.List, java.util.Map) instead.
static String findReferredPackages(List<HostComponentRegistration> registrations)
This method is deprecated. Since 2.7.0, use findReferredPackageNames(java.util.List) instead.
static String generatePackageVersionString(Map<StringString> packages)
Generate package version string such as "com.abc;version=1.2,com.atlassian".
static String getPluginKey(Manifest mf)
Gets the plugin key from the jar manifest
static String getPluginKey(Bundle bundle)
Gets the plugin key from the bundle WARNING: shamelessly copied at com.atlassian.plugin.osgi.bridge.PluginBundleUtils, which can't use this class due to creating a cyclic build dependency.
static Map<StringMap<StringString>> parseHeader(String header)
Parses an OSGi header line into a map structure
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public OsgiHeaderUtil ()

Public Methods

public static String buildHeader (Map<StringMap<StringString>> values)

Builds the header string from a map

Parameters
values The header values
Returns
  • A string, suitable for inclusion into an OSGI header string

public static String buildHeader (String key, Map<StringString> attrs)

Builds the header string from a map

Parameters
key The header value
attrs The map of attributes
Returns
  • A string, suitable for inclusion into an OSGI header string

public static Set<String> findReferredPackageNames (List<HostComponentRegistration> registrations)

Finds all referred packages for host component registrations by scanning their declared interfaces' bytecode. Packages starting with "java." are ignored.

Parameters
registrations A list of host component registrations
Returns
  • The set of referred packages.
Throws
IOException If there are any problems scanning bytecode

public static Map<StringString> findReferredPackageVersions (List<HostComponentRegistration> registrations, Map<StringString> packageVersions)

Finds all referred packages for host component registrations by scanning their declared interfaces' bytecode.

Parameters
registrations A list of host component registrations
Returns
  • The referred package map ( package-> version ).
Throws
IOException If there are any problems scanning bytecode

public static String findReferredPackages (List<HostComponentRegistration> registrations, Map<StringString> packageVersions)

This method is deprecated.
Since 2.7.0, use findReferredPackageVersions(java.util.List, java.util.Map) instead.

Finds all referred packages for host component registrations by scanning their declared interfaces' bytecode.

Parameters
registrations A list of host component registrations
Returns
  • The referred packages in a format compatible with an OSGi header
Throws
IOException If there are any problems scanning bytecode

public static String findReferredPackages (List<HostComponentRegistration> registrations)

This method is deprecated.
Since 2.7.0, use findReferredPackageNames(java.util.List) instead.

Finds all referred packages for host component registrations by scanning their declared interfaces' bytecode.

Parameters
registrations A list of host component registrations
Returns
  • The referred packages in a format compatible with an OSGi header
Throws
IOException If there are any problems scanning bytecode

public static String generatePackageVersionString (Map<StringString> packages)

Generate package version string such as "com.abc;version=1.2,com.atlassian". The output can be used for import or export.

Parameters
packages map of packagename->version.

public static String getPluginKey (Manifest mf)

Gets the plugin key from the jar manifest

Parameters
mf The plugin jar manifest
Returns
  • The plugin key, cannot be null

public static String getPluginKey (Bundle bundle)

Gets the plugin key from the bundle WARNING: shamelessly copied at com.atlassian.plugin.osgi.bridge.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.

Parameters
bundle The plugin bundle
Returns
  • The plugin key, cannot be null

public static Map<StringMap<StringString>> parseHeader (String header)

Parses an OSGi header line into a map structure

Parameters
header The header line
Returns
  • A map with the key the entry value and the value a map of attributes