axisservicebasedmultilanguageemitter.java
来自「开源的axis2框架的源码。用于开发WEBSERVER」· Java 代码 · 共 1,546 行 · 第 1/5 页
JAVA
1,546 行
Iterator iter = this.axisService.getOperations();
AxisOperation axisOperation;
for (; iter.hasNext();) {
axisOperation = (AxisOperation) iter.next();
if (mep == null) {
// add the fault messages
addFaultMessages(axisOperation.getFaultMessages(), faultListForMep);
} else {
if (mep.equals(axisOperation.getMessageExchangePattern())) {
// add the fault messages
addFaultMessages(axisOperation.getFaultMessages(), faultListForMep);
}
}
}
Element rootElement = doc.createElement("fault-list");
Element faultElement;
String key;
Iterator iterator = faultListForMep.iterator();
while (iterator.hasNext()) {
faultElement = doc.createElement("fault");
key = (String) iterator.next();
//as for the name of a fault, we generate an exception
addAttribute(doc, "name",
(String) fullyQualifiedFaultClassNameMap.get(key),
faultElement);
addAttribute(doc, "shortName",
(String) faultClassNameMap.get(key),
faultElement);
//the type represents the type that will be wrapped by this
//name
String typeMapping =
this.mapper.getTypeMappingName((QName) faultElementQNameMap.get(key));
addAttribute(doc, "type", (typeMapping == null)
? ""
: typeMapping, faultElement);
String attribValue = (String) instantiatableMessageClassNames.
get(key);
addAttribute(doc, "instantiatableType",
attribValue == null ? "" : attribValue,
faultElement);
String exceptionName = ((QName) faultElementQNameMap.get(key)).getLocalPart();
addAttribute(doc, "localname",
exceptionName == null ? "" : exceptionName,
faultElement);
// add an extra attribute to say whether the type mapping is
// the default
if (mapper.getDefaultMappingName().equals(typeMapping)) {
addAttribute(doc, "default", "yes", faultElement);
}
addAttribute(doc, "value", getParamInitializer(typeMapping),
faultElement);
rootElement.appendChild(faultElement);
}
return rootElement;
}
/**
* Adds the endpoint to the document.
*
* @param doc
* @param rootElement
*/
protected void addEndpoint(Document doc, Element rootElement) throws Exception {
Element endpointElement = doc.createElement("endpoint");
String endpoint = this.axisEndpoint.getEndpointURL();
Text text = doc.createTextNode((endpoint != null)
? endpoint
: "");
endpointElement.appendChild(text);
rootElement.appendChild(endpointElement);
}
/**
* Looks for the SOAPVersion and adds it.
*
* @param doc
* @param rootElement
*/
protected void addSoapVersion(Document doc, Element rootElement) {
// loop through the extensibility elements to get to the bindings element
addAttribute(doc, "soap-version",
(String) axisBinding.getProperty(WSDL2Constants.ATTR_WSOAP_VERSION),
rootElement);
}
/**
* Writes the exceptions.
*/
protected void writeExceptions() throws Exception {
Element faultElement;
String key;
Iterator iterator = fullyQualifiedFaultClassNameMap.keySet().iterator();
while (iterator.hasNext()) {
Document doc = getEmptyDocument();
faultElement = doc.createElement("fault");
addAttribute(doc, "package", codeGenConfiguration.getPackageName(), faultElement);
key = (String) iterator.next();
//as for the name of a fault, we generate an exception
addAttribute(doc, "name",
(String) faultClassNameMap.get(key),
faultElement);
addAttribute(doc, "shortName",
(String) faultClassNameMap.get(key),
faultElement);
//the type represents the type that will be wrapped by this
//name
String typeMapping =
this.mapper.getTypeMappingName((QName) faultElementQNameMap.get(key));
addAttribute(doc, "type", (typeMapping == null)
? ""
: typeMapping, faultElement);
String attribValue = (String) instantiatableMessageClassNames.
get(key);
addAttribute(doc, "instantiatableType",
attribValue == null ? "" : attribValue,
faultElement);
// add an extra attribute to say whether the type mapping is
// the default
if (mapper.getDefaultMappingName().equals(typeMapping)) {
addAttribute(doc, "default", "yes", faultElement);
}
addAttribute(doc, "value", getParamInitializer(typeMapping),
faultElement);
ExceptionWriter exceptionWriter =
new ExceptionWriter(
codeGenConfiguration.isFlattenFiles() ?
getOutputDirectory(codeGenConfiguration.getOutputLocation(),
null) :
getOutputDirectory(codeGenConfiguration.getOutputLocation(),
codeGenConfiguration.getSourceLocation()),
codeGenConfiguration.getOutputLanguage());
doc.appendChild(faultElement);
//////////////////////////////////////////////////////////
// System.out.println(DOM2Writer.nodeToString(doc));
////////////////////////////////////////////////////////////
exceptionWriter.setOverride(codeGenConfiguration.isOverride());
writeFile(doc, exceptionWriter);
}
}
/**
* Generates the model for the callbacks.
*/
protected Document createDOMDocumentForException() {
Document doc = getEmptyDocument();
Element rootElement = doc.createElement("callback");
addAttribute(doc, "package", codeGenConfiguration.getPackageName(), rootElement);
addAttribute(doc, "name",
makeJavaClassName(axisService.getName()) + CALL_BACK_HANDLER_SUFFIX,
rootElement);
// TODO JAXRPC mapping support should be considered here ??
this.loadOperations(doc, rootElement, null);
doc.appendChild(rootElement);
return doc;
}
/**
* Writes the callback handlers.
*/
protected void writeCallBackHandlers() throws Exception {
if (codeGenConfiguration.isAsyncOn()) {
Document interfaceModel = createDOMDocumentForCallbackHandler();
debugLogDocument("Document for callback handler:", interfaceModel);
CallbackHandlerWriter callbackWriter =
new CallbackHandlerWriter(
codeGenConfiguration.isFlattenFiles() ?
getOutputDirectory(codeGenConfiguration.getOutputLocation(),
null) :
getOutputDirectory(codeGenConfiguration.getOutputLocation(),
codeGenConfiguration.getSourceLocation()),
codeGenConfiguration.getOutputLanguage());
callbackWriter.setOverride(codeGenConfiguration.isOverride());
writeFile(interfaceModel, callbackWriter);
}
}
/**
* Generates the model for the callbacks.
*/
protected Document createDOMDocumentForCallbackHandler() {
Document doc = getEmptyDocument();
Element rootElement = doc.createElement("callback");
addAttribute(doc, "package", codeGenConfiguration.getPackageName(), rootElement);
if (codeGenConfiguration.isPackClasses() && this.axisService.getEndpoints().size() > 1) {
addAttribute(doc, "name",
makeJavaClassName(axisService.getName() + axisService.getEndpointName())
+ CALL_BACK_HANDLER_SUFFIX, rootElement);
} else {
addAttribute(doc, "name",
makeJavaClassName(axisService.getName()) + CALL_BACK_HANDLER_SUFFIX,
rootElement);
}
// TODO JAXRPC mapping support should be considered here ??
this.loadOperations(doc, rootElement, null);
doc.appendChild(rootElement);
return doc;
}
/**
* Writes the interfaces.
*
* @throws Exception
*/
protected void writeInterface(boolean writeDatabinders) throws Exception {
Document interfaceModel = createDOMDocumentForInterface(writeDatabinders);
debugLogDocument("Document for interface:", interfaceModel);
InterfaceWriter interfaceWriter =
new InterfaceWriter(
codeGenConfiguration.isFlattenFiles() ?
getOutputDirectory(codeGenConfiguration.getOutputLocation(), null) :
getOutputDirectory(codeGenConfiguration.getOutputLocation(),
codeGenConfiguration.getSourceLocation()),
this.codeGenConfiguration.getOutputLanguage());
interfaceWriter.setOverride(codeGenConfiguration.isOverride());
writeFile(interfaceModel, interfaceWriter);
}
/**
* Creates the DOM tree for the interface creation. Uses the interface.
*/
protected Document createDOMDocumentForInterface(boolean writeDatabinders) {
Document doc = getEmptyDocument();
Element rootElement = doc.createElement("interface");
String localPart = null;
if (this.codeGenConfiguration.isBackwordCompatibilityMode()) {
localPart =
makeJavaClassName(axisService.getEndpointName() + STUB_INTERFACE_SUFFIX_BACK);
} else {
if (this.axisService.getEndpoints().size() > 1) {
localPart =
makeJavaClassName(axisService.getName() + axisService.getEndpointName());
} else {
localPart = makeJavaClassName(axisService.getName());
}
}
addAttribute(doc, "package", codeGenConfiguration.getPackageName(), rootElement);
addAttribute(doc, "name", localPart, rootElement);
addAttribute(doc, "callbackname",
makeJavaClassName(axisService.getName()) + CALL_BACK_HANDLER_SUFFIX,
rootElement);
//add backwordcompatibility attribute
addAttribute(doc, "isbackcompatible",
String.valueOf(codeGenConfiguration.isBackwordCompatibilityMode()),
rootElement);
fillSyncAttributes(doc, rootElement);
loadOperations(doc, rootElement, null);
// ###########################################################################################
// this block of code specifically applies to the integration of databinding code into the
// generated classes tightly (probably as inner classes)
// ###########################################################################################
// check for the special models in the mapper and if they are present process them
if (writeDatabinders) {
if (mapper.isObjectMappingPresent()) {
// add an attribute to the root element showing that the writing has been skipped
addAttribute(doc, "skip-write", "yes", rootElement);
// process the mapper objects
processModelObjects(mapper.getAllMappedObjects(), rootElement, doc);
}
}
// #############################################################################################
doc.appendChild(rootElement);
return doc;
}
/**
* Update mapper for message receiver
*/
protected void updateMapperForMessageReceiver() {
updateMapperClassnames(getFullyQualifiedMessageReceiverName());
}
/**
* @return fully qualified MR name
*/
protected String getFullyQualifiedMessageReceiverName() {
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?