public XmlElement add(XmlElement inputElement) {
logger.finest(XMLUtil.xmlElementToString(inputElement));
ServiceNotificationSender notifier = ServiceNotificationSender
.invoked(inputElement);
XmlElement xElement = inputElement.requiredElement(null, "x");
XmlElement yElement = inputElement.requiredElement(null, "y");
String xString = xElement.requiredTextContent();
String yString = yElement.requiredTextContent();
int x = Integer.parseInt(xString);
int y = Integer.parseInt(yString);
int z = x + y;
Random random = new Random();
int msec = random.nextInt(5000);
logger.info("Sleep for " + msec + " msec");
try {
Thread.sleep(msec);
} catch (InterruptedException e) {
logger.caught(e);
}
String zString = "" + z;
XmlNamespace namespace = XmlConstants.BUILDER
.newNamespace("addertypens",
"http://www.extreme.indiana.edu/math/adder/xsd/");
XmlElement outputElement = XmlConstants.BUILDER.newFragment(namespace,
"AddOutput");
XmlElement zElement = outputElement.addElement("z");
zElement.addChild(zString);
if (notifier != null) {
notifier.sendingResult(outputElement);
}
logger.finest(XMLUtil.xmlElementToString(outputElement));