Search in sources :

Example 1 with AdaptPermission

use of org.osgi.framework.AdaptPermission in project logging-log4j2 by apache.

the class Activator method loadProvider.

private void loadProvider(final Bundle bundle) {
    if (bundle.getState() == Bundle.UNINSTALLED) {
        return;
    }
    try {
        checkPermission(new AdminPermission(bundle, AdminPermission.RESOURCE));
        checkPermission(new AdaptPermission(BundleWiring.class.getName(), bundle, AdaptPermission.ADAPT));
        loadProvider(bundle.adapt(BundleWiring.class));
    } catch (final SecurityException e) {
        LOGGER.debug("Cannot access bundle [{}] contents. Ignoring.", bundle.getSymbolicName(), e);
    } catch (final Exception e) {
        LOGGER.warn("Problem checking bundle {} for Log4j 2 provider.", bundle.getSymbolicName(), e);
    }
}
Also used : AdminPermission(org.osgi.framework.AdminPermission) BundleWiring(org.osgi.framework.wiring.BundleWiring) AdaptPermission(org.osgi.framework.AdaptPermission)

Aggregations

AdaptPermission (org.osgi.framework.AdaptPermission)1 AdminPermission (org.osgi.framework.AdminPermission)1 BundleWiring (org.osgi.framework.wiring.BundleWiring)1