classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: gnu.CORBA.ListenerPort property.


From: Meskauskas Audrius
Subject: [cp-patches] FYI: gnu.CORBA.ListenerPort property.
Date: Mon, 17 Oct 2005 00:35:19 +0200
User-agent: Mozilla Thunderbird 1.0.2 (Windows/20050317)

Various firewalls does not allow opening multiple randomly selected ports, as
the default CORBA implementation used to do. The firewall must be configured
to allow CORBA to work on one fixed port or (for better performance) on a
small fixed range of ports. This does not restrict the maximal number of the
connected objects as the objects can share the same port.

As far as I currently know, there is no OMG standard property for this, but
there are proprietary properties like com.ibm.CORBA.ListenerPort
or com.sun.CORBA.POA.ORBPersistentServerPort. Lack of this feature
may prevent adaptation of java programs that needs them, so I suggest to
introduce the analogical gnu.CORBA.ListenerPort property. The value of this property is a single port or range of ports, boundary values (inclusive) being
separated by dash (for instance,  "1245-1250").

2005-10-17  Audrius Meskauskas  <address@hidden>

* gnu/CORBA/Focused_ORB.java: New file.
* gnu/CORBA/Functional_ORB.java,
org/omg/CORBA/ORB.java: Adapted to support the new property.

? gnu/CORBA/Focused_ORB.java
Index: gnu/CORBA/Functional_ORB.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/CORBA/Functional_ORB.java,v
retrieving revision 1.20
diff -u -r1.20 Functional_ORB.java
--- gnu/CORBA/Functional_ORB.java       5 Oct 2005 16:25:42 -0000       1.20
+++ gnu/CORBA/Functional_ORB.java       16 Oct 2005 17:37:14 -0000
@@ -103,12 +103,13 @@
    * may listen on multiple ports and process the requests in separate threads.
    * Normally the server takes one port per object being served.
    */
-  class portServer extends Thread
+  protected class portServer
+    extends Thread
   {
     /**
      * The number of the currently running parallel threads.
      */
-    int running_threads; 
+    int running_threads;
 
     /**
      * The port on that this portServer is listening for requests.
@@ -132,27 +133,26 @@
     {
       s_port = _port;
       setDaemon(true);
-    }
-
-    /**
-     * Enter the serving loop (get request/process it). All portServer normally
-     * terminate thy threads when the Functional_ORB.running is set to false.
-     */
-    public void run()
-    {
       try
         {
           service = new ServerSocket(s_port);
         }
       catch (IOException ex)
         {
-          BAD_OPERATION bad =
-            new BAD_OPERATION("Unable to open the server socket at "+s_port);
+          BAD_OPERATION bad = new BAD_OPERATION(
+            "Unable to open the server socket at " + s_port);
           bad.minor = Minor.Socket;
           bad.initCause(ex);
           throw bad;
         }
+    }
 
+    /**
+     * Enter the serving loop (get request/process it). All portServer normally
+     * terminate thy threads when the Functional_ORB.running is set to false.
+     */
+    public void run()
+    {
       while (running)
         {
           try
@@ -183,10 +183,11 @@
 
     /**
      * Perform a single serving step.
-     *
+     * 
      * @throws java.lang.Exception
      */
-    void tick() throws Exception
+    void tick()
+      throws Exception
     {
       serve(this, service);
     }
@@ -222,7 +223,7 @@
    * serving multiple requests (probably to the different objects) on the same
    * thread.
    */
-  class sharedPortServer extends portServer
+  protected class sharedPortServer extends portServer
   {
     /**
      * Create a new portServer, serving on specific port.
@@ -395,7 +396,7 @@
   /**
    * The currently active portServers.
    */
-  private ArrayList portServers = new ArrayList();
+  protected ArrayList portServers = new ArrayList();
 
   /**
    * The host, on that the name service is expected to be running.
@@ -964,7 +965,7 @@
   
   /**
    * Start the server in a new thread, if not already running. This method is
-   * used to ensure that the objects being transfered will be served fro the 
+   * used to ensure that the objects being transfered will be served from the 
    * remote side, if required. If the ORB is started using this method, it
    * starts as a daemon thread.
    */
@@ -1233,7 +1234,7 @@
    * @throws BAD_PARAM if the object does not implement the
    * address@hidden InvokeHandler}).
    */
-  private void prepareObject(org.omg.CORBA.Object object, IOR ior)
+  protected void prepareObject(org.omg.CORBA.Object object, IOR ior)
     throws BAD_PARAM
   {
     /*
@@ -1587,8 +1588,12 @@
         return;
       }
   }
-
-  private void useProperties(Properties props)
+  
+  /**
+   * Set the ORB parameters from the properties that were accumulated
+   * from several locations.
+   */
+  protected void useProperties(Properties props)
   {
     if (props != null)
       {
Index: org/omg/CORBA/ORB.java
===================================================================
RCS file: /cvsroot/classpath/classpath/org/omg/CORBA/ORB.java,v
retrieving revision 1.18
diff -u -r1.18 ORB.java
--- org/omg/CORBA/ORB.java      13 Oct 2005 20:58:54 -0000      1.18
+++ org/omg/CORBA/ORB.java      16 Oct 2005 22:25:52 -0000
@@ -38,6 +38,7 @@
 
 package org.omg.CORBA;
 
+import gnu.CORBA.Focused_ORB;
 import gnu.CORBA.ObjectCreator;
 import gnu.CORBA.Restricted_ORB;
 import gnu.CORBA.fixedTypeCode;
@@ -59,17 +60,17 @@
 import java.util.Properties;
 
 /**
- * A central class in CORBA implementation, responsible for sending and
- * handling remote invocations. ORB also works as a factory for
- * creating instances of certain CORBA classes.
- *
- * Despite the core library contains the fully working CORBA implementation,
- * it also provides a simple way to plug-in the alternative CORBA support.
- * This is done by replacing the ORB. The alternative ORB can be specified
- * via properties, passed to ORB.Init(...).
- *
- * When creating an ORB instance, the class name
- * is searched in the following locations:
+ * A central class in CORBA implementation, responsible for sending and 
handling
+ * remote invocations. ORB also works as a factory for creating instances of
+ * certain CORBA classes.
+ * 
+ * Despite the core library contains the fully working CORBA implementation, it
+ * also provides a simple way to plug-in the alternative CORBA support. This is
+ * done by replacing the ORB. The alternative ORB can be specified via
+ * properties, passed to ORB.Init(...).
+ * 
+ * When creating an ORB instance, the class name is searched in the following
+ * locations:
  * <p>
  * 1. Applet parameter or application string array, if any.<br>
  * 2. The properties parameter, if any.<br>
@@ -77,25 +78,40 @@
  * 4. The orb.properties file located in the user.home directory (if any).<br>
  * 5. The orb.properties file located in the java.home/lib directory (if any).
  * </p>
- *
- * The supported properties are:
- * <table border="1">
- * <tr><td> org.omg.CORBA.ORBClass</td><td>The class,
- *   implementing the functional ORB, returned by
- *   address@hidden #init(Applet, Properties)} or
- *   address@hidden #init(String[], Properties)} </td></tr>
- * <tr><td>org.omg.CORBA.ORBSingletonClass</td><td>The class,
- *   implementing the restricted ORB, returned by
- *   address@hidden #init()}.
- * </td></tr>
- * <tr><td>org.omg.CORBA.ORBInitRef</td><td>Specifies the
- * initial reference, accessible by name with the method
- * address@hidden #resolve_initial_references(String)}.
- * </table>
- * The command line accepts the same properties as a keys. When specifying
- * in the command line, the prefix org.omg.CORBA can be omitted,
- * for instance<code> -ORBInitRef NameService=IOR:aabbccdd....</code>
- *
+ * 
+ * The supported properties are: <table border="1">
+ * <tr>
+ * <td> org.omg.CORBA.ORBClass</td>
+ * <td>The class, implementing the functional ORB, returned by
+ * address@hidden #init(Applet, Properties)} or address@hidden #init(String[], 
Properties)}
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>org.omg.CORBA.ORBSingletonClass</td>
+ * <td>The class, implementing the restricted ORB, returned by address@hidden 
#init()}.
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>org.omg.CORBA.ORBInitRef</td>
+ * <td>Specifies the initial reference, accessible by name with the method
+ * address@hidden #resolve_initial_references(String)}.</td>
+ * </tr>
+ * <tr>
+ * <td>gnu.CORBA.ListenerPort</td>
+ * <td>Specifies that this ORB should serve all its objects on a single port
+ * (for example, "1234") or on a specified port range (for example,
+ * "1100-1108"). The property is used when working with firewals and serves as 
a
+ * replacement for the proprietary properties like com.ibm.CORBA.ListenerPort
+ * or com.sun.CORBA.POA.ORBPersistentServerPort. The specified port or range
+ * should not overlap with the values, specified for other ORB's.
+ * </td>
+ * </tr>
+ * </table> 
+ * <p>The command line accepts the same properties as a keys. When
+ * specifying in the command line, the prefix org.omg.CORBA can be omitted, for
+ * instance<code> -ORBInitRef NameService=IOR:aabbccdd....</code>
+ * </p>
+ * 
  * @author Audrius Meskauskas (address@hidden)
  */
 public abstract class ORB
@@ -115,18 +131,21 @@
    */
   private static final String RESTRICTED_ORB =
     "org.omg.CORBA.ORBSingletonClass";
-
+  
+  private static final String LISTENER_PORT =
+    Focused_ORB.LISTENER_PORT;
+  
   /**
    * The class, implementing the default fully functional ORB.
    */
   private static final String DEFAULT_FUNCTIONAL_ORB =
     gnu.CORBA.Poa.ORB_1_4.class.getName();
-
-  /**
-   * The class, implementing the default restricted ORB.
-   */
-  private static final String DEFAULT_RESTRICTED_ORB =
-    gnu.CORBA.Restricted_ORB.class.getName();
+  
+  private static final String DEFAULT_FOCUSED_ORB =
+    gnu.CORBA.Focused_ORB.class.getName();
+  
+  // There is no need for name of the default restricted ORB as it is 
+  // singleton and it is more effectively referred directly.
 
   /**
    * Connect the given CORBA object to this ORB. After the object is
@@ -780,7 +799,7 @@
    */
   public static ORB init()
   {
-    String orb_cn = getORBName(null, RESTRICTED_ORB);
+    String orb_cn = getCumulatedProperty(null, RESTRICTED_ORB);
     if (orb_cn == null)
       return Restricted_ORB.Singleton;
     else
@@ -805,6 +824,11 @@
   public static ORB init(Applet applet, Properties props)
   {
     String ocn = applet.getParameter(FUNCTIONAL_ORB);
+    String lp = applet.getParameter(LISTENER_PORT);
+    
+    if (ocn==null && lp!=null)
+      ocn = DEFAULT_FOCUSED_ORB;
+    
     ORB orb = createORB(props, ocn);
     orb.set_parameters(applet, props);
 
@@ -812,40 +836,44 @@
   }
 
   /**
-   * Creates the working instance of ORB for a
-   * standalone application.
-   *
-   * By default the built-in fully functional ORB is returned. The ORB class
-   * is found as described in the header of this class.
-   *
+   * Creates the working instance of ORB for a standalone application.
+   * 
+   * By default the built-in fully functional ORB is returned. The ORB class is
+   * found as described in the header of this class.
+   * 
    * @param args the parameters, passed to the applications
-   * <code>main(String[] args)</code> method, may be <code>null</code>.
-   * The parameter -org.omg.CORBA.ORBClass <class name>
-   * if present, defines the used ORB implementation class. If this
-   * property is not present, the ORB class is found as described in the
-   * class header.
-
-   *
+   * <code>main(String[] args)</code> method, may be <code>null</code>. The
+   * parameter -org.omg.CORBA.ORBClass <class name> if present, defines the 
used
+   * ORB implementation class. If this property is not present, the ORB class 
is
+   * found as described in the class header.
+   * 
    * @param props application specific properties, may be <code>null</code>.
-   *
+   * 
    * @return a newly created functional derivative of this abstract class.
    */
   public static ORB init(String[] args, Properties props)
   {
     String ocn = null;
+    String lp = null;
 
     String orbKey = "-" + FUNCTIONAL_ORB;
+    String lpKey = "-" + LISTENER_PORT;
 
     if (args != null)
       if (args.length >= 2)
         {
           for (int i = 0; i < args.length - 1; i++)
             {
-              if (args [ i ].equals(orbKey))
-                ocn = args [ i + 1 ];
+              if (args[i].equals(orbKey))
+                ocn = args[i + 1];
+              if (args[i].equals(lpKey))
+                lp = args[i + 1];
             }
         }
 
+    if (lp != null && ocn == null)
+      ocn = DEFAULT_FOCUSED_ORB;
+
     ORB orb = createORB(props, ocn);
 
     orb.set_parameters(args, props);
@@ -854,9 +882,9 @@
 
   /**
    * List the initially available CORBA objects (services).
-   *
+   * 
    * @return a list of services.
-   *
+   * 
    * @see #resolve_initial_references(String)
    */
   public abstract String[] list_initial_services();
@@ -1075,23 +1103,10 @@
   protected abstract void set_parameters(Applet app, Properties props);
 
   /**
-   * Checks if the communication over network is allowed.
-   * @throws java.lang.SecurityException
+   * Get the property with the given name, searching in the standard
+   * places for the ORB properties.
    */
-  private static final void checkNetworkingPermission(String host, int port)
-                                               throws SecurityException
-  {
-    SecurityManager security = System.getSecurityManager();
-    if (security != null)
-      {
-        security.checkConnect(host, port);
-      }
-  }
-
-  /**
-   * Get the ORB class name.
-   */
-  private static String getORBName(Properties props, String property)
+  private static String getCumulatedProperty(Properties props, String property)
   {
     String orb_cn = null;
 
@@ -1106,7 +1121,7 @@
 
     if (orb_cn == null)
       orb_cn = checkFile(property, "java.home", "lib");
-
+    
     return orb_cn;
   }
 
@@ -1149,10 +1164,10 @@
 
   /**
    * Create ORB when its name is possibly known.
-   *
+   * 
    * @param props properties, possibly containing the ORB name.
-   * @param orbClassName the direct ORB class name, overriding
-   * other possible locations, or null if not specified.
+   * @param orbClassName the direct ORB class name, overriding other possible
+   * locations, or null if not specified.
    */
   private static ORB createORB(Properties props, String orbClassName)
   {
@@ -1160,10 +1175,16 @@
 
     if (orbClassName == null)
       {
-        orbClassName = getORBName(props, FUNCTIONAL_ORB);
+        orbClassName = getCumulatedProperty(props, FUNCTIONAL_ORB);
 
         if (orbClassName == null)
-          orbClassName = DEFAULT_FUNCTIONAL_ORB;
+          {
+            String lp = getCumulatedProperty(props, LISTENER_PORT);
+            if (lp != null)
+              orbClassName = DEFAULT_FOCUSED_ORB;
+            else
+              orbClassName = DEFAULT_FUNCTIONAL_ORB;
+          }
       }
 
     try

reply via email to

[Prev in Thread] Current Thread [Next in Thread]