本文整理匯總了Java中org.osgi.framework.Bundle.getLocation方法的典型用法代碼示例。如果您正苦於以下問題:Java Bundle.getLocation方法的具體用法?Java Bundle.getLocation怎麽用?Java Bundle.getLocation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.osgi.framework.Bundle
的用法示例。
在下文中一共展示了Bundle.getLocation方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: patchBundle
import org.osgi.framework.Bundle; //導入方法依賴的package包/類
private void patchBundle(final Bundle bundle){
if(hotpatchBundles.get(bundle.getLocation())==null){
return;
}
String lockKey = bundle.getLocation() + ".patch";
try {
BundleLock.WriteLock(lockKey);
if (activePatchs.get(bundle.getLocation()) != null) {
return;
}
long version = hotpatchBundles.get(bundle.getLocation());
File bundlePatchFile = new File(sCurrentVersionPatchDir,String.format("%s/%s%s",
bundle.getLocation(),version,HOTFIX_NAME_POSTFIX));
if (bundlePatchFile.exists()) {
purgeOldPatchsOfBundle(bundlePatchFile,version);
activePatch(bundle.getLocation(),new Patch(bundlePatchFile,((BundleImpl)bundle).getClassLoader()));
}
}catch(Exception e){
e.printStackTrace();
}finally {
BundleLock.WriteUnLock(lockKey);
}
}
示例2: startBundle
import org.osgi.framework.Bundle; //導入方法依賴的package包/類
/**
* Starts a bundle and prints a nice logging message in case of failure.
*
* @param bundle to start
* @throws BundleException
*/
private void startBundle(Bundle bundle) throws BundleException {
boolean debug = logger.isDebugEnabled();
String info = "[" + OsgiStringUtils.nullSafeNameAndSymName(bundle) + "|" + bundle.getLocation() + "]";
if (!OsgiBundleUtils.isFragment(bundle)) {
if (debug)
logger.debug("Starting " + info);
try {
bundle.start();
} catch (BundleException ex) {
logger.error("cannot start bundle " + info, ex);
throw ex;
}
} else {
// if (!OsgiBundleUtils.isBundleResolved(bundle)) {
// logger.error("fragment not resolved: " + info);
// throw new BundleException("Unable to resolve fragment: " + info);
// } else if (debug)
logger.debug(info + " is a fragment; start not invoked");
}
}
示例3: toActivate
import org.osgi.framework.Bundle; //導入方法依賴的package包/類
private static Set<String> toActivate(Framework f, Collection<? extends Module> allModules) {
ServiceReference sr = f.getBundleContext().getServiceReference("org.osgi.service.packageadmin.PackageAdmin"); // NOI18N
if (sr == null) {
return null;
}
PackageAdmin pkgAdm = (PackageAdmin)f.getBundleContext().getService(sr);
if (pkgAdm == null) {
return null;
}
Set<String> allCnbs = new HashSet<String>(allModules.size() * 2);
for (ModuleInfo m : allModules) {
allCnbs.add(m.getCodeNameBase());
}
Set<String> needEnablement = new HashSet<String>();
for (Bundle b : f.getBundleContext().getBundles()) {
String loc = b.getLocation();
if (loc.startsWith("netigso://")) {
loc = loc.substring("netigso://".length());
} else {
continue;
}
RequiredBundle[] arr = pkgAdm.getRequiredBundles(loc);
if (arr != null) for (RequiredBundle rb : arr) {
for (Bundle n : rb.getRequiringBundles()) {
if (allCnbs.contains(n.getSymbolicName().replace('-', '_'))) {
needEnablement.add(loc);
}
}
}
}
return needEnablement;
}
示例4: toString
import org.osgi.framework.Bundle; //導入方法依賴的package包/類
@Override
public String toString() {
Bundle b = bundle;
if (b == null) {
return "uninitialized";
}
return b.getLocation();
}
示例5: handleMessage
import org.osgi.framework.Bundle; //導入方法依賴的package包/類
@Override
public void handleMessage(Message msg) {
if (msg == null || isSecurityCheckFailed == true) {
return;
}
Bundle bundle = (Bundle) msg.obj;
/**
* Skip bundle security check once updated.
*/
if(BaselineInfoManager.instance().isUpdated(bundle.getLocation()) || BaselineInfoManager.instance().isDexPatched(bundle.getLocation())){
return;
}
String location = bundle.getLocation();
File file= null;
if(!TextUtils.isEmpty(location)) {
file = Atlas.getInstance().getBundleFile(location);
if (file == null) {
return;
}
}
if(file!=null){
if (!RuntimeVariables.verifyBundle(file.getAbsolutePath())) {
Log.e(TAG, "Security check failed. " + location);
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new postInvalidBundle());
// AtlasMonitor.getInstance().trace(AtlasMonitor.BUNDLE_INSTALL_FAIL, location, AtlasMonitor.SECURITY_CHECK_FAILED,
// FileUtils.getDataAvailableSpace());
isSecurityCheckFailed = true;
}
if (isSecurityCheckFailed == false) {
Log.d(TAG, "Security check success. " + location);
}
}
}
示例6: testDontRemoveExistingBundle
import org.osgi.framework.Bundle; //導入方法依賴的package包/類
@Test
public void testDontRemoveExistingBundle() throws Exception {
// Precondition: no example bundles
assertNull("example bundle already present - broken prior test?", findBundle("org.example.a"));
assertNull("example bundle already present - broken prior test?", findBundle("org.example.b"));
FrameworkInstaller installer = this.fwkInstallerTracker.getService();
assertNotNull("installer service not found", installer);
Bundle existingBundle = findBundle("org.apache.felix.scr");
assertNotNull("SCR bundle has been uninstalled -- broken prior test?", existingBundle);
String locationA = new File(this.dataDir, "org.example.a.jar").toURI().toString();
String locationB = new File(this.dataDir, "org.example.b.jar").toURI().toString();
String existingLocation = existingBundle.getLocation();
// Install set including A, B and SCR
Object sponsor = new Object();
List<String> locations = Arrays.asList(locationA, locationB, existingLocation);
installer.addLocations(sponsor, locations);
assertNotNull("example bundle not present after install", findBundle("org.example.a"));
assertNotNull("example bundle not present after install", findBundle("org.example.b"));
assertNotNull("preexisting bundle not present after install", findBundle("org.apache.felix.scr"));
// Uninstall set - bundles A and B should go away but not SCR
installer.removeSponsor(sponsor);
assertNull("example bundle still present after uninstall", findBundle("org.example.a"));
assertNull("example bundle still present after uninstall", findBundle("org.example.b"));
assertNotNull("preexisting bundle uninstalled", findBundle("org.apache.felix.scr"));
}
示例7: getIdentifierWithRefection
import org.osgi.framework.Bundle; //導入方法依賴的package包/類
private int getIdentifierWithRefection(String name, String defType,
String defPackage) {
if(defType==null && defPackage==null)
{
String rawName = name;
name = rawName.substring(name.indexOf("/")+1);
defType = rawName.substring(rawName.indexOf(":")+1, rawName.indexOf("/"));
}
if(TextUtils.isEmpty(name) || TextUtils.isEmpty(defType)){
return 0;
}
List<Bundle> bundles = Framework.getBundles();
if (bundles != null && !bundles.isEmpty()) {
for (Bundle b : Framework.getBundles()) {
String pkgName = b.getLocation();
final String searchKey = pkgName+":"+name;
if(!resIdentifierMap.isEmpty() && resIdentifierMap.containsKey(searchKey)){
ResInfo info = resIdentifierMap.get(searchKey);
if(info!=null && info.type!=null && defType!=null && info.type.equals(defType)){
return info.resId;
}
}
BundleImpl bundle = (BundleImpl) b;
if(bundle.getArchive().isDexOpted()){
ClassLoader classloader = bundle.getClassLoader();
try {
if (classloader != null) {
StringBuilder resClass = new StringBuilder(pkgName);
resClass.append(".R$");
resClass.append(defType);
Class clazz = classloader.loadClass(resClass.toString());
int tmpResID = getFieldValueOfR(clazz,name);
if(tmpResID != 0){
resIdentifierMap.put(searchKey,new ResInfo(defType,tmpResID));
return tmpResID;
}
}
} catch (ClassNotFoundException e) {
}
}
}
}
return 0;
}