All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fr.perigee.commonsvfs.webdav.TimedSardineImpl Maven / Gradle / Ivy

Go to download

A Sardine-backed webdav module providing webdav access to Commons-VFS through a fast and efficient library

The newest version!
package fr.perigee.commonsvfs.webdav;

import java.net.ProxySelector;

import org.apache.http.impl.client.AbstractHttpClient;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;

import com.googlecode.sardine.Sardine;
import com.googlecode.sardine.impl.SardineImpl;

public class TimedSardineImpl extends SardineImpl implements Sardine {

	private static final String SARDINE_SOCKET_TIMEOUT = "SARDINE_SOCKET_TIMEOUT";
	private static final String SARDINE_CONNECTION_TIMEOUT = "SARDINE_CONNECTION_TIMEOUT";

	public TimedSardineImpl(AbstractHttpClient http) {
		super(http);
	}

	public TimedSardineImpl(String username, String password) {
		super(username, password);
	}

	public TimedSardineImpl(String username, String password, ProxySelector selector) {
		super(username, password, selector);
	}

	public TimedSardineImpl(AbstractHttpClient http, String username, String password) {
		super(http, username, password);
	}

	@Override
	protected HttpParams createDefaultHttpParams() {
		HttpParams returned = super.createDefaultHttpParams();
		HttpConnectionParams.setConnectionTimeout(returned, getConnectionTimeout());
		HttpConnectionParams.setSoTimeout(returned, getSocketTimeout());
		return returned;
	}

	public static int getSocketTimeout() {
		return getFromSystemProperties(SARDINE_SOCKET_TIMEOUT);
	}

	protected static int getFromSystemProperties(String timeout) {
		try {
			return Integer.parseInt(System.getProperty(timeout));
		} catch(Exception e) {
			return 60*1000;
		}
	}

	public static int getConnectionTimeout() {
		return getFromSystemProperties(SARDINE_CONNECTION_TIMEOUT);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy