take care about performance for debug log

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1129385 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2011-05-30 21:35:23 +00:00
parent 5b823ae184
commit 949cb108d8
1 changed files with 33 additions and 27 deletions

View File

@ -58,9 +58,9 @@ import org.codehaus.plexus.registry.Registry;
import org.codehaus.plexus.registry.RegistryListener; import org.codehaus.plexus.registry.RegistryListener;
import org.codehaus.plexus.taskqueue.TaskQueueException; import org.codehaus.plexus.taskqueue.TaskQueueException;
import org.codehaus.plexus.util.SelectorUtils; import org.codehaus.plexus.util.SelectorUtils;
import org.codehaus.redback.components.springutils.ComponentContainer;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
@ -69,6 +69,7 @@ import javax.inject.Named;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -111,7 +112,7 @@ public class DefaultRepositoryProxyConnectors
private MetadataTools metadataTools; private MetadataTools metadataTools;
@Inject @Inject
private ComponentContainer componentContainer; private ApplicationContext applicationContext;
/** /**
* @plexus.requirement role="org.apache.maven.archiva.policies.PreDownloadPolicy" * @plexus.requirement role="org.apache.maven.archiva.policies.PreDownloadPolicy"
@ -156,9 +157,9 @@ public class DefaultRepositoryProxyConnectors
{ {
initConnectorsAndNetworkProxies(); initConnectorsAndNetworkProxies();
archivaConfiguration.addChangeListener( this ); archivaConfiguration.addChangeListener( this );
this.postDownloadPolicies = componentContainer.buildMapWithRole( PostDownloadPolicy.class ); this.postDownloadPolicies = applicationContext.getBeansOfType( PostDownloadPolicy.class );
this.preDownloadPolicies = componentContainer.buildMapWithRole( PreDownloadPolicy.class ); this.preDownloadPolicies = applicationContext.getBeansOfType( PreDownloadPolicy.class );
this.downloadErrorPolicies = componentContainer.buildMapWithRole( DownloadErrorPolicy.class ); this.downloadErrorPolicies = applicationContext.getBeansOfType( DownloadErrorPolicy.class );
} }
@SuppressWarnings( "unchecked" ) @SuppressWarnings( "unchecked" )
@ -290,19 +291,19 @@ public class DefaultRepositoryProxyConnectors
if ( fileExists( downloadedFile ) ) if ( fileExists( downloadedFile ) )
{ {
log.debug( "Successfully transferred: " + downloadedFile.getAbsolutePath() ); log.debug( "Successfully transferred: {}", downloadedFile.getAbsolutePath() );
return downloadedFile; return downloadedFile;
} }
} }
catch ( NotFoundException e ) catch ( NotFoundException e )
{ {
log.debug( "Artifact " + Keys.toKey( artifact ) + " not found on repository \"" log.debug( "Artifact {} not found on repository \"{}\".", Keys.toKey( artifact ),
+ targetRepository.getRepository().getId() + "\"." ); targetRepository.getRepository().getId() );
} }
catch ( NotModifiedException e ) catch ( NotModifiedException e )
{ {
log.debug( "Artifact " + Keys.toKey( artifact ) + " not updated on repository \"" log.debug( "Artifact {} not updated on repository \"{}\".", Keys.toKey( artifact ),
+ targetRepository.getRepository().getId() + "\"." ); targetRepository.getRepository().getId() );
} }
catch ( ProxyException e ) catch ( ProxyException e )
{ {
@ -317,7 +318,7 @@ public class DefaultRepositoryProxyConnectors
previousExceptions ); previousExceptions );
} }
log.debug( "Exhausted all target repositories, artifact " + Keys.toKey( artifact ) + " not found." ); log.debug( "Exhausted all target repositories, artifact {} not found.", Keys.toKey( artifact ) );
return null; return null;
} }
@ -357,20 +358,19 @@ public class DefaultRepositoryProxyConnectors
if ( fileExists( downloadedFile ) ) if ( fileExists( downloadedFile ) )
{ {
log.debug( "Successfully transferred: " + downloadedFile.getAbsolutePath() ); log.debug( "Successfully transferred: {}", downloadedFile.getAbsolutePath() );
return downloadedFile; return downloadedFile;
} }
} }
catch ( NotFoundException e ) catch ( NotFoundException e )
{ {
log.debug( "Resource " + path + " not found on repository \"" + targetRepository.getRepository().getId() log.debug( "Resource {} not found on repository \"{}\".", path,
+ "\"." ); targetRepository.getRepository().getId() );
} }
catch ( NotModifiedException e ) catch ( NotModifiedException e )
{ {
log.debug( log.debug( "Resource {} not updated on repository \"{}\".", path,
"Resource " + path + " not updated on repository \"" + targetRepository.getRepository().getId() targetRepository.getRepository().getId() );
+ "\"." );
} }
catch ( ProxyException e ) catch ( ProxyException e )
{ {
@ -381,7 +381,7 @@ public class DefaultRepositoryProxyConnectors
} }
} }
log.debug( "Exhausted all target repositories, resource " + path + " not found." ); log.debug( "Exhausted all target repositories, resource {} not found.", path );
return null; return null;
} }
@ -420,13 +420,19 @@ public class DefaultRepositoryProxyConnectors
} }
catch ( NotFoundException e ) catch ( NotFoundException e )
{ {
log.debug( "Metadata " + logicalPath + " not found on remote repository \"" if ( log.isDebugEnabled() )
+ targetRepository.getRepository().getId() + "\".", e ); {
log.debug( "Metadata " + logicalPath + " not found on remote repository \""
+ targetRepository.getRepository().getId() + "\".", e );
}
} }
catch ( NotModifiedException e ) catch ( NotModifiedException e )
{ {
log.debug( "Metadata " + logicalPath + " not updated on remote repository \"" if ( log.isDebugEnabled() )
+ targetRepository.getRepository().getId() + "\".", e ); {
log.debug( "Metadata " + logicalPath + " not updated on remote repository \""
+ targetRepository.getRepository().getId() + "\".", e );
}
} }
catch ( ProxyException e ) catch ( ProxyException e )
{ {
@ -775,7 +781,7 @@ public class DefaultRepositoryProxyConnectors
try try
{ {
transferSimpleFile( wagon, remoteRepository, remotePath + ext, repository, resource, destFile ); transferSimpleFile( wagon, remoteRepository, remotePath + ext, repository, resource, destFile );
log.debug( "Checksum " + url + " Downloaded: " + destFile + " to move to " + resource ); log.debug( "Checksum {} Downloaded: {} to move to {}", Arrays.asList( url, destFile, resource ).toArray() );
} }
catch ( NotFoundException e ) catch ( NotFoundException e )
{ {
@ -887,7 +893,7 @@ public class DefaultRepositoryProxyConnectors
String defaultSetting = policy.getDefaultOption(); String defaultSetting = policy.getDefaultOption();
String setting = StringUtils.defaultString( settings.get( key ), defaultSetting ); String setting = StringUtils.defaultString( settings.get( key ), defaultSetting );
log.debug( "Applying [" + key + "] policy with [" + setting + "]" ); log.debug( "Applying [{}] policy with [{}]", key, setting );
try try
{ {
policy.applyPolicy( setting, request, localFile ); policy.applyPolicy( setting, request, localFile );
@ -1002,8 +1008,8 @@ public class DefaultRepositoryProxyConnectors
{ {
if ( target.exists() ) if ( target.exists() )
{ {
log.debug( "Tried to copy file " + temp.getName() + " to " + target.getAbsolutePath() log.debug( "Tried to copy file {} to {} but file with this name already exists.", temp.getName(),
+ " but file with this name already exists." ); target.getAbsolutePath() );
} }
else else
{ {
@ -1062,7 +1068,7 @@ public class DefaultRepositoryProxyConnectors
if ( StringUtils.isNotBlank( username ) && StringUtils.isNotBlank( password ) ) if ( StringUtils.isNotBlank( username ) && StringUtils.isNotBlank( password ) )
{ {
log.debug( "Using username " + username + " to connect to remote repository " + remoteRepository.getURL() ); log.debug( "Using username {} to connect to remote repository {}", username, remoteRepository.getURL() );
authInfo = new AuthenticationInfo(); authInfo = new AuthenticationInfo();
authInfo.setUserName( username ); authInfo.setUserName( username );
authInfo.setPassword( password ); authInfo.setPassword( password );