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


Java PackageAdmin.refreshPackages方法代码示例

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


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

示例1: refreshBundle

import org.osgi.service.packageadmin.PackageAdmin; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public void refreshBundle(Bundle changedBundle, BundleContext context) {
	try {
		ServiceReference ref = context.getServiceReference(PackageAdmin.class.getName());
		PackageAdmin pa = (ref == null) ? null : (PackageAdmin) context.getService(ref);
		System.out.println("Refreshing bundle " + changedBundle);
		pa.refreshPackages(new Bundle[] { changedBundle });
	} catch (Throwable e) {
		System.err.println(e.getMessage());
		e.printStackTrace();
	}
}
 
开发者ID:codessentials,项目名称:felinx,代码行数:13,代码来源:FrameworkRunner.java

示例2: refreshDependentBundles

import org.osgi.service.packageadmin.PackageAdmin; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
public void refreshDependentBundles(Bundle changedBundle, BundleContext context) {
	try {
		long myId = changedBundle.getBundleId();
		Dictionary<String, String> headers = changedBundle.getHeaders();

		String exported = headers.get("Export-Package") + ",";
		Bundle[] bundles = context.getBundles();
		Set<Bundle> toRefresh = new HashSet<Bundle>();
		for (int i = 0; i < bundles.length; i++) {
			Bundle bundle = bundles[i];
			if (bundle.getBundleId() != myId) {
				if (!bundle.getSymbolicName().startsWith("org.apache")) {
					Dictionary<String, String> headers2 = bundle.getHeaders();
					String imported = headers2.get("Import-Package");
					String[] packages = imported.split(",");
					for (int j = 0; j < packages.length; j++) {
						String importedPackage = packages[j].trim();
						importedPackage = importedPackage.split(";")[0];// no version - for now
						if (exported.contains(importedPackage)) {
							toRefresh.add(bundle);
						}
					}
				}
			}
		}
		ServiceReference ref = context.getServiceReference(PackageAdmin.class.getName());
		PackageAdmin pa = (ref == null) ? null : (PackageAdmin) context.getService(ref);
		System.out.println(pa);
		Bundle[] refreshList = toRefresh.toArray(new Bundle[0]);
		for (Bundle bundleToRefresh : refreshList) {
			System.out.println("Refreshing dependend bundle " + bundleToRefresh);
		}
		pa.refreshPackages(refreshList);
	} catch (Throwable e) {
		System.err.println(e.getMessage());
		e.printStackTrace();
	}
}
 
开发者ID:codessentials,项目名称:felinx,代码行数:40,代码来源:FrameworkRunner.java


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