axisservice.java
来自「开源的axis2框架的源码。用于开发WEBSERVER」· Java 代码 · 共 1,682 行 · 第 1/5 页
JAVA
1,682 行
/*
* 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.description;
import org.apache.axiom.om.OMElement;
import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.description.java2wsdl.*;
import org.apache.axis2.addressing.AddressingConstants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.context.MessageContext;
import org.apache.axis2.dataretrieval.AxisDataLocator;
import org.apache.axis2.dataretrieval.AxisDataLocatorImpl;
import org.apache.axis2.dataretrieval.DRConstants;
import org.apache.axis2.dataretrieval.Data;
import org.apache.axis2.dataretrieval.DataRetrievalException;
import org.apache.axis2.dataretrieval.DataRetrievalRequest;
import org.apache.axis2.dataretrieval.LocatorType;
import org.apache.axis2.dataretrieval.OutputForm;
import org.apache.axis2.dataretrieval.WSDLSupplier;
import org.apache.axis2.deployment.util.PhasesInfo;
import org.apache.axis2.deployment.util.Utils;
import org.apache.axis2.deployment.DeploymentConstants;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.engine.DefaultObjectSupplier;
import org.apache.axis2.engine.MessageReceiver;
import org.apache.axis2.engine.ObjectSupplier;
import org.apache.axis2.engine.ServiceLifeCycle;
import org.apache.axis2.i18n.Messages;
import org.apache.axis2.phaseresolver.PhaseResolver;
import org.apache.axis2.transport.TransportListener;
import org.apache.axis2.transport.http.server.HttpUtils;
import org.apache.axis2.util.Loader;
import org.apache.axis2.util.XMLUtils;
import org.apache.axis2.util.XMLPrettyPrinter;
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.neethi.Policy;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaElement;
import org.apache.ws.commons.schema.XmlSchemaExternal;
import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
import org.apache.ws.commons.schema.utils.NamespaceMap;
import org.apache.ws.commons.schema.utils.NamespacePrefixList;
import org.codehaus.jam.JMethod;
import org.w3c.dom.*;
import org.xml.sax.SAXException;
import javax.wsdl.*;
import javax.wsdl.extensions.soap.SOAPAddress;
import javax.wsdl.extensions.schema.Schema;
import javax.wsdl.extensions.soap12.SOAP12Address;
import javax.wsdl.extensions.http.HTTPAddress;
import javax.wsdl.factory.WSDLFactory;
import javax.wsdl.xml.WSDLReader;
import javax.wsdl.xml.WSDLWriter;
import javax.xml.namespace.QName;
import javax.xml.parsers.ParserConfigurationException;
import java.io.*;
import java.net.SocketException;
import java.net.URL;
import java.net.URISyntaxException;
import java.security.PrivilegedAction;
import java.util.*;
/**
* Class AxisService
*/
public class AxisService extends AxisDescription {
//////////////////////////////////////////////////////////////////
// Standard Parameter names
/**
* If this param is true, and the service has exactly one AxisOperation,
* normal operation dispatch (via URI/soapAction/etc) will not be necessary,
* and we'll just default to funneling all messages to that op. This is
* useful for passthrough/ESB/embedded applications.
*/
public static final String SUPPORT_SINGLE_OP = "supportSingleOperation";
//////////////////////////////////////////////////////////////////
public static final String IMPORT_TAG = "import";
public static final String INCLUDE_TAG = "include";
public static final String SCHEMA_LOCATION = "schemaLocation";
private Map endpointMap = new HashMap();
/*This is a map between the QName of the element of a message
*specified in the WSDL and an Operation. It enables SOAP Body-based
*dispatching for doc-literal bindings.
*/
private Map messageElementQNameToOperationMap = new HashMap();
private int nsCount = 0;
private static final Log log = LogFactory.getLog(AxisService.class);
private URL fileName;
// Maps httpLocations to corresponding operations. Used to dispatch rest messages.
private HashMap httpLocationDispatcherMap = null;
/**
* Map from String(action URI) -> AxisOperation
*/
private HashMap operationsAliasesMap = null;
// Collection of aliases that are invalid for this service because they are duplicated across
// multiple operations under this service.
private List invalidOperationsAliases = null;
// private HashMap operations = new HashMap();
// to store module ref at deploy time parsing
private ArrayList moduleRefs = null;
// to keep the time that last update time of the service
private long lastupdate;
private HashMap moduleConfigmap;
private String name;
private ClassLoader serviceClassLoader;
//to keep the XMLScheam getting either from WSDL or java2wsdl
private ArrayList schemaList;
//private XmlSchema schema;
//wsdl is there for this service or not (in side META-INF)
private boolean wsdlFound = false;
//to store the scope of the service
private String scope;
//to store default message receivers
private HashMap messageReceivers;
// to set the handler chain available in phase info
private boolean useDefaultChains = true;
//to keep the status of the service , since service can stop at the run time
private boolean active = true;
private boolean elementFormDefault = true;
//to keep the service target name space
private String targetNamespace =
Java2WSDLConstants.DEFAULT_TARGET_NAMESPACE;
private String targetNamespacePrefix =
Java2WSDLConstants.TARGETNAMESPACE_PREFIX;
// to store the target namespace for the schema
private String schematargetNamespace;// = Java2WSDLConstants.AXIS2_XSD;
private String schematargetNamespacePrefix =
Java2WSDLConstants.SCHEMA_NAMESPACE_PRFIX;
private boolean enableAllTransports = true;
private List exposedTransports = new ArrayList();
//To keep reference to ServiceLifeCycle instance , if the user has
// specified in services.xml
private ServiceLifeCycle serviceLifeCycle;
/**
* Keeps track whether the schema locations are adjusted
*/
private boolean schemaLocationsAdjusted = false;
private boolean wsdlImportLocationAdjusted = false;
/**
* A table that keeps a mapping of unique xsd names (Strings)
* against the schema objects. This is populated in the first
* instance the schemas are asked for and then used to serve
* the subsequent requests
*/
private Map schemaMappingTable = null;
/**
* counter variable for naming the schemas
*/
private int count = 0;
/**
* A custom schema Name prefix. if set this will be used to
* modify the schema names
*/
private String customSchemaNamePrefix = null;
/**
* A custom schema name suffix. will be attached to the
* schema file name when the files are uniquely named.
* A good place to add a file extension if needed
*/
private String customSchemaNameSuffix = null;
/////////////////////////////////////////
// WSDL related stuff ////////////////////
////////////////////////////////////////
/** Map of prefix -> namespaceURI */
private NamespaceMap namespaceMap;
private String soapNsUri;
private String endpointName;
private String endpointURL;
// Flag representing whether WS-Addressing is required to use this service.
// Reflects the wsaw:UsingAddressing wsdl extension element
private String wsaddressingFlag = AddressingConstants.ADDRESSING_UNSPECIFIED;
private boolean clientSide = false;
//To keep a ref to ObjectSupplier instance
private ObjectSupplier objectSupplier;
// package to namespace mapping
private Map p2nMap;
private TypeTable typeTable;
// Data Locators for WS-Mex Support
private HashMap dataLocators;
private HashMap dataLocatorClassNames;
private AxisDataLocatorImpl defaultDataLocator;
// Define search sequence for datalocator based on Data Locator types.
LocatorType[] availableDataLocatorTypes = new LocatorType[] {
LocatorType.SERVICE_DIALECT,
LocatorType.SERVICE_LEVEL,
LocatorType.GLOBAL_DIALECT,
LocatorType.GLOBAL_LEVEL,
LocatorType.DEFAULT_AXIS
};
// name of the binding used : use in codegeneration
private String bindingName;
// names list keep to preserve the parameter order
private List operationsNameList;
private String[] eprs;
private boolean customWsdl = false;
public AxisEndpoint getEndpoint(String key) {
return (AxisEndpoint) endpointMap.get(key);
}
public void addEndpoint(String key, AxisEndpoint axisEndpoint) {
this.endpointMap.put(key, axisEndpoint);
}
public String getWSAddressingFlag() {
return wsaddressingFlag;
}
public void setWSAddressingFlag(String ar) {
wsaddressingFlag = ar;
if (wsaddressingFlag == null) {
wsaddressingFlag = AddressingConstants.ADDRESSING_UNSPECIFIED;
}
}
public boolean isSchemaLocationsAdjusted() {
return schemaLocationsAdjusted;
}
public void setSchemaLocationsAdjusted(boolean schemaLocationsAdjusted) {
this.schemaLocationsAdjusted = schemaLocationsAdjusted;
}
public Map getSchemaMappingTable() {
return schemaMappingTable;
}
public void setSchemaMappingTable(Map schemaMappingTable) {
this.schemaMappingTable = schemaMappingTable;
}
public String getCustomSchemaNamePrefix() {
return customSchemaNamePrefix;
}
public void setCustomSchemaNamePrefix(String customSchemaNamePrefix) {
this.customSchemaNamePrefix = customSchemaNamePrefix;
}
public String getCustomSchemaNameSuffix() {
return customSchemaNameSuffix;
}
public void setCustomSchemaNameSuffix(String customSchemaNameSuffix) {
this.customSchemaNameSuffix = customSchemaNameSuffix;
}
/**
* Constructor AxisService.
*/
public AxisService() {
super();
this.operationsAliasesMap = new HashMap();
this.invalidOperationsAliases = new ArrayList();
moduleConfigmap = new HashMap();
//by default service scope is for the request
scope = Constants.SCOPE_REQUEST;
httpLocationDispatcherMap = new HashMap();
messageReceivers = new HashMap();
moduleRefs = new ArrayList();
schemaList = new ArrayList();
serviceClassLoader = (ClassLoader) org.apache.axis2.java.security.AccessController
.doPrivileged(new PrivilegedAction() {
public Object run() {
return Thread.currentThread().getContextClassLoader();
}
});
objectSupplier = new DefaultObjectSupplier();
dataLocators = new HashMap();
dataLocatorClassNames = new HashMap();
}
/**
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?