Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [p2-dev] Complete installation without restart

Thanks Mickael for the clue!

I finally been able to get it working thanks to stuff in ProvisioningOperationRunner.requestRestart(...)

 

Sharing hereafter the raw code of my snippet in case it can helps in the future, the 2 missing lines were those about  Policy.RESTART_POLICY_FORCE_APPLY.

 

ProvisioningUI ui = ProvisioningUI.getDefaultUI();

InstallOperation installOperation = ui.getInstallOperation(toInstall, repositories);

IStatus status = installOperation.resolveModal(monitor);

if (status.isOK()) {

       ProvisioningJob job = installOperation.getProvisioningJob(monitor);

       ui.getPolicy().setRestartPolicy(Policy.RESTART_POLICY_FORCE_APPLY);

       ui.manageJob(job, Policy.RESTART_POLICY_FORCE_APPLY);

 

       job.addJobChangeListener(new JobChangeAdapter() {

              public void done(IJobChangeEvent event) {

                     if (event.getResult().isOK()) {

                           Bundle bundle = Platform.getBundle(...);

                           if (bundle != null) {

                                  bundle.start();

                           }

                     }

              }

       });

       job.setUser(user);

       job.schedule();

}

 

/Julien

 

From: p2-dev-bounces@xxxxxxxxxxx <p2-dev-bounces@xxxxxxxxxxx> On Behalf Of Mickael Istria
Sent: vendredi 17 janvier 2020 09:37
To: P2 developer discussions <p2-dev@xxxxxxxxxxx>
Subject: Re: [p2-dev] Complete installation without restart

 

 

 

On Fri, Jan 17, 2020 at 9:29 AM Julien DEHAUDT <julien.dehaudt@xxxxxx> wrote:

Hi gents,

 

Hi, 

 

 I’m wondering if there is a way to force the enablement of a plugin freshly installed without restarting Eclipse?

 

It's possible using p2 APIs. However, not something I can remember now.

 

 

They're indeed outdated. What can make a plugin dynamic enough is mostly whether the extension point provider (the plugin that defines the extension point and reads the extension) does implement listening to change in the extension registry. Same thing for loading services from context or OSGi (although I believe OSGi does natively has dynamism for services).

 

I remember that in the past there was an “Apply changes” button after an installation, this is somehow what I try to restore for a specific installation.

 

Beware this was removed because in many cases, the result was incomplete or not satisfying: old extensions where remaining and failing, new ones ignored (because some plugins only look at extension registry once). Those are issues that would be relatively hard to avoid, so be careful.

 

Installation already done programmatically (feature well installed if I restart the rcp), I’m just missing the last rocket floor J

 

I don't recall the exact API. I suggest you look at the history of the installation complete notification dialog, find a version when "Apply" was still here and then see what it was bound to.

 

HTH


Back to the top