コード例 #1
0
 @Execute
 public void execute(
     @OSGiBundle BundleContext bundleContext,
     @Named(PLUGIN_LOCATION_PARAMETER) String pluginLocation,
     @Optional Logger logger) {
   try {
     URL fileURL = FileLocator.toFileURL(new URL(pluginLocation));
     String refLocation = "reference:" + fileURL.toExternalForm();
     Bundle installedBundle = bundleContext.installBundle(refLocation);
     installedBundle.start(Bundle.START_TRANSIENT);
     Activator.getDefault().addDynamicBundle(installedBundle);
   } catch (BundleException e) {
     if (logger != null) {
       logger.warn(e, "Failed to load plugin from: " + pluginLocation);
     }
   } catch (MalformedURLException e) {
     if (logger != null) {
       logger.warn(e, "Failed to load plugin from: " + pluginLocation);
     }
   } catch (IOException e) {
     if (logger != null) {
       logger.warn(e, "Failed to load plugin from: " + pluginLocation);
     }
   }
 }
コード例 #2
0
 @Execute
 public void execute(
     @OSGiBundle BundleContext bundleContext,
     @Named(PLUGIN_ID_PARAMETER) String pluginId,
     @Optional Logger logger) {
   Bundle bundle = Platform.getBundle(pluginId);
   if (bundle != null) {
     try {
       bundle.uninstall();
       Activator.getDefault().removeDynamicBundle(bundle);
     } catch (BundleException e) {
       logger.warn(e, "Failed to uninstall bundle " + bundle.getSymbolicName());
     }
   }
 }