jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r393456 - /jackrabbit/trunk/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java
Date Wed, 12 Apr 2006 13:29:51 GMT
Author: fmeschbe
Date: Wed Apr 12 06:29:46 2006
New Revision: 393456

URL: http://svn.apache.org/viewcvs?rev=393456&view=rev
Log:
[JCR-396] RMI published Repository using the jcr-rmi library gets lost over time

Modified:
    jackrabbit/trunk/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java

Modified: jackrabbit/trunk/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java
URL: http://svn.apache.org/viewcvs/jackrabbit/trunk/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java?rev=393456&r1=393455&r2=393456&view=diff
==============================================================================
--- jackrabbit/trunk/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java
(original)
+++ jackrabbit/trunk/jcr-server/webapp/src/java/org/apache/jackrabbit/j2ee/RepositoryStartupServlet.java
Wed Apr 12 06:29:46 2006
@@ -167,6 +167,19 @@
     private String rmiURI;
 
     /**
+     * Keeps a strong reference to the server side RMI repository instance to
+     * prevent the RMI distributed Garbage Collector from collecting the
+     * instance making the repository unaccessible though it should still be.
+     * This field is only set to a non-<code>null</code> value, if registration
+     * of the repository to an RMI registry succeeded in the
+     * {@link #registerRMI()} method.
+     *
+     * @see #registerRMI()
+     * @see #unregisterRMI()
+     */
+    private Remote rmiRepository;
+
+    /**
      * Initializes the servlet
      * @throws ServletException
      */
@@ -471,7 +484,10 @@
                 log.debug("Registering repository as " + rmiName
                     + " to registry " + reg);
                 reg.bind(rmiName, remote);
+
+                // when successfull, keep references
                 this.rmiURI = rmiURI;
+                this.rmiRepository = remote;
             log.info("Repository bound via RMI with name: " + rmiURI);
             } else {
                 log.info("RMI registry missing, cannot bind repository via RMI");
@@ -526,6 +542,10 @@
      * been registered.
      */
     private void unregisterRMI() {
+        // drop strong referenece to remote repository
+        rmiRepository = null;
+
+        // unregister repository
         if (rmiURI != null) {
             try {
                 Naming.unbind(rmiURI);



Mime
View raw message