options.java
来自「开源的axis2框架的源码。用于开发WEBSERVER」· Java 代码 · 共 1,690 行 · 第 1/5 页
JAVA
1,690 行
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.axis2.client;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.util.UUIDGenerator;
import org.apache.axiom.soap.SOAP11Constants;
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.AddressingConstants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.addressing.RelatesTo;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.description.TransportInDescription;
import org.apache.axis2.description.TransportOutDescription;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.i18n.Messages;
import org.apache.axis2.transport.TransportListener;
import org.apache.axis2.util.MetaDataEntry;
import org.apache.axis2.util.ObjectStateUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.xml.namespace.QName;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Holder for operation client options. This is used by the other classes in
* this package to configure various aspects of how a client communicates with a
* service. It exposes a number of predefined properties as part of the API
* (with specific getXXX and setXXX methods), and also allows for arbitrary
* named properties to be passed using a properties map with the property name
* as the key value. Instances of this class can be chained together for
* property inheritance, so that if a property is not set in one instance it
* will check its parent for a setting.
*/
public class Options implements Externalizable {
/*
* setup for logging
*/
private static final Log log = LogFactory.getLog(Options.class);
private static final String myClassName = "Options";
/**
* An ID which can be used to correlate operations on an instance of
* this object in the log files
*/
private String logCorrelationIDString = null;
/**
* @serial The serialization version ID tracks the version of the class.
* If a class definition changes, then the serialization/externalization
* of the class is affected. If a change to the class is made which is
* not compatible with the serialization/externalization of the class,
* then the serialization version ID should be updated.
* Refer to the "serialVer" utility to compute a serialization
* version ID.
*/
private static final long serialVersionUID = -8318751890845181507L;
/**
* @serial Tracks the revision level of a class to identify changes to the
* class definition that are compatible to serialization/externalization.
* If a class definition changes, then the serialization/externalization
* of the class is affected.
* Refer to the writeExternal() and readExternal() methods.
*/
// supported revision levels, add a new level to manage compatible changes
private static final int REVISION_1 = 1;
// current revision level of this object
private static final int revisionID = REVISION_1;
/**
* Default blocking timeout value.
*/
public static final int DEFAULT_TIMEOUT_MILLISECONDS = 30 * 1000;
/**
* @serial parent
*/
private Options parent;
/**
* @serial properties
*/
private Map properties;
// ==========================================================================
// Parameters that can be set via Options
// ==========================================================================
private String soapVersionURI; // defaults to
// SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
private Boolean isExceptionToBeThrownOnSOAPFault; // defaults to true;
private long timeOutInMilliSeconds = -1; // =
// DEFAULT_TIMEOUT_MILLISECONDS;
private Boolean useSeparateListener; // defaults to false
// Addressing specific properties
private String action;
private EndpointReference faultTo;
private EndpointReference from;
private TransportListener listener;
private TransportInDescription transportIn;
private String transportInProtocol;
private String messageId;
// Array of RelatesTo objects
private List relationships;
private EndpointReference replyTo;
private ArrayList referenceParameters;
/**
* This is used for sending and receiving messages.
*/
protected TransportOutDescription transportOut;
private EndpointReference to;
//To control , session management , default is set to true , if user wants he can set that to true
// The operation client will manage session using ServiceGroupID if it is there in the response
private boolean manageSession = false;
//----------------------------------------------------------------
// MetaData for data to be restored in activate after readExternal
//----------------------------------------------------------------
/**
* Indicates whether this object has been reconstituted
* and needs to have its object references reconciled
*/
private transient boolean needsToBeReconciled = false;
/**
* The TransportOutDescription metadata will be used during
* activate to match up with an existing object
*/
private transient MetaDataEntry metaTransportOut = null;
/**
* The TransportInDescription metadata will be used during
* activate to match up with an existing object
*/
private transient MetaDataEntry metaTransportIn = null;
/**
* The TransportListener metadata will be used during
* activate to match up with an existing object, if possible
*/
private transient MetaDataEntry metaListener = null;
//This property can be used to specify to call the auto transport clean up
private transient boolean callTransportCleanup ;
private transient String userName;
private transient String password;
//----------------------------------------------------------------
// end MetaData section
//----------------------------------------------------------------
/**
* Default constructor
*/
public Options() {
}
/**
* In normal mode operation, this options will try to fulfil the request
* from its values. If that is not possible, this options will request those
* information from its parent.
*
* @param parent
*/
public Options(Options parent) {
this.parent = parent;
}
/**
* Get WS-Addressing Action / SOAP Action string.
*
* @return action
*/
public String getAction() {
if (action == null && parent != null) {
return parent.getAction();
}
return action;
}
/**
* Get WS-Addressing FaultTo endpoint reference.
*
* @return endpoint
*/
public EndpointReference getFaultTo() {
if (faultTo == null && parent != null) {
return parent.getFaultTo();
}
return faultTo;
}
/**
* Set WS-Addressing From endpoint reference.
*
* @return endpoint
*/
public EndpointReference getFrom() {
if (from == null && parent != null) {
return parent.getFrom();
}
return from;
}
/**
* Get listener used for incoming message.
*
* @return listener
*/
public TransportListener getListener() {
checkActivateWarning("getListener");
if (listener == null && parent != null) {
return parent.getListener();
}
return listener;
}
/**
* Get transport used for incoming message.
*
* @return transport information
*/
public TransportInDescription getTransportIn() {
checkActivateWarning("getTransportIn");
if (transportIn == null && parent != null) {
return parent.getTransportIn();
}
return transportIn;
}
/**
* Get transport protocol used for incoming message.
*
* @return name protocol name ("http", "tcp", etc.)
*/
public String getTransportInProtocol() {
if (transportInProtocol == null && parent != null) {
return parent.getTransportInProtocol();
}
return transportInProtocol;
}
/**
* Get WS-Addressing MessageId.
*
* @return uri string
*/
public String getMessageId() {
if (messageId == null && parent != null) {
return parent.getMessageId();
}
return messageId;
}
/**
* Get a copy of the general option properties. Because of the way options
* are stored this does not include properties with specific get/set
* methods, only the general properties identified by a text string. The
* returned map merges properties inherited from parent options, if any, to
* give a complete set of property definitions as seen by users of this
* options instance. The returned copy is not "live", so changes you make to
* the copy are not reflected in the actual option settings. However, you
* can make the modified values take effect with a call to {@link
* #setProperties(Map)},
*
* @return copy of general properties
*/
public Map getProperties() {
// make sure that the Options properties exists
if (this.properties == null) {
this.properties = new HashMap();
}
if (parent == null) {
return new HashMap(properties);
} else {
Map props = parent.getProperties();
props.putAll(properties);
return props;
}
}
/**
* Get named property value.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?