Examples of OSWorkflowEndpoint


Examples of org.apache.servicemix.osworkflow.OSWorkflowEndpoint

     *      java.util.Map, com.opensymphony.module.propertyset.PropertySet)
     */
    public void execute(Map transientVars, Map args, PropertySet propertySet) throws WorkflowException
        {
        NormalizedMessage msg = null;
        OSWorkflowEndpoint ep = null;
        boolean isAsynchron = false;
        MessageExchange exchange = null;
       
        if (transientVars.containsKey(OSWorkflow.KEY_ASYNC_PROCESSING))
            {
            isAsynchron = (Boolean)transientVars.get(OSWorkflow.KEY_ASYNC_PROCESSING);
            }
        else
            {
            throw new WorkflowException("ExampleFunction: Missing transient variable for async object. (" + OSWorkflow.KEY_ASYNC_PROCESSING + ")");
            }

        if (transientVars.containsKey(OSWorkflow.KEY_EXCHANGE))
            {
            exchange = (MessageExchange)transientVars.get(OSWorkflow.KEY_EXCHANGE);
            }
        else
            {
            throw new WorkflowException("ExampleFunction: Missing transient variable for exchange object. (" + OSWorkflow.KEY_EXCHANGE + ")");
            }
       
        if (transientVars.containsKey(OSWorkflow.KEY_IN_MESSAGE))
            {
            msg = (NormalizedMessage)transientVars.get(OSWorkflow.KEY_IN_MESSAGE);
            }
        else
            {
            throw new WorkflowException("ExampleFunction: Missing transient variable for message object. (" + OSWorkflow.KEY_IN_MESSAGE + ")");
            }
       
        if (transientVars.containsKey(OSWorkflow.KEY_ENDPOINT))
            {
            ep = (OSWorkflowEndpoint)transientVars.get(OSWorkflow.KEY_ENDPOINT);
            }
        else
            {
            throw new WorkflowException("ExampleFunction: Missing transient variable for endpoint object. (" + OSWorkflow.KEY_ENDPOINT + ")");
            }
       
        SourceTransformer sourceTransformer = new SourceTransformer();

        try
            {
            DOMSource inMessageXml = (DOMSource)sourceTransformer.toDOMSource(msg.getContent());

            // Parse out the actual message content
            CachedXPathAPI xpath = new CachedXPathAPI();
           
            Node exampleNode = xpath.selectSingleNode(inMessageXml.getNode(), "/example");
           
            if (exampleNode != null)
                {
                String value = exampleNode.getTextContent();
                propertySet.setString("ExampleKey", value);
                }
            else
                {
                throw new WorkflowException("ExampleFunction: Missing tag: example");
                }
            }
        catch (Exception ex)
            {
            throw new WorkflowException(ex);
            }
        finally
            {
            // if the exchange came as asynchronous inOnly or RobustInOnly
            // we will now send a receipt to the sender
            try
                {
                if (isAsynchron)
                    {
                    ep.done(exchange);
                    }
                }
            catch (MessagingException mex)
                {
                throw new WorkflowException(mex);
View Full Code Here

Examples of org.apache.servicemix.osworkflow.OSWorkflowEndpoint

     * @see com.opensymphony.workflow.FunctionProvider#execute(java.util.Map,
     *      java.util.Map, com.opensymphony.module.propertyset.PropertySet)
     */
    public void execute(Map transientVars, Map args, PropertySet propertySet)
        throws WorkflowException {
        OSWorkflowEndpoint ep = null;
        boolean isAsynchron = false;
        MessageExchange exchange = null;

        if (transientVars.containsKey(OSWorkflow.KEY_ENDPOINT)) {
            ep = (OSWorkflowEndpoint) transientVars
                    .get(OSWorkflow.KEY_ENDPOINT);
        } else {
            throw new WorkflowException(
                    "FailExampleFunction: Missing transient variable for endpoint object. ("
                            + OSWorkflow.KEY_ENDPOINT + ")");
        }

        if (transientVars.containsKey(OSWorkflow.KEY_ASYNC_PROCESSING)) {
            isAsynchron = (Boolean) transientVars
                    .get(OSWorkflow.KEY_ASYNC_PROCESSING);
        } else {
            throw new WorkflowException(
                    "FailExampleFunction: Missing transient variable for async object. ("
                            + OSWorkflow.KEY_ASYNC_PROCESSING + ")");
        }

        if (transientVars.containsKey(OSWorkflow.KEY_EXCHANGE)) {
            exchange = (MessageExchange) transientVars
                    .get(OSWorkflow.KEY_EXCHANGE);
        } else {
            throw new WorkflowException(
                    "FailExampleFunction: Missing transient variable for exchange object. ("
                            + OSWorkflow.KEY_EXCHANGE + ")");
        }

        if (!isAsynchron) {
            try {
                NormalizedMessage msg = exchange.createMessage();
                msg.setContent(new StringSource(
                        "<example>Error Case Test passed!</example>"));
                exchange.setMessage(msg, "out");
                ep.send(exchange, false);
            } catch (Exception ex) {
                throw new WorkflowException(
                        "FailExampleFunction: Unable to answer request.", ex);
            }
        }
View Full Code Here

Examples of org.apache.servicemix.osworkflow.OSWorkflowEndpoint

     * @see com.opensymphony.workflow.FunctionProvider#execute(java.util.Map,
     *      java.util.Map, com.opensymphony.module.propertyset.PropertySet)
     */
    public void execute(Map transientVars, Map args, PropertySet propertySet)
        throws WorkflowException {
        OSWorkflowEndpoint ep = null;
        boolean isAsynchron = false;
        MessageExchange exchange = null;

        if (transientVars.containsKey(OSWorkflow.KEY_ENDPOINT)) {
            ep = (OSWorkflowEndpoint) transientVars
                    .get(OSWorkflow.KEY_ENDPOINT);
        } else {
            throw new WorkflowException(
                    "AnswerExampleFunction: Missing transient variable for endpoint object. ("
                            + OSWorkflow.KEY_ENDPOINT + ")");
        }

        if (transientVars.containsKey(OSWorkflow.KEY_ASYNC_PROCESSING)) {
            isAsynchron = (Boolean) transientVars
                    .get(OSWorkflow.KEY_ASYNC_PROCESSING);
        } else {
            throw new WorkflowException(
                    "AnswerExampleFunction: Missing transient variable for async object. ("
                            + OSWorkflow.KEY_ASYNC_PROCESSING + ")");
        }

        if (transientVars.containsKey(OSWorkflow.KEY_EXCHANGE)) {
            exchange = (MessageExchange) transientVars
                    .get(OSWorkflow.KEY_EXCHANGE);
        } else {
            throw new WorkflowException(
                    "AnswerExampleFunction: Missing transient variable for exchange object. ("
                            + OSWorkflow.KEY_EXCHANGE + ")");
        }

        if (!isAsynchron) {
            try {
                NormalizedMessage msg = exchange.createMessage();
                msg.setContent(new StringSource(
                        "<example>Test passed!</example>"));
                exchange.setMessage(msg, "out");
                ep.send(exchange, false);
            } catch (Exception ex) {
                throw new WorkflowException(
                        "AnswerExampleFunction: Unable to answer request.", ex);
            }
        }
View Full Code Here

Examples of org.apache.servicemix.osworkflow.OSWorkflowEndpoint

        throws WorkflowException {

        logger.info("Executing function...");

        NormalizedMessage msg = null;
        OSWorkflowEndpoint ep = null;
        boolean isAsynchron = false;
        MessageExchange exchange = null;

        if (transientVars.containsKey(OSWorkflow.KEY_ASYNC_PROCESSING)) {
            isAsynchron = (Boolean) transientVars
                    .get(OSWorkflow.KEY_ASYNC_PROCESSING);
        } else {
            throw new WorkflowException(
                    "ExampleFunction: Missing transient variable for async object. ("
                            + OSWorkflow.KEY_ASYNC_PROCESSING + ")");
        }

        if (transientVars.containsKey(OSWorkflow.KEY_EXCHANGE)) {
            exchange = (MessageExchange) transientVars
                    .get(OSWorkflow.KEY_EXCHANGE);
        } else {
            throw new WorkflowException(
                    "ExampleFunction: Missing transient variable for exchange object. ("
                            + OSWorkflow.KEY_EXCHANGE + ")");
        }

        if (transientVars.containsKey(OSWorkflow.KEY_IN_MESSAGE)) {
            msg = (NormalizedMessage) transientVars
                    .get(OSWorkflow.KEY_IN_MESSAGE);
        } else {
            throw new WorkflowException(
                    "ExampleFunction: Missing transient variable for message object. ("
                            + OSWorkflow.KEY_IN_MESSAGE + ")");
        }

        if (transientVars.containsKey(OSWorkflow.KEY_ENDPOINT)) {
            ep = (OSWorkflowEndpoint) transientVars
                    .get(OSWorkflow.KEY_ENDPOINT);
        } else {
            throw new WorkflowException(
                    "ExampleFunction: Missing transient variable for endpoint object. ("
                            + OSWorkflow.KEY_ENDPOINT + ")");
        }

        SourceTransformer sourceTransformer = new SourceTransformer();

        try {
            DOMSource inMessageXml = (DOMSource) sourceTransformer
                    .toDOMSource(msg.getContent());

            // Parse out the actual message content
            CachedXPathAPI xpath = new CachedXPathAPI();

            Node exampleNode = xpath.selectSingleNode(inMessageXml.getNode(),
                    "/example");

            if (exampleNode != null) {
                String value = exampleNode.getTextContent();
                logger.info("Received content: " + value);
                propertySet.setString("ExampleKey", value);
            } else {
                throw new WorkflowException(
                        "ExampleFunction: Missing tag: example");
            }
        } catch (Exception ex) {
            throw new WorkflowException(ex);
        } finally {
            // if the exchange came as asynchronous inOnly or RobustInOnly
            // we will now send a receipt to the sender
            try {
                if (isAsynchron) {
                    ep.done(exchange);
                }
            } catch (MessagingException mex) {
                throw new WorkflowException(mex);
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.