KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > slide > webdav > WebdavMethodFactory


1 /*
2  * $Header: /home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/WebdavMethodFactory.java,v 1.6.2.1 2004/09/12 17:36:35 luetzkendorf Exp $
3  * $Revision: 1.6.2.1 $
4  * $Date: 2004/09/12 17:36:35 $
5  *
6  * ====================================================================
7  *
8  * Copyright 1999-2002 The Apache Software Foundation
9  *
10  * Licensed under the Apache License, Version 2.0 (the "License");
11  * you may not use this file except in compliance with the License.
12  * You may obtain a copy of the License at
13  *
14  * http://www.apache.org/licenses/LICENSE-2.0
15  *
16  * Unless required by applicable law or agreed to in writing, software
17  * distributed under the License is distributed on an "AS IS" BASIS,
18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19  * See the License for the specific language governing permissions and
20  * limitations under the License.
21  *
22  */

23
24 package org.apache.slide.webdav;
25
26 import org.apache.slide.webdav.method.DefaultMethodFactory;
27
28 /**
29  * Factory encapsulating the creation of WebdavMethod implementations.
30  *
31  */

32 public abstract class WebdavMethodFactory {
33     
34     
35     // ----------------------------------------------------- Instance Variables
36

37     // --------------------------------------------------------- Static Methods
38

39     /**
40      * Creates a new instance of a WebdavMethodFactory implementation.
41      *
42      * @param config configuration of the WebDAV servlet
43      */

44     public static WebdavMethodFactory newInstance(WebdavServletConfig config) {
45         
46         WebdavMethodFactory factory = null;
47         String JavaDoc className = config.getMethodFactory();
48         if (className != null) {
49             try {
50                 Class JavaDoc factoryClass = Class.forName(className);
51                 factory = (WebdavMethodFactory)factoryClass.newInstance();
52             } catch (Exception JavaDoc e) {
53                 // TOO BAD, we'll use the default method factory instead
54
}
55         }
56         
57         if (factory == null) {
58             factory = new DefaultMethodFactory();
59         }
60         factory.setConfig(config);
61         
62         return factory;
63     }
64     
65     
66     // ------------------------------------------------ Public Abstract Methods
67

68     
69     /**
70      * Creates a WebdavMethod implementation for the given method name.
71      *
72      * @param name WebDAV/HTTP method name ("GET", "PROPFIND", etc.)
73      * @return the corresponding WebdavMethod implementation, or
74      * <tt>null</tt> if the method is unknown or unsupported
75      */

76     public abstract WebdavMethod createMethod(String JavaDoc name);
77     
78     
79     // --------------------------------------------- Protected Abstract Methods
80

81     
82     /**
83      * Returns the configuration of the WebDAV servlet.
84      *
85      * @return configuration of the WebDAV servlet
86      */

87     protected abstract void setConfig(WebdavServletConfig config);
88     
89     
90 }
91
92
Popular Tags