cmlenz      2002/06/18 08:44:37

  Modified:    src/webdav/server/org/apache/slide/webdav
                        WebdavMethodFactory.java WebdavServlet.java
                        WebdavServletConfig.java
  Log:
  WebdavServletConfig now only holds the class name of the method factory
  The servlet is responsible for instantiating it
  
  Revision  Changes    Path
  1.3       +4 -6      
jakarta-slide/src/webdav/server/org/apache/slide/webdav/WebdavMethodFactory.java
  
  Index: WebdavMethodFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/WebdavMethodFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WebdavMethodFactory.java  14 Jun 2002 15:28:11 -0000      1.2
  +++ WebdavMethodFactory.java  18 Jun 2002 15:44:37 -0000      1.3
  @@ -94,9 +94,7 @@
       public static WebdavMethodFactory newInstance(WebdavServletConfig config) {
           
           WebdavMethodFactory factory = null;
  -        String className =
  -            config.getInitParameter
  -                (WebdavServletConfig.METHOD_FACTORY_PARAMETER);
  +        String className = config.getMethodFactory();
           if (className != null) {
               try {
                   Class factoryClass = Class.forName(className);
  
  
  
  1.48      +24 -15    
jakarta-slide/src/webdav/server/org/apache/slide/webdav/WebdavServlet.java
  
  Index: WebdavServlet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/WebdavServlet.java,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- WebdavServlet.java        14 Jun 2002 15:28:11 -0000      1.47
  +++ WebdavServlet.java        18 Jun 2002 15:44:37 -0000      1.48
  @@ -158,6 +158,12 @@
       protected boolean handleLifecycle = true;
       
       
  +    /**
  +     * Instance of the WebdavMethodFactory to use by this servlet.
  +     */
  +    protected WebdavMethodFactory methodFactory;
  +    
  +    
       // -------------------------------------------------------- Servlet Methods
       
       
  @@ -202,17 +208,16 @@
               
               resp.setStatus(WebdavStatus.SC_OK);
               
  -            String name = req.getMethod();
  -            if ((name.equalsIgnoreCase("GET") ||
  -                 name.equalsIgnoreCase("POST")) &&
  +            String methodName = req.getMethod();
  +            if ((methodName.equalsIgnoreCase("GET") ||
  +                 methodName.equalsIgnoreCase("POST")) &&
                   WebdavUtils.isCollection(token, req, config)) {
                   // let the standard doGet() / doPost() methods handle
                   // GET/POST requests on collections (to display a directory
                   // index pag or something similar)
                   super.service(req, resp);
               } else {
  -                WebdavMethod method =
  -                    config.getMethodFactory().createMethod(req.getMethod());
  +                WebdavMethod method = methodFactory.createMethod(methodName);
                   method.run(req, resp);
               }
               
  @@ -381,18 +386,22 @@
               }
               getServletContext().setAttribute(ATTRIBUTE_NAME, token);
               
  -            if (directoryBrowsing) {
  -                directoryIndexGenerator =
  -                    new DirectoryIndexGenerator
  -                        (token, (WebdavServletConfig)getServletConfig());
  -            }
  -            
           } catch (DomainInitializationFailedError e) {
               log("Could not initialize domain", e);
               throw new UnavailableException(e.toString());
           } catch (Throwable t) {
               t.printStackTrace();
               throw new ServletException(t.toString());
  +        }
  +        
  +        methodFactory =
  +            WebdavMethodFactory.newInstance(
  +                (WebdavServletConfig)getServletConfig());
  +        
  +        if (directoryBrowsing) {
  +            directoryIndexGenerator =
  +                new DirectoryIndexGenerator
  +                    (token, (WebdavServletConfig)getServletConfig());
           }
       }
       
  
  
  
  1.7       +12 -12    
jakarta-slide/src/webdav/server/org/apache/slide/webdav/WebdavServletConfig.java
  
  Index: WebdavServletConfig.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/WebdavServletConfig.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- WebdavServletConfig.java  14 Jun 2002 15:28:11 -0000      1.6
  +++ WebdavServletConfig.java  18 Jun 2002 15:44:37 -0000      1.7
  @@ -147,9 +147,9 @@
       
       
       /**
  -     * Instance of the WebdavMethodFactory.
  +     * Class name of the WebdavMethodFactory.
        */
  -    private WebdavMethodFactory methodFactory;
  +    private String methodFactory;
       
       
       // ----------------------------------------------------------- Construction
  @@ -200,13 +200,13 @@
               isDefaultServlet = Boolean.valueOf(value).booleanValue();
           }
           
  -        // read 'default-mime-type' parameter
  +        // read 'method-factory' parameter
           value = getInitParameter(METHOD_FACTORY_PARAMETER);
           if (value == null) {
               value = context.getInitParameter(METHOD_FACTORY_PARAMETER);
           }
           if (value != null) {
  -            methodFactory = WebdavMethodFactory.newInstance(this);
  +            methodFactory = value;
           }
       }
       
  @@ -298,13 +298,13 @@
       
       
       /**
  -     * Returns the WebdavMethodFactory configured by the user, or the default 
  -     * WebdavMethodFactory if the corresponding initialization parameter
  -     * 'method-factory' was not provided.
  +     * Returns the name of the WebdavMethodFactory class configured by the 
  +     * user, or the default class name if the corresponding initialization 
  +     * parameter 'method-factory' was not provided.
        *
  -     * @return the method factory
  +     * @return class name of the method factory
        */
  -    public WebdavMethodFactory getMethodFactory() {
  +    public String getMethodFactory() {
           
           return methodFactory;
       }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to