001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.commons.vfs2.provider.http; 018 019import java.util.Collection; 020 021import org.apache.commons.httpclient.HttpClient; 022import org.apache.commons.httpclient.HttpConnectionManager; 023import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager; 024import org.apache.commons.vfs2.Capability; 025import org.apache.commons.vfs2.FileObject; 026import org.apache.commons.vfs2.FileSystemOptions; 027import org.apache.commons.vfs2.provider.AbstractFileName; 028import org.apache.commons.vfs2.provider.AbstractFileSystem; 029import org.apache.commons.vfs2.provider.GenericFileName; 030 031/** 032 * An HTTP file system. 033 * 034 * @deprecated Use {@link org.apache.commons.vfs2.provider.http5}. 035 */ 036@Deprecated 037public class HttpFileSystem extends AbstractFileSystem { 038 039 private final HttpClient httpClient; 040 041 /** 042 * Constructs a new instance. 043 * 044 * @param rootName root base name 045 * @param httpClient {@link HttpClient} instance 046 * @param fileSystemOptions Options to build this file system. 047 */ 048 protected HttpFileSystem(final GenericFileName rootName, final HttpClient httpClient, 049 final FileSystemOptions fileSystemOptions) { 050 super(rootName, null, fileSystemOptions); 051 this.httpClient = httpClient; 052 } 053 054 /** 055 * Adds the capabilities of this file system. 056 */ 057 @Override 058 protected void addCapabilities(final Collection<Capability> caps) { 059 caps.addAll(HttpFileProvider.CAPABILITIES); 060 } 061 062 /** @since 2.0 */ 063 @Override 064 public void closeCommunicationLink() { 065 if (getClient() != null) { 066 final HttpConnectionManager mgr = getClient().getHttpConnectionManager(); 067 if (mgr instanceof MultiThreadedHttpConnectionManager) { 068 ((MultiThreadedHttpConnectionManager) mgr).shutdown(); 069 } 070 } 071 } 072 073 /** 074 * Creates a file object. This method is called only if the requested file is not cached. 075 */ 076 @Override 077 protected FileObject createFile(final AbstractFileName name) throws Exception { 078 return new HttpFileObject<>(name, this); 079 } 080 081 /** 082 * Gets the HTTP client. 083 * 084 * @return the HttpClient. 085 */ 086 protected HttpClient getClient() { 087 return httpClient; 088 } 089}