Search in sources :

Example 36 with PackageAdmin

use of org.osgi.service.packageadmin.PackageAdmin in project rt.equinox.framework by eclipse.

the class PackageAdminBundleTests method testBug415447.

public void testBug415447() {
    PackageAdmin pa = installer.getPackageAdmin();
    Bundle[] systemBundles = pa.getBundles(Constants.SYSTEM_BUNDLE_SYMBOLICNAME, null);
    assertNotNull("No system bundles found.", systemBundles);
    assertEquals("Srong number of system bundles.", 1, systemBundles.length);
    assertEquals("Wrong system bundle found.", OSGiTestsActivator.getContext().getBundle(Constants.SYSTEM_BUNDLE_LOCATION), systemBundles[0]);
}
Also used : PackageAdmin(org.osgi.service.packageadmin.PackageAdmin)

Example 37 with PackageAdmin

use of org.osgi.service.packageadmin.PackageAdmin in project rt.equinox.framework by eclipse.

the class InstallTests method testInstall2SingletonBundles.

/**
 * Ensures two versions of a singleton bundle are accepted
 */
public void testInstall2SingletonBundles() throws BundleException, IOException {
    // $NON-NLS-1$
    Bundle installed1 = BundleTestingHelper.installBundle(OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle08");
    ServiceReference packageAdminSR = OSGiTestsActivator.getContext().getServiceReference(PackageAdmin.class.getName());
    PackageAdmin packageAdmin = (PackageAdmin) OSGiTestsActivator.getContext().getService(packageAdminSR);
    packageAdmin.resolveBundles(null);
    // $NON-NLS-1$
    Bundle installed2 = BundleTestingHelper.installBundle(OSGiTestsActivator.getContext(), OSGiTestsActivator.TEST_FILES_ROOT + "internal/plugins/installTests/bundle08b");
    packageAdmin.resolveBundles(null);
    OSGiTestsActivator.getContext().ungetService(packageAdminSR);
    try {
        // $NON-NLS-1$ //$NON-NLS-2$
        assertEquals("1.0", "bundle08", installed1.getSymbolicName());
        // $NON-NLS-1$
        assertEquals("1.1", Bundle.RESOLVED, installed1.getState());
        // $NON-NLS-1$ //$NON-NLS-2$
        assertEquals("1.2", "1.0.0", installed1.getHeaders().get(Constants.BUNDLE_VERSION));
        // $NON-NLS-1$ //$NON-NLS-2$
        assertEquals("1.3", "bundle08", installed2.getSymbolicName());
        // $NON-NLS-1$
        assertEquals("1.4", Bundle.INSTALLED, installed2.getState());
        // $NON-NLS-1$ //$NON-NLS-2$
        assertEquals("1.5", "1.0.0.b", installed2.getHeaders().get(Constants.BUNDLE_VERSION));
    } finally {
        installed1.uninstall();
        installed2.uninstall();
    }
}
Also used : PackageAdmin(org.osgi.service.packageadmin.PackageAdmin)

Example 38 with PackageAdmin

use of org.osgi.service.packageadmin.PackageAdmin in project Payara by payara.

the class BundleProvisioner method refresh.

/**
 * Refresh packages
 */
public void refresh() {
    final ServiceReference reference = getBundleContext().getServiceReference(PackageAdmin.class.getName());
    PackageAdmin pa = PackageAdmin.class.cast(getBundleContext().getService(reference));
    // null to refresh any bundle that's obsolete
    pa.refreshPackages(null);
    getBundleContext().ungetService(reference);
}
Also used : PackageAdmin(org.osgi.service.packageadmin.PackageAdmin) ServiceReference(org.osgi.framework.ServiceReference)

Aggregations

PackageAdmin (org.osgi.service.packageadmin.PackageAdmin)38 Bundle (org.osgi.framework.Bundle)21 BundleContext (org.osgi.framework.BundleContext)14 ServiceReference (org.osgi.framework.ServiceReference)14 ExportedPackage (org.osgi.service.packageadmin.ExportedPackage)12 Test (org.junit.Test)11 RequiredBundle (org.osgi.service.packageadmin.RequiredBundle)6 StartLevel (org.osgi.service.startlevel.StartLevel)6 ArrayList (java.util.ArrayList)5 FrameworkUtils.getServicesInUseByBundle (org.apache.aries.jmx.util.FrameworkUtils.getServicesInUseByBundle)5 Version (org.osgi.framework.Version)4 File (java.io.File)3 IOException (java.io.IOException)3 Hashtable (java.util.Hashtable)3 NotCompliantMBeanException (javax.management.NotCompliantMBeanException)3 Logger (org.apache.aries.jmx.Logger)3 Expectations (org.jmock.Expectations)3 BundleException (org.osgi.framework.BundleException)3 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)3 LinkedHashMap (java.util.LinkedHashMap)2