本文整理了Java中org.osgi.framework.Bundle.getBundleId()
方法的一些代码示例,展示了Bundle.getBundleId()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bundle.getBundleId()
方法的具体详情如下:
包路径:org.osgi.framework.Bundle
类名称:Bundle
方法名:getBundleId
[英]Returns this bundle's unique identifier. This bundle is assigned a unique identifier by the Framework when it was installed in the OSGi environment.
A bundle's unique identifier has the following attributes:
This method must continue to return this bundle's unique identifier while this bundle is in the UNINSTALLED state.
[中]返回此捆绑包的唯一标识符。在OSGi环境中安装此捆绑包时,框架会为其分配一个唯一标识符。
捆绑包的唯一标识符具有以下属性:
*是独一无二的和持久的。
*这是一个漫长的过程。
*它的值不会重新用于另一个捆绑包,即使在卸载捆绑包之后也是如此。
*在捆绑包保持安装状态时不会更改。
*在更新捆绑包时不会更改。
此捆绑包处于卸载状态时,此方法必须继续返回此捆绑包的唯一标识符。
代码示例来源:origin: apache/ignite
/**
* Builds a {@link ClassNotFoundException}.
*
* @param clsName Class name.
* @return The exception.
*/
protected ClassNotFoundException classNotFoundException(String clsName) {
String s = "Failed to resolve class [name=" + clsName +
", bundleId=" + bundle.getBundleId() +
", symbolicName=" + bundle.getSymbolicName() +
", fallbackClsLdr=" + clsLdr + ']';
return new ClassNotFoundException(s);
}
}
代码示例来源:origin: org.osgi/org.osgi.core
public Void run() {
props.put("id", new Long(bundle.getBundleId()));
props.put("location", bundle.getLocation());
String name = bundle.getSymbolicName();
if (name != null) {
props.put("name", name);
}
SignerProperty signer = new SignerProperty(bundle);
if (signer.isBundleSigned()) {
props.put("signer", signer);
}
return null;
}
});
代码示例来源:origin: jersey/jersey
private void register(final Bundle bundle) {
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.log(Level.FINEST, "checking bundle {0}", bundle.getBundleId());
}
Map<String, Callable<List<Class<?>>>> map;
lock.writeLock().lock();
try {
map = factories.get(bundle.getBundleId());
if (map == null) {
map = new ConcurrentHashMap<String, Callable<List<Class<?>>>>();
factories.put(bundle.getBundleId(), map);
}
} finally {
lock.writeLock().unlock();
}
final Enumeration<URL> e = findEntries(bundle, "META-INF/services/", "*", false);
if (e != null) {
while (e.hasMoreElements()) {
final URL u = e.nextElement();
final String url = u.toString();
if (url.endsWith("/")) {
continue;
}
final String factoryId = url.substring(url.lastIndexOf("/") + 1);
map.put(factoryId, new BundleSpiProvidersLoader(factoryId, u, bundle));
}
}
}
代码示例来源:origin: jersey/jersey
private void register(final Bundle bundle) {
if (LOGGER.isLoggable(Level.FINEST)) {
LOGGER.log(Level.FINEST, "checking bundle {0}", bundle.getBundleId());
}
Map<String, Callable<List<Class<?>>>> map;
lock.writeLock().lock();
try {
map = factories.get(bundle.getBundleId());
if (map == null) {
map = new ConcurrentHashMap<String, Callable<List<Class<?>>>>();
factories.put(bundle.getBundleId(), map);
}
} finally {
lock.writeLock().unlock();
}
final Enumeration<URL> e = findEntries(bundle, "META-INF/services/", "*", false);
if (e != null) {
while (e.hasMoreElements()) {
final URL u = e.nextElement();
final String url = u.toString();
if (url.endsWith("/")) {
continue;
}
final String factoryId = url.substring(url.lastIndexOf("/") + 1);
map.put(factoryId, new BundleSpiProvidersLoader(factoryId, u, bundle));
}
}
}
代码示例来源:origin: org.osgi/org.osgi.core
public Void run() {
props.put("id", new Long(bundle.getBundleId()));
props.put("location", bundle.getLocation());
String name = bundle.getSymbolicName();
if (name != null) {
props.put("name", name);
}
SignerProperty signer = new SignerProperty(bundle);
if (signer.isBundleSigned()) {
props.put("signer", signer);
}
return null;
}
});
代码示例来源:origin: jersey/jersey
@Override
public void bundleChanged(final BundleEvent event) {
if (event.getType() == BundleEvent.RESOLVED) {
register(event.getBundle());
} else if (event.getType() == BundleEvent.UNRESOLVED || event.getType() == BundleEvent.UNINSTALLED) {
final Bundle unregisteredBundle = event.getBundle();
lock.writeLock().lock();
try {
factories.remove(unregisteredBundle.getBundleId());
if (unregisteredBundle.getSymbolicName().equals(CoreBundleSymbolicNAME)) {
bundleContext.removeBundleListener(this);
factories.clear();
}
} finally {
lock.writeLock().unlock();
}
}
}
代码示例来源:origin: spring-projects/spring-roo
for (int i = 0; i < bundles.length; i++)
installedBundleMap.put(bundles[i].getLocation(), bundles[i]);
if (b.getBundleId() != 0)
代码示例来源:origin: org.osgi/org.osgi.core
public Void run() {
map.put("id", new Long(bundle.getBundleId()));
map.put("location", bundle.getLocation());
String name = bundle.getSymbolicName();
if (name != null) {
map.put("name", name);
}
SignerProperty signer = new SignerProperty(bundle);
if (signer.isBundleSigned()) {
map.put("signer", signer);
}
return null;
}
});
代码示例来源:origin: jersey/jersey
@Override
public void bundleChanged(final BundleEvent event) {
if (event.getType() == BundleEvent.RESOLVED) {
register(event.getBundle());
} else if (event.getType() == BundleEvent.UNRESOLVED || event.getType() == BundleEvent.UNINSTALLED) {
final Bundle unregisteredBundle = event.getBundle();
lock.writeLock().lock();
try {
factories.remove(unregisteredBundle.getBundleId());
if (unregisteredBundle.getSymbolicName().equals(CoreBundleSymbolicNAME)) {
bundleContext.removeBundleListener(this);
factories.clear();
}
} finally {
lock.writeLock().unlock();
}
}
}
代码示例来源:origin: org.apache.geronimo.modules/geronimo-myfaces
protected boolean findFaceletsConfigResources(Bundle bundle) {
Enumeration<URL> metaInfEn = bundle.findEntries("META-INF/", "*.taglib.xml", false);
if (metaInfEn == null) {
return false;
}
List<URL> faceletsConfigResources = new ArrayList<URL>();
while (metaInfEn.hasMoreElements()) {
faceletsConfigResources.add(metaInfEn.nextElement());
}
bundleIdFaceletsConfigResourcesMap.put(bundle.getBundleId(), faceletsConfigResources);
return true;
}
代码示例来源:origin: org.osgi/org.osgi.core
public Void run() {
map.put("id", new Long(bundle.getBundleId()));
map.put("location", bundle.getLocation());
String name = bundle.getSymbolicName();
if (name != null) {
map.put("name", name);
}
SignerProperty signer = new SignerProperty(bundle);
if (signer.isBundleSigned()) {
map.put("signer", signer);
}
return null;
}
});
代码示例来源:origin: org.eclipse.core/runtime
/**
* Returns a string representation of the plug-in, suitable
* for debugging purposes only.
*/
@Override
public String toString() {
Bundle myBundle = getBundle();
if (myBundle == null)
return ""; //$NON-NLS-1$
String name = myBundle.getSymbolicName();
return name == null ? new Long(myBundle.getBundleId()).toString() : name;
}
代码示例来源:origin: org.ops4j.pax.cdi/pax-cdi-weld
@Override
public CdiContainer createContainer(Bundle bundle, Collection<Bundle> extensions) {
WeldCdiContainer container = new WeldCdiContainer(bundleContext.getBundle(),
bundle, extensions);
containers.put(bundle.getBundleId(), container);
log.debug("Weld Container created");
return container;
}
代码示例来源:origin: org.osgi/org.osgi.core
public Void run() {
map.put("id", new Long(bundle.getBundleId()));
map.put("location", bundle.getLocation());
String name = bundle.getSymbolicName();
if (name != null) {
map.put("name", name);
}
SignerProperty signer = new SignerProperty(bundle);
if (signer.isBundleSigned()) {
map.put("signer", signer);
}
return null;
}
});
代码示例来源:origin: spring-projects/spring-roo
/**
* Locates the bundle ID for this BundleSymbolicName, if available.
*
* @param context to search (required)
* @return the ID (or null if cannot be found)
*/
public Long findBundleIdWithoutFail(final BundleContext context) {
Validate.notNull(context, "Bundle context is unavailable");
final Bundle[] bundles = context.getBundles();
if (bundles == null) {
throw new IllegalStateException("Bundle IDs cannot be retrieved as BundleContext unavailable");
}
for (final Bundle b : bundles) {
if (getKey().equals(b.getSymbolicName())) {
return b.getBundleId();
}
}
throw new IllegalStateException("Bundle symbolic name '" + getKey()
+ "' has no local bundle ID at this time");
}
代码示例来源:origin: apache/karaf
@Override
public void blueprintEvent(BlueprintEvent blueprintEvent) {
if (LOG.isDebugEnabled()) {
BundleState state = getState(blueprintEvent);
LOG.debug("Blueprint app state changed to " + state + " for bundle "
+ blueprintEvent.getBundle().getBundleId());
}
states.put(blueprintEvent.getBundle().getBundleId(), blueprintEvent);
}
代码示例来源:origin: org.osgi/org.osgi.compendium
public Object run() {
map.put("id", new Long(bundle.getBundleId()));
map.put("location", bundle.getLocation());
String name = bundle.getSymbolicName();
if (name != null) {
map.put("name", name);
}
SignerProperty signer = new SignerProperty(bundle);
if (signer.isBundleSigned()) {
map.put("signer", signer);
}
return null;
}
});
代码示例来源:origin: org.apache.felix/org.apache.felix.webconsole
UpdateHelper( final SimpleWebConsolePlugin plugin, final Bundle bundle, final File bundleFile,
boolean refreshPackages )
{
super( plugin, "Background Update " + bundle.getSymbolicName() + " (" + bundle.getBundleId() + ")",
bundleFile, refreshPackages );
this.bundle = bundle;
}
代码示例来源:origin: apache/karaf
public void onOsgiApplicationEvent(OsgiBundleApplicationContextEvent event) {
if (LOG.isDebugEnabled()) {
BundleState state = mapEventToState(event);
LOG.debug("Spring app state changed to " + state + " for bundle " + event.getBundle().getBundleId());
}
states.put(event.getBundle().getBundleId(), event);
}
代码示例来源:origin: com.cognifide.cq/cqsm-bundle
@Override
public void modifiedBundle(Bundle bundle, BundleEvent event, Object object) {
final List<Class<?>> scanned = new ClassScanner(bundle, bundleContext)
.findClasses(bundleHeader, annotationClass);
classes.remove(bundle.getBundleId());
if (scanned.size() > 0) {
if (LOG.isDebugEnabled()) {
LOG.debug("Updating classes ({}) from bundle: {}", scanned.size(), bundle.getSymbolicName());
}
classes.put(bundle.getBundleId(), scanned);
}
}
内容来源于网络,如有侵权,请联系作者删除!