Package org.apache.airavata.xbaya.test.service

Examples of org.apache.airavata.xbaya.test.service.ServiceNotificationSender


    /**
     * @see org.apache.airavata.xbaya.test.service.adder.Adder#add(org.xmlpull.v1.builder.XmlElement)
     */
    public XmlElement add(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);

        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.error(e.getMessage(), 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.info(XMLUtil.xmlElementToString(outputElement));
        return outputElement;
    }
View Full Code Here


     * @see org.apache.airavata.xbaya.test.service.arraygen.ArrayGenerator#generate(org.xmlpull.v1.builder.XmlElement)
     */
    public XmlElement generate(XmlElement inputElement) {
        logger.info(XMLUtil.xmlElementToString(inputElement));

        ServiceNotificationSender notifier = ServiceNotificationSender.invoked(inputElement);

        XmlElement nElement = inputElement.requiredElement(null, "n");
        String nString = nElement.requiredTextContent();

        int n = Integer.parseInt(nString);

        Random random = new Random();
        int msec = random.nextInt(5000);
        logger.info("Sleep for " + msec + " msec");
        try {
            Thread.sleep(msec);
        } catch (InterruptedException e) {
            logger.error(e.getMessage(), e);
        }

        XmlNamespace namespace = XmlConstants.BUILDER.newNamespace("typens",
                "http://www.extreme.indiana.edu/math/arraygen/xsd/");
        XmlElement outputElement = XmlConstants.BUILDER.newFragment(namespace, "ArrayGeneratorOutput");

        XmlElement arrayElement = outputElement.addElement("output");
        for (int i = 0; i < n; i++) {
            XmlElement valueElement = arrayElement.addElement("value");
            valueElement.addChild("" + i);
        }

        if (notifier != null) {
            notifier.sendingResult(outputElement);
        }
        logger.info(XMLUtil.xmlElementToString(outputElement));
        return outputElement;
    }
View Full Code Here

     * @see org.apache.airavata.xbaya.test.service.multiplier.Multiplier#multiply(org.xmlpull.v1.builder.XmlElement)
     */
    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));
        return outputElement;
    }
View Full Code Here

    /**
     * @see org.apache.airavata.xbaya.test.service.approver.Approver#approve(org.xmlpull.v1.builder.XmlElement)
     */
    public XmlElement approve(XmlElement inputElement) {
        logger.info(XMLUtil.xmlElementToString(inputElement));
        ServiceNotificationSender notifier = ServiceNotificationSender.invoked(inputElement);

        XmlElement amountElement = inputElement.requiredElement(null, "amount");
        String amountString = amountElement.requiredTextContent();
        int amount = Integer.parseInt(amountString);
        logger.info("amount: " + amount);

        Random random = new Random();
        int msec = random.nextInt(5000);
        logger.info("Sleep for " + msec + " msec");
        try {
            Thread.sleep(msec);
        } catch (InterruptedException e) {
            logger.error(e.getMessage(), e);
        }

        String accept = "No";

        XmlNamespace namespace = XmlConstants.BUILDER.newNamespace("approvertypens",
                "http://www.extreme.indiana.edu/loan/approver/xsd/");
        XmlElement outputElement = XmlConstants.BUILDER.newFragment(namespace, "ApproveOutput");
        XmlElement acceptElement = outputElement.addElement("accept");
        acceptElement.addChild(accept);

        if (notifier != null) {
            notifier.sendingResult(outputElement);
        }
        logger.info(XMLUtil.xmlElementToString(outputElement));
        return outputElement;
    }
View Full Code Here

     * @see org.apache.airavata.xbaya.test.service.echo.Echo#echo(org.xmlpull.v1.builder.XmlElement)
     */
    public XmlElement echo(XmlElement inputElement) {
        logger.info(XMLUtil.xmlElementToString(inputElement));

        ServiceNotificationSender notifier = ServiceNotificationSender.invoked(inputElement);

        XmlElement input = inputElement.requiredElement(null, "input");

        Random random = new Random();
        int msec = random.nextInt(5000);
        logger.info("Sleep for " + msec + " msec");
        try {
            Thread.sleep(msec);
        } catch (InterruptedException e) {
            logger.error(e.getMessage(), e);
        }

        XmlElement output = input;
        output.setParent(null);
        output.setName("output");

        XmlNamespace namespace = XmlConstants.BUILDER.newNamespace("echotypens",
                "http://www.extreme.indiana.edu/math/echo/xsd/");
        XmlElement outputElement = XmlConstants.BUILDER.newFragment(namespace, "EchoOutput");
        outputElement.addElement(output);

        if (notifier != null) {
            notifier.sendingResult(outputElement);
        }
        logger.info(XMLUtil.xmlElementToString(outputElement));
        return outputElement;
    }
View Full Code Here

     * @see org.apache.airavata.xbaya.test.service.arrayadder.ArrayAdder#add(org.xmlpull.v1.builder.XmlElement)
     */
    public XmlElement add(XmlElement inputElement) {
        logger.info(XMLUtil.xmlElementToString(inputElement));

        ServiceNotificationSender notifier = ServiceNotificationSender.invoked(inputElement);

        XmlElement arrayElement = inputElement.requiredElement(null, "input");

        int sum = 0;
        @SuppressWarnings("rawtypes")
    Iterator valueIt = arrayElement.elements(null, "value").iterator();
        while (valueIt.hasNext()) {
            XmlElement valueElement = (XmlElement) valueIt.next();
            String valueString = valueElement.requiredTextContent();
            int value = Integer.parseInt(valueString);
            sum += value;
        }

        Random random = new Random();
        int msec = random.nextInt(5000);
        logger.info("Sleep for " + msec + " msec");
        try {
            Thread.sleep(msec);
        } catch (InterruptedException e) {
            logger.error(e.getMessage(), e);
        }

        String sumString = "" + sum;

        XmlNamespace namespace = XmlConstants.BUILDER.newNamespace("typens",
                "http://www.extreme.indiana.edu/math/arrayadder/xsd/");
        XmlElement outputElement = XmlConstants.BUILDER.newFragment(namespace, "ArrayAdderOutput");
        XmlElement sumElement = outputElement.addElement("sum");
        sumElement.addChild(sumString);

        if (notifier != null) {
            notifier.sendingResult(outputElement);
        }
        logger.info(XMLUtil.xmlElementToString(outputElement));
        return outputElement;
    }
View Full Code Here

TOP

Related Classes of org.apache.airavata.xbaya.test.service.ServiceNotificationSender

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.