Skip to content

Commit

Permalink
[MRESOLVER-248] Make DF and BF collector implementations coexist (#161)
Browse files Browse the repository at this point in the history
Revive replaced DF collector, and make them both coexists. Default one remains "old" DF, while new BF may be activated on demand (based on session config).
  • Loading branch information
cstamas authored Apr 8, 2022
1 parent 0dd0693 commit 4b9255b
Show file tree
Hide file tree
Showing 24 changed files with 3,104 additions and 1,349 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
import org.eclipse.aether.internal.impl.checksum.Sha256ChecksumAlgorithmFactory;
import org.eclipse.aether.internal.impl.checksum.Sha512ChecksumAlgorithmFactory;
import org.eclipse.aether.internal.impl.checksum.DefaultChecksumAlgorithmFactorySelector;
import org.eclipse.aether.internal.impl.collect.DependencyCollectorDelegate;
import org.eclipse.aether.internal.impl.collect.bf.BfDependencyCollector;
import org.eclipse.aether.internal.impl.collect.df.DfDependencyCollector;
import org.eclipse.aether.internal.impl.synccontext.DefaultSyncContextFactory;
import org.eclipse.aether.internal.impl.synccontext.named.NamedLockFactorySelector;
import org.eclipse.aether.internal.impl.synccontext.named.SimpleNamedLockFactorySelector;
Expand Down Expand Up @@ -132,8 +135,14 @@ protected void configure()
.to( DefaultRepositorySystem.class ).in( Singleton.class );
bind( ArtifactResolver.class ) //
.to( DefaultArtifactResolver.class ).in( Singleton.class );

bind( DependencyCollector.class ) //
.to( DefaultDependencyCollector.class ).in( Singleton.class );
bind( DependencyCollectorDelegate.class ).annotatedWith( Names.named( BfDependencyCollector.NAME ) )
.to( BfDependencyCollector.class ).in( Singleton.class );
bind( DependencyCollectorDelegate.class ).annotatedWith( Names.named( DfDependencyCollector.NAME ) )
.to( DfDependencyCollector.class ).in( Singleton.class );

bind( Deployer.class ) //
.to( DefaultDeployer.class ).in( Singleton.class );
bind( Installer.class ) //
Expand Down Expand Up @@ -212,6 +221,19 @@ protected void configure()

}

@Provides
@Singleton
Map<String, DependencyCollectorDelegate> dependencyCollectorDelegates(
@Named( BfDependencyCollector.NAME ) DependencyCollectorDelegate bf,
@Named( DfDependencyCollector.NAME ) DependencyCollectorDelegate df
)
{
Map<String, DependencyCollectorDelegate> dependencyCollectorDelegates = new HashMap<>();
dependencyCollectorDelegates.put( BfDependencyCollector.NAME, bf );
dependencyCollectorDelegates.put( DfDependencyCollector.NAME, df );
return dependencyCollectorDelegates;
}

@Provides
@Singleton
Map<String, ProvidedChecksumsSource> provideChecksumSources(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@
import org.eclipse.aether.artifact.ArtifactTypeRegistry;

/**
* A short-lived artifact type registry that caches results from a presumedly slower type registry.
* A short-lived artifact type registry that caches results from a presumably slower type registry.
* Internal helper class for collector implementations.
*/
class CachingArtifactTypeRegistry
public class CachingArtifactTypeRegistry
implements ArtifactTypeRegistry
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@
import org.eclipse.aether.version.VersionConstraint;

/**
* Internal helper class for collector implementations.
*/
final class DataPool
public final class DataPool
{

private static final String ARTIFACT_POOL = DataPool.class.getName() + "$Artifact";
Expand All @@ -58,7 +59,7 @@ final class DataPool

private static final String DESCRIPTORS = DataPool.class.getName() + "$Descriptors";

static final ArtifactDescriptorResult NO_DESCRIPTOR =
public static final ArtifactDescriptorResult NO_DESCRIPTOR =
new ArtifactDescriptorResult( new ArtifactDescriptorRequest() );

private ObjectPool<Artifact> artifacts;
Expand All @@ -72,7 +73,7 @@ final class DataPool
private final Map<Object, List<DependencyNode>> nodes = new HashMap<>( 256 );

@SuppressWarnings( "unchecked" )
DataPool( RepositorySystemSession session )
public DataPool( RepositorySystemSession session )
{
RepositoryCache cache = session.getCache();

Expand Down Expand Up @@ -103,7 +104,7 @@ final class DataPool

if ( descriptors == null )
{
descriptors = Collections.synchronizedMap( new WeakHashMap<Object, Descriptor>( 256 ) );
descriptors = Collections.synchronizedMap( new WeakHashMap<>( 256 ) );
if ( cache != null )
{
cache.put( session, DESCRIPTORS, descriptors );
Expand All @@ -121,12 +122,12 @@ public Dependency intern( Dependency dependency )
return dependencies.intern( dependency );
}

Object toKey( ArtifactDescriptorRequest request )
public Object toKey( ArtifactDescriptorRequest request )
{
return request.getArtifact();
}

ArtifactDescriptorResult getDescriptor( Object key, ArtifactDescriptorRequest request )
public ArtifactDescriptorResult getDescriptor( Object key, ArtifactDescriptorRequest request )
{
Descriptor descriptor = descriptors.get( key );
if ( descriptor != null )
Expand All @@ -136,22 +137,22 @@ ArtifactDescriptorResult getDescriptor( Object key, ArtifactDescriptorRequest re
return null;
}

void putDescriptor( Object key, ArtifactDescriptorResult result )
public void putDescriptor( Object key, ArtifactDescriptorResult result )
{
descriptors.put( key, new GoodDescriptor( result ) );
}

void putDescriptor( Object key, ArtifactDescriptorException e )
public void putDescriptor( Object key, ArtifactDescriptorException e )
{
descriptors.put( key, BadDescriptor.INSTANCE );
}

Object toKey( VersionRangeRequest request )
public Object toKey( VersionRangeRequest request )
{
return new ConstraintKey( request );
}

VersionRangeResult getConstraint( Object key, VersionRangeRequest request )
public VersionRangeResult getConstraint( Object key, VersionRangeRequest request )
{
Constraint constraint = constraints.get( key );
if ( constraint != null )
Expand All @@ -161,7 +162,7 @@ VersionRangeResult getConstraint( Object key, VersionRangeRequest request )
return null;
}

void putConstraint( Object key, VersionRangeResult result )
public void putConstraint( Object key, VersionRangeResult result )
{
constraints.put( key, new Constraint( result ) );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
import org.eclipse.aether.graph.Dependency;

/**
* @see DefaultDependencyCollector
* Internal helper class for collector implementations.
*/
final class DefaultDependencyCollectionContext
public final class DefaultDependencyCollectionContext
implements DependencyCollectionContext
{

Expand All @@ -41,7 +41,7 @@ final class DefaultDependencyCollectionContext

private List<Dependency> managedDependencies;

DefaultDependencyCollectionContext( RepositorySystemSession session, Artifact artifact,
public DefaultDependencyCollectionContext( RepositorySystemSession session, Artifact artifact,
Dependency dependency, List<Dependency> managedDependencies )
{
this.session = session;
Expand Down
Loading

0 comments on commit 4b9255b

Please sign in to comment.