How to use p2 in E4 application [message #860928] |
Sat, 28 April 2012 09:21 |
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 09:52] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03188 seconds