protected void loadInterface(Element interfaceElement, String sInterfaceName)
{
XMLMetadataHelper.verifyRootElement(interfaceElement, "Interface");
XMLMetadataHelper.validateName(sInterfaceName);
final Interface iface = m_metadata.defineInterface(sInterfaceName, null);
if (!iface.isForward())
{
m_metadata.addInterface(iface);
}
iface.setForward(false);
iface.setResourceName(m_helper.getCurResourceName());
String sFormatName = XMLUtil.getStringAttr(interfaceElement, "format");
if (sFormatName != null)
{
iface.setFormat(m_metadata.getFormat(sFormatName));
}
XMLUtil.withFirstChildElement(interfaceElement, "Requests", false, new ElementHandler()
{
public void handleElement(Element requestsElement)
{
XMLUtil.forEachChildElement(requestsElement, "Request", m_helper.new ElementHandler("request")
{
public void handleElement(Element requestElement, String sMessageName)
{
iface.addRequest(m_metadata.getMessage(sMessageName));
}
protected String getName(Element element)
{
return XMLUtil.getReqStringAttr(element, "message");
}
});
}
});
XMLUtil.withFirstChildElement(interfaceElement, "Responses", false, new ElementHandler()
{
public void handleElement(Element requestsElement)
{
XMLUtil.forEachChildElement(requestsElement, "Response", m_helper.new ElementHandler("response")
{
public void handleElement(Element requestElement, String sMessageName)
{
iface.addResponse(m_metadata.getMessage(sMessageName));
}
protected String getName(Element element)
{
return XMLUtil.getReqStringAttr(element, "message");
}
});
}
});
addSingletonFixup(new ContextFixup(m_helper)
{
public void fixup()
{
MessageTable table = iface.getRequestTable();
if (table.getFormat() != null)
{
((MessageParser)table.getFormat().getParser().getInstance(null)).initializeMessageTable(table);
}
table = iface.getResponseTable();
if (table.getFormat() != null)
{
((MessageParser)table.getFormat().getParser().getInstance(null)).initializeMessageTable(table);
}