⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 orbfunctional.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/* OrbFunctional.java --   Copyright (C) 2005 Free Software Foundation, Inc.This file is part of GNU Classpath.GNU Classpath is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU Classpath is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Classpath; see the file COPYING.  If not, write to theFree Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA02110-1301 USA.Linking this library statically or dynamically with other modules ismaking a combined work based on this library.  Thus, the terms andconditions of the GNU General Public License cover the wholecombination.As a special exception, the copyright holders of this library give youpermission to link this library with independent modules to produce anexecutable, regardless of the license terms of these independentmodules, and to copy and distribute the resulting executable underterms of your choice, provided that you also meet, for each linkedindependent module, the terms and conditions of the license of thatmodule.  An independent module is a module which is not derived fromor based on this library.  If you modify this library, you may extendthis exception to your version of the library, but you are notobligated to do so.  If you do not wish to do so, delete thisexception statement from your version. */package gnu.CORBA;import gnu.CORBA.CDR.UnknownExceptionCtxHandler;import gnu.CORBA.CDR.BufferredCdrInput;import gnu.CORBA.CDR.BufferedCdrOutput;import gnu.CORBA.GIOP.CloseMessage;import gnu.CORBA.GIOP.ErrorMessage;import gnu.CORBA.GIOP.MessageHeader;import gnu.CORBA.GIOP.ReplyHeader;import gnu.CORBA.GIOP.RequestHeader;import gnu.CORBA.NamingService.NameParser;import gnu.CORBA.NamingService.NamingServiceTransient;import gnu.CORBA.Poa.gnuForwardRequest;import gnu.CORBA.interfaces.SocketFactory;import org.omg.CORBA.BAD_OPERATION;import org.omg.CORBA.BAD_PARAM;import org.omg.CORBA.CompletionStatus;import org.omg.CORBA.MARSHAL;import org.omg.CORBA.NO_RESOURCES;import org.omg.CORBA.OBJECT_NOT_EXIST;import org.omg.CORBA.Request;import org.omg.CORBA.SystemException;import org.omg.CORBA.UNKNOWN;import org.omg.CORBA.WrongTransaction;import org.omg.CORBA.ORBPackage.InvalidName;import org.omg.CORBA.portable.Delegate;import org.omg.CORBA.portable.InvokeHandler;import org.omg.CORBA.portable.ObjectImpl;import org.omg.CORBA.portable.UnknownException;import org.omg.CosNaming.NamingContextExt;import org.omg.CosNaming.NamingContextExtHelper;import java.applet.Applet;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;import java.net.InetAddress;import java.net.ServerSocket;import java.net.Socket;import java.net.SocketException;import java.net.UnknownHostException;import java.util.ArrayList;import java.util.Enumeration;import java.util.Hashtable;import java.util.Iterator;import java.util.LinkedList;import java.util.Map;import java.util.Properties;import java.util.Random;import java.util.StringTokenizer;import java.util.TreeMap;/** * The ORB implementation, capable to handle remote invocations on the * registered object. This class implements all features, required till the jdk * 1.3 inclusive, but does not support the POA that appears since 1.4. The POA * is supported by {@link gnu.CORBA.Poa.ORB_1_4}. * * @author Audrius Meskauskas (AudriusA@Bioinformatics.org) */public class OrbFunctional extends OrbRestricted{  /**   * A server, responsible for listening on requests on some local port. The ORB   * may listen on multiple ports and process the requests in separate threads.   * Normally the server takes one port per object being served.   */  protected class portServer    extends Thread  {    /**     * The number of the currently running parallel threads.     */    int running_threads;    /**     * The port on that this portServer is listening for requests.     */    int s_port;    /**     * The server socket of this portServer.     */    ServerSocket service;    /**     * True if the serving node must shutdown due call of the close_now().     */    boolean terminated;    /**     * Create a new portServer, serving on specific port.     */    portServer(int _port)    {      s_port = _port;      setDaemon(true);      try        {          service = socketFactory.createServerSocket(s_port);        }      catch (IOException ex)        {          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 OrbFunctional.running is set to false.     */    public void run()    {      while (running)        {          try            {              tick();            }          catch (SocketException ex)            {              // May be thrown when the service is closed by              // the close_now().              if (terminated)                return;            }          catch (Exception iex)            {              // Wait. Do not terminate the              // service due potentially transient error.              try                {                  Thread.sleep(TWAIT_SERVER_ERROR_PAUSE);                }              catch (InterruptedException ex)                {                }            }        }    }    /**     * Perform a single serving step.     *      * @throws java.lang.Exception     */    void tick()      throws Exception    {      serve(this, service);    }    /**     * Forcibly close the server socket and mark this port as free.     */    public void close_now()    {      try        {          terminated = true;          service.close();        }      catch (Exception ex)        {          // This may happen if the service has not been opened or          // cannot be closed. Return without action.        }    }    /**     * If the thread is no longer in use, close the socket (if opened).     */    protected void finalize()    {      close_now();    }  }  /**   * A server, responsible for listening on requests on some local port and   * serving multiple requests (probably to the different objects) on the same   * thread.   */  protected class sharedPortServer extends portServer  {    /**     * Create a new portServer, serving on specific port.     */    sharedPortServer(int _port)    {      super(_port);    }    /**     * Perform a single serving step.     *     * @throws java.lang.Exception     */    void tick() throws Exception    {      Socket request = service.accept();      serveStep(request, false);    }  }  /**   * The default value where the first instance of this ORB will start looking   * for a free port.   */  public static int DEFAULT_INITIAL_PORT = 1126;    /**   * When trying to open the socket on a random port, start of the interval to   * try.   */  public static int RANDOM_PORT_FROM = 1024;    /**   * When trying to open the socket on a random port, end of the interval to   * try.   */  public static int RANDOM_PORT_TO = 4024;    /**   * The number of attempts to try when opening random port.   */  public static int RANDOM_PORT_ATTEMPTS = 64;  /**   * The property of port, on that this ORB is listening for requests from   * clients. This class supports one port per ORB only.   */  public static final String LISTEN_ON = "gnu.classpath.CORBA.ListenOn";  /**   * The property, defining the IOR of the intial reference to resolve.   */  public static final String REFERENCE = "org.omg.CORBA.ORBInitRef";  /**   * The property, defining the port on that the default name service is   * running.   */  public static final String NS_PORT = "org.omg.CORBA.ORBInitialPort";  /**   * The property, defining the host on that the default name service is   * running.   */  public static final String NS_HOST = "org.omg.CORBA.ORBInitialHost";  /**   * The string, defining the naming service initial reference.   */  public static final String NAME_SERVICE = "NameService";    /**   * Defines the ORB ID that is accessible by IOR interceptors.   */  public static final String ORB_ID = "org.omg.CORBA.ORBid";      /**   * Defines the SERVER ID that is accessible by IOR interceptors.   */  public static final String SERVER_ID = "org.omg.CORBA.ServerId";    /**   * The if the client has once opened a socket, it should start sending the   * message header in a given time. Otherwise the server will close the socket.   * This prevents server hang when the client opens the socket, but does not   * send any message, usually due crash on the client side.   */  public static String START_READING_MESSAGE =    "gnu.classpath.CORBA.TOUT_START_READING_MESSAGE";  /**   * If the client has started to send the request message, the socket time out   * changes to the specified value.   */  public static String WHILE_READING =    "gnu.classpath.CORBA.TOUT_WHILE_READING";  /**   * If the message body is received, the time out changes to the specifice   * value. This must be longer, as includes time, required to process the   * received task. We make it 40 minutes.   */  public static String AFTER_RECEIVING =    "gnu.classpath.CORBA.TOUT_AFTER_RECEIVING";    /**   * The server waits for this duration after the potentially transient error   * during its servicing cycle.   */  public static String SERVER_ERROR_PAUSE =    "gnu.classpath.CORBA.SERVER_ERROR_PAUSE";  /**   * The address of the local host.   */  public final String LOCAL_HOST;  /**   * The if the client has once opened a socket, it should start sending the   * message header in a given time. Otherwise the server will close the socket.   * This prevents server hang when the client opens the socket, but does not   * send any message, usually due crash on the client side.   */  public int TOUT_START_READING_MESSAGE = 20 * 1000;  // (Here and below, we use * to make the meaning of the constant clearler).  /**   * If the client has started to send the request message, the socket time out   * changes to the specified value.   */  public int TOUT_WHILE_READING = 2 * 60 * 1000;  /**   * If the message body is received, the time out changes to the specifice   * value. This must be longer, as includes time, required to process the   * received task. We make it 40 minutes.   */  public int TOUT_AFTER_RECEIVING = 40 * 60 * 1000;    /**   * The server waits for this duration after the potentially transient error   * during its servicing cycle.   */  public int TWAIT_SERVER_ERROR_PAUSE = 5000;  /**   * Some clients tend to submit multiple requests over the same socket. The   * server waits for the next request on the same socket for the duration,   * specified below. In additions, the request of this implementation also   * waits for the same duration before closing the socket. The default time is   * seven seconds.   */  public static int TANDEM_REQUESTS = 7000;    /**   * The Id of this ORB.   */  public String orb_id = "orb_"+hashCode();    /**   * The Id of this Server. This field is defined static to ensure it has   * the same value over all ORB's in this machine.   */  public static String server_id = "server_"+OrbFunctional.class.hashCode();   /**   * The map of the already conncted objects.   */  protected final Connected_objects connected_objects =    new Connected_objects();  /**   * The maximal CORBA version, supported by this ORB. The default value 0 means   * that the ORB will not check the request version while trying to respond.   */  protected Version max_version;  /**   * Setting this value to false causes the ORB to shutdown after the latest   * serving operation is complete.   */  protected boolean running;  /**   * The map of the initial references.   */  protected Map initial_references = new TreeMap();  /**   * The currently active portServers.   */  protected ArrayList portServers = new ArrayList();  /**   * The host, on that the name service is expected to be running.   */  private String ns_host;  /**   * Probably free port, under that the ORB will try listening for remote   * requests first. When the new object is connected, this port is used first,   * then it is incremented by 1, etc. If the given port is not available, up to   * 20 subsequent values are tried and then the parameterless server socket   * contructor is called. The constant is shared between multiple instances of   * this ORB.   */  private static int Port = DEFAULT_INITIAL_PORT;  /**   * The port, on that the name service is expected to be running.   */  private int ns_port = 900;    /**   * The name parser.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -