Save This Page
Home » openjdk-7 » com.sun.corba.se.impl » protocol » [javadoc | source]
    1   /*
    2    * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
    3    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    4    *
    5    * This code is free software; you can redistribute it and/or modify it
    6    * under the terms of the GNU General Public License version 2 only, as
    7    * published by the Free Software Foundation.  Oracle designates this
    8    * particular file as subject to the "Classpath" exception as provided
    9    * by Oracle in the LICENSE file that accompanied this code.
   10    *
   11    * This code is distributed in the hope that it will be useful, but WITHOUT
   12    * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13    * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14    * version 2 for more details (a copy is included in the LICENSE file that
   15    * accompanied this code).
   16    *
   17    * You should have received a copy of the GNU General Public License version
   18    * 2 along with this work; if not, write to the Free Software Foundation,
   19    * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20    *
   21    * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   22    * or visit www.oracle.com if you need additional information or have any
   23    * questions.
   24    */
   25   
   26   /*
   27    * Licensed Materials - Property of IBM
   28    * RMI-IIOP v1.0
   29    * Copyright IBM Corp. 1998 1999  All Rights Reserved
   30    *
   31    */
   32   
   33   package com.sun.corba.se.impl.protocol;
   34   
   35   import java.io.IOException;
   36   import java.util.Iterator;
   37   import java.rmi.RemoteException;
   38   import java.nio.ByteBuffer;
   39   
   40   import javax.rmi.CORBA.Util;
   41   import javax.rmi.CORBA.Tie;
   42   
   43   import org.omg.CORBA.COMM_FAILURE;
   44   import org.omg.CORBA.INTERNAL;
   45   import org.omg.CORBA.SystemException;
   46   import org.omg.CORBA.CompletionStatus;
   47   import org.omg.CORBA.WrongTransaction;
   48   import org.omg.CORBA.Request;
   49   import org.omg.CORBA.NamedValue;
   50   import org.omg.CORBA.NVList;
   51   import org.omg.CORBA.Context;
   52   import org.omg.CORBA.ContextList;
   53   import org.omg.CORBA.ExceptionList;
   54   import org.omg.CORBA.TypeCode;
   55   import org.omg.CORBA.DATA_CONVERSION;
   56   import org.omg.CORBA.UNKNOWN;
   57   import org.omg.CORBA.portable.RemarshalException;
   58   import org.omg.CORBA_2_3.portable.InputStream;
   59   import org.omg.CORBA_2_3.portable.OutputStream;
   60   import org.omg.CORBA.portable.Delegate;
   61   import org.omg.CORBA.portable.ServantObject;
   62   import org.omg.CORBA.portable.ApplicationException;
   63   import org.omg.CORBA.portable.UnknownException;
   64   import org.omg.IOP.TAG_CODE_SETS;
   65   
   66   import com.sun.org.omg.SendingContext.CodeBase;
   67   
   68   import com.sun.corba.se.pept.broker.Broker;
   69   import com.sun.corba.se.pept.encoding.InputObject;
   70   import com.sun.corba.se.pept.encoding.OutputObject;
   71   import com.sun.corba.se.pept.protocol.ClientRequestDispatcher;
   72   import com.sun.corba.se.pept.protocol.MessageMediator;
   73   import com.sun.corba.se.pept.transport.Connection;
   74   import com.sun.corba.se.pept.transport.ConnectionCache;
   75   import com.sun.corba.se.pept.transport.ContactInfo;
   76   
   77   import com.sun.corba.se.spi.ior.IOR;
   78   import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
   79   import com.sun.corba.se.spi.ior.iiop.IIOPProfileTemplate;
   80   import com.sun.corba.se.spi.ior.iiop.CodeSetsComponent;
   81   import com.sun.corba.se.spi.oa.OAInvocationInfo;
   82   import com.sun.corba.se.spi.oa.ObjectAdapterFactory;
   83   import com.sun.corba.se.spi.orb.ORB;
   84   import com.sun.corba.se.spi.orb.ORBVersion;
   85   import com.sun.corba.se.spi.orb.ORBVersionFactory;
   86   import com.sun.corba.se.spi.protocol.CorbaMessageMediator;
   87   import com.sun.corba.se.spi.protocol.RequestDispatcherRegistry;
   88   import com.sun.corba.se.spi.transport.CorbaContactInfo;
   89   import com.sun.corba.se.spi.transport.CorbaContactInfoList;
   90   import com.sun.corba.se.spi.transport.CorbaContactInfoListIterator;
   91   import com.sun.corba.se.spi.transport.CorbaConnection;
   92   
   93   import com.sun.corba.se.spi.servicecontext.ServiceContext;
   94   import com.sun.corba.se.spi.servicecontext.ServiceContexts;
   95   import com.sun.corba.se.spi.servicecontext.UEInfoServiceContext;
   96   import com.sun.corba.se.spi.servicecontext.CodeSetServiceContext;
   97   import com.sun.corba.se.spi.servicecontext.MaxStreamFormatVersionServiceContext;
   98   import com.sun.corba.se.spi.servicecontext.SendingContextServiceContext;
   99   import com.sun.corba.se.impl.encoding.ByteBufferWithInfo;
  100   import com.sun.corba.se.impl.encoding.CDRInputObject;
  101   import com.sun.corba.se.impl.encoding.CDROutputObject;
  102   import com.sun.corba.se.impl.encoding.CDROutputStream;
  103   import com.sun.corba.se.impl.encoding.CodeSetComponentInfo;
  104   import com.sun.corba.se.impl.encoding.CodeSetConversion;
  105   import com.sun.corba.se.impl.encoding.MarshalOutputStream;
  106   import com.sun.corba.se.impl.encoding.MarshalInputStream;
  107   import com.sun.corba.se.impl.orbutil.ORBUtility;
  108   import com.sun.corba.se.impl.orbutil.ORBConstants;
  109   import com.sun.corba.se.impl.protocol.giopmsgheaders.ReplyMessage;
  110   import com.sun.corba.se.impl.protocol.giopmsgheaders.KeyAddr;
  111   import com.sun.corba.se.impl.protocol.giopmsgheaders.ProfileAddr;
  112   import com.sun.corba.se.impl.protocol.giopmsgheaders.ReferenceAddr;
  113   import com.sun.corba.se.impl.transport.CorbaContactInfoListIteratorImpl;
  114   import com.sun.corba.se.impl.util.JDKBridge;
  115   
  116   /**
  117    * ClientDelegate is the RMI client-side subcontract or representation
  118    * It implements RMI delegate as well as our internal ClientRequestDispatcher
  119    * interface.
  120    */
  121   public class SharedCDRClientRequestDispatcherImpl
  122       extends
  123           CorbaClientRequestDispatcherImpl
  124   {
  125       // REVISIT:
  126       // Rather than have separate CDR subcontract,
  127       // use same CorbaClientRequestDispatcherImpl but have
  128       // different MessageMediator finishSendingRequest and waitForResponse
  129       // handle what is done below.
  130       // Benefit: then in ContactInfo no need to do a direct new
  131       // of subcontract - does not complicate subcontract registry.
  132   
  133       public InputObject marshalingComplete(java.lang.Object self,
  134                                             OutputObject outputObject)
  135           throws
  136               ApplicationException,
  137               org.omg.CORBA.portable.RemarshalException
  138       {
  139         ORB orb = null;
  140         CorbaMessageMediator messageMediator = null;
  141         try {
  142           messageMediator = (CorbaMessageMediator)
  143               outputObject.getMessageMediator();
  144   
  145           orb = (ORB) messageMediator.getBroker();
  146   
  147           if (orb.subcontractDebugFlag) {
  148               dprint(".marshalingComplete->: " + opAndId(messageMediator));
  149           }
  150   
  151           CDROutputObject cdrOutputObject = (CDROutputObject) outputObject;
  152   
  153           //
  154           // Create server-side input object.
  155           //
  156   
  157           ByteBufferWithInfo bbwi = cdrOutputObject.getByteBufferWithInfo();
  158           cdrOutputObject.getMessageHeader().setSize(bbwi.byteBuffer, bbwi.getSize());
  159   
  160           CDRInputObject cdrInputObject =
  161               new CDRInputObject(orb, null, bbwi.byteBuffer,
  162                                  cdrOutputObject.getMessageHeader());
  163           messageMediator.setInputObject(cdrInputObject);
  164           cdrInputObject.setMessageMediator(messageMediator);
  165   
  166           //
  167           // Dispatch
  168           //
  169   
  170           // REVISIT: Impl cast.
  171           ((CorbaMessageMediatorImpl)messageMediator).handleRequestRequest(
  172               messageMediator);
  173   
  174           // InputStream must be closed on the InputObject so that its
  175           // ByteBuffer can be released to the ByteBufferPool. We must do
  176           // this before we re-assign the cdrInputObject reference below.
  177           try { cdrInputObject.close(); }
  178           catch (IOException ex) {
  179               // No need to do anything since we're done with the input stream
  180               // and cdrInputObject will be re-assigned a new client-side input
  181               // object, (i.e. won't result in a corba error).
  182   
  183               if (orb.transportDebugFlag) {
  184                  dprint(".marshalingComplete: ignoring IOException - " + ex.toString());
  185               }
  186           }
  187   
  188           //
  189           // Create client-side input object
  190           //
  191   
  192           cdrOutputObject = (CDROutputObject) messageMediator.getOutputObject();
  193           bbwi = cdrOutputObject.getByteBufferWithInfo();
  194           cdrOutputObject.getMessageHeader().setSize(bbwi.byteBuffer, bbwi.getSize());
  195           cdrInputObject =
  196               new CDRInputObject(orb, null, bbwi.byteBuffer,
  197                                  cdrOutputObject.getMessageHeader());
  198           messageMediator.setInputObject(cdrInputObject);
  199           cdrInputObject.setMessageMediator(messageMediator);
  200   
  201           cdrInputObject.unmarshalHeader();
  202   
  203           InputObject inputObject = cdrInputObject;
  204   
  205           return processResponse(orb, messageMediator, inputObject);
  206   
  207         } finally {
  208           if (orb.subcontractDebugFlag) {
  209               dprint(".marshalingComplete<-: " + opAndId(messageMediator));
  210           }
  211         }
  212       }
  213   
  214       protected void dprint(String msg)
  215       {
  216           ORBUtility.dprint("SharedCDRClientRequestDispatcherImpl", msg);
  217       }
  218   }
  219   
  220   // End of file.

Save This Page
Home » openjdk-7 » com.sun.corba.se.impl » protocol » [javadoc | source]