Package org.osgi.service.packageadmin

Examples of org.osgi.service.packageadmin.ExportedPackage


    private Bundle getDummyHostBundle(String packageName) {
       
        if (packageAdmin == null)
            return null;
       
        ExportedPackage exp = packageAdmin.getExportedPackage(packageName);
        if (exp == null)
            return null;
        else
            return exp.getExportingBundle();
    }
View Full Code Here


                    throw new Exception("Found multiple bundles with the same symbolic name: " + symbolicName);
                } else {
                    return bundles[0];
                }
            } else if (packageName != null) {
                ExportedPackage exportedPackage = packageAdmin.getExportedPackage(packageName);
                if (exportedPackage == null) {
                    throw new Exception("Unable to find bundle based on package name. There is no bundle that exports " + packageName + " package");
                }
                return exportedPackage.getExportingBundle();
            } else {
                return bundleContext.getBundle();
            }
        } finally {
            bundleContext.ungetService(reference);
View Full Code Here

  public GlobalPolicy(PackageAdmin admin) {
    this.admin = admin;
  }

  public Class<?> loadClass(String name) {
    ExportedPackage pkg = admin.getExportedPackage(BundleLoader.getPackageName(name));
    if (pkg == null)
      return null;
    try {
      return pkg.getExportingBundle().loadClass(name);
    } catch (ClassNotFoundException e) {
      return null;
    }
  }
View Full Code Here

    }
  }

  public URL loadResource(String name) {
    //get all exported packages that match the resource's package
    ExportedPackage pkg = admin.getExportedPackage(BundleLoader.getResourcePackageName(name));
    if (pkg == null)
      return null;
    return pkg.getExportingBundle().getResource(name);
  }
View Full Code Here

            if (packageAdmin == null) {
                throw new IOException("PackageAdmin is not available");
            }
            Version packageVersion = new Version(version);

            ExportedPackage foundPackage = Utils.findPackage(packageAdmin.getExportedPackages(bundle), packageName, packageVersion);
            if (foundPackage == null) {
                throw new IllegalArgumentException("Package name/vesion are wrong: " + packageName + ", " + version);
            }
            return Utils.getIds(foundPackage.getImportingBundles());
        } catch (IllegalArgumentException e) {
            logVisitor.warning("getImportingBundles error", e);
            throw e;
        } catch (IOException e) {
            logVisitor.warning("getImportingBundles error", e);
View Full Code Here

            if (packageAdmin == null) {
                throw new IOException("PackageAdmin is not available");
            }
            Version packageVersion = new Version(version);

            ExportedPackage foundPackage = Utils.findPackage(packageAdmin.getExportedPackages(bundle), packageName, packageVersion);
            if (foundPackage == null) {
                throw new IllegalArgumentException("Package name/vesion are wrong: " + packageName + ", " + version);
            }
            return foundPackage.isRemovalPending();
        } catch (IllegalArgumentException e) {
            logVisitor.warning("isRemovalPending error", e);
            throw e;
        } catch (IOException e) {
            logVisitor.warning("isRemovalPending error", e);
View Full Code Here

  public GlobalPolicy(PackageAdmin admin) {
    this.admin = admin;
  }

  public Class loadClass(String name) {
    ExportedPackage pkg = admin.getExportedPackage(BundleLoader.getPackageName(name));
    if (pkg == null)
      return null;
    try {
      return pkg.getExportingBundle().loadClass(name);
    } catch (ClassNotFoundException e) {
      return null;
    }
  }
View Full Code Here

    }
  }

  public URL loadResource(String name) {
    //get all exported packages that match the resource's package
    ExportedPackage pkg = admin.getExportedPackage(BundleLoader.getResourcePackageName(name));
    if (pkg == null)
      return null;
    return pkg.getExportingBundle().getResource(name);
  }
View Full Code Here

            } );

            JSONArray val = new JSONArray();
            for ( int j = 0; j < exports.length; j++ )
            {
                ExportedPackage export = exports[j];
                collectExport( val, export.getName(), export.getVersion() );
                Bundle[] ubList = export.getImportingBundles();
                if ( ubList != null )
                {
                    for ( int i = 0; i < ubList.length; i++ )
                    {
                        Bundle ub = ubList[i];
                        String name = ub.getSymbolicName();
                        if (name == null) name = ub.getLocation();
                        usingBundles.put( name, ub );
                    }
                }
            }
            WebConsoleUtil.keyVal( jw, "Exported Packages", val );
        }
        else
        {
            WebConsoleUtil.keyVal( jw, "Exported Packages", "---" );
        }

        exports = packageAdmin.getExportedPackages( ( Bundle ) null );
        if ( exports != null && exports.length > 0 )
        {
            // collect import packages first
            final List imports = new ArrayList();
            for ( int i = 0; i < exports.length; i++ )
            {
                final ExportedPackage ep = exports[i];
                final Bundle[] importers = ep.getImportingBundles();
                for ( int j = 0; importers != null && j < importers.length; j++ )
                {
                    if ( importers[j].getBundleId() == bundle.getBundleId() )
                    {
                        imports.add( ep );

                        break;
                    }
                }
            }
            // now sort
            JSONArray val = new JSONArray();
            if ( imports.size() > 0 )
            {
                final ExportedPackage[] packages = ( ExportedPackage[] ) imports.toArray( new ExportedPackage[imports
                    .size()] );
                Arrays.sort( packages, new Comparator()
                {
                    public int compare( ExportedPackage p1, ExportedPackage p2 )
                    {
                        return p1.getName().compareTo( p2.getName() );
                    }


                    public int compare( Object o1, Object o2 )
                    {
                        return compare( ( ExportedPackage ) o1, ( ExportedPackage ) o2 );
                    }
                } );
                // and finally print out
                for ( int i = 0; i < packages.length; i++ )
                {
                    ExportedPackage ep = packages[i];
                    collectImport( val, ep.getName(), ep.getVersion(), false, ep, pluginRoot );
                }
            }
            else
            {
                // add description if there are no imports
View Full Code Here

                    if ( exports != null && exports.length > 0 )
                    {

                        for ( int i = 0; i < exports.length; i++ )
                        {
                            final ExportedPackage ep = exports[i];

                            Clause imp = ( Clause ) imports.get( ep.getName() );
                            if ( imp != null && isSatisfied( imp, ep ) )
                            {
                                candidates.put( ep.getName(), ep );
                            }
                        }
                    }
                }

                // now sort
                JSONArray val = new JSONArray();
                if ( imports.size() > 0 )
                {
                    for ( Iterator ii = imports.values().iterator(); ii.hasNext(); )
                    {
                        Clause r4Import = ( Clause ) ii.next();
                        ExportedPackage ep = ( ExportedPackage ) candidates.get( r4Import.getName() );

                        // if there is no matching export, check whether this
                        // bundle has the package, ignore the entry in this case
                        if ( ep == null )
                        {
View Full Code Here

TOP

Related Classes of org.osgi.service.packageadmin.ExportedPackage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.