public XmlElement multiply(XmlElement inputElement) {
logger.info(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);
Random random = new Random();
int msec = random.nextInt(10000);
logger.info("Sleep for " + msec + " msec");
try {
Thread.sleep(msec);
} catch (InterruptedException e) {
logger.error(e.getMessage(), e);
}
int z = x * y;
String zString = "" + z;
XmlNamespace namespace = XmlConstants.BUILDER.newNamespace("multipliertypens",
"http://www.extreme.indiana.edu/math/multiplier/xsd/");
XmlElement outputElement = XmlConstants.BUILDER.newFragment(namespace, "MultiplyOutput");
XmlElement zElement = outputElement.addElement("z");
zElement.addChild(zString);
if (notifier != null) {
notifier.sendingResult(outputElement);
}
logger.info(XMLUtil.xmlElementToString(outputElement));