Simple "check for update" library in java
I'm using Eclipse RCP, but, mainly because i have total control of the UI (removed all contributions, made Preferences from scratch, etc) i just cannot accept the complexity and demand of the included UPDATE MANAGER (also, i use PLUGINS not features, and the app Plugin must be EXTRACTED - though i could get arround this last issue).
Anyway, on a first approach i just want to check IF there is a newer version of the app available.
The logical way would be to check against a file (xml?) on a server.
Is there a good library and example out there?
开发者_运维问答Thanks.
Eclipse now supports p2, a much more flexible system over the old update manager. It can be used to install new software and check for updates on existing software.
You can include the self-updating portion of p2 with no UI, although the full process that includes the Help>Install New updates is described here http://wiki.eclipse.org/Equinox/p2/Adding_Self-Update_to_an_RCP_Application
All updates in eclipse are easier to manager if you use a feature, but the feature is where you can mark your RCP app plugin to be expanded to a directory instead of as a jar (it'll do it automatically).
Adding self-updating to any app is non-trivial. Do you update all jars at once, or only select ones? Which jars does it make sense to update at the same time? With eclipse based on OSGi, how do you make sure that your update leaves your system in a working state? p2 was built to help manage these usecases. See http://wiki.eclipse.org/P2
Edit:
Simple self-updating can be added using the p2 API without including any of the UI code:
public class SelfUpdateOperation {
public static void update() {
BundleContext context = FrameworkUtil.getBundle(
SelfUpdateOperation.class).getBundleContext();
ServiceReference<?> reference = context
.getServiceReference(IProvisioningAgent.SERVICE_NAME);
if (reference == null)
return;
Object obj = context.getService(reference);
IProvisioningAgent agent = (IProvisioningAgent) obj;
ProvisioningSession session = new ProvisioningSession(agent);
UpdateOperation update = new UpdateOperation(session);
IStatus result = update.resolveModal(new NullProgressMonitor());
if (result.isOK()) {
update.getProvisioningJob(new NullProgressMonitor()).schedule();
} else {
// can't update for some reason
}
context.ungetService(reference);
}
}
This needs a little work (maybe the product has to include the update site), but that's the basic API.
Use Java Web Start to launch the app. Auto-update is one of the main features of JWS.
精彩评论