工件和元数据存储库管理器为空

发布于 2024-11-30 06:19:04 字数 889 浏览 1 评论 0原文

我尝试加载工件和元数据存储库管理器,如下所示

private IArtifactRepositoryManager getArtifactRepositoryManager() {
  IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) 
     ServiceHelper.getService(ProvUIActivator.getContext(),
     IArtifactRepositoryManager.class.getName());
  if(artifactManager == null) {
    LOG.error("ArtifactRepositoryManager service nor found");
  }
  return artifactManager;
}

ServiceHelper 始终返回 null。还有其他方法来获取存储库管理器吗?我正在使用 Eclipse/RCP 3.7 (Indigo)。

我之前使用过 Eclipse 3.5 中的捆绑包,并且使用此代码一切正常:

private IMetadataRepositoryManager getMetadataRepositoryManager() {
  //Load repository manager
  IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) context.getService(
      context.getServiceReference(IMetadataRepositoryManager.class.getName()));
  return metadataManager;
}

I try to load an artifact and metadata repository manager as follows

private IArtifactRepositoryManager getArtifactRepositoryManager() {
  IArtifactRepositoryManager artifactManager = (IArtifactRepositoryManager) 
     ServiceHelper.getService(ProvUIActivator.getContext(),
     IArtifactRepositoryManager.class.getName());
  if(artifactManager == null) {
    LOG.error("ArtifactRepositoryManager service nor found");
  }
  return artifactManager;
}

ServiceHelper always returns null. Is there another way to get the repository managers? I'm using Eclipse/RCP 3.7 (Indigo).

I used bundles from Eclipse 3.5 before and everything works fine with this code:

private IMetadataRepositoryManager getMetadataRepositoryManager() {
  //Load repository manager
  IMetadataRepositoryManager metadataManager = (IMetadataRepositoryManager) context.getService(
      context.getServiceReference(IMetadataRepositoryManager.class.getName()));
  return metadataManager;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

十秒萌定你 2024-12-07 06:19:04

我认为解决方案是确保 p2 插件在您的插件启动之前启动。在您的产品配置中相应地设置自动启动级别。

<configurations>
  <plugin id="my.plugin" autoStart="false" startLevel="7" />
  <plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="6" />
  <plugin id="org.eclipse.equinox.p2.core" autoStart="true" startLevel="5" />
</configurations>

I think the solution is to make sure the p2 plug-ins start before your plug-in starts. Set the auto-start levels in your product configuration accordingly.

<configurations>
  <plugin id="my.plugin" autoStart="false" startLevel="7" />
  <plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="6" />
  <plugin id="org.eclipse.equinox.p2.core" autoStart="true" startLevel="5" />
</configurations>
薯片软お妹 2024-12-07 06:19:04

我通过阅读“可用软件站点”首选项页面的源代码找到了解决方案。这很简单,但您找不到任何有关它的文档:

final ProvisioningUI ui = ProvUIActivator.getDefault().getProvisioningUI();
IArtifactRepositoryManager artifactManager = ProvUI.getArtifactRepositoryManager(ui.getSession());
artifactManager.addRepository(new URI(UPDATE_SITE_URL);

IMetadataRepositoryManager metadataManager = ProvUI.getMetadataRepositoryManager(ui.getSession());
metadataManager.addRepository(new URI(UPDATE_SITE_URL);

这适用于 Eclipse 3.7。对于 ProvUIProvisioningUI,您必须导入包 org.eclipse.equinox.p2.uiorg.eclipse.equinox.p2 .操作(等等)。

I found a solution by reading the source code of the "Available Software Sites" preference page. It's easy but you can't find any documentation about it:

final ProvisioningUI ui = ProvUIActivator.getDefault().getProvisioningUI();
IArtifactRepositoryManager artifactManager = ProvUI.getArtifactRepositoryManager(ui.getSession());
artifactManager.addRepository(new URI(UPDATE_SITE_URL);

IMetadataRepositoryManager metadataManager = ProvUI.getMetadataRepositoryManager(ui.getSession());
metadataManager.addRepository(new URI(UPDATE_SITE_URL);

This works with Eclipse 3.7. For ProvUI and ProvisioningUI you have to import bundles org.eclipse.equinox.p2.ui and org.eclipse.equinox.p2.operations (among others).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文