<description>
The organisation info.
</description>
- </field>
+ </field>
+ <field>
+ <name>networkConfiguration</name>
+ <version>1.4.0+</version>
+ <association>
+ <type>NetworkConfiguration</type>
+ <multiplicity>1</multiplicity>
+ </association>
+ <description>
+ The NetworkConfiguration .
+ </description>
+ </field>
</fields>
<codeSegments>
<codeSegment>
</fields>
</class>
+ <class>
+ <name>NetworkConfiguration</name>
+ <version>1.4.0+</version>
+ <description>
+ The network configuration for external http request to repositories.
+ </description>
+ <fields>
+ <field>
+ <name>maxTotal</name>
+ <description>maximum total external http connections.</description>
+ <version>1.4.0+</version>
+ <type>int</type>
+ <defaultValue>30</defaultValue>
+ </field>
+ <field>
+ <name>maxTotalPerHost</name>
+ <description>maximum total external http connections per host</description>
+ <version>1.4.0+</version>
+ <type>int</type>
+ <defaultValue>30</defaultValue>
+ </field>
+ <field>
+ <name>usePooling</name>
+ <description>use or not http connection pooling default true</description>
+ <version>1.4.0+</version>
+ <type>boolean</type>
+ <defaultValue>true</defaultValue>
+ </field>
+ </fields>
+ </class>
+
</classes>
</model>
import org.apache.archiva.admin.model.admin.ArchivaAdministration;
import org.apache.archiva.admin.model.beans.FileType;
import org.apache.archiva.admin.model.beans.LegacyArtifactPath;
+import org.apache.archiva.admin.model.beans.NetworkConfiguration;
import org.apache.archiva.admin.model.beans.OrganisationInformation;
import org.apache.archiva.admin.model.beans.UiConfiguration;
{
}
+
+ public NetworkConfiguration getNetworkConfiguration()
+ throws RepositoryAdminException
+ {
+ return null;
+ }
+
+ public void setNetworkConfiguration( NetworkConfiguration networkConfiguration )
+ throws RepositoryAdminException
+ {
+
+ }
}
import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.beans.FileType;
import org.apache.archiva.admin.model.beans.LegacyArtifactPath;
+import org.apache.archiva.admin.model.beans.NetworkConfiguration;
import org.apache.archiva.admin.model.beans.OrganisationInformation;
import org.apache.archiva.admin.model.beans.UiConfiguration;
void updateUiConfiguration( UiConfiguration uiConfiguration )
throws RepositoryAdminException;
+ NetworkConfiguration getNetworkConfiguration()
+ throws RepositoryAdminException;
+
+ void setNetworkConfiguration( NetworkConfiguration networkConfiguration )
+ throws RepositoryAdminException;
+
}
--- /dev/null
+package org.apache.archiva.admin.model.beans;
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import javax.xml.bind.annotation.XmlRootElement;
+import java.io.Serializable;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+@XmlRootElement( name = "networkConfiguration" )
+public class NetworkConfiguration
+ implements Serializable
+{
+ /**
+ * maximum total external http connections.
+ */
+ private int maxTotal = 30;
+
+ /**
+ * maximum total external http connections per host.
+ */
+ private int maxTotalPerHost = 30;
+
+ private boolean usePooling = true;
+
+ public NetworkConfiguration()
+ {
+ // no op
+ }
+
+ public NetworkConfiguration( int maxTotal, int maxTotalPerHost, boolean usePooling )
+ {
+ this.maxTotal = maxTotal;
+ this.maxTotalPerHost = maxTotalPerHost;
+ this.usePooling = usePooling;
+ }
+
+ public int getMaxTotal()
+ {
+ return maxTotal;
+ }
+
+ public void setMaxTotal( int maxTotal )
+ {
+ this.maxTotal = maxTotal;
+ }
+
+ public int getMaxTotalPerHost()
+ {
+ return maxTotalPerHost;
+ }
+
+ public void setMaxTotalPerHost( int maxTotalPerHost )
+ {
+ this.maxTotalPerHost = maxTotalPerHost;
+ }
+
+ public boolean isUsePooling()
+ {
+ return usePooling;
+ }
+
+ public void setUsePooling( boolean usePooling )
+ {
+ this.usePooling = usePooling;
+ }
+
+ @Override
+ public String toString()
+ {
+ final StringBuilder sb = new StringBuilder();
+ sb.append( "NetworkConfiguration" );
+ sb.append( "{maxTotal=" ).append( maxTotal );
+ sb.append( ", maxTotalPerHost=" ).append( maxTotalPerHost );
+ sb.append( ", usePooling=" ).append( usePooling );
+ sb.append( '}' );
+ return sb.toString();
+ }
+}
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.apache.maven.wagon</groupId>
+ <artifactId>wagon-http</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
import org.apache.archiva.admin.model.admin.ArchivaAdministration;
import org.apache.archiva.admin.model.beans.FileType;
import org.apache.archiva.admin.model.beans.LegacyArtifactPath;
+import org.apache.archiva.admin.model.beans.NetworkConfiguration;
import org.apache.archiva.admin.model.beans.OrganisationInformation;
import org.apache.archiva.admin.model.beans.UiConfiguration;
import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
import org.apache.archiva.configuration.UserInterfaceOptions;
import org.apache.archiva.configuration.WebappConfiguration;
import org.apache.commons.lang.StringUtils;
+import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
+import org.apache.maven.wagon.providers.http.HttpWagon;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
new BeanReplicator().replicateBean( legacyArtifactPath, LegacyArtifactPath.class ) );
}
return legacyArtifactPaths;
-
}
public void addLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath, AuditInformation auditInformation )
}
-//-------------------------
+ public NetworkConfiguration getNetworkConfiguration()
+ throws RepositoryAdminException
+ {
+ org.apache.archiva.configuration.NetworkConfiguration networkConfiguration =
+ getArchivaConfiguration().getConfiguration().getNetworkConfiguration();
+
+ if ( networkConfiguration == null )
+ {
+ return null;
+ }
+ return new BeanReplicator().replicateBean( networkConfiguration, NetworkConfiguration.class );
+ }
+
+ public void setNetworkConfiguration( NetworkConfiguration networkConfiguration )
+ throws RepositoryAdminException
+ {
+ Configuration configuration = getArchivaConfiguration().getConfiguration();
+ if ( networkConfiguration == null )
+ {
+ configuration.setNetworkConfiguration( null );
+ // back to default values
+ HttpWagon.setUseClientManagerPooled( true );
+ ThreadSafeClientConnManager threadSafeClientConnManager = new ThreadSafeClientConnManager();
+ threadSafeClientConnManager.setDefaultMaxPerRoute( 30 );
+ threadSafeClientConnManager.setMaxTotal( 30 );
+ HttpWagon.setConnectionManagerPooled( threadSafeClientConnManager );
+
+ }
+ else
+ {
+ HttpWagon.setUseClientManagerPooled( networkConfiguration.isUsePooling() );
+ ThreadSafeClientConnManager threadSafeClientConnManager = new ThreadSafeClientConnManager();
+ 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 );
+ }
+
+ //-------------------------
//
//-------------------------
import org.apache.archiva.admin.model.admin.ArchivaAdministration;
import org.apache.archiva.admin.model.beans.FileType;
import org.apache.archiva.admin.model.beans.LegacyArtifactPath;
+import org.apache.archiva.admin.model.beans.NetworkConfiguration;
import org.apache.archiva.admin.model.beans.OrganisationInformation;
import org.apache.archiva.admin.model.beans.UiConfiguration;
import org.apache.archiva.admin.repository.AbstractRepositoryAdminTest;
assertFalse( ui.isAppletFindEnabled() );
assertFalse( ui.isShowFindArtifacts() );
}
+
+ @Test
+ public void networkConfiguration()
+ throws Exception
+ {
+ NetworkConfiguration networkConfiguration = archivaAdministration.getNetworkConfiguration();
+ assertNotNull( networkConfiguration );
+
+ assertTrue( networkConfiguration.isUsePooling() );
+ assertEquals( 30, networkConfiguration.getMaxTotal() );
+ assertEquals( 30, networkConfiguration.getMaxTotalPerHost() );
+ }
}
import org.apache.archiva.admin.model.admin.ArchivaAdministration;
import org.apache.archiva.admin.model.beans.FileType;
import org.apache.archiva.admin.model.beans.LegacyArtifactPath;
+import org.apache.archiva.admin.model.beans.NetworkConfiguration;
import org.apache.archiva.admin.model.beans.OrganisationInformation;
import org.apache.archiva.admin.model.beans.UiConfiguration;
import org.apache.archiva.configuration.ArchivaConfiguration;
public void updateUiConfiguration( UiConfiguration uiConfiguration )
throws RepositoryAdminException
{
- //To change body of implemented methods use File | Settings | File Templates.
+
+ }
+
+
+ public NetworkConfiguration getNetworkConfiguration()
+ throws RepositoryAdminException
+ {
+ return null;
+ }
+
+ public void setNetworkConfiguration( NetworkConfiguration networkConfiguration )
+ throws RepositoryAdminException
+ {
+
}
}
import org.apache.archiva.admin.model.admin.ArchivaAdministration;
import org.apache.archiva.admin.model.beans.FileType;
import org.apache.archiva.admin.model.beans.LegacyArtifactPath;
+import org.apache.archiva.admin.model.beans.NetworkConfiguration;
import org.apache.archiva.admin.model.beans.OrganisationInformation;
import org.apache.archiva.admin.model.beans.UiConfiguration;
import org.apache.archiva.configuration.ArchivaConfiguration;
{
}
+
+ public NetworkConfiguration getNetworkConfiguration()
+ throws RepositoryAdminException
+ {
+ return null;
+ }
+
+ public void setNetworkConfiguration( NetworkConfiguration networkConfiguration )
+ throws RepositoryAdminException
+ {
+
+ }
}
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.apache.httpcomponents</groupId>
+ <artifactId>httpclient</artifactId>
+ <version>4.1.2</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-provider-api</artifactId>