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 package com.sun.corba.se.spi.presentation.rmi ;
  27 
  28 import org.omg.CORBA_2_3.portable.InputStream ;
  29 import org.omg.CORBA_2_3.portable.OutputStream ;
  30 import org.omg.CORBA.portable.ApplicationException ;
  31 
  32 import java.lang.reflect.Method ;
  33 
  34 import java.rmi.RemoteException ;
  35 
  36 import com.sun.corba.se.spi.orb.ORB ;
  37 
  38 /** Used to read and write arguments and results for a particular method.
  39 *
  40 */
  41 public interface DynamicMethodMarshaller
  42 {
  43     /** Returns the method used to create this DynamicMethodMarshaller.
  44      */
  45     Method getMethod() ;
  46 
  47     /** Copy the arguments as needed for this particular method.
  48      * Can be optimized so that as little copying as possible is
  49      * performed.
  50      */
  51     Object[] copyArguments( Object[] args, ORB orb ) throws RemoteException ;
  52 
  53     /** Read the arguments for this method from the InputStream.
  54      * Returns null if there are no arguments.
  55      */
  56     Object[] readArguments( InputStream is ) ;
  57 
  58     /** Write arguments for this method to the OutputStream.
  59      * Does nothing if there are no arguments.
  60      */
  61     void writeArguments( OutputStream os, Object[] args ) ;
  62 
  63     /** Copy the result as needed for this particular method.
  64      * Can be optimized so that as little copying as possible is
  65      * performed.
  66      */
  67     Object copyResult( Object result, ORB orb ) throws RemoteException ;
  68 
  69     /** Read the result from the InputStream.  Returns null
  70      * if the result type is null.
  71      */
  72     Object readResult( InputStream is ) ;
  73 
  74     /** Write the result to the OutputStream.  Does nothing if
  75      * the result type is null.
  76      */
  77     void writeResult( OutputStream os, Object result ) ;
  78 
  79     /** Returns true iff thr's class is a declared exception (or a subclass of
  80      * a declared exception) for this DynamicMethodMarshaller's method.
  81      */
  82     boolean isDeclaredException( Throwable thr ) ;
  83 
  84     /** Write the repository ID of the exception and the value of the
  85      * exception to the OutputStream.  ex should be a declared exception
  86      * for this DynamicMethodMarshaller's method.
  87      */
  88     void writeException( OutputStream os, Exception ex ) ;
  89 
  90     /** Reads an exception ID and the corresponding exception from
  91      * the input stream.  This should be an exception declared in
  92      * this method.
  93      */
  94     Exception readException( ApplicationException ae ) ;
  95 }