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 });
        when(admin.getExportedPackages(b3)).thenReturn(null);
View Full Code Here

    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

    }
   
    private void registerTlds(PackageAdmin packageAdmin) throws Exception {
        String[] packageNames = packageNameList.split(",");
        for (String packageName : packageNames) {
            ExportedPackage exportedPackage = packageAdmin.getExportedPackage(packageName.trim());
            if (exportedPackage == null) {
                LOGGER.warn("Package {} is not currently exported by any bundle", packageName);
            } else {
                Bundle exportingBundle = exportedPackage.getExportingBundle();
               
                BundleResourceFinder resourceFinder = new BundleResourceFinder(packageAdmin, exportingBundle, "META-INF/", ".tld");
                TldResourceFinderCallback callback = new TldResourceFinderCallback();
                resourceFinder.find(callback);
                if (!callback.getTlds().isEmpty()) {
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

    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

    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

        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(exported.getExportingBundle()).thenReturn(bundle);
        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);
        when(ep1.getExportingBundle()).thenReturn(b1);
        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"));
        when(ep2.getExportingBundle()).thenReturn(b2);
        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

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.