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


Java Bundle.getLocation方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:24,代码来源:AtlasHotPatchManager.java

示例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");
        }
    }
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:28,代码来源:AbstractOsgiTests.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:Netigso.java

示例4: toString

import org.osgi.framework.Bundle; //导入方法依赖的package包/类
@Override
public String toString() {
    Bundle b = bundle;
    if (b == null) {
        return "uninitialized";
    }
    return b.getLocation();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:NetigsoLoader.java

示例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);
                }
            }
        }
 
开发者ID:alibaba,项目名称:atlas,代码行数:39,代码来源:SecurityHandler.java

示例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"));
}
 
开发者ID:opensecuritycontroller,项目名称:osc-core,代码行数:31,代码来源:InstallerIntegrationTest.java

示例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;
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:45,代码来源:ResourceIdFetcher.java


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