当前位置: 首页>>代码示例>>Java>>正文


Java Bundle类代码示例

本文整理汇总了Java中org.osgi.framework.Bundle的典型用法代码示例。如果您正苦于以下问题:Java Bundle类的具体用法?Java Bundle怎么用?Java Bundle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Bundle类属于org.osgi.framework包,在下文中一共展示了Bundle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startDependencyAsynch

import org.osgi.framework.Bundle; //导入依赖的package包/类
private void startDependencyAsynch(final Bundle bundle) {
	System.out.println("starting dependency test bundle");
	Runnable runnable = new Runnable() {

		public void run() {
			try {
				bundle.start();
				System.out.println("started dependency test bundle");
			}
			catch (BundleException ex) {
				System.err.println("can't start bundle " + ex);
			}
		}
	};
	Thread thread = new Thread(runnable);
	thread.setDaemon(false);
	thread.setName("dependency test bundle");
	thread.start();
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:20,代码来源:DependencyTest.java

示例2: getPlatformName

import org.osgi.framework.Bundle; //导入依赖的package包/类
public static String getPlatformName(BundleContext bundleContext) {
	String vendorProperty = bundleContext.getProperty(Constants.FRAMEWORK_VENDOR);
	String frameworkVersion = bundleContext.getProperty(Constants.FRAMEWORK_VERSION);

	// get system bundle
	Bundle bundle = bundleContext.getBundle(0);
	String name = (String) bundle.getHeaders().get(Constants.BUNDLE_NAME);
	String version = (String) bundle.getHeaders().get(Constants.BUNDLE_VERSION);
	String symName = bundle.getSymbolicName();

	StringBuilder buf = new StringBuilder();
	buf.append(name);
	buf.append(" ");
	buf.append(symName);
	buf.append("|");
	buf.append(version);
	buf.append("{");
	buf.append(frameworkVersion);
	buf.append(" ");
	buf.append(vendorProperty);
	buf.append("}");

	return buf.toString();
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:25,代码来源:OsgiUtils.java

示例3: installBundleFromApk

import org.osgi.framework.Bundle; //导入依赖的package包/类
private Bundle installBundleFromApk(String bundleName) throws Exception{
    Bundle bundle = null;
    findBundleSource(bundleName);
    if(mTmpBundleSourceFile!=null){
        bundle = Framework.installNewBundle(bundleName,mTmpBundleSourceFile);
    }else if(mTmpBundleSourceInputStream!=null){
        bundle = Framework.installNewBundle(bundleName,mTmpBundleSourceInputStream);
    }else{
        IOException e = new IOException("can not find bundle source file");
        Map<String, Object> detail = new HashMap<>();
        detail.put("installBundleFromApk",bundleName);
        AtlasMonitor.getInstance().report(AtlasMonitor.CONTAINER_BUNDLE_SOURCE_MISMATCH, detail, e);
        throw e;
    }
    return bundle;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:17,代码来源:BundleInstaller.java

示例4: getDataAsObject

import org.osgi.framework.Bundle; //导入依赖的package包/类
public Object getDataAsObject ( final Bundle bundle, final Object defaultValue )
{
    try
    {
        final Object result = getDataAsObject ( bundle );
        if ( result == null )
        {
            return defaultValue;
        }
        else
        {
            return result;
        }
    }
    catch ( final Exception e )
    {
        return defaultValue;
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:20,代码来源:DataNode.java

示例5: getIcon

import org.osgi.framework.Bundle; //导入依赖的package包/类
protected Image getIcon(String fullPath) throws IOException {

		if (fullPath==null)      return defaultIcon;
		if ("".equals(fullPath)) return defaultIcon;

		try {
			if (iconMap.containsKey(fullPath)) return iconMap.get(fullPath);
			final String[] sa = fullPath.split("/");
			final Bundle bundle = Platform.getBundle(sa[0]);
			if (bundle==null) return defaultIcon;
			if (bundle!=null) {
				Image image = new Image(null, bundle.getResource(sa[1]+"/"+sa[2]).openStream());
				iconMap.put(fullPath, image);
			}
			return iconMap.get(fullPath);
		} catch (Exception ne) {
			logger.debug("Cannot get icon for "+fullPath, ne);
			return defaultIcon;
		}
	}
 
开发者ID:eclipse,项目名称:scanning,代码行数:21,代码来源:DetectorView.java

示例6: testInstallBundle

import org.osgi.framework.Bundle; //导入依赖的package包/类
@Test
public void testInstallBundle() throws Exception {
    final String installCommand ="bundle:install mvn:"
            + OSGIFX_GROUP_ID + "/"
            + IT_DUMMY_BUNDLE_ARTIFACT_ID + "/"
            + PROJECT_VERSION;
    session.execute(installCommand);
    Bundle dummyBundle = null;
    for (Bundle bundle : bundleContext.getBundles())
    {
        if (bundle.getSymbolicName() != null && bundle.getSymbolicName().equals(OSGIFX_GROUP_ID + "." + IT_DUMMY_BUNDLE_ARTIFACT_ID))
        {
            dummyBundle = bundle;
            break;
        }
    }
    assertNotNull(dummyBundle);
}
 
开发者ID:jtkb,项目名称:flexfx,代码行数:19,代码来源:DeployOsgiFxTest.java

示例7: testInvocationWhenServiceNA

import org.osgi.framework.Bundle; //导入依赖的package包/类
public void testInvocationWhenServiceNA() throws Throwable {
	// service n/a
	ServiceReference reference = new MockServiceReference() {
		public Bundle getBundle() {
			return null;
		}
	};

	interceptor = new ServiceStaticInterceptor(new MockBundleContext(), reference);

	Object target = new Object();
	Method m = target.getClass().getDeclaredMethod("hashCode", null);

	MethodInvocation invocation = new MockMethodInvocation(m);
	try {
		interceptor.invoke(invocation);
		fail("should have thrown exception");
	}
	catch (ServiceUnavailableException ex) {
		// expected
	}
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:23,代码来源:OsgiServiceStaticInterceptorTest.java

示例8: findBundle

import org.osgi.framework.Bundle; //导入依赖的package包/类
private Bundle findBundle ( final String symbolicName )
{
    final Bundle[] bundles = this.context.getBundles ();
    if ( bundles == null )
    {
        return null;
    }

    for ( final Bundle bundle : bundles )
    {
        if ( bundle.getSymbolicName ().equals ( symbolicName ) )
        {
            return bundle;
        }
    }

    return null;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:19,代码来源:Activator.java

示例9: isFullyStarted

import org.osgi.framework.Bundle; //导入依赖的package包/类
private boolean isFullyStarted(Bundle bundle) {
    Component[] components = scrService.getComponents(bundle);
    if (components != null) {
        for (Component component : components) {
            if (!isFullyStarted(component)) {
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:12,代码来源:ComponentsMonitor.java

示例10: ungetService

import org.osgi.framework.Bundle; //导入依赖的package包/类
/**
 * Called if a bundle releases the service (stop the scope).
 * 
 * @see org.osgi.framework.ServiceFactory#ungetService(org.osgi.framework.Bundle,
 *      org.osgi.framework.ServiceRegistration, java.lang.Object)
 */
public void ungetService(Bundle bundle, ServiceRegistration registration, Object service) {
	try {
		// tell the scope, it's an outside bundle that does the call
		EXTERNAL_BUNDLE.set(Boolean.TRUE);
		// unget object first
		decoratedServiceFactory.ungetService(bundle, registration, service);

		// then apply the destruction callback (if any)
		Runnable callback = callbacks.remove(bundle);
		if (callback != null)
			callback.run();
	}
	finally {
		// clean ThreadLocal
		EXTERNAL_BUNDLE.set(null);
	}
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:24,代码来源:OsgiBundleScope.java

示例11: notifyFrameworkListeners

import org.osgi.framework.Bundle; //导入依赖的package包/类
/**
 * notify all framework listeners.
 *
 * @param state the new state.
 * @param bundle the bundle.
 * @param throwable a throwable.
 */
static void notifyFrameworkListeners(final int state, final Bundle bundle, final Throwable throwable) {

    if (frameworkListeners.isEmpty()) {
        return;
    }

    final FrameworkEvent event = new FrameworkEvent(state);

    final FrameworkListener[] listeners = frameworkListeners.toArray(new FrameworkListener[frameworkListeners.size()]);

    for (int i = 0; i < listeners.length; i++) {
        final FrameworkListener listener = listeners[i];

        listener.frameworkEvent(event);
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:24,代码来源:Framework.java

示例12: createIcons

import org.osgi.framework.Bundle; //导入依赖的package包/类
private void createIcons() {
	icons   = new HashMap<String, Image>(7);

	final IConfigurationElement[] eles = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.scanning.api.generator");
	for (IConfigurationElement e : eles) {
		final String     identity = e.getAttribute("id");

		final String icon = e.getAttribute("icon");
		if (icon !=null) {
			final String   cont  = e.getContributor().getName();
			final Bundle   bundle= Platform.getBundle(cont);
			final URL      entry = bundle.getEntry(icon);
			final ImageDescriptor des = ImageDescriptor.createFromURL(entry);
			icons.put(identity, des.createImage());
		}

	}
}
 
开发者ID:eclipse,项目名称:scanning,代码行数:19,代码来源:GeneratorDescriptor.java

示例13: testUnmanagedBundlesAreIgnoredForShutdownOrdering

import org.osgi.framework.Bundle; //导入依赖的package包/类
/**
 * If the service of a managed bundle are consumed by an unmanaged bundle,
 * that dependency should not affect the shutdown ordering as gemini blueprint is only responsible for
 * orderly shutting down the bundles it is managing.
 */
public void testUnmanagedBundlesAreIgnoredForShutdownOrdering() throws Exception {
    DependencyMockBundle a = new DependencyMockBundle("A");
    DependencyMockBundle b = new DependencyMockBundle("B");
    DependencyMockBundle c = new DependencyMockBundle("C");
    DependencyMockBundle d = new DependencyMockBundle("D");
    DependencyMockBundle e = new DependencyMockBundle("E");
    DependencyMockBundle unmanaged = new DependencyMockBundle("F");

    b.setDependentOn(c);
    d.setDependentOn(e, -13, 12);
    e.setDependentOn(d, 0, 14);
    a.setDependentOn(unmanaged);

    List<Bundle> order = getOrder(a, b, c, d, e);
    assertOrder(order, c, a, b, d, e);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:22,代码来源:BlueprintShutdownSorterTest.java

示例14: createApplicationContext

import org.osgi.framework.Bundle; //导入依赖的package包/类
public DelegatedExecutionOsgiBundleApplicationContext createApplicationContext(BundleContext bundleContext)
		throws Exception {
	Bundle bundle = bundleContext.getBundle();
	ApplicationContextConfiguration config = new BlueprintContainerConfig(bundle);
	String bundleName = OsgiStringUtils.nullSafeNameAndSymName(bundle);
	if (log.isTraceEnabled())
		log.trace("Created configuration " + config + " for bundle " + bundleName);

	// it's not a spring bundle, ignore it
	if (!config.isSpringPoweredBundle()) {
		if (log.isDebugEnabled())
			log.debug("No blueprint configuration found in bundle " + bundleName + "; ignoring it...");
		return null;
	}

	log.info("Discovered configurations " + ObjectUtils.nullSafeToString(config.getConfigurationLocations())
			+ " in bundle [" + bundleName + "]");

	DelegatedExecutionOsgiBundleApplicationContext sdoac =
			new OsgiBundleXmlApplicationContext(config.getConfigurationLocations());
	sdoac.setBundleContext(bundleContext);
	sdoac.setPublishContextAsService(config.isPublishContextAsService());

	return sdoac;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:26,代码来源:BlueprintContainerCreator.java

示例15: getMelangeBundle

import org.osgi.framework.Bundle; //导入依赖的package包/类
/**
 * Return a bundle with a .melange declaring 'language'
 */
public static Bundle getMelangeBundle(String languageName){
	
	IConfigurationElement[] melangeLanguages = Platform
			.getExtensionRegistry().getConfigurationElementsFor(
					"fr.inria.diverse.melange.language");
	String melangeBundleName = "";
	
	for (IConfigurationElement lang : melangeLanguages) {
		if(lang.getAttribute("id").equals(languageName)){
			melangeBundleName = lang.getContributor().getName();
			return Platform.getBundle(melangeBundleName);
		}
	}
	
	return null;
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:20,代码来源:MelangeHelper.java


注:本文中的org.osgi.framework.Bundle类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。