Repository delegate = new RepositoryAggregator(new DefaultMavenIdentityRepository(propertyProvider)); Repository repository = new DefaultPersistentRepository(propertyProvider, delegate);
The concept of a Repository is that of a persistent Resource store that can delegate to other Repositories. A typical Repository setup would look like this
Repository delegate = new RepositoryAggregator(new DefaultMavenIdentityRepository(propertyProvider)); Repository repository = new DefaultPersistentRepository(propertyProvider, delegate);
Assuming that the Repository has been populated properly, we start finding Capability providers for given Requirements.
MavenCoordinates mavenid = MavenCoordinates.parse("org.jboss.logging:jboss-logging:3.1.3.GA"); Requirement req = new MavenIdentityRequirementBuilder(mavenid).getRequirement(); Collection<Capability> providers = repository.findProviders(req); Assert.assertEquals("One provider", 1, providers.size());
The above code sample would internally do this:
Try to find providers in the local ResourceStore
If not found, delegate to the MavenIdentityRepository
If a repository delegate finds providers, add the associated Resources to the local ResourceStore
Return the Capabilities that match the given Requirements from the local ResourceStore
Subsequent requests for the same Maven identity requirement would not have to contact the Maven repository.
Adding Resources to a Repository is a matter of adding them to the associated ResourceStore
RepositoryStorage storage = repository.adapt(RepositoryStorage.class); storage.addResource(resource);