/[classpath]/classpath/gnu/CORBA/Functional_ORB.java
ViewVC logotype

Diff of /classpath/gnu/CORBA/Functional_ORB.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.15 by audriusa, Fri Jul 22 16:57:47 2005 UTC revision 1.16 by audriusa, Sun Aug 28 11:23:36 2005 UTC
# Line 1  Line 1 
1  /* FunctionalORB.java --  /* Functional_ORB.java --
2     Copyright (C) 2005 Free Software Foundation, Inc.     Copyright (C) 2005 Free Software Foundation, Inc.
3    
4  This file is part of GNU Classpath.  This file is part of GNU Classpath.
# Line 58  import org.omg.CORBA.ORBPackage.InvalidN Line 58  import org.omg.CORBA.ORBPackage.InvalidN
58  import org.omg.CORBA.Request;  import org.omg.CORBA.Request;
59  import org.omg.CORBA.SystemException;  import org.omg.CORBA.SystemException;
60  import org.omg.CORBA.UNKNOWN;  import org.omg.CORBA.UNKNOWN;
61    import org.omg.CORBA.WrongTransaction;
62  import org.omg.CORBA.portable.Delegate;  import org.omg.CORBA.portable.Delegate;
63  import org.omg.CORBA.portable.InvokeHandler;  import org.omg.CORBA.portable.InvokeHandler;
64  import org.omg.CORBA.portable.ObjectImpl;  import org.omg.CORBA.portable.ObjectImpl;
# Line 88  import java.util.TreeMap; Line 89  import java.util.TreeMap;
89    
90  /**  /**
91   * The ORB implementation, capable to handle remote invocations on the   * The ORB implementation, capable to handle remote invocations on the
92   * registered object. This class implements all features, required till   * registered object. This class implements all features, required till the jdk
93   * the jdk 1.3 inclusive, but does not support the POA that appears since   * 1.3 inclusive, but does not support the POA that appears since 1.4. The POA
94   * 1.4. The POA is supported by {@link gnu.CORBA.Poa.ORB_1_4}.   * is supported by {@link gnu.CORBA.Poa.ORB_1_4}.
95   *   *
96   * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)   * @author Audrius Meskauskas (AudriusA@Bioinformatics.org)
97   */   */
98  public class Functional_ORB  public class Functional_ORB extends Restricted_ORB
   extends Restricted_ORB  
99  {  {
100    /**    /**
101     * A server, responsible for listening on requests on some     * A server, responsible for listening on requests on some local port. The ORB
102     * local port. The ORB may listen on multiple ports and process     * may listen on multiple ports and process the requests in separate threads.
103     * the requests in separate threads. Normally the server takes     * Normally the server takes one port per object being served.
    * one port per object being served.  
104     */     */
105    class portServer    class portServer extends Thread
     extends Thread  
106    {    {
107      /**      /**
108       * The number of the currently running parallel threads.       * The number of the currently running parallel threads.
109       */       */
110      private int running_threads;      int running_threads;
111    
112      /**      /**
113       * The port on that this portServer is listening for requests.       * The port on that this portServer is listening for requests.
# Line 122  public class Functional_ORB Line 120  public class Functional_ORB
120      ServerSocket service;      ServerSocket service;
121    
122      /**      /**
123       * True if the serving node must shutdown due       * True if the serving node must shutdown due call of the close_now().
      * call of the close_now().  
124       */       */
125      boolean terminated;      boolean terminated;
126    
# Line 136  public class Functional_ORB Line 133  public class Functional_ORB
133      }      }
134    
135      /**      /**
136       * Enter the serving loop (get request/process it).       * Enter the serving loop (get request/process it). All portServer normally
137       * All portServer normally terminate thy threads when       * terminate thy threads when the Functional_ORB.running is set to false.
      * the Functional_ORB.running is set to false.  
138       */       */
139      public void run()      public void run()
140      {      {
# Line 184  public class Functional_ORB Line 180  public class Functional_ORB
180    
181      /**      /**
182       * Perform a single serving step.       * Perform a single serving step.
183         *
184       * @throws java.lang.Exception       * @throws java.lang.Exception
185       */       */
186      void tick()      void tick() throws Exception
        throws Exception  
187      {      {
188        serve(this, service);        serve(this, service);
189      }      }
# Line 219  public class Functional_ORB Line 215  public class Functional_ORB
215    }    }
216    
217    /**    /**
218     * A server, responsible for listening on requests on some     * A server, responsible for listening on requests on some local port and
219     * local port and serving multiple requests (probably to the     * serving multiple requests (probably to the different objects) on the same
220     * different objects) on the same thread.     * thread.
221     */     */
222    class sharedPortServer    class sharedPortServer extends portServer
     extends portServer  
223    {    {
224      /**      /**
225       * Create a new portServer, serving on specific port.       * Create a new portServer, serving on specific port.
# Line 236  public class Functional_ORB Line 231  public class Functional_ORB
231    
232      /**      /**
233       * Perform a single serving step.       * Perform a single serving step.
234         *
235       * @throws java.lang.Exception       * @throws java.lang.Exception
236       */       */
237      void tick()      void tick() throws Exception
        throws Exception  
238      {      {
239        Socket request = service.accept();        Socket request = service.accept();
240        serveStep(request, false);        serveStep(request, false);
# Line 247  public class Functional_ORB Line 242  public class Functional_ORB
242    }    }
243    
244    /**    /**
245     * The default value where the first instance of this ORB will start     * The default value where the first instance of this ORB will start looking
246     * looking for a free port.     * for a free port.
247     */     */
248    public static int DEFAULT_INITIAL_PORT = 1126;    public static int DEFAULT_INITIAL_PORT = 1126;
249    
250    /**    /**
251     * The property of port, on that this ORB is listening for requests from clients.     * The property of port, on that this ORB is listening for requests from
252     * This class supports one port per ORB only.     * clients. This class supports one port per ORB only.
253     */     */
254    public static final String LISTEN_ON = "gnu.classpath.CORBA.ListenOn";    public static final String LISTEN_ON = "gnu.classpath.CORBA.ListenOn";
255    
# Line 264  public class Functional_ORB Line 259  public class Functional_ORB
259    public static final String REFERENCE = "org.omg.CORBA.ORBInitRef";    public static final String REFERENCE = "org.omg.CORBA.ORBInitRef";
260    
261    /**    /**
262     * The property, defining the port on that the default name service is running.     * The property, defining the port on that the default name service is
263       * running.
264     */     */
265    public static final String NS_PORT = "org.omg.CORBA.ORBInitialPort";    public static final String NS_PORT = "org.omg.CORBA.ORBInitialPort";
266    
267    /**    /**
268     * The property, defining the host on that the default name service is running.     * The property, defining the host on that the default name service is
269       * running.
270     */     */
271    public static final String NS_HOST = "org.omg.CORBA.ORBInitialHost";    public static final String NS_HOST = "org.omg.CORBA.ORBInitialHost";
272    
# Line 279  public class Functional_ORB Line 276  public class Functional_ORB
276    public static final String NAME_SERVICE = "NameService";    public static final String NAME_SERVICE = "NameService";
277    
278    /**    /**
279     * The if the client has once opened a socket, it should start sending     * The if the client has once opened a socket, it should start sending the
280     * the message header in a given time. Otherwise the server will close the     * message header in a given time. Otherwise the server will close the socket.
281     * socket. This prevents server hang when the client opens the socket,     * This prevents server hang when the client opens the socket, but does not
282     * but does not send any message, usually due crash on the client side.     * send any message, usually due crash on the client side.
283     */     */
284    public static String START_READING_MESSAGE =    public static String START_READING_MESSAGE =
285      "gnu.classpath.CORBA.TOUT_START_READING_MESSAGE";      "gnu.classpath.CORBA.TOUT_START_READING_MESSAGE";
286    
287    /**    /**
288     * If the client has started to send the request message, the socket time     * If the client has started to send the request message, the socket time out
289     * out changes to the specified value.     * changes to the specified value.
290     */     */
291    public static String WHILE_READING = "gnu.classpath.CORBA.TOUT_WHILE_READING";    public static String WHILE_READING =
292        "gnu.classpath.CORBA.TOUT_WHILE_READING";
293    
294    /**    /**
295     * If the message body is received, the time out changes to the     * If the message body is received, the time out changes to the specifice
296     * specifice value. This must be longer, as includes time, required to     * value. This must be longer, as includes time, required to process the
297     * process the received task. We make it 40 minutes.     * received task. We make it 40 minutes.
298     */     */
299    public static String AFTER_RECEIVING =    public static String AFTER_RECEIVING =
300      "gnu.classpath.CORBA.TOUT_AFTER_RECEIVING";      "gnu.classpath.CORBA.TOUT_AFTER_RECEIVING";
# Line 307  public class Functional_ORB Line 305  public class Functional_ORB
305    public final String LOCAL_HOST;    public final String LOCAL_HOST;
306    
307    /**    /**
308     * The if the client has once opened a socket, it should start sending     * The if the client has once opened a socket, it should start sending the
309     * the message header in a given time. Otherwise the server will close the     * message header in a given time. Otherwise the server will close the socket.
310     * socket. This prevents server hang when the client opens the socket,     * This prevents server hang when the client opens the socket, but does not
311     * but does not send any message, usually due crash on the client side.     * send any message, usually due crash on the client side.
312     */     */
313    private int TOUT_START_READING_MESSAGE = 20 * 1000;    private int TOUT_START_READING_MESSAGE = 20 * 1000;
314    
315    // (Here and below, we use * to make the meaning of the constant clearler).    // (Here and below, we use * to make the meaning of the constant clearler).
316    
317    /**    /**
318     * If the client has started to send the request message, the socket time     * If the client has started to send the request message, the socket time out
319     * out changes to the specified value.     * changes to the specified value.
320     */     */
321    private int TOUT_WHILE_READING = 2 * 60 * 1000;    private int TOUT_WHILE_READING = 2 * 60 * 1000;
322    
323    /**    /**
324     * If the message body is received, the time out changes to the     * If the message body is received, the time out changes to the specifice
325     * specifice value. This must be longer, as includes time, required to     * value. This must be longer, as includes time, required to process the
326     * process the received task. We make it 40 minutes.     * received task. We make it 40 minutes.
327     */     */
328    private int TOUT_AFTER_RECEIVING = 40 * 60 * 1000;    private int TOUT_AFTER_RECEIVING = 40 * 60 * 1000;
329    
330    /**    /**
331     * Some clients tend to submit multiple requests over the     * Some clients tend to submit multiple requests over the same socket. The
332     * same socket. The server waits for the next request on     * server waits for the next request on the same socket for the duration,
333     * the same socket for the duration, specified     * specified below. In additions, the request of this implementation also
334     * below. In additions, the request of this implementation also     * waits for the same duration before closing the socket. The default time is
335     * waits for the same duration before closing the socket.     * seven seconds.
    * The default time is seven seconds.  
336     */     */
337    public static int TANDEM_REQUESTS = 7000;    public static int TANDEM_REQUESTS = 7000;
338    
339    /**    /**
340     * The map of the already conncted objects.     * The map of the already conncted objects.
341     */     */
342    protected final Connected_objects connected_objects = new Connected_objects();    protected final Connected_objects connected_objects =
343        new Connected_objects();
344    
345    /**    /**
346     * The maximal CORBA version, supported by this ORB. The default value     * The maximal CORBA version, supported by this ORB. The default value 0 means
347     * 0 means that the ORB will not check the request version while trying     * that the ORB will not check the request version while trying to respond.
    * to respond.  
348     */     */
349    protected Version max_version;    protected Version max_version;
350    
351    /**    /**
352     * Setting this value to false causes the ORB to shutdown after the     * Setting this value to false causes the ORB to shutdown after the latest
353     * latest serving operation is complete.     * serving operation is complete.
354     */     */
355    protected boolean running;    protected boolean running;
356    
# Line 373  public class Functional_ORB Line 370  public class Functional_ORB
370    private String ns_host;    private String ns_host;
371    
372    /**    /**
373     * Probably free port, under that the ORB will try listening for     * Probably free port, under that the ORB will try listening for remote
374     * remote requests first. When the new object is connected, this     * requests first. When the new object is connected, this port is used first,
375     * port is used first, then it is incremented by 1, etc. If the given     * then it is incremented by 1, etc. If the given port is not available, up to
376     * port is not available, up to 20 subsequent values are tried and then     * 20 subsequent values are tried and then the parameterless server socket
377     * the parameterless server socket contructor is called. The constant is     * contructor is called. The constant is shared between multiple instances of
378     * shared between multiple instances of this ORB.     * this ORB.
379     */     */
380    private static int Port = DEFAULT_INITIAL_PORT;    private static int Port = DEFAULT_INITIAL_PORT;
381    
# Line 404  public class Functional_ORB Line 401  public class Functional_ORB
401    protected Hashtable identities = new Hashtable();    protected Hashtable identities = new Hashtable();
402    
403    /**    /**
404     * The maximal allowed number of the currently running parallel     * The maximal allowed number of the currently running parallel threads per
405     * threads per object. For security reasons, this is made private and     * object. For security reasons, this is made private and unchangeable. After
406     * unchangeable. After exceeding this limit, the NO_RESOURCES     * exceeding this limit, the NO_RESOURCES is thrown back to the client.
    * is thrown back to the client.  
407     */     */
408    private int MAX_RUNNING_THREADS = 256;    private int MAX_RUNNING_THREADS = 256;
409    
# Line 431  public class Functional_ORB Line 427  public class Functional_ORB
427    }    }
428    
429    /**    /**
430    * If the max version is assigned, the orb replies with the error     * If the max version is assigned, the orb replies with the error message if
431    * message if the request version is above the supported 1.2 version.     * the request version is above the supported 1.2 version. This behavior is
432    * This behavior is recommended by OMG, but not all implementations     * recommended by OMG, but not all implementations respond that error message
433    * respond that error message by re-sending the request, encoded in the older     * by re-sending the request, encoded in the older version.
434    * version.     */
   */  
435    public void setMaxVersion(Version max_supported)    public void setMaxVersion(Version max_supported)
436    {    {
437      max_version = max_supported;      max_version = max_supported;
438    }    }
439    
440    /**    /**
441     * Get the maximal supported GIOP version or null if the version is     * Get the maximal supported GIOP version or null if the version is not
442     * not checked.     * checked.
443     */     */
444    public Version getMaxVersion()    public Version getMaxVersion()
445    {    {
# Line 452  public class Functional_ORB Line 447  public class Functional_ORB
447    }    }
448    
449    /**    /**
450     * Get the currently free port, starting from the initially set port     * Get the currently free port, starting from the initially set port and going
451     * and going up max 20 steps, then trying to bind into any free     * up max 20 steps, then trying to bind into any free address.
    * address.  
452     *     *
453     * @return the currently available free port.     * @return the currently available free port.
454     *     *
455     * @throws NO_RESOURCES if the server socked cannot be opened on the     * @throws NO_RESOURCES if the server socked cannot be opened on the local
456     * local host.     * host.
457     */     */
458    public int getFreePort()    public int getFreePort() throws BAD_OPERATION
                   throws BAD_OPERATION  
459    {    {
460      ServerSocket s;      ServerSocket s;
461      int a_port;      int a_port;
# Line 519  public class Functional_ORB Line 512  public class Functional_ORB
512    }    }
513    
514    /**    /**
515     * Set the port, on that the server is listening for the client requests.     * Set the port, on that the server is listening for the client requests. If
516     * If only one object is connected to the orb, the server will be     * only one object is connected to the orb, the server will be try listening
517     * try listening on this port first. It the port is busy, or if more     * on this port first. It the port is busy, or if more objects are connected,
518     * objects are connected, the subsequent object will receive a larger     * the subsequent object will receive a larger port values, skipping
519     * port values, skipping unavailable ports, if required. The change     * unavailable ports, if required. The change applies globally.
    * applies globally.  
520     *     *
521     * @param a_Port a port, on that the server is listening for requests.     * @param a_Port a port, on that the server is listening for requests.
522     */     */
# Line 534  public class Functional_ORB Line 526  public class Functional_ORB
526    }    }
527    
528    /**    /**
529     * Connect the given CORBA object to this ORB. After the object is     * Connect the given CORBA object to this ORB. After the object is connected,
530     * connected, it starts receiving remote invocations via this ORB.     * it starts receiving remote invocations via this ORB.
531     *     *
532     * The ORB tries to connect the object to the port, that has been     * The ORB tries to connect the object to the port, that has been previously
533     * previously set by {@link setPort(int)}. On failure, it tries     * set by {@link setPort(int)}. On failure, it tries 20 subsequent larger
534     * 20 subsequent larger values and then calls the parameterless     * values and then calls the parameterless server socked constructor to get
535     * server socked constructor to get any free local port.     * any free local port. If this fails, the {@link NO_RESOURCES} is thrown.
    * If this fails, the {@link NO_RESOURCES} is thrown.  
536     *     *
537     * @param object the object, must implement the {@link InvokeHandler})     * @param object the object, must implement the {@link InvokeHandler})
538     * interface.     * interface.
# Line 561  public class Functional_ORB Line 552  public class Functional_ORB
552    }    }
553    
554    /**    /**
555     * Connect the given CORBA object to this ORB, explicitly specifying     * Connect the given CORBA object to this ORB, explicitly specifying the
556     * the object key.     * object key.
557     *     *
558     * The ORB tries to connect the object to the port, that has been     * The ORB tries to connect the object to the port, that has been previously
559     * previously set by {@link setPort(int)}. On failure, it tries     * set by {@link setPort(int)}. On failure, it tries 20 subsequent larger
560     * 20 subsequent larger values and then calls the parameterless     * values and then calls the parameterless server socked constructor to get
561     * server socked constructor to get any free local port.     * any free local port. If this fails, the {@link NO_RESOURCES} is thrown.
    * If this fails, the {@link NO_RESOURCES} is thrown.  
562     *     *
563     * @param object the object, must implement the {@link InvokeHandler})     * @param object the object, must implement the {@link InvokeHandler})
564     * interface.     * interface.
565     * @param key the object key, usually used to identify the object from     * @param key the object key, usually used to identify the object from remote
566     * remote side.     * side.
567     *     *
568     * @throws BAD_PARAM if the object does not implement the     * @throws BAD_PARAM if the object does not implement the
569     * {@link InvokeHandler}).     * {@link InvokeHandler}).
# Line 591  public class Functional_ORB Line 581  public class Functional_ORB
581    }    }
582    
583    /**    /**
584     * Connect the given CORBA object to this ORB, explicitly specifying     * Connect the given CORBA object to this ORB, explicitly specifying the
585     * the object key and the identity of the thread (and port), where the     * object key and the identity of the thread (and port), where the object must
586     * object must be served. The identity is normally the POA.     * be served. The identity is normally the POA.
587     *     *
588     * The new port server will be started only if there is no one     * The new port server will be started only if there is no one already running
589     * already running for the same identity. Otherwise, the task of     * for the same identity. Otherwise, the task of the existing port server will
590     * the existing port server will be widened, including duty to serve     * be widened, including duty to serve the given object. All objects,
591     * the given object. All objects, connected to a single identity by     * connected to a single identity by this method, will process they requests
592     * this method, will process they requests subsequently in the same     * subsequently in the same thread. The method is used when the expected
593     * thread. The method is used when the expected number of the     * number of the objects is too large to have a single port and thread per
594     * objects is too large to have a single port and thread per object.     * object. This method is used by POAs, having a single thread policy.
    * This method is used by POAs, having a single thread policy.  
595     *     *
596     * @param object the object, must implement the {@link InvokeHandler})     * @param object the object, must implement the {@link InvokeHandler})
597     * interface.     * interface.
598     * @param key the object key, usually used to identify the object from     * @param key the object key, usually used to identify the object from remote
599     * remote side.     * side.
600     * @param port the port, where the object must be connected.     * @param port the port, where the object must be connected.
601     *     *
602     * @throws BAD_PARAM if the object does not implement the     * @throws BAD_PARAM if the object does not implement the
603     * {@link InvokeHandler}).     * {@link InvokeHandler}).
604     */     */
605    public void connect_1_thread(org.omg.CORBA.Object object, byte[] key,    public void connect_1_thread(org.omg.CORBA.Object object, byte[] key,
606                                 java.lang.Object identity      java.lang.Object identity
607                                )    )
608    {    {
609      sharedPortServer shared = (sharedPortServer) identities.get(identity);      sharedPortServer shared = (sharedPortServer) identities.get(identity);
610      if (shared == null)      if (shared == null)
# Line 653  public class Functional_ORB Line 642  public class Functional_ORB
642     */     */
643    public void destroy()    public void destroy()
644    {    {
     super.destroy();  
   
645      portServer p;      portServer p;
646      for (int i = 0; i < portServers.size(); i++)      for (int i = 0; i < portServers.size(); i++)
647        {        {
648          p = (portServer) portServers.get(i);          p = (portServer) portServers.get(i);
649          p.close_now();          p.close_now();
650        }        }
651        super.destroy();
652    }    }
653    
654    /**    /**
655     * Disconnect the given CORBA object from this ORB. The object will be     * Disconnect the given CORBA object from this ORB. The object will be no
656     * no longer receiving the remote invocations. In response to the     * longer receiving the remote invocations. In response to the remote
657     * remote invocation on this object, the ORB will send the     * invocation on this object, the ORB will send the exception
658     * exception {@link OBJECT_NOT_EXIST}. The object, however, is not     * {@link OBJECT_NOT_EXIST}. The object, however, is not destroyed and can
659     * destroyed and can receive the local invocations.     * receive the local invocations.
660       *
661     * @param object the object to disconnect.     * @param object the object to disconnect.
662     */     */
663    public void disconnect(org.omg.CORBA.Object object)    public void disconnect(org.omg.CORBA.Object object)
# Line 692  public class Functional_ORB Line 680  public class Functional_ORB
680      // object implementation.      // object implementation.
681      if (rmKey == null)      if (rmKey == null)
682        rmKey = connected_objects.getKey(object);        rmKey = connected_objects.getKey(object);
   
     // Disconnect the object on any success.  
683      if (rmKey != null)      if (rmKey != null)
684        {        {
685          // Find and stop the corresponding portServer.          // Find and stop the corresponding portServer.
# Line 714  public class Functional_ORB Line 700  public class Functional_ORB
700    }    }
701    
702    /**    /**
703     * Notifies ORB that the shared service indentity (usually POA)     * Notifies ORB that the shared service indentity (usually POA) is destroyed.
704     * is destroyed. The matching shared port server is terminated     * The matching shared port server is terminated and the identity table entry
705     * and the identity table entry is deleted. If this identity     * is deleted. If this identity is not known for this ORB, the method returns
706     * is not known for this ORB, the method returns without action.     * without action.
707     *     *
708     * @param identity the identity that has been destroyed.     * @param identity the identity that has been destroyed.
709     */     */
# Line 728  public class Functional_ORB Line 714  public class Functional_ORB
714    
715      sharedPortServer ise = (sharedPortServer) identities.get(identity);      sharedPortServer ise = (sharedPortServer) identities.get(identity);
716      if (ise != null)      if (ise != null)
717        synchronized (connected_objects)        {
718          {          synchronized (connected_objects)
719            ise.close_now();            {
720            identities.remove(identity);              ise.close_now();
721                identities.remove(identity);
722    
723            Connected_objects.cObject obj;              Connected_objects.cObject obj;
724            Map.Entry m;              Map.Entry m;
725            Iterator iter = connected_objects.entrySet().iterator();              Iterator iter = connected_objects.entrySet().iterator();
726            while (iter.hasNext())              while (iter.hasNext())
727              {                {
728                m = (Map.Entry) iter.next();                  m = (Map.Entry) iter.next();
729                obj = (Connected_objects.cObject) m.getValue();                  obj = (Connected_objects.cObject) m.getValue();
730                if (obj.identity == identity)                  if (obj.identity == identity)
                 {  
731                    iter.remove();                    iter.remove();
732                  }                }
733              }            }
734          }        }
735    }    }
736    
737    /**    /**
# Line 753  public class Functional_ORB Line 739  public class Functional_ORB
739     *     *
740     * @param ior the ior of the potentially local object.     * @param ior the ior of the potentially local object.
741     *     *
742     * @return the local object, represented by the given IOR,     * @return the local object, represented by the given IOR, or null if this is
743     * or null if this is not a local connected object.     * not a local connected object.
744     */     */
745    public org.omg.CORBA.Object find_local_object(IOR ior)    public org.omg.CORBA.Object find_local_object(IOR ior)
746    {    {
# Line 783  public class Functional_ORB Line 769  public class Functional_ORB
769    
770      Iterator iter = initial_references.keySet().iterator();      Iterator iter = initial_references.keySet().iterator();
771      while (iter.hasNext())      while (iter.hasNext())
772        refs [ p++ ] = (String) iter.next();        {
773            refs [ p++ ] = (String) iter.next();
774          }
775      return refs;      return refs;
776    }    }
777    
778    /**    /**
779     * Get the IOR reference string for the given object.     * Get the IOR reference string for the given object. The string embeds
780     * The string embeds information about the object     * information about the object repository Id, its access key and the server
781     * repository Id, its access key and the server internet     * internet address and port. With this information, the object can be found
782     * address and port. With this information, the object     * by another ORB, possibly located on remote computer.
    * can be found by another ORB, possibly located on remote  
    * computer.  
783     *     *
784     * @param the CORBA object     * @param the CORBA object
785     * @return the object IOR representation.     * @return the object IOR representation.
786     *     *
787     * @throws BAD_PARAM if the object has not been previously     * @throws BAD_PARAM if the object has not been previously connected to this
788     * connected to this ORB.     * ORB.
789     * @throws BAD_OPERATION in the unlikely case if the local host     *
790     * address cannot be resolved.     * @throws BAD_OPERATION in the unlikely case if the local host address cannot
791       * be resolved.
792     *     *
793     * @see string_to_object(String)     * @see string_to_object(String)
794     */     */
# Line 821  public class Functional_ORB Line 807  public class Functional_ORB
807    
808      if (rec == null)      if (rec == null)
809        throw new BAD_PARAM("The object " + forObject +        throw new BAD_PARAM("The object " + forObject +
810                            " has not been previously connected to this ORB"          " has not been previously connected to this ORB"
811                           );        );
812    
813      IOR ior = createIOR(rec);      IOR ior = createIOR(rec);
814    
# Line 830  public class Functional_ORB Line 816  public class Functional_ORB
816    }    }
817    
818    /**    /**
819     * Find and return the easily accessible CORBA object, addressed     * Get the local IOR for the given object, null if the object is not local.
820     * by name.     */
821      public IOR getLocalIor(org.omg.CORBA.Object forObject)
822      {
823        Connected_objects.cObject rec = connected_objects.getKey(forObject);
824        if (rec == null)
825          return null;
826        else
827          return createIOR(rec);
828      }
829    
830      /**
831       * Find and return the easily accessible CORBA object, addressed by name.
832     *     *
833     * @param name the object name.     * @param name the object name.
834     * @return the object     * @return the object
835     *     *
836     * @throws org.omg.CORBA.ORBPackage.InvalidName if the given name     * @throws org.omg.CORBA.ORBPackage.InvalidName if the given name is not
837     * is not associated with the known object.     * associated with the known object.
838     */     */
839    public org.omg.CORBA.Object resolve_initial_references(String name)    public org.omg.CORBA.Object resolve_initial_references(String name)
840                                                    throws InvalidName      throws InvalidName
841    {    {
842      org.omg.CORBA.Object object = null;      org.omg.CORBA.Object object = null;
843      try      try
# Line 866  public class Functional_ORB Line 863  public class Functional_ORB
863    }    }
864    
865    /**    /**
866     * Start the ORBs main working cycle     * Start the ORBs main working cycle (receive invocation - invoke on the local
867     * (receive invocation - invoke on the local object - send response -     * object - send response - wait for another invocation).
    *  wait for another invocation).  
868     *     *
869     * The method only returns after calling {@link #shutdown(boolean)}.     * The method only returns after calling {@link #shutdown(boolean)}.
870     */     */
# Line 894  public class Functional_ORB Line 890  public class Functional_ORB
890              portServers.add(subserver);              portServers.add(subserver);
891            }            }
892          else          else
893            {            subserver = (portServer) identities.get(obj.identity);
             subserver = (portServer) identities.get(obj.identity);  
           }  
894    
895          if (!subserver.isAlive())          if (!subserver.isAlive())
896            {            {
# Line 917  public class Functional_ORB Line 911  public class Functional_ORB
911    /**    /**
912     * Shutdown the ORB server.     * Shutdown the ORB server.
913     *     *
914     * @param wait_for_completion if true, the current thread is     * @param wait_for_completion if true, the current thread is suspended until
915     * suspended until the shutdown process is complete.     * the shutdown process is complete.
916     */     */
917    public void shutdown(boolean wait_for_completion)    public void shutdown(boolean wait_for_completion)
918    {    {
# Line 936  public class Functional_ORB Line 930  public class Functional_ORB
930    }    }
931    
932    /**    /**
933     * Find and return the CORBA object, addressed by the given     * Find and return the CORBA object, addressed by the given IOR string
934     * IOR string representation. The object can (an usually is)     * representation. The object can (an usually is) located on a remote
935     * located on a remote computer, possibly running a different     * computer, possibly running a different (not necessary java) CORBA
936     * (not necessary java) CORBA implementation.     * implementation.
937     *     *
938     * @param ior the object IOR representation string.     * @param ior the object IOR representation string.
939     *     *
# Line 956  public class Functional_ORB Line 950  public class Functional_ORB
950          try          try
951            {            {
952              if (impl._get_delegate() == null)              if (impl._get_delegate() == null)
953                {                impl._set_delegate(new IOR_Delegate(this, ior));
                 impl._set_delegate(new IOR_Delegate(this, ior));  
               }  
954            }            }
955          catch (BAD_OPERATION ex)          catch (BAD_OPERATION ex)
956            {            {
# Line 974  public class Functional_ORB Line 966  public class Functional_ORB
966    }    }
967    
968    /**    /**
969     * Get the default naming service for the case when there no     * Get the default naming service for the case when there no NameService
970     * NameService entries.     * entries.
971     */     */
972    protected org.omg.CORBA.Object getDefaultNameService()    protected org.omg.CORBA.Object getDefaultNameService()
973    {    {
974      if (initial_references.containsKey(NAME_SERVICE))      if (initial_references.containsKey(NAME_SERVICE))
975        {        return (org.omg.CORBA.Object) initial_references.get(NAME_SERVICE);
         return (org.omg.CORBA.Object) initial_references.get(NAME_SERVICE);  
       }  
976    
977      IOR ior = new IOR();      IOR ior = new IOR();
978      ior.Id = NamingContextExtHelper.id();      ior.Id = NamingContextExtHelper.id();
# Line 997  public class Functional_ORB Line 987  public class Functional_ORB
987    }    }
988    
989    /**    /**
990     * Find and return the object, that must be previously connected     * Find and return the object, that must be previously connected to this ORB.
991     * to this ORB. Return null if no such object is available.     * Return null if no such object is available.
992     *     *
993     * @param key the object key.     * @param key the object key.
994     *     *
# Line 1017  public class Functional_ORB Line 1007  public class Functional_ORB
1007     * @param app the current applet.     * @param app the current applet.
1008     *     *
1009     * @param props application specific properties, passed as the second     * @param props application specific properties, passed as the second
1010     * parameter in {@link #init(Applet, Properties)}.     * parameter in {@link #init(Applet, Properties)}. Can be <code>null</code>.
    * Can be <code>null</code>.  
1011     */     */
1012    protected void set_parameters(Applet app, Properties props)    protected void set_parameters(Applet app, Properties props)
1013    {    {
# Line 1031  public class Functional_ORB Line 1020  public class Functional_ORB
1020            {            {
1021              if (para [ i ] [ 0 ].equals(LISTEN_ON))              if (para [ i ] [ 0 ].equals(LISTEN_ON))
1022                Port = Integer.parseInt(para [ i ] [ 1 ]);                Port = Integer.parseInt(para [ i ] [ 1 ]);
   
1023              if (para [ i ] [ 0 ].equals(REFERENCE))              if (para [ i ] [ 0 ].equals(REFERENCE))
1024                {                {
1025                  StringTokenizer st = new StringTokenizer(para [ i ] [ 1 ], "=");                  StringTokenizer st =
1026                      new StringTokenizer(para [ i ] [ 1 ], "=");
1027                  initial_references.put(st.nextToken(),                  initial_references.put(st.nextToken(),
1028                                         string_to_object(st.nextToken())                    string_to_object(st.nextToken())
1029                                        );                  );
1030                }                }
1031    
1032              if (para [ i ] [ 0 ].equals(NS_HOST))              if (para [ i ] [ 0 ].equals(NS_HOST))
1033                ns_host = para [ i ] [ 1 ];                ns_host = para [ i ] [ 1 ];
   
1034              if (para [ i ] [ 0 ].equals(START_READING_MESSAGE))              if (para [ i ] [ 0 ].equals(START_READING_MESSAGE))
1035                TOUT_START_READING_MESSAGE = Integer.parseInt(para [ i ] [ 1 ]);                TOUT_START_READING_MESSAGE = Integer.parseInt(para [ i ] [ 1 ]);
   
1036              if (para [ i ] [ 0 ].equals(WHILE_READING))              if (para [ i ] [ 0 ].equals(WHILE_READING))
1037                TOUT_WHILE_READING = Integer.parseInt(para [ i ] [ 1 ]);                TOUT_WHILE_READING = Integer.parseInt(para [ i ] [ 1 ]);
   
1038              if (para [ i ] [ 0 ].equals(AFTER_RECEIVING))              if (para [ i ] [ 0 ].equals(AFTER_RECEIVING))
1039                TOUT_AFTER_RECEIVING = Integer.parseInt(para [ i ] [ 1 ]);                TOUT_AFTER_RECEIVING = Integer.parseInt(para [ i ] [ 1 ]);
   
1040              try              try
1041                {                {
1042                  if (para [ i ] [ 0 ].equals(NS_PORT))                  if (para [ i ] [ 0 ].equals(NS_PORT))
# Line 1061  public class Functional_ORB Line 1046  public class Functional_ORB
1046                {                {
1047                  BAD_PARAM bad =                  BAD_PARAM bad =
1048                    new BAD_PARAM("Invalid " + NS_PORT +                    new BAD_PARAM("Invalid " + NS_PORT +
1049                                  "property, unable to parse '" +                      "property, unable to parse '" +
1050                                  props.getProperty(NS_PORT) + "'"                      props.getProperty(NS_PORT) + "'"
1051                                 );                    );
1052                  bad.initCause(ex);                  bad.initCause(ex);
1053                  throw bad;                  throw bad;
1054                }                }
# Line 1075  public class Functional_ORB Line 1060  public class Functional_ORB
1060     * Set the ORB parameters. This method is normally called from     * Set the ORB parameters. This method is normally called from
1061     * {@link #init(String[], Properties)}.     * {@link #init(String[], Properties)}.
1062     *     *
1063     * @param para the parameters, that were passed as the parameters     * @param para the parameters, that were passed as the parameters to the
1064     * to the  <code>main(String[] args)</code> method of the current standalone     * <code>main(String[] args)</code> method of the current standalone
1065     * application.     * application.
1066     *     *
1067     * @param props application specific properties that were passed     * @param props application specific properties that were passed as a second
1068     * as a second parameter in {@link init(String[], Properties)}).     * parameter in {@link init(String[], Properties)}). Can be <code>null</code>.
    * Can be <code>null</code>.  
1069     */     */
1070    protected void set_parameters(String[] para, Properties props)    protected void set_parameters(String[] para, Properties props)
1071    {    {
1072      if (para.length > 1)      if (para.length > 1)
1073        for (int i = 0; i < para.length - 1; i++)        {
1074          {          for (int i = 0; i < para.length - 1; i++)
1075            if (para [ i ].endsWith("ListenOn"))            {
1076              Port = Integer.parseInt(para [ i + 1 ]);              if (para [ i ].endsWith("ListenOn"))
1077                  Port = Integer.parseInt(para [ i + 1 ]);
1078            if (para [ i ].endsWith("ORBInitRef"))              if (para [ i ].endsWith("ORBInitRef"))
1079              {                {
1080                StringTokenizer st = new StringTokenizer(para [ i + 1 ], "=");                  StringTokenizer st = new StringTokenizer(para [ i + 1 ], "=");
1081                initial_references.put(st.nextToken(),                  initial_references.put(st.nextToken(),
1082                                       string_to_object(st.nextToken())                    string_to_object(st.nextToken())
1083                                      );                  );
1084              }                }
   
           if (para [ i ].endsWith("ORBInitialHost"))  
             ns_host = para [ i + 1 ];  
1085    
1086            try              if (para [ i ].endsWith("ORBInitialHost"))
1087              {                ns_host = para [ i + 1 ];
1088                if (para [ i ].endsWith("ORBInitialPort"))              try
1089                  ns_port = Integer.parseInt(para [ i + 1 ]);                {
1090              }                  if (para [ i ].endsWith("ORBInitialPort"))
1091            catch (NumberFormatException ex)                    ns_port = Integer.parseInt(para [ i + 1 ]);
1092              {                }
1093                throw new BAD_PARAM("Invalid " + para [ i ] +              catch (NumberFormatException ex)
1094                                    "parameter, unable to parse '" +                {
1095                                    props.getProperty(para [ i + 1 ]) + "'"                  throw new BAD_PARAM("Invalid " + para [ i ] +
1096                                   );                    "parameter, unable to parse '" +
1097              }                    props.getProperty(para [ i + 1 ]) + "'"
1098          }                  );
1099                  }
1100              }
1101          }
1102    
1103      useProperties(props);      useProperties(props);
1104    }    }
1105    
1106    private IOR createIOR(Connected_objects.cObject ref)    /**
1107                   throws BAD_OPERATION     * Create IOR for the given object references.
1108       */
1109      protected IOR createIOR(Connected_objects.cObject ref)
1110        throws BAD_OPERATION
1111    {    {
1112      IOR ior = new IOR();      IOR ior = new IOR();
1113      ior.key = ref.key;      ior.key = ref.key;
# Line 1134  public class Functional_ORB Line 1121  public class Functional_ORB
1121        }        }
1122      if (ior.Id == null)      if (ior.Id == null)
1123        ior.Id = ref.object.getClass().getName();        ior.Id = ref.object.getClass().getName();
   
1124      try      try
1125        {        {
1126          ior.Internet.host = InetAddress.getLocalHost().getHostAddress();          ior.Internet.host = InetAddress.getLocalHost().getHostAddress();
# Line 1156  public class Functional_ORB Line 1142  public class Functional_ORB
1142     * {@link InvokeHandler}).     * {@link InvokeHandler}).
1143     */     */
1144    private void prepareObject(org.omg.CORBA.Object object, IOR ior)    private void prepareObject(org.omg.CORBA.Object object, IOR ior)
1145                        throws BAD_PARAM      throws BAD_PARAM
1146    {    {
1147      /*      /*
1148      if (!(object instanceof InvokeHandler))       * if (!(object instanceof InvokeHandler)) throw new
1149        throw new BAD_PARAM(object.getClass().getName() +       * BAD_PARAM(object.getClass().getName() + " does not implement
1150                            " does not implement InvokeHandler. "       * InvokeHandler. " );
                          );  
1151       */       */
1152    
1153      // If no delegate is set, set the default delegate.      // If no delegate is set, set the default delegate.
# Line 1172  public class Functional_ORB Line 1157  public class Functional_ORB
1157          try          try
1158            {            {
1159              if (impl._get_delegate() == null)              if (impl._get_delegate() == null)
1160                {                impl._set_delegate(new Simple_delegate(this, ior));
                 impl._set_delegate(new Simple_delegate(this, ior));  
               }  
1161            }            }
1162          catch (BAD_OPERATION ex)          catch (BAD_OPERATION ex)
1163            {            {
# Line 1190  public class Functional_ORB Line 1173  public class Functional_ORB
1173     * @param net_out the stream to write response into     * @param net_out the stream to write response into
1174     * @param msh_request the request message header     * @param msh_request the request message header
1175     * @param rh_request the request header     * @param rh_request the request header
1176     * @param handler the invocation handler that has been used to     * @param handler the invocation handler that has been used to invoke the
1177     * invoke the operation     * operation
1178     * @param sysEx the system exception, thrown during the invocation,     * @param sysEx the system exception, thrown during the invocation, null if
1179     * null if none.     * none.
1180     *     *
1181     * @throws IOException     * @throws IOException
1182     */     */
1183    private void respond_to_client(OutputStream net_out,    private void respond_to_client(OutputStream net_out,
1184                                   MessageHeader msh_request,      MessageHeader msh_request, RequestHeader rh_request,
1185                                   RequestHeader rh_request,      bufferedResponseHandler handler, SystemException sysEx
1186                                   bufferedResponseHandler handler,    ) throws IOException
                                  SystemException sysEx  
                                 )  
                           throws IOException  
1187    {    {
1188      // Set the reply header properties.      // Set the reply header properties.
1189      ReplyHeader reply = handler.reply_header;      ReplyHeader reply = handler.reply_header;
# Line 1214  public class Functional_ORB Line 1194  public class Functional_ORB
1194        reply.reply_status = ReplyHeader.USER_EXCEPTION;        reply.reply_status = ReplyHeader.USER_EXCEPTION;
1195      else      else
1196        reply.reply_status = ReplyHeader.NO_EXCEPTION;        reply.reply_status = ReplyHeader.NO_EXCEPTION;
   
1197      reply.request_id = rh_request.request_id;      reply.request_id = rh_request.request_id;
1198    
1199      cdrBufOutput out = new cdrBufOutput(50 + handler.getBuffer().buffer.size());      cdrBufOutput out =
1200          new cdrBufOutput(50 + handler.getBuffer().buffer.size());
1201      out.setOrb(this);      out.setOrb(this);
1202    
1203      out.setOffset(msh_request.getHeaderSize());      out.setOffset(msh_request.getHeaderSize());
1204    
1205      reply.write(out);      reply.write(out);
1206    
1207      // Write the reply data from the handler.      if (msh_request.version.since_inclusive(1, 2))
1208          {
1209            out.align(8);
1210    
1211            // Write the reply data from the handler. The handler data already
1212            // include the necessary heading zeroes for alignment.
1213          }
1214      handler.getBuffer().buffer.writeTo(out);      handler.getBuffer().buffer.writeTo(out);
1215    
1216      MessageHeader msh_reply = new MessageHeader();      MessageHeader msh_reply = new MessageHeader();
# Line 1240  public class Functional_ORB Line 1226  public class Functional_ORB
1226    }    }
1227    
1228    /**    /**
1229     * Forward request to another target, as indicated by the passed     * Forward request to another target, as indicated by the passed exception.
    * exception.  
1230     */     */
1231    private void forward_request(OutputStream net_out, MessageHeader msh_request,    private void forward_request(OutputStream net_out,
1232                                 RequestHeader rh_request, gnuForwardRequest info      MessageHeader msh_request, RequestHeader rh_request, gnuForwardRequest info
1233                                )    ) throws IOException
                         throws IOException  
1234    {    {
1235      MessageHeader msh_forward = new MessageHeader();      MessageHeader msh_forward = new MessageHeader();
1236      msh_forward.version = msh_request.version;      msh_forward.version = msh_request.version;
# Line 1265  public class Functional_ORB Line 1249  public class Functional_ORB
1249    
1250      if (msh_forward.version.since_inclusive(1, 2))      if (msh_forward.version.since_inclusive(1, 2))
1251        out.align(8);        out.align(8);
   
1252      out.write_Object(info.forward_reference);      out.write_Object(info.forward_reference);
1253    
1254      msh_forward.message_size = out.buffer.size();      msh_forward.message_size = out.buffer.size();
# Line 1279  public class Functional_ORB Line 1262  public class Functional_ORB
1262    /**    /**
1263     * Contains a single servicing task.     * Contains a single servicing task.
1264     *     *
1265     * Normally, each task matches a single remote invocation.     * Normally, each task matches a single remote invocation. However under
1266     * However under frequent tandem submissions the same     * frequent tandem submissions the same task may span over several
1267     * task may span over several invocations.     * invocations.
1268     *     *
1269     * @param serverSocket the ORB server socket.     * @param serverSocket the ORB server socket.
1270     *     *
1271     * @throws MARSHAL     * @throws MARSHAL
1272     * @throws IOException     * @throws IOException
1273     */     */
1274    private void serve(final portServer p, ServerSocket serverSocket)    void serve(final portServer p, ServerSocket serverSocket)
1275                throws MARSHAL, IOException      throws MARSHAL, IOException
1276    {    {
1277      final Socket service;      final Socket service;
1278      service = serverSocket.accept();      service = serverSocket.accept();
# Line 1327  public class Functional_ORB Line 1310  public class Functional_ORB
1310    /**    /**
1311     * A single servicing step, when the client socket is alrady open.     * A single servicing step, when the client socket is alrady open.
1312     *     *
1313     * Normally, each task matches a single remote invocation.     * Normally, each task matches a single remote invocation. However under
1314     * However under frequent tandem submissions the same     * frequent tandem submissions the same task may span over several
1315     * task may span over several invocations.     * invocations.
1316     *     *
1317     * @param service the opened client socket.     * @param service the opened client socket.
1318     * @param no_resources if true, the "NO RESOURCES" exception     * @param no_resources if true, the "NO RESOURCES" exception is thrown to the
1319     * is thrown to the client.     * client.
1320     */     */
1321    private void serveStep(Socket service, boolean no_resources)    void serveStep(Socket service, boolean no_resources)
1322    {    {
1323      try      try
1324        {        {
# Line 1358  public class Functional_ORB Line 1341  public class Functional_ORB
1341                }                }
1342    
1343              if (max_version != null)              if (max_version != null)
1344                if (!msh_request.version.until_inclusive(max_version.major,                {
1345                                                         max_version.minor                  if (!msh_request.version.until_inclusive(max_version.major,
1346                                                        )                      max_version.minor
1347                   )                    )
1348                  {                  )
1349                    OutputStream out = service.getOutputStream();                    {
1350                    new ErrorMessage(max_version).write(out);                      OutputStream out = service.getOutputStream();
1351                    return;                      new ErrorMessage(max_version).write(out);
1352                  }                      return;
1353                      }
1354                  }
1355    
1356              byte[] r = new byte[ msh_request.message_size ];              byte[] r = new byte[ msh_request.message_size ];
1357    
# Line 1400  public class Functional_ORB Line 1385  public class Functional_ORB
1385                  // in 1.2 and higher, align the current position at                  // in 1.2 and higher, align the current position at
1386                  // 8 octet boundary.                  // 8 octet boundary.
1387                  if (msh_request.version.since_inclusive(1, 2))                  if (msh_request.version.since_inclusive(1, 2))
1388                    cin.align(8);                    {
1389                        cin.align(8);
1390    
1391                        // find the target object.
1392                      }
1393    
                 // find the target object.  
1394                  InvokeHandler target =                  InvokeHandler target =
1395                    (InvokeHandler) find_connected_object(rh_request.object_key);                    (InvokeHandler) find_connected_object(rh_request.object_key);
1396    
# Line 1413  public class Functional_ORB Line 1401  public class Functional_ORB
1401    
1402                  // TODO log errors about not existing objects and methods.                  // TODO log errors about not existing objects and methods.
1403                  bufferedResponseHandler handler =                  bufferedResponseHandler handler =
1404                    new bufferedResponseHandler(this, msh_request, rh_reply);                    new bufferedResponseHandler(this, msh_request, rh_reply,
1405                        rh_request
1406                      );
1407    
1408                  SystemException sysEx = null;                  SystemException sysEx = null;
1409    
# Line 1449  public class Functional_ORB Line 1439  public class Functional_ORB
1439                    {                    {
1440                      except.printStackTrace();                      except.printStackTrace();
1441                      sysEx =                      sysEx =
1442                        new UNKNOWN("Unknown", 2, CompletionStatus.COMPLETED_MAYBE);                        new UNKNOWN("Unknown", 2,
1443                            CompletionStatus.COMPLETED_MAYBE
1444                          );
1445    
1446                      org.omg.CORBA.portable.OutputStream ech =                      org.omg.CORBA.portable.OutputStream ech =
1447                        handler.createExceptionReply();                        handler.createExceptionReply();
# Line 1462  public class Functional_ORB Line 1454  public class Functional_ORB
1454                    {                    {
1455                      OutputStream sou = service.getOutputStream();                      OutputStream sou = service.getOutputStream();
1456                      respond_to_client(sou, msh_request, rh_request, handler,                      respond_to_client(sou, msh_request, rh_request, handler,
1457                                        sysEx                        sysEx
1458                                       );                      );
1459                    }                    }
1460                }                }
1461              else if (msh_request.message_type == MessageHeader.CLOSE_CONNECTION ||              else if (msh_request.message_type == MessageHeader.CLOSE_CONNECTION ||
1462                       msh_request.message_type == MessageHeader.MESSAGE_ERROR                msh_request.message_type == MessageHeader.MESSAGE_ERROR
1463                      )              )
1464                {                {
1465                  CloseMessage.close(service.getOutputStream());                  CloseMessage.close(service.getOutputStream());
1466                  service.close();                  service.close();
# Line 1478  public class Functional_ORB Line 1470  public class Functional_ORB
1470    
1471              // TODO log error: "Not a request message."              // TODO log error: "Not a request message."
1472              if (service != null && !service.isClosed())              if (service != null && !service.isClosed())
1473                {  
1474                  // Wait for the subsequent invocations on the                // Wait for the subsequent invocations on the
1475                  // same socket for the TANDEM_REQUEST duration.                // same socket for the TANDEM_REQUEST duration.
1476                  service.setSoTimeout(TANDEM_REQUESTS);                service.setSoTimeout(TANDEM_REQUESTS);
               }  
1477              else              else
1478                return;                return;
1479            }            }
# Line 1506  public class Functional_ORB Line 1497  public class Functional_ORB
1497        {        {
1498          if (props.containsKey(LISTEN_ON))          if (props.containsKey(LISTEN_ON))
1499            Port = Integer.parseInt(props.getProperty(LISTEN_ON));            Port = Integer.parseInt(props.getProperty(LISTEN_ON));
   
1500          if (props.containsKey(NS_HOST))          if (props.containsKey(NS_HOST))
1501            ns_host = props.getProperty(NS_HOST);            ns_host = props.getProperty(NS_HOST);
   
1502          try          try
1503            {            {
1504              if (props.containsKey(NS_PORT))              if (props.containsKey(NS_PORT))
1505                ns_port = Integer.parseInt(props.getProperty(NS_PORT));                ns_port = Integer.parseInt(props.getProperty(NS_PORT));
   
1506              if (props.containsKey(START_READING_MESSAGE))              if (props.containsKey(START_READING_MESSAGE))
1507                TOUT_START_READING_MESSAGE =                TOUT_START_READING_MESSAGE =
1508                  Integer.parseInt(props.getProperty(START_READING_MESSAGE));                  Integer.parseInt(props.getProperty(START_READING_MESSAGE));
   
1509              if (props.containsKey(WHILE_READING))              if (props.containsKey(WHILE_READING))
1510                TOUT_WHILE_READING =                TOUT_WHILE_READING =
1511                  Integer.parseInt(props.getProperty(WHILE_READING));                  Integer.parseInt(props.getProperty(WHILE_READING));
   
1512              if (props.containsKey(AFTER_RECEIVING))              if (props.containsKey(AFTER_RECEIVING))
1513                TOUT_AFTER_RECEIVING =                TOUT_AFTER_RECEIVING =
1514                  Integer.parseInt(props.getProperty(AFTER_RECEIVING));                  Integer.parseInt(props.getProperty(AFTER_RECEIVING));
# Line 1530  public class Functional_ORB Line 1516  public class Functional_ORB
1516          catch (NumberFormatException ex)          catch (NumberFormatException ex)
1517            {            {
1518              throw new BAD_PARAM("Invalid " + NS_PORT +              throw new BAD_PARAM("Invalid " + NS_PORT +
1519                                  "property, unable to parse '" +                "property, unable to parse '" + props.getProperty(NS_PORT) +
1520                                  props.getProperty(NS_PORT) + "'"                "'"
1521                                 );              );
1522            }            }
1523    
1524          Enumeration en = props.elements();          Enumeration en = props.elements();
# Line 1541  public class Functional_ORB Line 1527  public class Functional_ORB
1527              String item = (String) en.nextElement();              String item = (String) en.nextElement();
1528              if (item.equals(REFERENCE))              if (item.equals(REFERENCE))
1529                initial_references.put(item,                initial_references.put(item,
1530                                       string_to_object(props.getProperty(item))                  string_to_object(props.getProperty(item))
1531                                      );                );
1532            }            }
1533        }        }
1534    }    }
1535    
1536    /**    /**
1537     * Get the next instance with a response being received. If all currently     * Get the next instance with a response being received. If all currently sent
1538     * sent responses not yet processed, this method pauses till at least one of     * responses not yet processed, this method pauses till at least one of them
1539     * them is complete. If there are no requests currently sent, the method     * is complete. If there are no requests currently sent, the method pauses
1540     * pauses till some request is submitted and the response is received.     * till some request is submitted and the response is received. This strategy
1541     * This strategy is identical to the one accepted by Suns 1.4 ORB     * is identical to the one accepted by Suns 1.4 ORB implementation.
    * implementation.  
1542     *     *
1543     * The returned response is removed from the list of the currently     * The returned response is removed from the list of the currently submitted
1544     * submitted responses and is never returned again.     * responses and is never returned again.
1545     *     *
1546     * @return the previously sent request that now contains the received     * @return the previously sent request that now contains the received
1547     * response.     * response.
1548     *     *
1549     * @throws WrongTransaction If the method was called from the transaction     * @throws WrongTransaction If the method was called from the transaction
1550     * scope different than the one, used to send the request. The exception     * scope different than the one, used to send the request. The exception can
1551     * can be raised only if the request is implicitly associated with some     * be raised only if the request is implicitly associated with some particular
1552     * particular transaction.     * transaction.
1553     */     */
1554    public Request get_next_response()    public Request get_next_response() throws org.omg.CORBA.WrongTransaction
                             throws org.omg.CORBA.WrongTransaction  
1555    {    {
1556      return asynchron.get_next_response();      return asynchron.get_next_response();
1557    }    }
# Line 1576  public class Functional_ORB Line 1560  public class Functional_ORB
1560     * Find if any of the requests that have been previously sent with     * Find if any of the requests that have been previously sent with
1561     * {@link #send_multiple_requests_deferred}, have a response yet.     * {@link #send_multiple_requests_deferred}, have a response yet.
1562     *     *
1563     * @return true if there is at least one response to the previously     * @return true if there is at least one response to the previously sent
1564     * sent request, false otherwise.     * request, false otherwise.
1565     */     */
1566    public boolean poll_next_response()    public boolean poll_next_response()
1567    {    {
# Line 1585  public class Functional_ORB Line 1569  public class Functional_ORB
1569    }    }
1570    
1571    /**    /**
1572     * Send multiple prepared requests expecting to get a reply. All requests     * Send multiple prepared requests expecting to get a reply. All requests are
1573     * are send in parallel, each in its own separate thread. When the     * send in parallel, each in its own separate thread. When the reply arrives,
1574     * reply arrives, it is stored in the agreed fields of the corresponing     * it is stored in the agreed fields of the corresponing request data
1575     * request data structure. If this method is called repeatedly,     * structure. If this method is called repeatedly, the new requests are added
1576     * the new requests are added to the set of the currently sent requests,     * to the set of the currently sent requests, but the old set is not
1577     * but the old set is not discarded.     * discarded.
1578     *     *
1579     * @param requests the prepared array of requests.     * @param requests the prepared array of requests.
1580     *     *
# Line 1605  public class Functional_ORB Line 1589  public class Functional_ORB
1589    
1590    /**    /**
1591     * Send multiple prepared requests one way, do not caring about the answer.     * Send multiple prepared requests one way, do not caring about the answer.
1592     * The messages, containing requests, will be marked, indicating that     * The messages, containing requests, will be marked, indicating that the
1593     * the sender is not expecting to get a reply.     * sender is not expecting to get a reply.
1594     *     *
1595     * @param requests the prepared array of requests.     * @param requests the prepared array of requests.
1596     *     *
# Line 1620  public class Functional_ORB Line 1604  public class Functional_ORB
1604    /**    /**
1605     * Set the flag, forcing all server threads to terminate.     * Set the flag, forcing all server threads to terminate.
1606     */     */
1607    protected void finalize()    protected void finalize() throws java.lang.Throwable
                    throws java.lang.Throwable  
1608    {    {
1609      running = false;      running = false;
1610      super.finalize();      super.finalize();

Legend:
Removed from v.1.15  
changed lines
  Added in v.1.16

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26