Package org.osgi.service.packageadmin

Examples of org.osgi.service.packageadmin.ExportedPackage


        Bundle bundle = mock(Bundle.class);
        PackageAdmin admin = mock(PackageAdmin.class);
       
        assertEquals(0, getBundleExportedPackages(bundle, admin).length);
       
        ExportedPackage exported = mock(ExportedPackage.class);
        when(exported.getName()).thenReturn("org.apache.aries.jmx");
        when(exported.getVersion()).thenReturn(new Version("1.0.0"));
        when(admin.getExportedPackages(bundle)).thenReturn(new ExportedPackage[] { exported });
       
        assertArrayEquals(new String[] { "org.apache.aries.jmx;1.0.0"} , getBundleExportedPackages(bundle, admin));
       
    }
View Full Code Here


        Bundle b1 = mock(Bundle.class);
        Bundle b2 = mock(Bundle.class);
        Bundle b3 = mock(Bundle.class);
        when(context.getBundles()).thenReturn(new Bundle[] { bundle, b1, b2, b3 });
       
        ExportedPackage ep1 = mock(ExportedPackage.class);
        when(ep1.getImportingBundles()).thenReturn(new Bundle[] { bundle, b2, b3 });
        when(ep1.getName()).thenReturn("org.apache.aries.jmx.b1");
        when(ep1.getVersion()).thenReturn(Version.emptyVersion);
        ExportedPackage ep2 = mock(ExportedPackage.class);
        when(ep2.getImportingBundles()).thenReturn(new Bundle[] { bundle, b3 });
        when(ep2.getName()).thenReturn("org.apache.aries.jmx.b2");
        when(ep2.getVersion()).thenReturn(Version.parseVersion("2.0.1"));
      
       
        PackageAdmin admin = mock(PackageAdmin.class);
        when(admin.getExportedPackages(b1)).thenReturn(new ExportedPackage[] { ep1 });
        when(admin.getExportedPackages(b2)).thenReturn(new ExportedPackage[] { ep2 });
View Full Code Here

        headers.put(Constants.BUNDLE_SYMBOLICNAME, "test");
        headers.put(Constants.BUNDLE_VERSION, "0.0.0");
        when(bundle.getHeaders()).thenReturn(headers);
       
        //exported packages
        ExportedPackage exported = mock(ExportedPackage.class);
        when(exported.getName()).thenReturn("org.apache.aries.jmx");
        when(exported.getVersion()).thenReturn(new Version("1.0.0"));
        when(packageAdmin.getExportedPackages(bundle)).thenReturn(new ExportedPackage[] { exported });
       
        //imported packages
        ExportedPackage ep1 = mock(ExportedPackage.class);
        when(ep1.getImportingBundles()).thenReturn(new Bundle[] { bundle, b2, b3 });
        when(ep1.getName()).thenReturn("org.apache.aries.jmx.b1");
        when(ep1.getVersion()).thenReturn(Version.emptyVersion);
        ExportedPackage ep2 = mock(ExportedPackage.class);
        when(ep2.getImportingBundles()).thenReturn(new Bundle[] { bundle, b3 });
        when(ep2.getName()).thenReturn("org.apache.aries.jmx.b2");
        when(ep2.getVersion()).thenReturn(Version.parseVersion("2.0.1"));
        headers.put(Constants.DYNAMICIMPORT_PACKAGE, "*");
 
        when(packageAdmin.getExportedPackages(b1)).thenReturn(new ExportedPackage[] { ep1 });
        when(packageAdmin.getExportedPackages(b2)).thenReturn(new ExportedPackage[] { ep2 });
        when(packageAdmin.getExportedPackages(b3)).thenReturn(null);
View Full Code Here

      if (!seenBundles.contains(analyzedBundle)) {
        seenBundles.add(bundle);
        ExportedPackage[] epa = pa.getExportedPackages(analyzedBundle);
        if (epa != null)
          for (int j = 0; j < epa.length; j++) {
            ExportedPackage exportedPackage = epa[j];
            Bundle[] importingBundles = exportedPackage.getImportingBundles();
            if (importingBundles != null)
              for (int k = 0; k < importingBundles.length; k++) {
                if (bundle.equals(importingBundles[k])) {
                  importedPackages.add(exportedPackage.getName() + ";version="
                      + exportedPackage.getVersion());
                }
              }
          }
      }
    }
View Full Code Here

      // if the bundle is already included (it's a required one), there's no need to look at it again
      if (!importedBundles.containsKey(analyzedBundle)) {
        ExportedPackage[] epa = pa.getExportedPackages(analyzedBundle);
        if (epa != null)
          for (int j = 0; j < epa.length; j++) {
            ExportedPackage exportedPackage = epa[j];
            Bundle[] importingBundles = exportedPackage.getImportingBundles();
            if (importingBundles != null)
              for (int k = 0; k < importingBundles.length; k++) {
                if (bundle.equals(importingBundles[k])) {
                  addImportedBundle(importedBundles, exportedPackage);
                }
View Full Code Here

    }

    public void loadModel(ParsingContext ctx, String className) {
        int index = className.lastIndexOf('.');
        String packageName = index > 0 ? className.substring(0, index) : "";
        ExportedPackage pkg = pkgAdmin.getExportedPackage(packageName);

        if (pkg != null) {
            Bundle srcBundle = pkg.getExportingBundle();
            String resourceName = className.replace('.', '/');
            if (! resourceName.endsWith(".class"))
                resourceName += ".class";
            URL url = srcBundle.getResource(resourceName);
            byte[] data = null;
View Full Code Here

    @Override
    public InputStream openResourceStream(String className) throws IOException {
        int index = className.lastIndexOf('/');
        String packageName = index > 0 ? className.substring(0, index) : "";
        ExportedPackage pkg = pkgAdmin.getExportedPackage(packageName.replace('/', '.'));

//        System.out.println("** CommonModelRegistry::openResourceStream called  for: " + className);

        InputStream inputStream = null;
        if (pkg != null) {
            Bundle srcBundle = pkg.getExportingBundle();
//            String resourceName = className.replace('.', '/');
//            if (! resourceName.endsWith(".class"))
//                resourceName += ".class";
            URL url = srcBundle.getResource(className);
            byte[] data = null;
View Full Code Here

    @Override
    public URL getResource(String className) {
        int index = className.lastIndexOf('/');
        String packageName = index > 0 ? className.substring(0, index) : "";
        ExportedPackage pkg = pkgAdmin.getExportedPackage(packageName.replace('/', '.'));

//        System.out.println("** CommonModelRegistry::getResource called  for: " + className);

        InputStream inputStream = null;
        if (pkg != null) {
            Bundle srcBundle = pkg.getExportingBundle();
//            String resourceName = className.replace('.', '/');
//            if (! resourceName.endsWith(".class"))
//                resourceName += ".class";
            return srcBundle.getResource(className);
        }
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.