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

📄 localrequest.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* LocalRequest.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.Poa;import gnu.CORBA.CDR.BufferedCdrOutput;import gnu.CORBA.GIOP.MessageHeader;import gnu.CORBA.GIOP.v1_2.ReplyHeader;import gnu.CORBA.GIOP.v1_2.RequestHeader;import gnu.CORBA.Interceptor.gnuClientRequestInfo;import gnu.CORBA.Interceptor.gnuServerRequestInfo;import gnu.CORBA.typecodes.RecordTypeCode;import gnu.CORBA.ObjectCreator;import gnu.CORBA.Unexpected;import gnu.CORBA.gnuAny;import gnu.CORBA.gnuRequest;import gnu.CORBA.StreamHolder;import gnu.CORBA.StreamBasedRequest;import org.omg.CORBA.ARG_OUT;import org.omg.CORBA.Any;import org.omg.CORBA.BAD_INV_ORDER;import org.omg.CORBA.BAD_OPERATION;import org.omg.CORBA.Bounds;import org.omg.CORBA.NamedValue;import org.omg.CORBA.ORB;import org.omg.CORBA.SystemException;import org.omg.CORBA.TCKind;import org.omg.CORBA.UnknownUserException;import org.omg.CORBA.UserException;import org.omg.CORBA.portable.ApplicationException;import org.omg.CORBA.portable.InputStream;import org.omg.CORBA.portable.InvokeHandler;import org.omg.CORBA.portable.ObjectImpl;import org.omg.CORBA.portable.OutputStream;import org.omg.CORBA.portable.ResponseHandler;import org.omg.PortableInterceptor.ClientRequestInterceptorOperations;import org.omg.PortableInterceptor.ForwardRequest;import org.omg.PortableInterceptor.ServerRequestInterceptorOperations;import org.omg.PortableServer.CurrentOperations;import org.omg.PortableServer.CurrentPackage.NoContext;import org.omg.PortableServer.DynamicImplementation;import org.omg.PortableServer.POA;import org.omg.PortableServer.Servant;import org.omg.PortableServer.ServantLocatorPackage.CookieHolder;import org.omg.PortableServer.portable.Delegate;import java.io.IOException;/** * Directs the invocation to the locally available servant. The POA servant does * not longer implement the CORBA object and cannot be substituted directly. * * @author Audrius Meskauskas, Lithuania (AudriusA@Bioinformatics.org) */public class LocalRequest extends gnuRequest implements ResponseHandler,  CurrentOperations{  /**   * Used by servant locator, if involved.   */  CookieHolder cookie;  /**   * The object Id.   */  final byte[] Id;  /**   * The message header (singleton is sufficient).   */  private static final MessageHeader header = new MessageHeader();  /**       * True if the stream was obtained by invoking {@link #createExceptionReply()},   * false otherwise.   */  boolean exceptionReply;  /**   * The buffer to write into.   */  BufferedCdrOutput buffer;  /**   * The responsible POA.   */  final gnuPOA poa;  /**   * The servant delegate to obtain the handler.   */  gnuServantObject object;  /**   * Used (reused) with dynamic implementation.   */  LocalServerRequest serverRequest;  /**   * Create an instance of the local request.   */  public LocalRequest(gnuServantObject local_object, gnuPOA a_poa, byte[] an_id)  {    Id = an_id;    poa = a_poa;    // Instantiate the cookie holder only if required.    if (poa.servant_locator != null)      {        cookie = new CookieHolder();      }    object = local_object;    prepareStream();  }  /**   * Make an invocation and return a stream from where the results can be read   * and throw ApplicationException, where applicable.   */  org.omg.CORBA.portable.InputStream s_invoke(InvokeHandler handler)    throws ApplicationException  {    try      {        poa.m_orb.currents.put(Thread.currentThread(), this);        org.omg.CORBA.portable.InputStream input = v_invoke(handler);        if (!exceptionReply)          {            return input;          }        else          {            input.mark(500);            String id = input.read_string();            try              {                input.reset();              }            catch (IOException ex)              {                InternalError ierr = new InternalError();                ierr.initCause(ex);                throw ierr;              }            throw new ApplicationException(id, input);          }      }    finally      {        poa.m_orb.currents.remove(Thread.currentThread());      }  }  /**   * Make an invocation and return a stream from where the results can be read.   *   * @param the invoke handler (can be null, then it is obtained self   * dependently).   */  public org.omg.CORBA.portable.InputStream v_invoke(InvokeHandler handler)  {    // Local request must be intercepted both by server and request    // interceptors.    boolean s_intercept = false;    ServerRequestInterceptorOperations s_interceptor = null;    gnuServerRequestInfo s_info = null;    boolean c_intercept = false;    ClientRequestInterceptorOperations c_interceptor = null;    gnuClientRequestInfo c_info = null;    try      {        if (poa.m_orb.iServer != null || poa.m_orb.iClient != null)          {            setORB(poa.m_orb);            // These two are only needed with interceptors.            m_rqh = new RequestHeader();            m_rqh.operation = m_operation;            m_rph = new ReplyHeader();            m_rqh.object_key = object.Id;            m_rph.request_id = m_rqh.request_id;          }        if (poa.m_orb.iClient != null)          {            c_interceptor = poa.m_orb.iClient;            c_info = new gnuClientRequestInfo(this);            c_intercept = true;            c_interceptor.send_request(c_info);            m_target = object;          }        if (poa.m_orb.iServer != null)          {            s_interceptor = poa.m_orb.iServer;            s_info = new gnuServerRequestInfo(object, m_rqh, m_rph);            s_info.m_request = this;            s_intercept = true;            s_interceptor.receive_request_service_contexts(s_info);          }        if (handler == null)          {            handler = object.getHandler(operation(), cookie, false);          }        BufferedCdrOutput request_part = new BufferedCdrOutput();        request_part.setOrb(orb());        if (m_args != null && m_args.count() > 0)          {            write_parameters(header, request_part);            if (m_parameter_buffer != null)              {                throw new BAD_INV_ORDER("Please either add parameters or " +                  "write them into stream, but not both " + "at once."                );              }          }        if (m_parameter_buffer != null)          {            write_parameter_buffer(header, request_part);          }        Servant servant;        if (handler instanceof Servant)          {            servant = (Servant) handler;          }        else          {            throw new BAD_OPERATION("Unexpected handler type " + handler);          }        org.omg.CORBA.portable.InputStream input =          request_part.create_input_stream();        // Ensure the servant (handler) has a delegate set.        ServantDelegateImpl sd = null;        Delegate d = null;        try          {            d = servant._get_delegate();          }        catch (Exception ex)          {            // In some cases exception is thrown if the delegate is not set.          }        if (d instanceof ServantDelegateImpl)          {            // If the delegate is already set, try to reuse the existing            // instance.            sd = (ServantDelegateImpl) d;            if (sd.object != object)              {                sd = new ServantDelegateImpl(servant, poa, Id);              }          }        else          {            sd = new ServantDelegateImpl(servant, poa, Id);          }        servant._set_delegate(sd);        try          {            ORB o = orb();            if (o instanceof ORB_1_4)              {                ((ORB_1_4) o).currents.put(Thread.currentThread(), this);              }            try              {                if (s_intercept)                  {                    s_interceptor.receive_request(s_info);                  }                handler._invoke(m_operation, input, this);                // Handler is casted into i_handler.                if ((s_intercept || c_intercept) && isExceptionReply())                  {                    s_info.m_reply_header.reply_status =                      ReplyHeader.USER_EXCEPTION;                    m_rph.reply_status = ReplyHeader.USER_EXCEPTION;                    // Make Any, holding the user exception.

⌨️ 快捷键说明

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