JavaDefinitionWriterpublic class JavaDefinitionWriter extends Object implements org.apache.axis.wsdl.gen.GeneratorThis is Wsdl2java's Definition Writer.
It currently writes the following files:
Faults as needed. |
Fields Summary |
---|
protected Emitter | emitterField emitter | protected javax.wsdl.Definition | definitionField definition | protected org.apache.axis.wsdl.symbolTable.SymbolTable | symbolTableField symbolTable | private HashSet | importedFilesCollect all of the faults used in this definition. |
Methods Summary |
---|
private void | collectFaults(javax.wsdl.Definition def, java.util.ArrayList faults)Method collectFaults
Map imports = def.getImports();
Object[] importValues = imports.values().toArray();
for (int i = 0; i < importValues.length; ++i) {
Vector v = (Vector) importValues[i];
for (int j = 0; j < v.size(); ++j) {
Import imp = (Import) v.get(j);
if (!importedFiles.contains(imp.getLocationURI())) {
importedFiles.add(imp.getLocationURI());
Definition importDef = imp.getDefinition();
if (importDef != null) {
collectFaults(importDef, faults);
}
}
}
}
// Traverse the bindings to find faults
Map bindings = def.getBindings();
Iterator bindi = bindings.values().iterator();
while (bindi.hasNext()) {
Binding binding = (Binding) bindi.next();
BindingEntry entry =
symbolTable.getBindingEntry(binding.getQName());
if (entry.isReferenced()) {
// use the map of bindingOperation -> fault info
// created in SymbolTable
Map faultMap = entry.getFaults();
Iterator it = faultMap.values().iterator();
while (it.hasNext()) {
ArrayList list = (ArrayList) it.next();
// Accumulate total list of faults
faults.addAll(list);
}
}
}
| public void | generate()Write other items from the definition as needed.
writeFaults();
| protected void | writeFaults()Write all the simple type faults.
The complexType Faults are automatically handled by JavaTypeWriter.
The fault name is derived from the fault message name per JAX-RPC
ArrayList faults = new ArrayList();
collectFaults(definition, faults);
// Fault classes we're actually writing (for dup checking)
HashSet generatedFaults = new HashSet();
// iterate over fault list, emitting code.
Iterator fi = faults.iterator();
while (fi.hasNext()) {
FaultInfo faultInfo = (FaultInfo) fi.next();
Message message = faultInfo.getMessage();
String name = Utils.getFullExceptionName(message,
symbolTable);
if (generatedFaults.contains(name)) {
continue;
}
generatedFaults.add(name);
// Generate the 'Simple' Faults.
// The complexType Faults are automatically handled
// by JavaTypeWriter.
MessageEntry me =
symbolTable.getMessageEntry(message.getQName());
boolean emitSimpleFault = true;
if (me != null) {
Boolean complexTypeFault = (Boolean) me.getDynamicVar(
JavaGeneratorFactory.COMPLEX_TYPE_FAULT);
if ((complexTypeFault != null)
&& complexTypeFault.booleanValue()) {
emitSimpleFault = false;
}
}
if (emitSimpleFault) {
try {
JavaFaultWriter writer = new JavaFaultWriter(emitter,
symbolTable, faultInfo);
// Go write the file
writer.generate();
} catch (DuplicateFileException dfe) {
System.err.println(Messages.getMessage("fileExistError00",
dfe.getFileName()));
}
}
}
|
|