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


Java BundleContext.getBundle方法代码示例

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


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

示例1: createApplicationContext

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

	// it's not a spring bundle, ignore it
	if (!config.isSpringPoweredBundle()) {
		return null;
	}

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

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

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

示例2: postProcessBeanFactory

import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
public void postProcessBeanFactory(BundleContext bundleContext, ConfigurableListableBeanFactory beanFactory)
		throws BeansException, OsgiException {

	Bundle bundle = bundleContext.getBundle();
	try {
		// Try and load the annotation code using the bundle classloader
		Class<?> annotationBppClass = bundle.loadClass(ANNOTATION_BPP_CLASS);
		// instantiate the class
		final BeanPostProcessor annotationBeanPostProcessor = (BeanPostProcessor) BeanUtils.instantiateClass(annotationBppClass);

		// everything went okay so configure the BPP and add it to the BF
		((BeanFactoryAware) annotationBeanPostProcessor).setBeanFactory(beanFactory);
		((BeanClassLoaderAware) annotationBeanPostProcessor).setBeanClassLoader(beanFactory.getBeanClassLoader());
		((BundleContextAware) annotationBeanPostProcessor).setBundleContext(bundleContext);
		beanFactory.addBeanPostProcessor(annotationBeanPostProcessor);
	}
	catch (ClassNotFoundException exception) {
		log.info("Spring-DM annotation package could not be loaded from bundle ["
				+ OsgiStringUtils.nullSafeNameAndSymName(bundle) + "]; annotation processing disabled...");
		if (log.isDebugEnabled())
			log.debug("Cannot load annotation injection processor", exception);
	}
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:24,代码来源:OsgiAnnotationPostProcessor.java

示例3: createApplicationContext

import org.osgi.framework.BundleContext; //导入方法依赖的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

示例4: registerManagedService

import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
public static ServiceRegistration registerManagedService(BundleContext bundleContext, ManagedService listener,
		String pid) {

       Dictionary<String, Object> props = new Hashtable<String, Object>();
	props.put(Constants.SERVICE_PID, pid);
	Bundle bundle = bundleContext.getBundle();
	props.put(Constants.BUNDLE_SYMBOLICNAME, OsgiStringUtils.nullSafeSymbolicName(bundle));
	props.put(Constants.BUNDLE_VERSION, OsgiBundleUtils.getBundleVersion(bundle));

	return bundleContext.registerService(ManagedService.class.getName(), listener, props);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:12,代码来源:CMUtils.java

示例5: getPlatformName

import org.osgi.framework.BundleContext; //导入方法依赖的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

示例6: invoke

import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
private static Object invoke(BundleContext context, long bundleID, String classFqn, String methodToInvoke,
		String[] args)
		throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {

	Bundle appBundle = context.getBundle(bundleID);
	Class<?> appClass = appBundle.loadClass(classFqn);
	final Method method = appClass.getMethod(methodToInvoke, args.getClass());
	return method.invoke(null, new Object[] { args });
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:10,代码来源:ProductLauncher.java

示例7: start

import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
public @Override void start(final BundleContext context) throws Exception {
        if (System.getProperty("netbeans.home") != null) {
            throw new IllegalStateException("Should not be run from inside regular NetBeans module system");
        }
        String storage = context.getProperty(Constants.FRAMEWORK_STORAGE);
        if (storage != null) {
            System.setProperty("netbeans.user", storage);
        }
        System.setProperty("TopSecurityManager.disable", "true");
        NbBundle.setBranding(System.getProperty("branding.token"));
        OSGiMainLookup.initialize(context);
        queue = new DependencyQueue<String,Bundle>();
        this.context = context;
        framework = ((Framework) context.getBundle(0));
        if (framework.getState() == Bundle.STARTING) {
            LOG.fine("framework still starting");
            final AtomicReference<FrameworkListener> frameworkListener = new AtomicReference<FrameworkListener>();
            frameworkListener.set(new FrameworkListener() {
                public @Override void frameworkEvent(FrameworkEvent event) {
                    if (event.getType() == FrameworkEvent.STARTED) {
//                        System.err.println("framework started");
                        context.removeFrameworkListener(frameworkListener.get());
                        context.addBundleListener(Activator.this);
                        processLoadedBundles();
                    }
                }
            });
            context.addFrameworkListener(frameworkListener.get());
        } else {
            LOG.fine("framework already started");
            context.addBundleListener(this);
            processLoadedBundles();
        }
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:Activator.java

示例8: start

import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
@Override
public void start(BundleContext context) throws Exception {
	this.listenerManager = new BlueprintListenerManager(context);
       EventAdminDispatcher dispatcher = new EventAdminDispatcher(context);
       Bundle bundle = context.getBundle();
	this.contextProcessor = new BlueprintContainerProcessor(dispatcher, listenerManager, bundle);
	this.typeChecker = new BlueprintTypeCompatibilityChecker(bundle);
       this.listenerServiceActivator.getMulticaster().addApplicationListener(this.contextProcessor);
	super.start(context);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:11,代码来源:BlueprintLoaderListener.java

示例9: setBundleContext

import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 * 
 * <p/> Will automatically determine the bundle, create a new <code>ResourceLoader</code> (and set its
 * <code>ClassLoader</code> (if none is set already) to a custom implementation that will delegate the calls to the
 * bundle).
 */
public void setBundleContext(BundleContext bundleContext) {
	this.bundleContext = bundleContext;
	this.bundle = bundleContext.getBundle();
	this.osgiPatternResolver = createResourcePatternResolver();

	if (getClassLoader() == null)
		this.setClassLoader(createBundleClassLoader(this.bundle));

	this.setDisplayName(ClassUtils.getShortName(getClass()) + "(bundle=" + getBundleSymbolicName() + ", config="
			+ StringUtils.arrayToCommaDelimitedString(getConfigLocations()) + ")");

	this.acc = AccessControlFactory.createContext(bundle);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:21,代码来源:AbstractOsgiBundleApplicationContext.java

示例10: getVersion

import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
/**
 * Returns the OSGi platform version (using the manifest entries from the system bundle). The version can be empty.
 * 
 * @param bundleContext bundle context to inspect
 * @return not-null system bundle version
 */
public static String getVersion(BundleContext bundleContext) {
	if (bundleContext == null)
		return "";

	// get system bundle
	Bundle sysBundle = bundleContext.getBundle(0);
	// force string conversion instead of casting just to be safe
	return "" + sysBundle.getHeaders().get(Constants.BUNDLE_VERSION);
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:16,代码来源:OsgiPlatformDetector.java

示例11: isTypeCompatible

import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
public boolean isTypeCompatible(BundleContext targetContext) {
	Bundle bnd = targetContext.getBundle();
	return (checkCompatibility(CONTAINER_PKG_CLASS, bnd, containerPkgClass) && checkCompatibility(
			REFLECT_PKG_CLASS, bnd, reflectPkgClass));
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:6,代码来源:BlueprintTypeCompatibilityChecker.java

示例12: injectBundleContext

import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
/**
 * Set the bundle context to be used by this test.
 * <p/>
 * <p/> This method is called automatically by the test infrastructure after the OSGi platform is being setup.
 */
private void injectBundleContext(BundleContext bundleContext) {
    this.bundleContext = bundleContext;
    // instantiate ResourceLoader
    this.resourceLoader = new OsgiBundleResourceLoader(bundleContext.getBundle());
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:11,代码来源:AbstractOsgiTests.java

示例13: instantiateModule

import org.osgi.framework.BundleContext; //导入方法依赖的package包/类
public ShutdownModule instantiateModule(final String instanceName, final DependencyResolver dependencyResolver,
                                        final ShutdownModule oldModule, final AutoCloseable oldInstance,
                                        final BundleContext bundleContext) {
    Bundle systemBundle = bundleContext.getBundle(0);
    return new ShutdownModule(new ModuleIdentifier(NAME, instanceName), oldModule, oldInstance, systemBundle);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:7,代码来源:ShutdownModuleFactory.java


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