Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » P2 » Artifact and metadata repository manager are null(Can not retrieve artifact and metadata repository manager by ServiceHelper.getService)
Artifact and metadata repository manager are null [message #717097] Fri, 19 August 2011 09:55 Go to next message
Daniel Murygin is currently offline Daniel MuryginFriend
Messages: 12
Registered: July 2010
Junior Member
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;
}


Re: Artifact and metadata repository manager are null [message #723797 is a reply to message #717097] Fri, 09 September 2011 14:12 Go to previous messageGo to next message
Daniel Murygin is currently offline Daniel MuryginFriend
Messages: 12
Registered: July 2010
Junior Member
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).
Re: Artifact and metadata repository manager are null [message #723798 is a reply to message #717097] Fri, 09 September 2011 14:13 Go to previous message
Daniel Murygin is currently offline Daniel MuryginFriend
Messages: 12
Registered: July 2010
Junior Member
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).
Previous Topic:Listing installation units in p2
Next Topic:Unable to find feature "org.eclipse.license" with version in range
Goto Forum:
  


Current Time: Fri Apr 26 05:22:48 GMT 2024

Powered by FUDForum. Page generated in 0.03053 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top