简体   繁体   English

在java中简单的“检查更新”库

[英]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). 我正在使用Eclipse RCP,但主要是因为我完全控制了UI(删除了所有贡献,从头开始制作了首选项等)我只是不能接受所包含的UPDATE MANAGER的复杂性和要求(另外,我使用PLUGINS而不是功能,应用程序插件必须提取 - 虽然我可以得到最后一期的问题)。

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. 逻辑方法是检查服务器上的文件(xml?)。

Is there a good library and example out there? 那里有一个很好的图书馆和例子吗?

Thanks. 谢谢。

Eclipse now supports p2, a much more flexible system over the old update manager. Eclipse现在支持p2,这是一个比旧的更新管理器更灵活的系统。 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 您可以在没有UI的情况下包含p2的自我更新部分,尽管此处描述了包含帮助>安装新更新的完整过程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). 如果您使用某项功能,eclipse中的所有更新都更容易管理,但该功能可以将您的RCP应用插件标记为扩展到目录而不是jar(它会自动执行)。

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? 使用基于OSGi的eclipse,如何确保更新使系统处于工作状态? p2 was built to help manage these usecases. p2旨在帮助管理这些用例。 See http://wiki.eclipse.org/P2 http://wiki.eclipse.org/P2

Edit: 编辑:

Simple self-updating can be added using the p2 API without including any of the UI code: 可以使用p2 API添加简单的自我更新,而不包含任何UI代码:

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. 这需要一点工作(可能产品必须包含更新站点),但这是基本的API。

Use Java Web Start to launch the app. 使用Java Web Start启动应用程序。 Auto-update is one of the main features of JWS. 自动更新是JWS的主要功能之一。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM