From 0aedd14607878bfcd53fec9a38ae41432d94ea9e Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Fri, 30 Sep 2011 13:37:30 +0000 Subject: [PATCH] [MRM-1526] configure http connection pool values for wagon http : configure wagon on Archiva start git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1177655 13f79535-47bb-0310-9956-ffa450edef68 --- .../admin/DefaultArchivaAdministration.java | 29 +++++++++++++++++-- .../admin/ArchivaAdministrationTest.java | 3 ++ 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java index 6a6999c8e..33727efed 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java @@ -37,6 +37,7 @@ import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager; import org.apache.maven.wagon.providers.http.HttpWagon; import org.springframework.stereotype.Service; +import javax.annotation.PostConstruct; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -49,6 +50,17 @@ public class DefaultArchivaAdministration extends AbstractRepositoryAdmin implements ArchivaAdministration { + + @PostConstruct + public void initialize() + throws RepositoryAdminException + { + // setup wagon on start with initial values + NetworkConfiguration networkConfiguration = getNetworkConfiguration(); + setupWagon( networkConfiguration ); + } + + public List getLegacyArtifactPaths() throws RepositoryAdminException { @@ -345,6 +357,20 @@ public class DefaultArchivaAdministration if ( networkConfiguration == null ) { configuration.setNetworkConfiguration( null ); + } + else + { + configuration.setNetworkConfiguration( new BeanReplicator().replicateBean( networkConfiguration, + org.apache.archiva.configuration.NetworkConfiguration.class ) ); + } + setupWagon( networkConfiguration ); + saveConfiguration( configuration ); + } + + protected void setupWagon( NetworkConfiguration networkConfiguration ) + { + if ( networkConfiguration == null ) + { // back to default values HttpWagon.setUseClientManagerPooled( true ); ThreadSafeClientConnManager threadSafeClientConnManager = new ThreadSafeClientConnManager(); @@ -360,10 +386,7 @@ public class DefaultArchivaAdministration threadSafeClientConnManager.setDefaultMaxPerRoute( networkConfiguration.getMaxTotalPerHost() ); threadSafeClientConnManager.setMaxTotal( networkConfiguration.getMaxTotal() ); HttpWagon.setConnectionManagerPooled( threadSafeClientConnManager ); - configuration.setNetworkConfiguration( new BeanReplicator().replicateBean( networkConfiguration, - org.apache.archiva.configuration.NetworkConfiguration.class ) ); } - saveConfiguration( configuration ); } //------------------------- diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java index 59165ba5c..93c8daacd 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java @@ -27,9 +27,11 @@ import org.apache.archiva.admin.model.beans.OrganisationInformation; import org.apache.archiva.admin.model.beans.UiConfiguration; import org.apache.archiva.admin.repository.AbstractRepositoryAdminTest; import org.apache.archiva.audit.AuditEvent; +import org.apache.maven.wagon.providers.http.HttpWagon; import org.junit.Test; import javax.inject.Inject; +import java.lang.reflect.Field; import java.util.Arrays; /** @@ -231,5 +233,6 @@ public class ArchivaAdministrationTest assertTrue( networkConfiguration.isUsePooling() ); assertEquals( 30, networkConfiguration.getMaxTotal() ); assertEquals( 30, networkConfiguration.getMaxTotalPerHost() ); + } } -- 2.39.5