src/share/classes/com/sun/corba/se/impl/io/IIOPOutputStream.java

Print this page
rev 597 : 8047722: @since tag cleanup in corba
Reviewed-by:


  51 import java.lang.reflect.Field;
  52 
  53 import java.util.Stack;
  54 
  55 import javax.rmi.CORBA.Util;
  56 import javax.rmi.CORBA.ValueHandlerMultiFormat;
  57 
  58 import sun.corba.Bridge ;
  59 
  60 import com.sun.corba.se.impl.io.ObjectStreamClass;
  61 import com.sun.corba.se.impl.util.Utility;
  62 import com.sun.corba.se.impl.util.RepositoryId;
  63 
  64 import com.sun.corba.se.spi.logging.CORBALogDomains ;
  65 import com.sun.corba.se.impl.logging.UtilSystemException ;
  66 
  67 /**
  68  * IIOPOutputStream is ...
  69  *
  70  * @author  Stephen Lewallen
  71  * @since   JDK1.1.6
  72  */
  73 
  74 public class IIOPOutputStream
  75     extends com.sun.corba.se.impl.io.OutputStreamHook
  76 {
  77     private UtilSystemException wrapper = UtilSystemException.get(
  78         CORBALogDomains.RPC_ENCODING ) ;
  79 
  80     private static Bridge bridge =
  81         (Bridge)AccessController.doPrivileged(
  82             new PrivilegedAction() {
  83                 public Object run() {
  84                     return Bridge.get() ;
  85                 }
  86             }
  87         ) ;
  88 
  89     private org.omg.CORBA_2_3.portable.OutputStream orbStream;
  90 
  91     private Object currentObject = null;


 126 
 127     final void setOrbStream(org.omg.CORBA_2_3.portable.OutputStream os) {
 128         orbStream = os;
 129     }
 130 
 131     final org.omg.CORBA_2_3.portable.OutputStream getOrbStream() {
 132         return orbStream;
 133     }
 134 
 135     final void increaseRecursionDepth(){
 136         recursionDepth++;
 137     }
 138 
 139     final int decreaseRecursionDepth(){
 140         return --recursionDepth;
 141     }
 142 
 143     /**
 144      * Override the actions of the final method "writeObject()"
 145      * in ObjectOutputStream.
 146      * @since     JDK1.1.6
 147      */
 148     public final void writeObjectOverride(Object obj)
 149         throws IOException
 150     {
 151         writeObjectState.writeData(this);
 152 
 153         Util.writeAbstractObject((OutputStream)orbStream, obj);
 154     }
 155 
 156     /**
 157      * Override the actions of the final method "writeObject()"
 158      * in ObjectOutputStream.
 159      * @since     JDK1.1.6
 160      */
 161     public final void simpleWriteObject(Object obj, byte formatVersion)
 162     /* throws IOException */
 163     {
 164         byte oldStreamFormatVersion = streamFormatVersion;
 165 
 166         streamFormatVersion = formatVersion;
 167 
 168         Object prevObject = currentObject;
 169         ObjectStreamClass prevClassDesc = currentClassDesc;
 170         simpleWriteDepth++;
 171 
 172         try {
 173             // if (!checkSpecialClasses(obj) && !checkSubstitutableSpecialClasses(obj))
 174             outputObject(obj);
 175 
 176         } catch (IOException ee) {
 177             if (abortIOException == null)
 178                 abortIOException = ee;
 179         } finally {


 186 
 187         /* If the recursion depth is 0, test for and clear the pending exception.
 188          * If there is a pending exception throw it.
 189          */
 190         IOException pending = abortIOException;
 191         if (simpleWriteDepth == 0)
 192             abortIOException = null;
 193         if (pending != null) {
 194             bridge.throwException( pending ) ;
 195         }
 196     }
 197 
 198     // Required by the superclass.
 199     ObjectStreamField[] getFieldsNoCopy() {
 200         return currentClassDesc.getFieldsNoCopy();
 201     }
 202 
 203     /**
 204      * Override the actions of the final method "defaultWriteObject()"
 205      * in ObjectOutputStream.
 206      * @since     JDK1.1.6
 207      */
 208     public final void defaultWriteObjectDelegate()
 209     /* throws IOException */
 210     {
 211         try {
 212             if (currentObject == null || currentClassDesc == null)
 213                 // XXX I18N, Logging needed.
 214                 throw new NotActiveException("defaultWriteObjectDelegate");
 215 
 216             ObjectStreamField[] fields =
 217                 currentClassDesc.getFieldsNoCopy();
 218             if (fields.length > 0) {
 219                 outputClassFields(currentObject, currentClassDesc.forClass(),
 220                                   fields);
 221             }
 222         } catch(IOException ioe) {
 223             bridge.throwException(ioe);
 224         }
 225     }
 226 
 227     /**
 228      * Override the actions of the final method "enableReplaceObject()"
 229      * in ObjectOutputStream.
 230      * @since     JDK1.1.6
 231      */
 232     public final boolean enableReplaceObjectDelegate(boolean enable)
 233     /* throws SecurityException */
 234     {
 235         return false;
 236 
 237     }
 238 
 239 
 240     protected final void annotateClass(Class<?> cl) throws IOException{
 241         // XXX I18N, Logging needed.
 242         throw new IOException("Method annotateClass not supported");
 243     }
 244 
 245     public final void close() throws IOException{
 246         // no op
 247     }
 248 
 249     protected final void drain() throws IOException{
 250         // no op


 256         } catch(Error e) {
 257             IOException ioexc = new IOException(e.getMessage());
 258             ioexc.initCause(e) ;
 259             throw ioexc ;
 260         }
 261     }
 262 
 263     protected final Object replaceObject(Object obj) throws IOException{
 264         // XXX I18N, Logging needed.
 265         throw new IOException("Method replaceObject not supported");
 266     }
 267 
 268     /**
 269      * Reset will disregard the state of any objects already written
 270      * to the stream.  The state is reset to be the same as a new
 271      * ObjectOutputStream.  The current point in the stream is marked
 272      * as reset so the corresponding ObjectInputStream will be reset
 273      * at the same point.  Objects previously written to the stream
 274      * will not be refered to as already being in the stream.  They
 275      * will be written to the stream again.
 276      * @since     JDK1.1
 277      */
 278     public final void reset() throws IOException{
 279         try{
 280             //orbStream.reset();
 281 
 282             if (currentObject != null || currentClassDesc != null)
 283                 // XXX I18N, Logging needed.
 284                 throw new IOException("Illegal call to reset");
 285 
 286             abortIOException = null;
 287 
 288             if (classDescStack == null)
 289                 classDescStack = new java.util.Stack();
 290             else
 291                 classDescStack.setSize(0);
 292 
 293         } catch(Error e) {
 294             IOException ioexc = new IOException(e.getMessage());
 295             ioexc.initCause(e) ;
 296             throw ioexc ;




  51 import java.lang.reflect.Field;
  52 
  53 import java.util.Stack;
  54 
  55 import javax.rmi.CORBA.Util;
  56 import javax.rmi.CORBA.ValueHandlerMultiFormat;
  57 
  58 import sun.corba.Bridge ;
  59 
  60 import com.sun.corba.se.impl.io.ObjectStreamClass;
  61 import com.sun.corba.se.impl.util.Utility;
  62 import com.sun.corba.se.impl.util.RepositoryId;
  63 
  64 import com.sun.corba.se.spi.logging.CORBALogDomains ;
  65 import com.sun.corba.se.impl.logging.UtilSystemException ;
  66 
  67 /**
  68  * IIOPOutputStream is ...
  69  *
  70  * @author  Stephen Lewallen
  71  * @since   1.1.6
  72  */
  73 
  74 public class IIOPOutputStream
  75     extends com.sun.corba.se.impl.io.OutputStreamHook
  76 {
  77     private UtilSystemException wrapper = UtilSystemException.get(
  78         CORBALogDomains.RPC_ENCODING ) ;
  79 
  80     private static Bridge bridge =
  81         (Bridge)AccessController.doPrivileged(
  82             new PrivilegedAction() {
  83                 public Object run() {
  84                     return Bridge.get() ;
  85                 }
  86             }
  87         ) ;
  88 
  89     private org.omg.CORBA_2_3.portable.OutputStream orbStream;
  90 
  91     private Object currentObject = null;


 126 
 127     final void setOrbStream(org.omg.CORBA_2_3.portable.OutputStream os) {
 128         orbStream = os;
 129     }
 130 
 131     final org.omg.CORBA_2_3.portable.OutputStream getOrbStream() {
 132         return orbStream;
 133     }
 134 
 135     final void increaseRecursionDepth(){
 136         recursionDepth++;
 137     }
 138 
 139     final int decreaseRecursionDepth(){
 140         return --recursionDepth;
 141     }
 142 
 143     /**
 144      * Override the actions of the final method "writeObject()"
 145      * in ObjectOutputStream.
 146      * @since     1.1.6
 147      */
 148     public final void writeObjectOverride(Object obj)
 149         throws IOException
 150     {
 151         writeObjectState.writeData(this);
 152 
 153         Util.writeAbstractObject((OutputStream)orbStream, obj);
 154     }
 155 
 156     /**
 157      * Override the actions of the final method "writeObject()"
 158      * in ObjectOutputStream.
 159      * @since     1.1.6
 160      */
 161     public final void simpleWriteObject(Object obj, byte formatVersion)
 162     /* throws IOException */
 163     {
 164         byte oldStreamFormatVersion = streamFormatVersion;
 165 
 166         streamFormatVersion = formatVersion;
 167 
 168         Object prevObject = currentObject;
 169         ObjectStreamClass prevClassDesc = currentClassDesc;
 170         simpleWriteDepth++;
 171 
 172         try {
 173             // if (!checkSpecialClasses(obj) && !checkSubstitutableSpecialClasses(obj))
 174             outputObject(obj);
 175 
 176         } catch (IOException ee) {
 177             if (abortIOException == null)
 178                 abortIOException = ee;
 179         } finally {


 186 
 187         /* If the recursion depth is 0, test for and clear the pending exception.
 188          * If there is a pending exception throw it.
 189          */
 190         IOException pending = abortIOException;
 191         if (simpleWriteDepth == 0)
 192             abortIOException = null;
 193         if (pending != null) {
 194             bridge.throwException( pending ) ;
 195         }
 196     }
 197 
 198     // Required by the superclass.
 199     ObjectStreamField[] getFieldsNoCopy() {
 200         return currentClassDesc.getFieldsNoCopy();
 201     }
 202 
 203     /**
 204      * Override the actions of the final method "defaultWriteObject()"
 205      * in ObjectOutputStream.
 206      * @since     1.1.6
 207      */
 208     public final void defaultWriteObjectDelegate()
 209     /* throws IOException */
 210     {
 211         try {
 212             if (currentObject == null || currentClassDesc == null)
 213                 // XXX I18N, Logging needed.
 214                 throw new NotActiveException("defaultWriteObjectDelegate");
 215 
 216             ObjectStreamField[] fields =
 217                 currentClassDesc.getFieldsNoCopy();
 218             if (fields.length > 0) {
 219                 outputClassFields(currentObject, currentClassDesc.forClass(),
 220                                   fields);
 221             }
 222         } catch(IOException ioe) {
 223             bridge.throwException(ioe);
 224         }
 225     }
 226 
 227     /**
 228      * Override the actions of the final method "enableReplaceObject()"
 229      * in ObjectOutputStream.
 230      * @since     1.1.6
 231      */
 232     public final boolean enableReplaceObjectDelegate(boolean enable)
 233     /* throws SecurityException */
 234     {
 235         return false;
 236 
 237     }
 238 
 239 
 240     protected final void annotateClass(Class<?> cl) throws IOException{
 241         // XXX I18N, Logging needed.
 242         throw new IOException("Method annotateClass not supported");
 243     }
 244 
 245     public final void close() throws IOException{
 246         // no op
 247     }
 248 
 249     protected final void drain() throws IOException{
 250         // no op


 256         } catch(Error e) {
 257             IOException ioexc = new IOException(e.getMessage());
 258             ioexc.initCause(e) ;
 259             throw ioexc ;
 260         }
 261     }
 262 
 263     protected final Object replaceObject(Object obj) throws IOException{
 264         // XXX I18N, Logging needed.
 265         throw new IOException("Method replaceObject not supported");
 266     }
 267 
 268     /**
 269      * Reset will disregard the state of any objects already written
 270      * to the stream.  The state is reset to be the same as a new
 271      * ObjectOutputStream.  The current point in the stream is marked
 272      * as reset so the corresponding ObjectInputStream will be reset
 273      * at the same point.  Objects previously written to the stream
 274      * will not be refered to as already being in the stream.  They
 275      * will be written to the stream again.
 276      * @since     1.1
 277      */
 278     public final void reset() throws IOException{
 279         try{
 280             //orbStream.reset();
 281 
 282             if (currentObject != null || currentClassDesc != null)
 283                 // XXX I18N, Logging needed.
 284                 throw new IOException("Illegal call to reset");
 285 
 286             abortIOException = null;
 287 
 288             if (classDescStack == null)
 289                 classDescStack = new java.util.Stack();
 290             else
 291                 classDescStack.setSize(0);
 292 
 293         } catch(Error e) {
 294             IOException ioexc = new IOException(e.getMessage());
 295             ioexc.initCause(e) ;
 296             throw ioexc ;