Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-core-dev] Dynamic Plug-in


My problem was that the bundle had dependencies that were unresolved. Fixed that and now the console shows:

RESOLVED    jdg2e@D:\I0529\JDG2EBonusPack\plugins\com.ibm.jdg2e.miniwp.bonus_pack_3.0.0 [28]

Added new perspectives, views, actions, and preferences and the components (UI) all responded accordingly.    

Thanks,
Scott Fairbrother

platform-core-dev-admin@xxxxxxxxxxx wrote on 06/01/2004 03:41:35 PM:

>
> After doing this if you look in the OSGi console (run with -console) and do an
> "ss", is your bundle there?  Is it RESOLVED?  Doing the refreshPackages will tell
> us to resolve.  As a result, the plugin.xml willbe parsed by the registry and the
> elements added.  A registry change event will then be broadcast.  From there on it
> is up to the components (e.g., UI) to listen and do the right thing.
>
> Jeff
>
>

>
> Scott Fairbrother <scottf@xxxxxxxxxx>
> Sent by: platform-core-dev-admin@xxxxxxxxxxx

> 06/01/2004 02:30 PM
>
> Please respond to
> platform-core-dev

>
> To

>
> platform-core-dev@xxxxxxxxxxx

>
> cc

>
> Subject

>
> [platform-core-dev] Dynamic Plug-in

>
>
>
>
>
> I'm trying to roll my own configurator, that will load a bundle(s).  I think I'm
> getting through the load process clean but the bundles extensions, menus, views,
> help, contributions are not updated in the UI.  Is there some trick to forcing the
> framework to parse the new plug-in stuff dynamically.
>
> Here is a simplified bit of code, gleaned from the update ConfigurationActivator.
>
>
> public void run(IAction action) {
>    List toRefresh = getUnresolvedBundles(); //Get all unresolved bundles
>    Bundle target;
>    try {
>      URL bundleURL = new URL(
>          "reference:file:"
>              + "D:/I0529/JDG2EBonusPack/plugins/com.ibm.jdg2e.mini.workplace.
> bonus_pack_3.0.0");
>      target = ConfiguratorPlugin
>          .getDefault()
>          .getPluginContext()
>          .installBundle(
>              "D:/I0529/eclipse/workspace/com.ibm.jdg2e.mini.workplace.bonus_pack/",
>              bundleURL.openStream());
>      toRefresh.add(target); // any new bundle should be refreshed as well
>      refreshPackages((Bundle[]) toRefresh
>          .toArray(new Bundle[toRefresh.size()])); //refresh all the bundles
>      // specified and their
>      // dependents.
>    } catch (Exception e) {
>      e.printStackTrace();
>    }
>    MessageDialog.openInformation(window.getShell(),
>        "Configurator Plug-in", "Bonus pack bundle was added");
>  }
>  private List getUnresolvedBundles() {
>    Bundle[] allBundles = ConfiguratorPlugin.getDefault()
>        .getPluginContext().getBundles();
>    List unresolved = new ArrayList();
>    for (int i = 0; i < allBundles.length; i++)
>      if (allBundles[i].getState() == Bundle.INSTALLED)
>        unresolved.add(allBundles[i]);
>    return unresolved;
>  }
>  private void refreshPackages(Bundle[] bundles) {
>    if (bundles.length == 0)
>      return;
>    ServiceReference packageAdminRef = ConfiguratorPlugin
>        .getDefault().getPluginContext().getServiceReference(
>            PackageAdmin.class.getName());
>    PackageAdmin packageAdmin = null;
>    if (packageAdminRef != null) {
>      packageAdmin = (PackageAdmin) ConfiguratorPlugin
>          .getDefault().getPluginContext().getService(
>              packageAdminRef);
>      if (packageAdmin == null)
>        return;
>    }
>
>    final boolean[] flag = new boolean[]{false};
>    FrameworkListener listener = new FrameworkListener() {
>      public void frameworkEvent(FrameworkEvent event) {
>        if (event.getType() == FrameworkEvent.PACKAGES_REFRESHED)
>          synchronized (flag) {
>            flag[0] = true;
>            flag.notifyAll();
>          }
>      }
>    };
>    ConfiguratorPlugin.getDefault().getPluginContext()
>        .addFrameworkListener(listener);
>    packageAdmin.refreshPackages(bundles);
>    synchronized (flag) {
>      while (!flag[0]) {
>        try {
>          flag.wait();
>        } catch (InterruptedException e) {
>        }
>      }
>    }
>    ConfiguratorPlugin.getDefault().getPluginContext()
>        .removeFrameworkListener(listener);
>    ConfiguratorPlugin.getDefault().getPluginContext()
>        .ungetService(packageAdminRef);
>  }
>
>
>    
>
> Thanks,
> Scott Fairbrother
> Eclipse/WebSphere Studio Jumpstart Team
> 607 Pinewood Dr
> Apex , NC 27502
>
> Voice : 919-367-9345  TL:  223-7851
>
> The Java Developer's Guide to Eclipse - http://www.aw.
> com/catalog/academic/product/1,4096,0321159640,00.html?type=PRE
> WebSphere Studio - http://www.ibm.com/software/ad/adstudio
> Ready for WebSphere Studio partner program - http://www.developer.ibm.
> com/websphere/ready.html

Back to the top