Java tutorial
/** * Copyright (c) 2000-present Liferay, Inc. All rights reserved. * * This library is free software; you can redistribute it and/or modify it under * the terms of the GNU Lesser General Public License as published by the Free * Software Foundation; either version 2.1 of the License, or (at your option) * any later version. * * This library is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. */ package com.liferay.portal.search.solr.http; import org.apache.http.auth.AuthScope; import org.apache.http.impl.conn.PoolingClientConnectionManager; /** * @author Lszl Csontos * @author Bruno Farache * @author Andr de Oliveira */ public class BasicAuthPoolingDelegatingHttpClientFactory extends DelegatingHttpClientFactory { public void afterPropertiesSet() { PoolingClientConnectionManager poolingClientConnectionManager = new PoolingClientConnectionManager(); BasicAuthPoolingHttpClientFactory basicAuthPoolingHttpClientFactory = new BasicAuthPoolingHttpClientFactory( poolingClientConnectionManager); basicAuthPoolingHttpClientFactory.setAuthScope(_authScope); basicAuthPoolingHttpClientFactory.setDefaultMaxConnectionsPerRoute(getDefaultMaxConnectionsPerRoute()); basicAuthPoolingHttpClientFactory.setHttpRequestInterceptors(getHttpRequestInterceptors()); basicAuthPoolingHttpClientFactory.setMaxTotalConnections(getMaxTotalConnections()); basicAuthPoolingHttpClientFactory.setPassword(_password); basicAuthPoolingHttpClientFactory.setUsername(_username); setHttpClientFactory(basicAuthPoolingHttpClientFactory); } public void setAuthScope(AuthScope authScope) { _authScope = authScope; } public void setPassword(String password) { _password = password; } public void setUsername(String username) { _username = username; } private AuthScope _authScope; private String _password; private String _username; }