001/* 002 ESXX - The friendly ECMAscript/XML Application Server 003 Copyright (C) 2007-2010 Martin Blom <martin@blom.org> 004 005 This program is free software: you can redistribute it and/or 006 modify it under the terms of the GNU Lesser General Public License 007 as published by the Free Software Foundation, either version 3 008 of the License, or (at your option) any later version. 009 010 This program is distributed in the hope that it will be useful, 011 but WITHOUT ANY WARRANTY; without even the implied warranty of 012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 013 GNU Lesser General Public License for more details. 014 015 You should have received a copy of the GNU Lesser General Public License 016 along with this program. If not, see <http://www.gnu.org/licenses/>. 017 018 019 PLEASE NOTE THAT THIS FILE'S LICENSE IS DIFFERENT FROM THE REST OF ESXX! 020*/ 021 022package groovyx.net.http.thirdparty; 023 024import java.net.*; 025import java.util.concurrent.TimeUnit; 026import org.apache.http.conn.*; 027import org.apache.http.params.*; 028import org.apache.http.conn.routing.HttpRoute; 029import org.apache.http.conn.scheme.*; 030 031public class GAEConnectionManager 032 implements ClientConnectionManager { 033 034 public GAEConnectionManager() { 035 SocketFactory no_socket_factory = new SocketFactory() { 036 public Socket connectSocket(Socket sock, String host, int port, 037 InetAddress localAddress, int localPort, 038 HttpParams params) { 039 return null; 040 } 041 042 public Socket createSocket() { 043 return null; 044 } 045 046 public boolean isSecure(Socket s) { 047 return false; 048 } 049 }; 050 051 schemeRegistry = new SchemeRegistry(); 052 schemeRegistry.register(new Scheme("http", no_socket_factory, 80)); 053 schemeRegistry.register(new Scheme("https", no_socket_factory, 443)); 054 } 055 056 057 public SchemeRegistry getSchemeRegistry() { 058 return schemeRegistry; 059 } 060 061 public ClientConnectionRequest requestConnection(final HttpRoute route, 062 final Object state) { 063 return new ClientConnectionRequest() { 064 public void abortRequest() { 065 // Nothing to do 066 } 067 068 public ManagedClientConnection getConnection(long timeout, TimeUnit tunit) { 069 return GAEConnectionManager.this.getConnection(route, state); 070 } 071 }; 072 } 073 074 public void releaseConnection(ManagedClientConnection conn, 075 long validDuration, TimeUnit timeUnit) { 076 } 077 078 public void closeIdleConnections(long idletime, TimeUnit tunit) { 079 } 080 081 public void closeExpiredConnections() { 082 } 083 084 public void shutdown() { 085 } 086 087 private ManagedClientConnection getConnection(HttpRoute route, Object state) { 088 return new GAEClientConnection(this, route, state); 089 } 090 091 private SchemeRegistry schemeRegistry; 092}