From f2e9b6ad91fed96b0d0f91fd8abd680ef5aa9f82 Mon Sep 17 00:00:00 2001 From: Maarten Coene Date: Thu, 21 Jun 2007 21:41:21 +0000 Subject: [PATCH] IMPROVEMENT: Upgraded VFS dependency to 1.0 and removed dependency on VFS-sandbox (IVY-498) git-svn-id: https://svn.apache.org/repos/asf/incubator/ivy/core/trunk@549622 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 1 + ivy.xml | 3 +- ivysettings.xml | 22 +- .../vfs/IvyWebdavClientFactory.java | 87 ------- .../vfs/IvyWebdavConnectionManager.java | 225 ------------------ .../repository/vfs/IvyWebdavFileProvider.java | 48 ---- .../repository/vfs/IvyWebdavFileSystem.java | 34 --- .../ivy/plugins/repository/vfs/ivy_vfs.xml | 8 - 8 files changed, 3 insertions(+), 425 deletions(-) delete mode 100644 src/java/org/apache/ivy/plugins/repository/vfs/IvyWebdavClientFactory.java delete mode 100644 src/java/org/apache/ivy/plugins/repository/vfs/IvyWebdavConnectionManager.java delete mode 100644 src/java/org/apache/ivy/plugins/repository/vfs/IvyWebdavFileProvider.java delete mode 100644 src/java/org/apache/ivy/plugins/repository/vfs/IvyWebdavFileSystem.java diff --git a/CHANGES.txt b/CHANGES.txt index 55b51314..196f0861 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -53,6 +53,7 @@ for detailed view of each issue, please consult http://issues.apache.org/jira/br - NEW: A checkstyle report is generated (IVY-483) (thanks to Jan Materne) - NEW: Hide private or specific conf when publishing (IVY-77) +- IMPROVEMENT: Upgraded VFS dependency to 1.0 and removed dependency on VFS-sandbox (IVY-498) - IMPROVEMENT: Use maven2 repository to download dependencies - IMPROVEMENT: Allow "main" parameters to be passed directly (instead of using -args flag) (IVY-480) (thanks to Archie Cobbs) - IMPROVEMENT: Remove @author tags (thanks to Stephane Bailliez) diff --git a/ivy.xml b/ivy.xml index b1223b74..c5e9ddc3 100644 --- a/ivy.xml +++ b/ivy.xml @@ -26,7 +26,6 @@ - @@ -45,7 +44,7 @@ - + diff --git a/ivysettings.xml b/ivysettings.xml index aa9ee458..f030a4b5 100644 --- a/ivysettings.xml +++ b/ivysettings.xml @@ -20,26 +20,6 @@ - - - - - - - + - - - - - - - - - - - - - - diff --git a/src/java/org/apache/ivy/plugins/repository/vfs/IvyWebdavClientFactory.java b/src/java/org/apache/ivy/plugins/repository/vfs/IvyWebdavClientFactory.java deleted file mode 100644 index 3bfe59a9..00000000 --- a/src/java/org/apache/ivy/plugins/repository/vfs/IvyWebdavClientFactory.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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. - * - */ -package org.apache.ivy.plugins.repository.vfs; - -import java.io.IOException; - -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.httpclient.HttpURL; -import org.apache.commons.vfs.FileSystemException; -import org.apache.commons.vfs.FileSystemOptions; -import org.apache.commons.vfs.provider.webdav.WebdavConnectionManager; -import org.apache.commons.vfs.provider.webdav.WebdavFileSystemConfigBuilder; -import org.apache.ivy.util.url.HttpClientHandler; -import org.apache.webdav.lib.WebdavResource; - -/*************************************************************************************************** - * Modified version of the WebdavClientFactory from VFS which adds support for httpclient 3.x. See - * http://issues.apache.org/jira/browse/VFS-74 for more info. Create a HttpClient instance - */ -class IvyWebdavClientFactory { - - private IvyWebdavClientFactory() { - } - - /*********************************************************************************************** - * Creates a new connection to the server. - */ - public static HttpClient createConnection(String hostname, int port, String username, - String password, FileSystemOptions fileSystemOptions) throws FileSystemException { - // Create an Http client - HttpClient client; - try { - final HttpURL url = new HttpURL(username, password, hostname, port, "/"); - - // WebdavResource resource = null; - WebdavResource resource = new WebdavResource() { - }; - - if (fileSystemOptions != null) { - String proxyHost = WebdavFileSystemConfigBuilder.getInstance().getProxyHost( - fileSystemOptions); - int proxyPort = WebdavFileSystemConfigBuilder.getInstance().getProxyPort( - fileSystemOptions); - - if (proxyHost != null && proxyPort > 0) { - // resource = new WebdavResource(url, proxyHost, proxyPort); - resource.setProxy(proxyHost, proxyPort); - } - } - - /* - * if (resource == null) { resource = new WebdavResource(url); } - * resource.setProperties(WebdavResource.NOACTION, 1); - */ - resource.setHttpURL(url, WebdavResource.NOACTION, 1); - - client = resource.retrieveSessionInstance(); - HttpClientHandler handler = new HttpClientHandler(); - int httpClientVersion = handler.getHttpClientMajorVersion(); - if (httpClientVersion == 2) { - // VFS only supports httpclient v2 for now... - client.setHttpConnectionManager(new WebdavConnectionManager()); - } else { - client.setHttpConnectionManager(new IvyWebdavConnectionManager()); - } - } catch (final IOException e) { - throw new FileSystemException("vfs.provider.webdav/connect.error", hostname, e); - } - - return client; - } -} diff --git a/src/java/org/apache/ivy/plugins/repository/vfs/IvyWebdavConnectionManager.java b/src/java/org/apache/ivy/plugins/repository/vfs/IvyWebdavConnectionManager.java deleted file mode 100644 index 095ee734..00000000 --- a/src/java/org/apache/ivy/plugins/repository/vfs/IvyWebdavConnectionManager.java +++ /dev/null @@ -1,225 +0,0 @@ -/* - * 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. - * - */ -package org.apache.ivy.plugins.repository.vfs; - -import java.io.IOException; -import java.io.InputStream; - -import org.apache.commons.httpclient.HostConfiguration; -import org.apache.commons.httpclient.HttpConnection; -import org.apache.commons.httpclient.HttpConnectionManager; -import org.apache.commons.httpclient.params.HttpConnectionManagerParams; - -/** - * Modified version of the WebdavConnectionManager from VFS which adds support for httpclient 3.x. - * See http://issues.apache.org/jira/browse/VFS-74 for more info. A connection manager that provides - * access to a single HttpConnection. This manager makes no attempt to provide exclusive access to - * the contained HttpConnection.

imario@apache.org: Keep connection in ThreadLocal. - */ -class IvyWebdavConnectionManager implements HttpConnectionManager { - - /** - * Since the same connection is about to be reused, make sure the previous request was - * completely processed, and if not consume it now. - * - * @param conn - * The connection - */ - static void finishLastResponse(HttpConnection conn) { - InputStream lastResponse = conn.getLastResponseInputStream(); - if (lastResponse != null) { - conn.setLastResponseInputStream(null); - try { - lastResponse.close(); - } catch (IOException ioe) { - // FIXME: badness - close to force reconnect. - conn.close(); - } - } - } - - /** - * The thread data - */ - protected ThreadLocal localHttpConnection = new ThreadLocal() { - protected Object initialValue() { - return new Entry(); - } - }; - - /** - * Collection of parameters associated with this connection manager. - */ - private HttpConnectionManagerParams params = new HttpConnectionManagerParams(); - - /** - * release the connection of the current thread - */ - public void releaseLocalConnection() { - if (getLocalHttpConnection() != null) { - releaseConnection(getLocalHttpConnection()); - } - } - - private static class Entry { - /** - * The http connection - */ - private HttpConnection conn = null; - - /** - * The time the connection was made idle. - */ - private long idleStartTime = Long.MAX_VALUE; - } - - public IvyWebdavConnectionManager() { - } - - protected HttpConnection getLocalHttpConnection() { - return ((Entry) localHttpConnection.get()).conn; - } - - protected void setLocalHttpConnection(HttpConnection conn) { - ((Entry) localHttpConnection.get()).conn = conn; - } - - protected long getIdleStartTime() { - return ((Entry) localHttpConnection.get()).idleStartTime; - } - - protected void setIdleStartTime(long idleStartTime) { - ((Entry) localHttpConnection.get()).idleStartTime = idleStartTime; - } - - /** - * @see HttpConnectionManager#getConnection(org.apache.commons.httpclient.HostConfiguration) - */ - public HttpConnection getConnection(HostConfiguration hostConfiguration) { - return getConnection(hostConfiguration, 0); - } - - /** - * Gets the staleCheckingEnabled value to be set on HttpConnections that are created. - * - * @return true if stale checking will be enabled on HttpConections - * @see HttpConnection#isStaleCheckingEnabled() - */ - public boolean isConnectionStaleCheckingEnabled() { - return this.params.isStaleCheckingEnabled(); - } - - /** - * Sets the staleCheckingEnabled value to be set on HttpConnections that are created. - * - * @param connectionStaleCheckingEnabled - * true if stale checking will be enabled on HttpConections - * @see HttpConnection#setStaleCheckingEnabled(boolean) - */ - public void setConnectionStaleCheckingEnabled(boolean connectionStaleCheckingEnabled) { - this.params.setStaleCheckingEnabled(connectionStaleCheckingEnabled); - } - - /** - * @see HttpConnectionManager#getConnection(HostConfiguration, long) - * @since 3.0 - */ - public HttpConnection getConnectionWithTimeout(HostConfiguration hostConfiguration, long timeout) { - - HttpConnection httpConnection = getLocalHttpConnection(); - if (httpConnection == null) { - httpConnection = new HttpConnection(hostConfiguration); - setLocalHttpConnection(httpConnection); - httpConnection.setHttpConnectionManager(this); - httpConnection.getParams().setDefaults(this.params); - } else { - - // make sure the host and proxy are correct for this connection - // close it and set the values if they are not - if (!hostConfiguration.hostEquals(httpConnection) - || !hostConfiguration.proxyEquals(httpConnection)) { - - if (httpConnection.isOpen()) { - httpConnection.close(); - } - - httpConnection.setHost(hostConfiguration.getHost()); - httpConnection.setPort(hostConfiguration.getPort()); - httpConnection.setProtocol(hostConfiguration.getProtocol()); - httpConnection.setLocalAddress(hostConfiguration.getLocalAddress()); - - httpConnection.setProxyHost(hostConfiguration.getProxyHost()); - httpConnection.setProxyPort(hostConfiguration.getProxyPort()); - } else { - finishLastResponse(httpConnection); - } - } - - // remove the connection from the timeout handler - setIdleStartTime(Long.MAX_VALUE); - - return httpConnection; - } - - /** - * @see HttpConnectionManager#getConnection(HostConfiguration, long) - * @deprecated Use #getConnectionWithTimeout(HostConfiguration, long) - */ - public HttpConnection getConnection(HostConfiguration hostConfiguration, long timeout) { - return getConnectionWithTimeout(hostConfiguration, timeout); - } - - /** - * @see HttpConnectionManager#releaseConnection(org.apache.commons.httpclient.HttpConnection) - */ - public void releaseConnection(HttpConnection conn) { - if (conn != getLocalHttpConnection()) { - throw new IllegalStateException("Unexpected release of an unknown connection."); - } - - finishLastResponse(getLocalHttpConnection()); - - // track the time the connection was made idle - setIdleStartTime(System.currentTimeMillis()); - } - - /** - * @since 3.0 - */ - public void closeIdleConnections(long idleTimeout) { - long maxIdleTime = System.currentTimeMillis() - idleTimeout; - if (getIdleStartTime() <= maxIdleTime) { - getLocalHttpConnection().close(); - } - } - - /** - * {@inheritDoc} - */ - public HttpConnectionManagerParams getParams() { - return params; - } - - /** - * {@inheritDoc} - */ - public void setParams(HttpConnectionManagerParams params) { - this.params = params; - } - -} diff --git a/src/java/org/apache/ivy/plugins/repository/vfs/IvyWebdavFileProvider.java b/src/java/org/apache/ivy/plugins/repository/vfs/IvyWebdavFileProvider.java deleted file mode 100644 index dcf9318e..00000000 --- a/src/java/org/apache/ivy/plugins/repository/vfs/IvyWebdavFileProvider.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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. - * - */ -package org.apache.ivy.plugins.repository.vfs; - -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.vfs.FileName; -import org.apache.commons.vfs.FileSystem; -import org.apache.commons.vfs.FileSystemException; -import org.apache.commons.vfs.FileSystemOptions; -import org.apache.commons.vfs.provider.GenericFileName; -import org.apache.commons.vfs.provider.webdav.WebdavFileProvider; - -/** - * Modified version of the WebdavFileProvider from VFS which adds support for httpclient 3.x. See - * http://issues.apache.org/jira/browse/VFS-74 for more info. A provider for WebDAV. - */ -public class IvyWebdavFileProvider extends WebdavFileProvider { - - /*********************************************************************************************** - * Creates a filesystem. - */ - protected FileSystem doCreateFileSystem(final FileName name, - final FileSystemOptions fileSystemOptions) throws FileSystemException { - // Create the file system - final GenericFileName rootName = (GenericFileName) name; - - HttpClient httpClient = IvyWebdavClientFactory.createConnection(rootName.getHostName(), - rootName.getPort(), rootName.getUserName(), rootName.getPassword(), fileSystemOptions); - - return new IvyWebdavFileSystem(rootName, httpClient, fileSystemOptions); - } - -} diff --git a/src/java/org/apache/ivy/plugins/repository/vfs/IvyWebdavFileSystem.java b/src/java/org/apache/ivy/plugins/repository/vfs/IvyWebdavFileSystem.java deleted file mode 100644 index 63b726ad..00000000 --- a/src/java/org/apache/ivy/plugins/repository/vfs/IvyWebdavFileSystem.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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. - * - */ -package org.apache.ivy.plugins.repository.vfs; - -import org.apache.commons.httpclient.HttpClient; -import org.apache.commons.vfs.FileSystemOptions; -import org.apache.commons.vfs.provider.GenericFileName; -import org.apache.commons.vfs.provider.webdav.WebDavFileSystem; - -/** - * This class extends from WebDavFileSystem because it doesn't provide an accessible constructor. - */ -class IvyWebdavFileSystem extends WebDavFileSystem { - - protected IvyWebdavFileSystem(GenericFileName arg0, HttpClient arg1, FileSystemOptions arg2) { - super(arg0, arg1, arg2); - } - -} diff --git a/src/java/org/apache/ivy/plugins/repository/vfs/ivy_vfs.xml b/src/java/org/apache/ivy/plugins/repository/vfs/ivy_vfs.xml index 55702506..3becc828 100644 --- a/src/java/org/apache/ivy/plugins/repository/vfs/ivy_vfs.xml +++ b/src/java/org/apache/ivy/plugins/repository/vfs/ivy_vfs.xml @@ -39,14 +39,6 @@ --> - - - - - - - -