【问题标题】:P2.inf: refer update sites based on locationP2.inf:根据位置引用更新站点
【发布时间】:2013-03-25 21:43:08
【问题描述】:

我开发了一个 RCP 应用程序并提供 p2 更新功能。

在我的 p2.inf 中,我提供了更新站点的 url。我不希望用户添加任何站点,因此我禁用了添加站点的选项。我的 p2.inf 看起来像:

instructions.configure=\
  addRepository(type:0,location:http${#58}//blrupdates.com/Updates);\
  addRepository(type:1,location:http${#58}//blrupdates.com/Updates);

如果用户位置是班加罗尔,RCP 应用程序应该去 brlupdates.com,如果用户位置是 chennai,那么 RCP 应用程序应该在 chnupdates.com 上寻找更新。

如何在 p2.inf 中添加另一个存储库位置?

-普里扬克

【问题讨论】:

    标签: eclipse-rcp p2


    【解决方案1】:

    您需要以编程方式添加存储库。以下解决方案取自here。另一种我不确定是否可行的解决方案是使用重定向。您定义一个 p2 存储库,然后将用户重定向到基于位置的存储库。

    import org.eclipse.equinox.internal.p2.ui.model.MetadataRepositoryElement;
    import org.eclipse.equinox.internal.p2.ui.model.ElementUtils;
    
    @SuppressWarnings("restriction")
    public class P2Util {
      private static String UPDATE_SITE = "http://www.example.com/update_site";
    
      public static void setRepositories() throws InvocationTargetException {
        try {
          final MetadataRepositoryElement element = new MetadataRepositoryElement(null, new URI(UPDATE_SITE), true);
          ElementUtils.updateRepositoryUsingElements(new MetadataRepositoryElement[] {element}, null);
        } catch (URISyntaxException e) {
          e.printStackTrace();
          throw new InvocationTargetException(e);
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-04-27
      • 1970-01-01
      • 2015-09-17
      • 1970-01-01
      • 2011-03-30
      • 1970-01-01
      • 1970-01-01
      • 2014-08-12
      相关资源
      最近更新 更多