KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > fr > jayasoft > ivy > url > URLHandlerRegistry


1 /*
2  * This file is subject to the license found in LICENCE.TXT in the root directory of the project.
3  *
4  * version 1.3.1
5  */

6 package fr.jayasoft.ivy.url;
7
8 import fr.jayasoft.ivy.util.Message;
9
10 /**
11  * @author Xavier Hanin
12  *
13  */

14 public class URLHandlerRegistry {
15     private static URLHandler _default = new BasicURLHandler();
16
17     public static URLHandler getDefault() {
18         return _default;
19     }
20     public static void setDefault(URLHandler def) {
21         _default = def;
22     }
23     
24     /**
25      * This method is used to get appropriate http downloader
26      * dependening on Jakarta Commons HttpClient
27      * availability in classpath, or simply use jdk url
28      * handling in other cases.
29      *
30      * @return most accurate http downloader
31      */

32     public static URLHandler getHttp() {
33         try {
34             Class.forName("org.apache.commons.httpclient.HttpClient");
35             Message.verbose("jakarta commons httpclient detected: using it for http downloading");
36             return new HttpClientHandler();
37         } catch (ClassNotFoundException JavaDoc e) {
38              Message.verbose("jakarta commons httpclient not found: using jdk url handling");
39             return new BasicURLHandler();
40         }
41     }
42
43 }
44
Popular Tags