options.java

来自「开源的axis2框架的源码。用于开发WEBSERVER」· Java 代码 · 共 1,690 行 · 第 1/5 页

JAVA
1,690
字号
    /* ===============================================================
    * Externalizable support
    * ===============================================================
    */

    /**
     * Save the contents of this object.
     * <p/>
     * NOTE: Transient fields and static fields are not saved.
     *
     * @param out The stream to write the object contents to
     * @throws IOException
     */
    public void writeExternal(ObjectOutput out) throws IOException {
        String logCorrelationIDString = getLogCorrelationIDString();

        // write out contents of this object

        // NOTES: For each item, where appropriate,
        //        write out the following information, IN ORDER:
        //           the class name
        //           the active or empty flag
        //           the data length, if appropriate
        //           the data

        //---------------------------------------------------------
        // in order to handle future changes to the message
        // context definition, be sure to maintain the
        // object level identifiers
        //---------------------------------------------------------
        // serialization version ID
        out.writeLong(serialVersionUID);

        // revision ID
        out.writeInt(revisionID);

        //---------------------------------------------------------
        // various simple fields
        //---------------------------------------------------------
        out.writeLong(timeOutInMilliSeconds);

        out.writeBoolean(manageSession);

        // the following objects could be null
        ObjectStateUtils.writeObject(out, isExceptionToBeThrownOnSOAPFault,
                                     logCorrelationIDString + ".isExceptionToBeThrownOnSOAPFault");
        ObjectStateUtils.writeObject(out, useSeparateListener,
                                     logCorrelationIDString + ".useSeparateListener");

        //---------------------------------------------------------
        // various strings
        //---------------------------------------------------------

        // String soapVersionURI
        ObjectStateUtils
                .writeString(out, soapVersionURI, logCorrelationIDString + ".soapVersionURI");

        // String action
        ObjectStateUtils.writeString(out, action, logCorrelationIDString + ".action");

        // String transportInProtocol
        ObjectStateUtils.writeString(out, transportInProtocol,
                                     logCorrelationIDString + ".transportInProtocol");

        // String messageId
        ObjectStateUtils.writeString(out, messageId, logCorrelationIDString + ".messageId");

        // String object id
        ObjectStateUtils.writeString(out, logCorrelationIDString,
                                     logCorrelationIDString + ".logCorrelationIDString");

        //---------------------------------------------------------
        // various objects
        //---------------------------------------------------------

        // put some try..catch blocks around the following objects
        // so that the writing to the output stream continues
        // even if one of the objects can't be serialized

        try {
            // EndpointReference faultTo
            ObjectStateUtils.writeObject(out, faultTo, logCorrelationIDString + ".faultTo");
        }
        catch (Exception e1) {
            // note that the utility class will provide the trace for the
            // exception so we won't have to
            // so just consume the exception for now
        }

        try {
            // EndpointReference from
            ObjectStateUtils.writeObject(out, from, logCorrelationIDString + ".from");
        }
        catch (Exception e2) {
            // note that the utility class will provide the trace for the
            // exception so we won't have to
            // so just consume the exception for now
        }

        try {
            // EndpointReference replyTo
            ObjectStateUtils.writeObject(out, replyTo, logCorrelationIDString + ".replyTo");
        }
        catch (Exception e3) {
            // note that the utility class will provide the trace for the
            // exception so we won't have to
            // so just consume the exception for now
        }

        try {
            // EndpointReference to
            ObjectStateUtils.writeObject(out, to, logCorrelationIDString + ".to");
        }
        catch (Exception e4) {
            // note that the utility class will provide the trace for the
            // exception so we won't have to
            // so just consume the exception for now
        }

        // TransportListener listener
        if (listener != null) {
            metaListener = new MetaDataEntry(listener.getClass().getName(), null);
        } else {
            metaListener = null;
        }
        ObjectStateUtils.writeObject(out, metaListener, logCorrelationIDString + ".listener");

        // TransportInDescription transportIn
        if (transportIn != null) {
            metaTransportIn = new MetaDataEntry(null, transportIn.getName().toString());
        } else {
            metaTransportIn = null;
        }
        ObjectStateUtils.writeObject(out, metaTransportIn, logCorrelationIDString + ".transportIn");

        // TransportOutDescription transportOut
        if (transportOut != null) {
            metaTransportOut = new MetaDataEntry(null, transportOut.getName().toString());
        } else {
            metaTransportOut = null;
        }
        ObjectStateUtils
                .writeObject(out, metaTransportOut, logCorrelationIDString + ".transportOut");

        //---------------------------------------------------------
        // collections and lists
        //---------------------------------------------------------

        // List relationships, which is an array of RelatesTo objects
        ArrayList tmp = null;

        if (relationships != null) {
            // make sure this is an array list
            tmp = new ArrayList(relationships);
        }

        ObjectStateUtils.writeArrayList(out, tmp, logCorrelationIDString + ".relationships");

        // ArrayList referenceParameters
        ObjectStateUtils.writeArrayList(out, referenceParameters,
                                        logCorrelationIDString + ".referenceParameters");

        //---------------------------------------------------------
        // properties
        //---------------------------------------------------------

        // HashMap properties
        HashMap tmpHM = new HashMap(getProperties());

        ObjectStateUtils.writeHashMap(out, tmpHM, logCorrelationIDString + ".properties");

        //---------------------------------------------------------
        // "nested"
        //---------------------------------------------------------

        try {
            // Options parent
            ObjectStateUtils.writeObject(out, parent, logCorrelationIDString + ".parent");
        }
        catch (Exception e5) {
            // note that the utility class will provide the trace for the
            // exception so we won't have to
            // so just consume the exception for now
        }

    }


    /**
     * Restore the contents of the MessageContext that was
     * previously saved.
     * <p/>
     * NOTE: The field data must read back in the same order and type
     * as it was written.  Some data will need to be validated when
     * resurrected.
     *
     * @param in The stream to read the object contents from
     * @throws IOException
     * @throws ClassNotFoundException
     */
    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
        // serialization version ID
        long suid = in.readLong();

        // revision ID
        int revID = in.readInt();

        // make sure the object data is in a version we can handle
        if (suid != serialVersionUID) {
            throw new ClassNotFoundException(ObjectStateUtils.UNSUPPORTED_SUID);
        }

        // make sure the object data is in a revision level we can handle
        if (revID != REVISION_1) {
            throw new ClassNotFoundException(ObjectStateUtils.UNSUPPORTED_REVID);
        }

        //---------------------------------------------------------
        // various simple fields
        //---------------------------------------------------------
        timeOutInMilliSeconds = in.readLong();

        manageSession = in.readBoolean();

        // the following objects could be null
        Object tmp1 = ObjectStateUtils.readObject(in, "Options.isExceptionToBeThrownOnSOAPFault");
        if (tmp1 != null) {
            isExceptionToBeThrownOnSOAPFault = (Boolean) tmp1;
        }

        Object tmp2 = ObjectStateUtils.readObject(in, "Options.useSeparateListener");
        if (tmp2 != null) {
            useSeparateListener = (Boolean) tmp2;
        }

        //---------------------------------------------------------
        // various strings
        //---------------------------------------------------------

        // String soapVersionURI
        soapVersionURI = ObjectStateUtils.readString(in, "Options.soapVersionURI");

        // String action
        action = ObjectStateUtils.readString(in, "Options.action");

        // String transportInProtocol
        transportInProtocol = ObjectStateUtils.readString(in, "Options.transportInProtocol");

        // String messageId
        messageId = ObjectStateUtils.readString(in, "Options.messageId");

        // String object id
        logCorrelationIDString = ObjectStateUtils.readString(in, "Options.logCorrelationIDString");

        // trace point
        log.trace(myClassName + ":readExternal():  reading the input stream for  [" +
                logCorrelationIDString + "]");

        //---------------------------------------------------------
        // various objects
        //---------------------------------------------------------

        // EndpointReference faultTo
        faultTo = (EndpointReference) ObjectStateUtils.readObject(in, "Options.faultTo");

        // EndpointReference from
        from = (EndpointReference) ObjectStateUtils.readObject(in, "Options.from");

        // EndpointReference replyTo
        replyTo = (EndpointReference) ObjectStateUtils.readObject(in, "Options.replyTo");

        // EndpointReference to
        to = (EndpointReference) ObjectStateUtils.readObject(in, "Options.to");

        // TransportListener listener
        // is not usable until the meta data has been reconciled
        listener = null;
        metaListener = (MetaDataEntry) ObjectStateUtils.readObject(in, "Options.metaListener");

        // TransportInDescription transportIn
        // is not usable until the meta data has been reconciled
        transportIn = null;
        metaTransportIn =
                (MetaDataEntry) ObjectStateUtils.readObject(in, "Options.metaTransportIn");

        // TransportOutDescription transportOut
        // is not usable until the meta data has been reconciled
        transportOut = null;
        metaTransportOut =
                (MetaDataEntry) ObjectStateUtils.readObject(in, "Options.metaTransportOut");

        //---------------------------------------------------------
        // collections and lists
        //---------------------------------------------------------

        // List relationships, which is an array of RelatesTo objects
        ArrayList tmpAL1 = ObjectStateUtils.readArrayList(in, "Options.relationships");
        if (tmpAL1 != null) {
            relationships = new ArrayList(tmpAL1);
        } else {
            relationships = null;
        }

        // ArrayList referenceParameters
        ArrayList tmpAL2 = ObjectStateUtils.readArrayList(in, "Options.referenceParameters");
        if (tmpAL2 != null) {
            referenceParameters = new ArrayList(tmpAL2);
        } else {
            referenceParameters = null;
        }

        //---------------------------------------------------------
        // properties
        //---------------------------------------------------------

        // HashMap properties
        HashMap tmpHM = ObjectStateUtils.readHashMap(in, "Options.properties");

        if (tmpHM != null) {
            properties = new HashMap(tmpHM);
        } else {
            properties = new HashMap();
        }

        //---------------------------------------------------------
        // "nested"
        //---------------------------------------------------------

        // Options parent
        Object tmpParent = ObjectStateUtils.readObject(in, "Options.parent");

        if (tmpParent != null) {
            parent = (Options) tmpParent;
        } else {
            parent = null;
        }


⌨️ 快捷键说明

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