public Class<HTTPBinding> getModelType() {
return HTTPBinding.class;
}
public HTTPBinding read(XMLStreamReader reader, ProcessorContext context) throws ContributionReadException,XMLStreamException {
HTTPBinding httpBinding = httpBindingFactory.createHTTPBinding();
/**
* <tuscany:binding.http uri="http://localhost:8085/Customer">
* <tuscany:wireFormat.json />
* <tuscany:operationSelector.default />
* <tuscany:response>
* <tuscany:wireFormat.xml />
* </tuscany:response>
* </tuscany:binding.http>
*
*/
while (reader.hasNext()) {
QName elementName = null;
int event = reader.getEventType();
switch (event) {
case START_ELEMENT:
elementName = reader.getName();
if (HTTPBinding.TYPE.equals(elementName)) {
String name = getString(reader, NAME);
if (name != null) {
httpBinding.setName(name);
}
String uri = getURIString(reader, URI);
if (uri != null) {
httpBinding.setURI(uri);
}
} else if (RESPONSE_QNAME.equals(elementName)) {
// skip response
reader.next();
// and position to the next start_element event
while (reader.hasNext()) {
int sub_event = reader.getEventType();
switch (sub_event) {
case START_ELEMENT:
elementName = reader.getName();
break;
default:
reader.next();
}
break;
}
// dispatch to read wire format for the response
Object extension = extensionProcessor.read(reader, context);
if (extension != null) {
if (extension instanceof WireFormat) {
httpBinding.setResponseWireFormat((WireFormat)extension);
}
}
break;
} else {
// Read an extension element
Object extension = extensionProcessor.read(reader, context);
if (extension != null) {
if (extension instanceof WireFormat) {
httpBinding.setRequestWireFormat((WireFormat)extension);
} else if (extension instanceof OperationSelector) {
httpBinding.setOperationSelector((OperationSelector)extension);
}
}
}
}