jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r543817 - in /jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi: client/RMIRepository.java client/RMIRepositoryFactory.java servlet/RMIBindingServlet.java servlet/RMIRepositoryServlet.java
Date Sun, 03 Jun 2007 00:59:28 GMT
Author: jukka
Date: Sat Jun  2 17:59:27 2007
New Revision: 543817

URL: http://svn.apache.org/viewvc?view=rev&rev=543817
Log:
JCR-956: Allow use of custom adapter factories and enable the Jackrabbit extensions by default.

Modified:
    jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/RMIRepository.java
    jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/RMIRepositoryFactory.java
    jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIBindingServlet.java
    jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIRepositoryServlet.java

Modified: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/RMIRepository.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/RMIRepository.java?view=diff&rev=543817&r1=543816&r2=543817
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/RMIRepository.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/RMIRepository.java
Sat Jun  2 17:59:27 2007
@@ -32,10 +32,11 @@
     /**
      * Creates a proxy for the remote repository in the given RMI URL.
      *
+     * @param factory local adapter factory
      * @param url RMI URL of the remote repository
      */
-    public RMIRepository(String url) {
-        super(new RMIRepositoryFactory(url));
+    public RMIRepository(LocalAdapterFactory factory, String url) {
+        super(new RMIRepositoryFactory(factory, url));
     }
 
 }

Modified: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/RMIRepositoryFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/RMIRepositoryFactory.java?view=diff&rev=543817&r1=543816&r2=543817
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/RMIRepositoryFactory.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/client/RMIRepositoryFactory.java
Sat Jun  2 17:59:27 2007
@@ -33,6 +33,11 @@
 public class RMIRepositoryFactory implements RepositoryFactory {
 
     /**
+     * Local adapter factory.
+     */
+    private final LocalAdapterFactory factory;
+
+    /**
      * RMI URL of the repository.
      */
     private final String url;
@@ -40,9 +45,11 @@
     /**
      * Creates a factory for looking up a repository from the given RMI URL.
      *
+     * @param factory local adapter factory
      * @param url RMI URL of the repository
      */
-    public RMIRepositoryFactory(String url) {
+    public RMIRepositoryFactory(LocalAdapterFactory factory, String url) {
+        this.factory = factory;
         this.url = url;
     }
 
@@ -54,7 +61,7 @@
      */
     public Repository getRepository() throws RepositoryException {
         try {
-            return new ClientRepositoryFactory().getRepository(url);
+            return new ClientRepositoryFactory(factory).getRepository(url);
         } catch (MalformedURLException e) {
             throw new RepositoryException("Invalid repository URL: " + url, e);
         } catch (NotBoundException e) {

Modified: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIBindingServlet.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIBindingServlet.java?view=diff&rev=543817&r1=543816&r2=543817
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIBindingServlet.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIBindingServlet.java
Sat Jun  2 17:59:27 2007
@@ -27,8 +27,8 @@
 import javax.servlet.http.HttpServlet;
 
 import org.apache.jackrabbit.commons.servlet.ServletRepository;
+import org.apache.jackrabbit.rmi.jackrabbit.JackrabbitServerAdapterFactory;
 import org.apache.jackrabbit.rmi.server.RemoteAdapterFactory;
-import org.apache.jackrabbit.rmi.server.ServerAdapterFactory;
 
 /**
  * Servlet that binds a repository from a servlet context attribute in RMI.
@@ -44,8 +44,8 @@
  *   <dd>
  *     Name of the remote adapter factory class used to create the remote
  *     repository reference. The configured class should have public
- *     constructor that takes no arguments. The default value is
- *     "<code>org.apache.jackrabbit.rmi.server.ServerAdapterFactory</code>".
+ *     constructor that takes no arguments. The default class is
+ *     {@link JackrabbitServerAdapterFactory}.
  *   </dd>
  *   <dt>url</dt>
  *   <dd>
@@ -116,7 +116,7 @@
             throws ServletException {
         String name = getInitParameter(RemoteAdapterFactory.class.getName());
         if (name == null) {
-            name = ServerAdapterFactory.class.getName();
+            name = JackrabbitServerAdapterFactory.class.getName();
         }
         try {
             Class factoryClass = Class.forName(name);

Modified: jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIRepositoryServlet.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIRepositoryServlet.java?view=diff&rev=543817&r1=543816&r2=543817
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIRepositoryServlet.java
(original)
+++ jackrabbit/trunk/jackrabbit-jcr-rmi/src/main/java/org/apache/jackrabbit/rmi/servlet/RMIRepositoryServlet.java
Sat Jun  2 17:59:27 2007
@@ -20,7 +20,9 @@
 import javax.servlet.ServletException;
 
 import org.apache.jackrabbit.commons.servlet.AbstractRepositoryServlet;
+import org.apache.jackrabbit.rmi.client.LocalAdapterFactory;
 import org.apache.jackrabbit.rmi.client.RMIRepository;
+import org.apache.jackrabbit.rmi.jackrabbit.JackrabbitClientAdapterFactory;
 
 /**
  * Servlet that makes a repository from RMI available as an attribute
@@ -33,6 +35,13 @@
  *     Name of the servlet context attribute to put the repository in.
  *     The default value is "<code>javax.jcr.Repository</code>".
  *   </dd>
+ *   <dt>org.apache.jackrabbit.rmi.client.LocalAdapterFactory</dt>
+ *   <dd>
+ *     Name of the local adapter factory class used to create the local
+ *     adapter for the remote repository. The configured class should have
+ *     public constructor that takes no arguments. The default class is
+ *     {@link JackrabbitClientAdapterFactory}.
+ *   </dd>
  *   <dt>url</dt>
  *   <dd>
  *     RMI URL of the remote repository. The default value is
@@ -59,7 +68,37 @@
      */
     protected Repository getRepository() throws ServletException {
         return new RMIRepository(
+                getLocalAdapterFactory(),
                 getInitParameter("url", "//localhost/javax/jcr/Repository"));
+    }
+
+    /**
+     * Instantiates and returns the configured local adapter factory.
+     *
+     * @return local adapter factory
+     * @throws ServletException if the factory could not be instantiated
+     */
+    private LocalAdapterFactory getLocalAdapterFactory()
+            throws ServletException {
+        String name = getInitParameter(
+                LocalAdapterFactory.class.getName(),
+                JackrabbitClientAdapterFactory.class.getName());
+        try {
+            Class factoryClass = Class.forName(name);
+            return (LocalAdapterFactory) factoryClass.newInstance();
+        } catch (ClassNotFoundException e) {
+            throw new ServletException(
+                    "Local adapter factory class not found: " + name, e);
+        } catch (InstantiationException e) {
+            throw new ServletException(
+                    "Failed to instantiate the adapter factory: " + name, e);
+        } catch (IllegalAccessException e) {
+            throw new ServletException(
+                    "Adapter factory constructor is not public: " + name, e);
+        } catch (ClassCastException e) {
+            throw new ServletException(
+                    "Invalid local adapter factory class: " + name, e);
+        }
     }
 
 }



Mime
View raw message