Search in sources :

Example 1 with SyncContext

use of org.sonatype.aether.SyncContext in project sonatype-aether by sonatype.

the class DefaultArtifactResolver method resolveArtifacts.

public List<ArtifactResult> resolveArtifacts(RepositorySystemSession session, Collection<? extends ArtifactRequest> requests) throws ArtifactResolutionException {
    SyncContext syncContext = syncContextFactory.newInstance(session, false);
    try {
        Collection<Artifact> artifacts = new ArrayList<Artifact>(requests.size());
        for (ArtifactRequest request : requests) {
            if (request.getArtifact().getProperty(ArtifactProperties.LOCAL_PATH, null) != null) {
                continue;
            }
            artifacts.add(request.getArtifact());
        }
        syncContext.acquire(artifacts, null);
        return resolve(session, requests);
    } finally {
        syncContext.release();
    }
}
Also used : ArtifactRequest(org.sonatype.aether.resolution.ArtifactRequest) LocalArtifactRequest(org.sonatype.aether.repository.LocalArtifactRequest) ArrayList(java.util.ArrayList) SyncContext(org.sonatype.aether.SyncContext) Artifact(org.sonatype.aether.artifact.Artifact)

Example 2 with SyncContext

use of org.sonatype.aether.SyncContext in project sonatype-aether by sonatype.

the class DefaultMetadataResolver method resolveMetadata.

public List<MetadataResult> resolveMetadata(RepositorySystemSession session, Collection<? extends MetadataRequest> requests) {
    SyncContext syncContext = syncContextFactory.newInstance(session, false);
    try {
        Collection<Metadata> metadata = new ArrayList<Metadata>(requests.size());
        for (MetadataRequest request : requests) {
            metadata.add(request.getMetadata());
        }
        syncContext.acquire(null, metadata);
        return resolve(session, requests);
    } finally {
        syncContext.release();
    }
}
Also used : MetadataRequest(org.sonatype.aether.resolution.MetadataRequest) LocalMetadataRequest(org.sonatype.aether.repository.LocalMetadataRequest) Metadata(org.sonatype.aether.metadata.Metadata) ArrayList(java.util.ArrayList) SyncContext(org.sonatype.aether.SyncContext)

Aggregations

ArrayList (java.util.ArrayList)2 SyncContext (org.sonatype.aether.SyncContext)2 Artifact (org.sonatype.aether.artifact.Artifact)1 Metadata (org.sonatype.aether.metadata.Metadata)1 LocalArtifactRequest (org.sonatype.aether.repository.LocalArtifactRequest)1 LocalMetadataRequest (org.sonatype.aether.repository.LocalMetadataRequest)1 ArtifactRequest (org.sonatype.aether.resolution.ArtifactRequest)1 MetadataRequest (org.sonatype.aether.resolution.MetadataRequest)1