简单的“检查更新” java中的库 [英] Simple "check for update" library in java

查看:114
本文介绍了简单的“检查更新” java中的库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Eclipse RCP,但主要是因为我完全控制了UI(删除了所有贡献,从头开始制作了首选项等)我只是无法接受所包含的UPDATE MANAGER的复杂性和需求(同样,我使用PLUGINS不是功能,应用程序插件必须提取 - 虽然我可以在最后一期发行。)

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.

逻辑方法是检查服务器上的文件(xml?)。

The logical way would be to check against a file (xml?) on a server.

那里有一个好的图书馆和例子吗?

Is there a good library and example out there?

谢谢。

推荐答案

Eclipse现在支持p2,这是一个比旧的更新管理器更灵活的系统。它可用于安装新软件并检查现有软件的更新。

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.

您可以在没有UI的情况下包含p2的自我更新部分,尽管完整的过程是包括帮助>安装新的更新在此处描述 http://wiki.eclipse.org/Equinox / p2 / Adding_Self-Update_to_an_RCP_Application

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

如果您使用某项功能,eclipse中的所有更新都更容易管理,但该功能可以标记您的RCP应用插件要扩展到目录而不是jar(它会自动执行)。

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).

将自我更新添加到任何应用程序都是非常重要的。您是一次更新所有罐子,还是只选择一个罐子?哪个罐子同时更新是有意义的?使用基于OSGi的eclipse,如何确保更新使系统处于工作状态? p2旨在帮助管理这些用例。请参阅 http://wiki.eclipse.org/P2

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

编辑:

可以使用p2 API添加简单的自我更新,而不包含任何UI代码:

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);
    }
}

这需要一点工作(也许产品必须包括更新站点),但这是基本的API。

This needs a little work (maybe the product has to include the update site), but that's the basic API.

这篇关于简单的“检查更新” java中的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆