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

📄 valuehandlerimpl.java

📁 Mobile 应用程序使用 Java Micro Edition (Java ME) 平台
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* * @(#)ValueHandlerImpl.java	1.66 05/11/17 * * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. *//* * Licensed Materials - Property of IBM * RMI-IIOP v1.0 * Copyright IBM Corp. 1998 1999  All Rights Reserved * * US Government Users Restricted Rights - Use, duplication or * disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */package com.sun.corba.se.impl.io;import javax.rmi.CORBA.Util;import javax.rmi.PortableRemoteObject;import java.util.Hashtable;import java.util.Stack;import java.io.IOException;import java.util.EmptyStackException;import com.sun.corba.se.impl.util.Utility;import com.sun.corba.se.impl.io.IIOPInputStream;import com.sun.corba.se.impl.io.IIOPOutputStream;import com.sun.corba.se.impl.util.RepositoryId;import com.sun.corba.se.impl.util.Utility;import org.omg.CORBA.TCKind;import org.omg.CORBA.MARSHAL;import org.omg.CORBA.BAD_PARAM;import org.omg.CORBA.CompletionStatus;import org.omg.CORBA.portable.IndirectionException;import com.sun.org.omg.SendingContext.CodeBase;import com.sun.org.omg.SendingContext.CodeBaseHelper;import java.security.AccessController;import java.security.PrivilegedAction; import com.sun.corba.se.impl.io.IIOPInputStream.ActiveRecursionManager;import com.sun.corba.se.spi.logging.CORBALogDomains;import com.sun.corba.se.impl.logging.OMGSystemException;import com.sun.corba.se.impl.logging.UtilSystemException;public class ValueHandlerImpl implements javax.rmi.CORBA.ValueHandlerMultiFormat {    // Property to override our maximum stream format version    public static final String FORMAT_VERSION_PROPERTY        = "com.sun.CORBA.MaxStreamFormatVersion";    private static final byte MAX_SUPPORTED_FORMAT_VERSION = (byte)2;    private static final byte STREAM_FORMAT_VERSION_1 = (byte)1;    // The ValueHandler's maximum stream format version to advertise,    // set in a static initializer.    private static final byte MAX_STREAM_FORMAT_VERSION;    static {        MAX_STREAM_FORMAT_VERSION = getMaxStreamFormatVersion();    }    // Looks for the FORMAT_VERSION_PROPERTY system property    // to allow the user to override our default stream format    // version.  Note that this still only allows them to pick    // a supported version (1 through MAX_STREAM_FORMAT_VERSION).    private static byte getMaxStreamFormatVersion() {        try {            String propValue = (String) AccessController.doPrivileged(                                        new PrivilegedAction() {		public java.lang.Object run() {	            return System.getProperty(ValueHandlerImpl.FORMAT_VERSION_PROPERTY);	        }            });            // The property wasn't set            if (propValue == null)                return MAX_SUPPORTED_FORMAT_VERSION;            byte result = Byte.parseByte(propValue);            // REVISIT.  Just set to MAX_SUPPORTED_FORMAT_VERSION            // or really let the system shutdown with this Error?            if (result < 1 || result > MAX_SUPPORTED_FORMAT_VERSION)		// XXX I18N, logging needed.                throw new ExceptionInInitializerError("Invalid stream format version: "                                                      + result                                                      + ".  Valid range is 1 through "                                                      + MAX_SUPPORTED_FORMAT_VERSION);            return result;        } catch (Exception ex) {            // REVISIT.  Swallow this or really let            // the system shutdown with this Error?            Error err = new ExceptionInInitializerError(ex);	    err.initCause( ex ) ;	    throw err ;        }    }    public static final short kRemoteType = 0;    public static final short kAbstractType = 1;    public static final short kValueType = 2;    private Hashtable inputStreamPairs = null;    private Hashtable outputStreamPairs = null;    private CodeBase codeBase = null;    private boolean useHashtables = true;    private boolean isInputStream = true;    private IIOPOutputStream outputStreamBridge = null;    private IIOPInputStream inputStreamBridge = null;    private OMGSystemException omgWrapper = OMGSystemException.get( 	CORBALogDomains.RPC_ENCODING ) ;    private UtilSystemException utilWrapper = UtilSystemException.get( 	CORBALogDomains.RPC_ENCODING ) ;    // See javax.rmi.CORBA.ValueHandlerMultiFormat    public byte getMaximumStreamFormatVersion() {        return MAX_STREAM_FORMAT_VERSION;    }    // See javax.rmi.CORBA.ValueHandlerMultiFormat    public void writeValue(org.omg.CORBA.portable.OutputStream out,                           java.io.Serializable value,                           byte streamFormatVersion) {        if (streamFormatVersion == 2) {            if (!(out instanceof org.omg.CORBA.portable.ValueOutputStream)) {		throw omgWrapper.notAValueoutputstream() ;            }        } else if (streamFormatVersion != 1) {	    throw omgWrapper.invalidStreamFormatVersion( 		new Integer(streamFormatVersion) ) ;        }        writeValueWithVersion(out, value, streamFormatVersion);    }    public ValueHandlerImpl(){}    public ValueHandlerImpl(boolean isInputStream) {	this();	useHashtables = false;	this.isInputStream = isInputStream;    }    /**     * Writes the value to the stream using java semantics.     * @param out The stream to write the value to     * @param value The value to be written to the stream     **/    public void writeValue(org.omg.CORBA.portable.OutputStream _out,                            java.io.Serializable value) {        writeValueWithVersion(_out, value, STREAM_FORMAT_VERSION_1);    }    private void writeValueWithVersion(org.omg.CORBA.portable.OutputStream _out,                                       java.io.Serializable value,                                       byte streamFormatVersion) {	org.omg.CORBA_2_3.portable.OutputStream out =	    (org.omg.CORBA_2_3.portable.OutputStream) _out;	if (!useHashtables) {            if (outputStreamBridge == null) {                outputStreamBridge = createOutputStream();                outputStreamBridge.setOrbStream(out);            }            try {                outputStreamBridge.increaseRecursionDepth();                writeValueInternal(outputStreamBridge, out, value, streamFormatVersion);            } finally {                outputStreamBridge.decreaseRecursionDepth();            }            return;        }		        IIOPOutputStream jdkToOrbOutputStreamBridge = null;	if (outputStreamPairs == null)	    outputStreamPairs = new Hashtable();		        jdkToOrbOutputStreamBridge = (IIOPOutputStream)outputStreamPairs.get(_out);        if (jdkToOrbOutputStreamBridge == null) {            jdkToOrbOutputStreamBridge = createOutputStream();            jdkToOrbOutputStreamBridge.setOrbStream(out);            outputStreamPairs.put(_out, jdkToOrbOutputStreamBridge);        }        try {	    jdkToOrbOutputStreamBridge.increaseRecursionDepth();	    writeValueInternal(jdkToOrbOutputStreamBridge, out, value, streamFormatVersion);        } finally {            if (jdkToOrbOutputStreamBridge.decreaseRecursionDepth() == 0) {                outputStreamPairs.remove(_out);	    }        }    }    private void writeValueInternal(IIOPOutputStream bridge,				    org.omg.CORBA_2_3.portable.OutputStream out,				    java.io.Serializable value,                                    byte streamFormatVersion)    {	Class clazz = value.getClass();        if (clazz.isArray())            write_Array(out, value, clazz.getComponentType());        else            bridge.simpleWriteObject(value, streamFormatVersion);    }    /**     * Reads a value from the stream using java semantics.     * @param in The stream to read the value from     * @param clazz The type of the value to be read in     * @param sender The sending context runtime     **/    public java.io.Serializable readValue(org.omg.CORBA.portable.InputStream _in,					  int offset, 					  java.lang.Class clazz, 					  String repositoryID,					  org.omg.SendingContext.RunTime _sender)    {        // Must use narrow rather than a direct cast to a com.sun        // class.  Fix for bug 4379539.	CodeBase sender = CodeBaseHelper.narrow(_sender);	org.omg.CORBA_2_3.portable.InputStream in = 	    (org.omg.CORBA_2_3.portable.InputStream) _in;	if (!useHashtables) {            if (inputStreamBridge == null) {                inputStreamBridge = createInputStream();                inputStreamBridge.setOrbStream(in);                inputStreamBridge.setSender(sender); //d11638                // backward compatability 4365188                inputStreamBridge.setValueHandler(this);             }			            java.io.Serializable result = null;            try {                inputStreamBridge.increaseRecursionDepth();                result = (java.io.Serializable) readValueInternal(inputStreamBridge, in, offset, clazz, repositoryID, sender);            } finally {                if (inputStreamBridge.decreaseRecursionDepth() == 0) {                    // Indirections are resolved immediately since                    // the change to the active recursion manager,                    // so this will never happen.                }            }            return result;        }                    IIOPInputStream jdkToOrbInputStreamBridge = null;        if (inputStreamPairs == null)            inputStreamPairs = new Hashtable();		        jdkToOrbInputStreamBridge = (IIOPInputStream)inputStreamPairs.get(_in);        if (jdkToOrbInputStreamBridge == null) {            jdkToOrbInputStreamBridge = createInputStream();            jdkToOrbInputStreamBridge.setOrbStream(in);            jdkToOrbInputStreamBridge.setSender(sender); //d11638            // backward compatability 4365188            jdkToOrbInputStreamBridge.setValueHandler(this);             inputStreamPairs.put(_in, jdkToOrbInputStreamBridge);        }	java.io.Serializable result = null;		

⌨️ 快捷键说明

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