Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/sorting/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Eclipse rcp P2.inf:参考基于位置的更新站点_Eclipse Rcp_P2 - Fatal编程技术网

Eclipse rcp P2.inf:参考基于位置的更新站点

Eclipse rcp P2.inf:参考基于位置的更新站点,eclipse-rcp,p2,Eclipse Rcp,P2,我开发了一个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应用程序,并提供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;若用户位置为钦奈,则RCP应用程序应在chnupdates.com上查找更新

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


-Priyank

您需要以编程方式添加存储库。以下解决方案取自。另一个解决方案是使用重定向,我不确定它是否有效。定义一个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);
    }
  }
}