You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by dp...@apache.org on 2010/03/19 11:30:03 UTC

svn commit: r925167 - /incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/servlet/CMISServlet.java

Author: dpfister
Date: Fri Mar 19 10:30:02 2010
New Revision: 925167

URL: http://svn.apache.org/viewvc?rev=925167&view=rev
Log:
CMIS-166 - Allow CMISServlet to get repository after instance creation

Modified:
    incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/servlet/CMISServlet.java

Modified: incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/servlet/CMISServlet.java
URL: http://svn.apache.org/viewvc/incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/servlet/CMISServlet.java?rev=925167&r1=925166&r2=925167&view=diff
==============================================================================
--- incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/servlet/CMISServlet.java (original)
+++ incubator/chemistry/trunk/chemistry/chemistry-atompub-server/src/main/java/org/apache/chemistry/atompub/server/servlet/CMISServlet.java Fri Mar 19 10:30:02 2010
@@ -16,13 +16,9 @@
  */
 package org.apache.chemistry.atompub.server.servlet;
 
-import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
 
-import javax.servlet.ServletContext;
-import javax.servlet.ServletException;
-
 import org.apache.abdera.Abdera;
 import org.apache.abdera.protocol.server.Provider;
 import org.apache.abdera.protocol.server.servlet.AbderaServlet;
@@ -33,7 +29,7 @@ public class CMISServlet extends AbderaS
 
     private static final long serialVersionUID = 1L;
 
-    private Repository repository;
+    protected Repository repository;
 
     /**
      * Empty constructor required by servlet spec.
@@ -46,38 +42,20 @@ public class CMISServlet extends AbderaS
     }
 
     @Override
-    public void init() throws ServletException {
-        if (repository == null) {
-            Map<String, String> params = new HashMap<String, String>();
-            @SuppressWarnings("unchecked")
-            Enumeration<String> names = getInitParameterNames();
-            while (names.hasMoreElements()) {
-                String name = names.nextElement();
-                params.put(name, getInitParameter(name));
-            }
-            repository = createRepository(getServletContext(), params);
-        }
-        super.init();
-    }
-
-    private Repository createRepository(ServletContext context,
-            Map<String, String> params) throws ServletException {
-        String className = params.get("class");
-        if (className == null) {
-            String msg = "Repository factory expected in 'class' parameter.";
-            throw new ServletException(msg);
-        }
-        // TODO create repository from factory
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
     protected Provider createProvider() {
-        Provider provider = new CMISProvider(repository);
+        Provider provider = new CMISProvider(getRepository());
         Abdera abdera = new Abdera();
         Map<String, String> properties = new HashMap<String, String>();
         provider.init(abdera, properties);
         return provider;
     }
 
+    /**
+     * Return the repository. Allows subclasses to create the repository if necessary.
+     *
+     * @return repository
+     */
+    protected Repository getRepository() {
+        return repository;
+    }
 }