Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » P2 » How to use p2 in E4 application
How to use p2 in E4 application [message #860928] Sat, 28 April 2012 05:21 Go to next message
Gang Lao is currently offline Gang Lao
Messages: 3
Registered: April 2012
Junior Member
I try to use p2 in my e4 application, but it have no use.

1) P2Util.java
public class P2Util {
static IStatus checkForUpdates(IProvisioningAgent agent,
IProgressMonitor monitor) throws OperationCanceledException,
URISyntaxException {
ProvisioningSession session = new ProvisioningSession(agent);
UpdateOperation operation = new UpdateOperation(session);

URI uri = new URI("file:/d:/tmp/export/repository/");
URI[] artifactUris = { uri };
URI[] metadataUris = { uri };
operation.getProvisioningContext()
.setArtifactRepositories(artifactUris);
operation.getProvisioningContext()
.setMetadataRepositories(metadataUris);

SubMonitor sub = SubMonitor.convert(monitor,
"Checking for application updates...", 200);
IStatus status = operation.resolveModal(sub.newChild(100));
if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
return status;
}
if (status.getSeverity() == IStatus.CANCEL)
throw new OperationCanceledException();

if (status.getSeverity() != IStatus.ERROR) {
ProvisioningJob job = operation.getProvisioningJob(null);
status = job.runModal(sub.newChild(100));
if (status.getSeverity() == IStatus.CANCEL)
throw new OperationCanceledException();
}
return status;
}
}

2) I update the application in the LifecycleURI
@ProcessAdditions
public void update(final IProvisioningAgent agent,
final IEclipseContext context) throws Exception {
//Logger logger = context.get(Logger.class);
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor)
throws InvocationTargetException,InterruptedException {
try {
P2Util.checkForUpdates(agent, monitor);
} catch (OperationCanceledException e) {
e.printStackTrace();
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
};
new ProgressMonitorDialog(null).run(true, true, runnable);
}

Everytime after call operation.resolveModal(sub.newChild(100)), I log the Isatus,
It alway show that "INFO: org.eclipse.equinox.p2.operations code=10000 No updates were found. null"

[Updated on: Sat, 28 April 2012 05:52]

Report message to a moderator

Re: How to use p2 in E4 application [message #871472 is a reply to message #860928] Sun, 13 May 2012 23:10 Go to previous message
Gang Lao is currently offline Gang Lao
Messages: 3
Registered: April 2012
Junior Member
I did it in M7, I think the most important phase is that my product must depenen on the p2 feature "org.eclipse.equnox.p2.rcp.feature"
Previous Topic:Problem to generate some plugins in p2 format
Next Topic:RCP P2 Update results in broken product after update
Goto Forum:
  


Current Time: Wed Aug 20 22:34:13 EDT 2014

Powered by FUDForum. Page generated in 0.02144 seconds