mirror of https://github.com/apache/maven.git
o Dispatched repository events via dedicated component
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1180679 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6a227fdf4c
commit
be54d99d17
|
@ -47,7 +47,6 @@ import org.codehaus.plexus.component.annotations.Component;
|
|||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.sonatype.aether.RepositoryEvent.EventType;
|
||||
import org.sonatype.aether.RepositoryException;
|
||||
import org.sonatype.aether.RepositoryListener;
|
||||
import org.sonatype.aether.RepositorySystemSession;
|
||||
import org.sonatype.aether.RequestTrace;
|
||||
import org.sonatype.aether.artifact.Artifact;
|
||||
|
@ -58,6 +57,7 @@ import org.sonatype.aether.graph.Exclusion;
|
|||
import org.sonatype.aether.impl.ArtifactDescriptorReader;
|
||||
import org.sonatype.aether.impl.ArtifactResolver;
|
||||
import org.sonatype.aether.impl.RemoteRepositoryManager;
|
||||
import org.sonatype.aether.impl.RepositoryEventDispatcher;
|
||||
import org.sonatype.aether.impl.VersionResolver;
|
||||
import org.sonatype.aether.transfer.ArtifactNotFoundException;
|
||||
import org.sonatype.aether.util.DefaultRequestTrace;
|
||||
|
@ -101,6 +101,9 @@ public class DefaultArtifactDescriptorReader
|
|||
@Requirement
|
||||
private ArtifactResolver artifactResolver;
|
||||
|
||||
@Requirement
|
||||
private RepositoryEventDispatcher repositoryEventDispatcher;
|
||||
|
||||
@Requirement
|
||||
private ModelBuilder modelBuilder;
|
||||
|
||||
|
@ -110,6 +113,7 @@ public class DefaultArtifactDescriptorReader
|
|||
setRemoteRepositoryManager( locator.getService( RemoteRepositoryManager.class ) );
|
||||
setVersionResolver( locator.getService( VersionResolver.class ) );
|
||||
setArtifactResolver( locator.getService( ArtifactResolver.class ) );
|
||||
setRepositoryEventDispatcher( locator.getService( RepositoryEventDispatcher.class ) );
|
||||
modelBuilder = locator.getService( ModelBuilder.class );
|
||||
if ( modelBuilder == null )
|
||||
{
|
||||
|
@ -153,6 +157,16 @@ public class DefaultArtifactDescriptorReader
|
|||
return this;
|
||||
}
|
||||
|
||||
public DefaultArtifactDescriptorReader setRepositoryEventDispatcher( RepositoryEventDispatcher repositoryEventDispatcher )
|
||||
{
|
||||
if ( repositoryEventDispatcher == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "repository event dispatcher has not been specified" );
|
||||
}
|
||||
this.repositoryEventDispatcher = repositoryEventDispatcher;
|
||||
return this;
|
||||
}
|
||||
|
||||
public DefaultArtifactDescriptorReader setModelBuilder( ModelBuilder modelBuilder )
|
||||
{
|
||||
if ( modelBuilder == null )
|
||||
|
@ -407,29 +421,23 @@ public class DefaultArtifactDescriptorReader
|
|||
private void missingDescriptor( RepositorySystemSession session, RequestTrace trace, Artifact artifact,
|
||||
Exception exception )
|
||||
{
|
||||
RepositoryListener listener = session.getRepositoryListener();
|
||||
if ( listener != null )
|
||||
{
|
||||
DefaultRepositoryEvent event =
|
||||
new DefaultRepositoryEvent( EventType.ARTIFACT_DESCRIPTOR_MISSING, session, trace );
|
||||
event.setArtifact( artifact );
|
||||
event.setException( exception );
|
||||
listener.artifactDescriptorMissing( event );
|
||||
}
|
||||
DefaultRepositoryEvent event =
|
||||
new DefaultRepositoryEvent( EventType.ARTIFACT_DESCRIPTOR_MISSING, session, trace );
|
||||
event.setArtifact( artifact );
|
||||
event.setException( exception );
|
||||
|
||||
repositoryEventDispatcher.dispatch( event );
|
||||
}
|
||||
|
||||
private void invalidDescriptor( RepositorySystemSession session, RequestTrace trace, Artifact artifact,
|
||||
Exception exception )
|
||||
{
|
||||
RepositoryListener listener = session.getRepositoryListener();
|
||||
if ( listener != null )
|
||||
{
|
||||
DefaultRepositoryEvent event =
|
||||
new DefaultRepositoryEvent( EventType.ARTIFACT_DESCRIPTOR_INVALID, session, trace );
|
||||
event.setArtifact( artifact );
|
||||
event.setException( exception );
|
||||
listener.artifactDescriptorInvalid( event );
|
||||
}
|
||||
DefaultRepositoryEvent event =
|
||||
new DefaultRepositoryEvent( EventType.ARTIFACT_DESCRIPTOR_INVALID, session, trace );
|
||||
event.setArtifact( artifact );
|
||||
event.setException( exception );
|
||||
|
||||
repositoryEventDispatcher.dispatch( event );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.codehaus.plexus.component.annotations.Component;
|
|||
import org.codehaus.plexus.component.annotations.Requirement;
|
||||
import org.codehaus.plexus.util.IOUtil;
|
||||
import org.sonatype.aether.RepositoryEvent.EventType;
|
||||
import org.sonatype.aether.RepositoryListener;
|
||||
import org.sonatype.aether.RepositorySystemSession;
|
||||
import org.sonatype.aether.RequestTrace;
|
||||
import org.sonatype.aether.SyncContext;
|
||||
|
@ -45,6 +44,7 @@ import org.sonatype.aether.version.Version;
|
|||
import org.sonatype.aether.version.VersionConstraint;
|
||||
import org.sonatype.aether.version.VersionScheme;
|
||||
import org.sonatype.aether.impl.MetadataResolver;
|
||||
import org.sonatype.aether.impl.RepositoryEventDispatcher;
|
||||
import org.sonatype.aether.impl.SyncContextFactory;
|
||||
import org.sonatype.aether.impl.VersionRangeResolver;
|
||||
import org.sonatype.aether.metadata.Metadata;
|
||||
|
@ -81,11 +81,15 @@ public class DefaultVersionRangeResolver
|
|||
@Requirement
|
||||
private SyncContextFactory syncContextFactory;
|
||||
|
||||
@Requirement
|
||||
private RepositoryEventDispatcher repositoryEventDispatcher;
|
||||
|
||||
public void initService( ServiceLocator locator )
|
||||
{
|
||||
setLogger( locator.getService( Logger.class ) );
|
||||
setMetadataResolver( locator.getService( MetadataResolver.class ) );
|
||||
setSyncContextFactory( locator.getService( SyncContextFactory.class ) );
|
||||
setRepositoryEventDispatcher( locator.getService( RepositoryEventDispatcher.class ) );
|
||||
}
|
||||
|
||||
public DefaultVersionRangeResolver setLogger( Logger logger )
|
||||
|
@ -114,6 +118,16 @@ public class DefaultVersionRangeResolver
|
|||
return this;
|
||||
}
|
||||
|
||||
public DefaultVersionRangeResolver setRepositoryEventDispatcher( RepositoryEventDispatcher repositoryEventDispatcher )
|
||||
{
|
||||
if ( repositoryEventDispatcher == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "repository event dispatcher has not been specified" );
|
||||
}
|
||||
this.repositoryEventDispatcher = repositoryEventDispatcher;
|
||||
return this;
|
||||
}
|
||||
|
||||
public VersionRangeResult resolveVersionRange( RepositorySystemSession session, VersionRangeRequest request )
|
||||
throws VersionRangeResolutionException
|
||||
{
|
||||
|
@ -271,15 +285,12 @@ public class DefaultVersionRangeResolver
|
|||
private void invalidMetadata( RepositorySystemSession session, RequestTrace trace, Metadata metadata,
|
||||
ArtifactRepository repository, Exception exception )
|
||||
{
|
||||
RepositoryListener listener = session.getRepositoryListener();
|
||||
if ( listener != null )
|
||||
{
|
||||
DefaultRepositoryEvent event = new DefaultRepositoryEvent( EventType.METADATA_INVALID, session, trace );
|
||||
event.setMetadata( metadata );
|
||||
event.setException( exception );
|
||||
event.setRepository( repository );
|
||||
listener.metadataInvalid( event );
|
||||
}
|
||||
DefaultRepositoryEvent event = new DefaultRepositoryEvent( EventType.METADATA_INVALID, session, trace );
|
||||
event.setMetadata( metadata );
|
||||
event.setException( exception );
|
||||
event.setRepository( repository );
|
||||
|
||||
repositoryEventDispatcher.dispatch( event );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ import org.sonatype.aether.ConfigurationProperties;
|
|||
import org.sonatype.aether.RepositoryCache;
|
||||
import org.sonatype.aether.RequestTrace;
|
||||
import org.sonatype.aether.RepositoryEvent.EventType;
|
||||
import org.sonatype.aether.RepositoryListener;
|
||||
import org.sonatype.aether.RepositorySystemSession;
|
||||
import org.sonatype.aether.SyncContext;
|
||||
import org.sonatype.aether.util.DefaultRequestTrace;
|
||||
|
@ -48,6 +47,7 @@ import org.sonatype.aether.util.listener.DefaultRepositoryEvent;
|
|||
import org.sonatype.aether.util.metadata.DefaultMetadata;
|
||||
import org.sonatype.aether.artifact.Artifact;
|
||||
import org.sonatype.aether.impl.MetadataResolver;
|
||||
import org.sonatype.aether.impl.RepositoryEventDispatcher;
|
||||
import org.sonatype.aether.impl.SyncContextFactory;
|
||||
import org.sonatype.aether.impl.VersionResolver;
|
||||
import org.sonatype.aether.impl.internal.CacheUtils;
|
||||
|
@ -93,11 +93,15 @@ public class DefaultVersionResolver
|
|||
@Requirement
|
||||
private SyncContextFactory syncContextFactory;
|
||||
|
||||
@Requirement
|
||||
private RepositoryEventDispatcher repositoryEventDispatcher;
|
||||
|
||||
public void initService( ServiceLocator locator )
|
||||
{
|
||||
setLogger( locator.getService( Logger.class ) );
|
||||
setMetadataResolver( locator.getService( MetadataResolver.class ) );
|
||||
setSyncContextFactory( locator.getService( SyncContextFactory.class ) );
|
||||
setRepositoryEventDispatcher( locator.getService( RepositoryEventDispatcher.class ) );
|
||||
}
|
||||
|
||||
public DefaultVersionResolver setLogger( Logger logger )
|
||||
|
@ -126,6 +130,16 @@ public class DefaultVersionResolver
|
|||
return this;
|
||||
}
|
||||
|
||||
public DefaultVersionResolver setRepositoryEventDispatcher( RepositoryEventDispatcher repositoryEventDispatcher )
|
||||
{
|
||||
if ( repositoryEventDispatcher == null )
|
||||
{
|
||||
throw new IllegalArgumentException( "repository event dispatcher has not been specified" );
|
||||
}
|
||||
this.repositoryEventDispatcher = repositoryEventDispatcher;
|
||||
return this;
|
||||
}
|
||||
|
||||
public VersionResult resolveVersion( RepositorySystemSession session, VersionRequest request )
|
||||
throws VersionResolutionException
|
||||
{
|
||||
|
@ -361,15 +375,12 @@ public class DefaultVersionResolver
|
|||
private void invalidMetadata( RepositorySystemSession session, RequestTrace trace, Metadata metadata,
|
||||
ArtifactRepository repository, Exception exception )
|
||||
{
|
||||
RepositoryListener listener = session.getRepositoryListener();
|
||||
if ( listener != null )
|
||||
{
|
||||
DefaultRepositoryEvent event = new DefaultRepositoryEvent( EventType.METADATA_INVALID, session, trace );
|
||||
event.setMetadata( metadata );
|
||||
event.setException( exception );
|
||||
event.setRepository( repository );
|
||||
listener.metadataInvalid( event );
|
||||
}
|
||||
DefaultRepositoryEvent event = new DefaultRepositoryEvent( EventType.METADATA_INVALID, session, trace );
|
||||
event.setMetadata( metadata );
|
||||
event.setException( exception );
|
||||
event.setRepository( repository );
|
||||
|
||||
repositoryEventDispatcher.dispatch( event );
|
||||
}
|
||||
|
||||
private void merge( Artifact artifact, Map<String, VersionInfo> infos, Versioning versioning,
|
||||
|
|
Loading…
Reference in New Issue