本文整理了Java中org.osgi.framework.Bundle.getHeaders()
方法的一些代码示例,展示了Bundle.getHeaders()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bundle.getHeaders()
方法的具体详情如下:
包路径:org.osgi.framework.Bundle
类名称:Bundle
方法名:getHeaders
[英]Returns this bundle's Manifest headers and values. This method returns all the Manifest headers and values from the main section of this bundle's Manifest file; that is, all lines prior to the first blank line.
Manifest header names are case-insensitive. The methods of the returned Dictionary object must operate on header names in a case-insensitive manner. If a Manifest header value starts with "%", it must be localized according to the default locale. If no localization is found for a header value, the header value without the leading "%" is returned.
For example, the following Manifest headers and values are included if they are present in the Manifest file:
Bundle-Name
Bundle-Vendor
Bundle-Version
Bundle-Description
Bundle-DocURL
Bundle-ContactAddress
This method must continue to return Manifest header information while this bundle is in the UNINSTALLED state.
[中]返回此捆绑包的清单头和值。此方法返回此捆绑包清单文件主部分中的所有清单头和值;即,第一个空行之前的所有行。
清单头名称不区分大小写。返回的Dictionary对象的方法必须以不区分大小写的方式对头名称进行操作。如果清单标头值以“%”开头,则必须根据默认区域设置对其进行本地化。如果未找到标头值的本地化,则返回不带前导“%”的标头值。
例如,如果清单文件中存在以下清单标题和值,则将包括这些标题和值:
Bundle-Name
Bundle-Vendor
Bundle-Version
Bundle-Description
Bundle-DocURL
Bundle-ContactAddress
此捆绑包处于卸载状态时,此方法必须继续返回清单头信息。
代码示例来源:origin: apache/ignite
if (b.getState() <= Bundle.RESOLVED || b.getHeaders().get(Constants.FRAGMENT_HOST) != null)
continue;
代码示例来源:origin: apache/ignite
/**
* @throws Exception
*/
@Test
public void testAllBundlesActiveAndFeaturesInstalled() throws Exception {
// Asssert all bundles except fragments are ACTIVE.
for (Bundle b : bundleCtx.getBundles()) {
System.out.println(String.format("Checking state of bundle [symbolicName=%s, state=%s]",
b.getSymbolicName(), b.getState()));
if (b.getHeaders().get(Constants.FRAGMENT_HOST) == null)
assertTrue(b.getState() == Bundle.ACTIVE);
}
// Check that according to the FeaturesService, all Ignite features except ignite-log4j are installed.
Feature[] features = featuresSvc.getFeatures(IGNITE_FEATURES_NAME_REGEX);
assertNotNull(features);
assertEquals(EXPECTED_FEATURES, features.length);
for (Feature f : features) {
if (IGNORED_FEATURES.contains(f.getName()))
continue;
boolean installed = featuresSvc.isInstalled(f);
System.out.println(String.format("Checking if feature is installed [featureName=%s, installed=%s]",
f.getName(), installed));
assertTrue(installed);
assertEquals(PROJECT_VERSION.replaceAll("-", "."), f.getVersion().replaceAll("-", "."));
}
}
代码示例来源:origin: spring-projects/spring-roo
private static boolean isFragment(Bundle bundle)
{
return bundle.getHeaders().get(Constants.FRAGMENT_HOST) != null;
}
}
代码示例来源:origin: rhuss/jolokia
protected String getBundleVersion(String pSymbolicName) {
BundleContext context = JolokiaServlet.getCurrentBundleContext();
if (context != null) {
for (Bundle bundle: context.getBundles()) {
if (pSymbolicName.equalsIgnoreCase(bundle.getSymbolicName())) {
Dictionary headers = bundle.getHeaders();
return (String) headers.get("Bundle-Version");
}
}
}
return null;
}
代码示例来源:origin: spring-projects/spring-roo
/**
* This service is being activated so setup it:
* <ul>
* <li>Create and open the {@link MetadataDependencyRegistryTracker}.</li>
* </ul>
*/
protected void activate(final ComponentContext componentContext) {
this.registryTracker =
new MetadataDependencyRegistryTracker(componentContext.getBundleContext(), this);
this.registryTracker.open();
for (final Bundle b : componentContext.getBundleContext().getBundles()) {
if (!MY_BUNDLE_SYMBOLIC_NAME.equals(b.getSymbolicName())) {
continue;
}
final Object v = b.getHeaders().get("Bundle-Version");
if (v != null) {
final String version = v.toString();
bundleVersionInfo = extractVersionInfoFromString(version);
}
break;
}
}
代码示例来源:origin: spring-projects/spring-roo
startLevel = (StartLevel) context.getService(startLevelServiceReference);
for (final Bundle bundle : context.getBundles()) {
final String value = bundle.getHeaders().get("Service-Component");
if (value != null) {
List<String> componentDescriptions = Arrays.asList(value.split("\\s*,\\s*"));
代码示例来源:origin: org.apache.felix/org.apache.felix.main
private static boolean isFragment(Bundle bundle)
{
return bundle.getHeaders().get(Constants.FRAGMENT_HOST) != null;
}
}
代码示例来源:origin: org.apache.clerezza/triaxrs
private String getDefaultPrefix(Bundle bundle) {
Dictionary<String, String> headers = bundle.getHeaders();
String defaultPrefix = headers.get(Constants.TRIAXRS_PATH_PREFIX);
if (defaultPrefix == null) {
defaultPrefix = "";
}
return defaultPrefix;
}
代码示例来源:origin: OpenNMS/opennms
private boolean shouldAutoExportOnmsServices(Bundle bundle) {
if (bundle == null) return false;
String headerValue = bundle.getHeaders().get("OnmsAutoExportServices");
if (headerValue == null) {
return false;
}
return Boolean.valueOf(headerValue);
}
}
代码示例来源:origin: OpenNMS/opennms
private boolean isVaadinBundle(Bundle bundle) {
String importedPackages = (String) bundle.getHeaders().get(
Constants.IMPORT_PACKAGE);
if (importedPackages == null) {
return false;
}
if (importedPackages.contains("com.vaadin")) {
return true;
}
return false;
}
}
代码示例来源:origin: protegeproject/protege
public static String getNiceBundleName(Bundle b) {
String name = (String) b.getHeaders().get(Constants.BUNDLE_NAME);
if (name == null) {
name = b.getSymbolicName();
}
return name;
}
代码示例来源:origin: org.ops4j.pax.logging/pax-logging-service
public static String getBundleSymbolicName(Bundle bundle) {
if (osgiVersion >= OSGI_1_3) {
return bundle.getSymbolicName();
} else {
return (String) bundle.getHeaders().get(Constants.BUNDLE_SYMBOLICNAME);
}
}
代码示例来源:origin: org.eclipse.gemini.blueprint/gemini-blueprint-core
/**
* Indicates if the given bundle is a fragment or not.
*
* @param bundle OSGi bundle
* @return true if the given bundle is a fragment, false otherwise
* @see Constants#FRAGMENT_HOST
*/
public static boolean isFragment(Bundle bundle) {
Assert.notNull(bundle, "bundle is required");
return bundle.getHeaders().get(Constants.FRAGMENT_HOST) != null;
}
代码示例来源:origin: org.apache.tuscany.sca/tuscany-contribution-osgi
/**
* Constructs a new BundleReference.
*
* @param bundle
*/
public BundleReference(Bundle bundle) {
this.bundle = bundle;
this.symbolicName = bundle.getSymbolicName();
this.version = (String)bundle.getHeaders().get(Constants.BUNDLE_VERSION);
}
代码示例来源:origin: org.apache.felix/org.apache.felix.shell
public void execute(String s, PrintStream out, PrintStream err)
{
out.println(m_context.getBundle(0).getHeaders().get(Constants.BUNDLE_VERSION));
}
}
代码示例来源:origin: apache/felix
public Hashtable getHeaders() {
Hashtable ht=new Hashtable();
Enumeration keys=bundle.getHeaders().keys();
while(keys.hasMoreElements()) {
Object key=keys.nextElement();
ht.put(key, bundle.getHeaders().get(key));
}
return ht;
}
/* (non-Javadoc)
代码示例来源:origin: apache/karaf
public static String getBundleName(Bundle bundle) {
if (bundle != null) {
String name = bundle.getHeaders().get(Constants.BUNDLE_NAME);
return (name == null)
? "Bundle " + Long.toString(bundle.getBundleId())
: name + " (" + Long.toString(bundle.getBundleId()) + ")";
}
return "[STALE BUNDLE]";
}
代码示例来源:origin: protegeproject/protege
public static boolean isSingleton(Bundle b) {
StringBuffer singleton1 = new StringBuffer(Constants.SINGLETON_DIRECTIVE);
singleton1.append(":=true");
StringBuffer singleton2 = new StringBuffer(Constants.SINGLETON_DIRECTIVE);
singleton2.append(":=\"true\"");
return ((String) b.getHeaders().get(Constants.BUNDLE_SYMBOLICNAME)).contains(singleton1.toString()) ||
((String) b.getHeaders().get(Constants.BUNDLE_SYMBOLICNAME)).contains(singleton2.toString());
}
代码示例来源:origin: apache/karaf
public static String getBundleName(Bundle bundle) {
if (bundle != null) {
String name = bundle.getHeaders().get(Constants.BUNDLE_NAME);
return (name == null)
? "Bundle " + Long.toString(bundle.getBundleId())
: name + " (" + Long.toString(bundle.getBundleId()) + ")";
}
return "[STALE BUNDLE]";
}
代码示例来源:origin: OpenNMS/opennms
private static Set<Bundle> getUnresolvedVaadinThemeFragments(BundleContext context) {
return Arrays.stream(context.getBundles())
.filter(bundle -> {
String fragmentHost = bundle.getHeaders().get("Fragment-Host");
return fragmentHost != null && fragmentHost.contains("com.vaadin.themes") && bundle.getState() == Bundle.INSTALLED;
})
.collect(Collectors.toSet());
}
}
内容来源于网络,如有侵权,请联系作者删除!