jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ju...@apache.org
Subject svn commit: r761613 - in /jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/server: RemoteAdapterFactory.java ServerAdapterFactory.java ServerEventCollection.java ServerObject.java
Date Fri, 03 Apr 2009 11:12:37 GMT
Author: jukka
Date: Fri Apr  3 11:12:36 2009
New Revision: 761613

URL: http://svn.apache.org/viewvc?rev=761613&view=rev
Log:
JCRRMI-13: Enhancement to get RMI through firewalls

Added a port number attribute to RemoteAdapterFactory interface. This port (0 for a random
port) is used by all ServerObject instances created by that factory.

The attribute is initialized to the value of the org.apache.jackrabbit.rmi.port system property,
or to 0 if the property is not set.

Thanks to Tony Richardson for the idea!

Modified:
    jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/server/RemoteAdapterFactory.java
    jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/server/ServerAdapterFactory.java
    jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/server/ServerEventCollection.java
    jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/server/ServerObject.java

Modified: jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/server/RemoteAdapterFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/server/RemoteAdapterFactory.java?rev=761613&r1=761612&r2=761613&view=diff
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/server/RemoteAdapterFactory.java
(original)
+++ jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/server/RemoteAdapterFactory.java
Fri Apr  3 11:12:36 2009
@@ -89,6 +89,16 @@
 public interface RemoteAdapterFactory {
 
     /**
+     * Returns the port number to which the server objects created by
+     * this factory are bound. This method is mostly used internally by
+     * the {@link ServerObject} constructor to determine which port number
+     * to use.
+     *
+     * @return port number, or 0 for a random port
+     */
+    int getPortNumber();
+
+    /**
      * Returns a remote adapter for the given local repository.
      *
      * @param repository local repository

Modified: jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/server/ServerAdapterFactory.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/server/ServerAdapterFactory.java?rev=761613&r1=761612&r2=761613&view=diff
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/server/ServerAdapterFactory.java
(original)
+++ jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/server/ServerAdapterFactory.java
Fri Apr  3 11:12:36 2009
@@ -102,6 +102,15 @@
     private int bufferSize = DEFAULT_BUFFER_SIZE;
 
     /**
+     * The port number for server objects. Initializes to the value of
+     * the <code>org.apache.jackrabbit.rmi.port</code> system property,
+     * or to 0 if the property is not set. Value 0 means that the server
+     * objects should use a random anonymous port.
+     */
+    private int portNumber =
+        Integer.getInteger("org.apache.jackrabbit.rmi.port", 0).intValue();
+
+    /**
      * Returns the iterator buffer size.
      *
      * @return iterator buffer size
@@ -120,6 +129,24 @@
     }
 
     /**
+     * Returns the port number for server objects.
+     *
+     * @return port number, or 0 for the default
+     */
+    public int getPortNumber() {
+        return portNumber;
+    }
+
+    /**
+     * Sets the port number for server objects.
+     *
+     * @param portNumber port number, or 0 for the default
+     */
+    public void setPortNumber(int portNumber) {
+        this.portNumber = portNumber;
+    }
+
+    /**
      * Creates a {@link ServerRepository ServerRepository} instance.
      * {@inheritDoc}
      */
@@ -318,7 +345,7 @@
                 try {
                     Event event = events.nextEvent();
                     eventList.add(new ServerEventCollection.ServerEvent(
-                            event.getType(), event.getPath(), event.getUserID()));
+                            event.getType(), event.getPath(), event.getUserID(), this));
                 } catch (RepositoryException re) {
                     throw new RemoteException(re.getMessage(), re);
                 }
@@ -329,7 +356,7 @@
             remoteEvents = new RemoteEventCollection.RemoteEvent[0]; // for safety
         }
 
-        return new ServerEventCollection(listenerId, remoteEvents);
+        return new ServerEventCollection(listenerId, remoteEvents, this);
     }
 
     /**

Modified: jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/server/ServerEventCollection.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/server/ServerEventCollection.java?rev=761613&r1=761612&r2=761613&view=diff
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/server/ServerEventCollection.java
(original)
+++ jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/server/ServerEventCollection.java
Fri Apr  3 11:12:36 2009
@@ -29,11 +29,6 @@
  * of events the unique identifier of the client-side listener has to be
  * provided such that the receiving listener may be identified on the
  * client-side.
- * <p>
- * This class does not require the
- * {@link org.apache.jackrabbit.rmi.server.RemoteAdapterFactory}and
- * consequently calls the base class constructor with a <code>null</code>
- * factory.
  */
 public class ServerEventCollection extends ServerObject implements
         RemoteEventCollection {
@@ -53,12 +48,13 @@
      * @param listenerId The unique identifier of the client-side listener to
      *            which the events should be sent.
      * @param events The list of {@link RemoteEvent remote events}.
-     *
+     * @param factory remote adapter factory
      * @throws RemoteException on RMI errors
      */
-    ServerEventCollection(long listenerId, RemoteEvent[] events)
+    ServerEventCollection(
+            long listenerId, RemoteEvent[] events, RemoteAdapterFactory factory)
             throws RemoteException {
-        super(null);
+        super(factory);
 
         this.listenerId = listenerId;
         this.events = events;
@@ -95,13 +91,13 @@
          * @param type The event type.
          * @param path The absolute path to the underlying item.
          * @param userId The userID of the originating session.
-         *
-         * @throws RemoteException declared because of the declaration in the
-         *      base class constructor called. In fact this exception is never
-         *      thrown.
+         * @param factory remote adapter factory
+         * @throws RemoteException on RMI errors
          */
-        ServerEvent(int type, String path, String userId) throws RemoteException {
-            super(null);
+        ServerEvent(
+                int type, String path, String userId, RemoteAdapterFactory factory)
+                throws RemoteException {
+            super(factory);
             this.type = type;
             this.path = path;
             this.userID = userId;

Modified: jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/server/ServerObject.java
URL: http://svn.apache.org/viewvc/jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/server/ServerObject.java?rev=761613&r1=761612&r2=761613&view=diff
==============================================================================
--- jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/server/ServerObject.java
(original)
+++ jackrabbit/commons/jcr-rmi/trunk/src/main/java/org/apache/jackrabbit/rmi/server/ServerObject.java
Fri Apr  3 11:12:36 2009
@@ -68,6 +68,7 @@
      */
     protected ServerObject(RemoteAdapterFactory factory)
             throws RemoteException {
+        super(factory.getPortNumber());
         this.factory = factory;
     }
 



Mime
View raw message