You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sa...@apache.org on 2014/04/14 20:31:19 UTC

[77/90] [abbrv] AIRAVATA-1124

http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorEventListener.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorEventListener.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorEventListener.java
new file mode 100644
index 0000000..5de91e4
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorEventListener.java
@@ -0,0 +1,387 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.interpretor;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.apache.airavata.client.api.exception.AiravataAPIInvocationException;
+import org.apache.airavata.common.utils.XMLUtil;
+import org.apache.airavata.registry.api.workflow.NodeExecutionError;
+import org.apache.airavata.workflow.model.graph.EPRPort;
+import org.apache.airavata.workflow.model.graph.Edge;
+import org.apache.airavata.workflow.model.graph.Graph;
+import org.apache.airavata.workflow.model.graph.Node;
+import org.apache.airavata.workflow.model.graph.Node.NodeExecutionState;
+import org.apache.airavata.workflow.model.graph.Port;
+import org.apache.airavata.workflow.model.graph.impl.NodeImpl;
+import org.apache.airavata.workflow.model.graph.system.InputNode;
+import org.apache.airavata.workflow.model.graph.system.OutputNode;
+import org.apache.airavata.workflow.model.graph.util.GraphUtil;
+import org.apache.airavata.workflow.model.graph.ws.WSGraph;
+import org.apache.airavata.workflow.model.wf.Workflow;
+import org.apache.airavata.ws.monitor.EventData;
+import org.apache.airavata.ws.monitor.MonitorException;
+import org.apache.airavata.ws.monitor.MonitorUtil;
+import org.apache.airavata.ws.monitor.MonitorUtil.EventType;
+import org.apache.airavata.wsmg.client.ConsumerNotificationHandler;
+import org.apache.airavata.wsmg.client.MsgBrokerClientException;
+import org.apache.airavata.wsmg.client.NotificationHandler;
+import org.apache.airavata.wsmg.client.WseMsgBrokerClient;
+import org.apache.airavata.wsmg.client.msgbox.MessagePuller;
+import org.apache.airavata.xbaya.XBayaConfiguration;
+import org.apache.airavata.xbaya.graph.controller.NodeController;
+import org.apache.airavata.xbaya.provenance.WorkflowNodeStatusUpdater;
+import org.apache.airavata.xbaya.provenance.WorkflowStatusUpdater;
+import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.addressing.EndpointReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.xmlpull.infoset.XmlElement;
+
+public class WorkflowInterpretorEventListener implements NotificationHandler, ConsumerNotificationHandler {
+
+    private Workflow workflow;
+    private boolean pullMode;
+    private WseMsgBrokerClient wseClient;
+    private URI brokerURL;
+    private String topic;
+    private URI messageBoxURL;
+    private String subscriptionID;
+    private MessagePuller messagePuller;
+    private WorkflowStatusUpdater workflowStatusUpdater;
+    private WorkflowNodeStatusUpdater workflowNodeStatusUpdater;
+    private WorkflowInterpreterConfiguration workflowInterpreterConfiguration;
+    private String lastSubscriptionId;
+
+    private static Logger logger = LoggerFactory.getLogger(WorkflowInterpretorEventListener.class);
+
+    public WorkflowInterpretorEventListener(Workflow workflow, XBayaConfiguration configuration) {
+        this.workflow = workflow;
+        this.brokerURL = configuration.getBrokerURL();
+        this.topic = configuration.getTopic();
+        this.pullMode = true;
+        this.messageBoxURL = configuration.getMessageBoxURL();
+        this.wseClient = new WseMsgBrokerClient();
+        this.wseClient.init(this.brokerURL.toString());
+        this.workflowInterpreterConfiguration = WorkflowInterpreter.getWorkflowInterpreterConfiguration();
+        this.workflowNodeStatusUpdater = new WorkflowNodeStatusUpdater(this.workflowInterpreterConfiguration.getAiravataAPI());
+        this.workflowStatusUpdater = new WorkflowStatusUpdater(this.workflowInterpreterConfiguration.getAiravataAPI());
+    }
+
+    public void start() throws MonitorException {
+
+        subscribe();
+    }
+
+    public void stop() throws MonitorException {
+        unsubscribe();
+    }
+
+    private synchronized void subscribe() throws MonitorException {
+        if (this.subscriptionID != null) {
+            throw new IllegalStateException();
+        }
+        try {
+            if (this.pullMode) {
+                EndpointReference messageBoxEPR = this.wseClient.createPullMsgBox(this.messageBoxURL.toString(),20000L);
+                this.subscriptionID = this.wseClient.subscribe(messageBoxEPR.getAddress(), this.topic, null);
+                this.messagePuller = this.wseClient.startPullingEventsFromMsgBox(messageBoxEPR, this, 1000L, 20000L);
+            } else {
+                String[] endpoints = this.wseClient.startConsumerService(2222, this);
+                this.subscriptionID = this.wseClient.subscribe(endpoints[0], this.topic, null);
+            }
+        } catch (IOException e) {
+            throw new MonitorException("Failed to subscribe.", e);
+        } catch (RuntimeException e) {
+            throw new MonitorException("Failed to subscribe.", e);
+        }
+    }
+
+    /**
+     * Unsubscribes from the notification.
+     * 
+     * @throws MonitorException
+     */
+    private synchronized void unsubscribe() throws MonitorException {
+        // This method needs to be synchronized along with subscribe() because
+        // unsubscribe() might be called while subscribe() is being executed.
+        if (this.subscriptionID == null) {
+            throw new IllegalStateException();
+        }
+        try {
+            if (this.pullMode) {
+                this.messagePuller.stopPulling();
+                try {
+                    Thread.sleep(100);
+                } catch (InterruptedException e) {
+                    throw new MonitorException("Error during stop message puller", e);
+                }
+//            } else {
+//                this.wseClient.unSubscribe(this.subscriptionID);
+            }
+            this.wseClient.unSubscribe(this.subscriptionID);
+
+        } catch (MsgBrokerClientException e) {
+            throw new MonitorException("Failed to unsubscribe.", e);
+        }
+
+    }
+
+    /**
+     * @see org.apache.airavata.wsmg.client.NotificationHandler#handleNotification(java.lang.String)
+     */
+    public void handleNotification(String message) {
+        try {
+            // String soapBody = WorkFlowUtils.getSoapBodyContent(message);
+            XmlElement event = XMLUtil.stringToXmlElement(message);
+            handleEvent(new EventData(event), true, this.workflow.getGraph());
+
+            // } catch (XMLStreamException e) {
+            // // Just log them because they can be unrelated messages sent to
+            // // this topic by accident.
+            // logger.warn("Could not parse received notification: " + message,
+            // e);
+            // }
+        } catch (RuntimeException e) {
+            logger.warn("Failed to process notification: " + message, e);
+        } catch (AiravataAPIInvocationException e) {
+            logger.error("Error occured during Exception saving to the Registry");
+        }
+    }
+
+    private void handleEvent(EventData event, boolean forward, Graph graph) throws AiravataAPIInvocationException {
+        EventType type = event.getType();
+        String nodeID = event.getNodeID();
+        Node node = graph.getNode(nodeID);
+
+        if (type == MonitorUtil.EventType.WORKFLOW_INVOKED) {
+            workflowStarted(graph, forward);
+            //todo ideally experimentID and workflowInstanceID has to be different
+            workflowStatusUpdater.saveWorkflowData(event.getExperimentID(), event.getExperimentID(),
+                    this.workflowInterpreterConfiguration.getWorkflow().getName());
+            workflowStatusUpdater.workflowStarted(event.getExperimentID());
+        } else if (type == MonitorUtil.EventType.WORKFLOW_TERMINATED) {
+            workflowFinished(graph, forward);
+            workflowStatusUpdater.workflowFinished(event.getExperimentID());
+            try {
+                this.unsubscribe();
+            } catch (MonitorException e) {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
+        } else if (type == EventType.INVOKING_SERVICE || type == EventType.SERVICE_INVOKED) {
+            if (node == null) {
+                if (nodeID!=null && !nodeID.equals("")) {
+					logger.warn("There is no node that has ID, " + nodeID);
+				}
+            } else {
+                nodeStarted(node, forward);
+                workflowNodeStatusUpdater.workflowNodeStarted(event.getExperimentID(), event.getNodeID()
+                        , event.getMessage(), event.getWorkflowID().toASCIIString());
+            }
+        } else if (type == MonitorUtil.EventType.RECEIVED_RESULT
+        // TODO this should be removed when GPEL sends all notification
+        // correctly.
+                || type == EventType.SENDING_RESULT) {
+            if (node == null) {
+            	if (nodeID!=null && !nodeID.equals("")) {
+					logger.warn("There is no node that has ID, " + nodeID);
+				}
+        	} else {
+                nodeFinished(node, forward);
+                workflowNodeStatusUpdater.workflowNodeFinished(event.getExperimentID(), event.getNodeID(), event.getMessage(),
+                        event.getWorkflowID().toASCIIString());
+            }
+        } else if (type == EventType.RECEIVED_FAULT
+                || type == EventType.SENDING_FAULT || type == EventType.SENDING_RESPONSE_FAILED) {
+            //Constructing NodeExecutionError with required data...
+            logger.error(event.getMessage());
+            NodeExecutionError nodeExecutionError = new NodeExecutionError();
+            nodeExecutionError.setExperimentId(event.getExperimentID());
+            nodeExecutionError.setNodeId(event.getNodeID());
+            nodeExecutionError.setWorkflowInstanceId(event.getExperimentID());
+            nodeExecutionError.setErrorMessage(event.getMessage());
+            nodeExecutionError.setErrorDescription(event.getMessage());
+            nodeExecutionError.setErrorTime(event.getTimestamp());
+            this.workflowInterpreterConfiguration.getAiravataAPI().getExecutionManager().addNodeExecutionError(nodeExecutionError);
+            if (node == null) {
+            	if (nodeID!=null && !nodeID.equals("")) {
+					logger.warn("There is no node that has ID, " + nodeID);
+				}
+            } else {
+                nodeFailed(node, forward);
+                workflowNodeStatusUpdater.workflowNodeFailed(event.getExperimentID(), event.getNodeID());
+            }
+            try {
+                this.unsubscribe();
+            } catch (MonitorException e) {
+                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            }
+        } else if (type == MonitorUtil.EventType.RESOURCE_MAPPING) {
+            if (node == null) {
+            	if (nodeID!=null && !nodeID.equals("")) {
+					logger.warn("There is no node that has ID, " + nodeID);
+				}
+            } else {
+                // nodeResourceMapped(node, event.getEvent(), forward);
+                workflowNodeStatusUpdater.workflowNodeRunning(event.getExperimentID(), event.getNodeID());
+            }
+        } else if(type == MonitorUtil.EventType.LOG_INFO){
+            // This is not very gram specific, if these data is required in other provider they have to send
+            // the notification in info mode with ending these text, DONE,PENDING and ACTIVE
+            if(event.getMessage().endsWith("DONE")) {
+                workflowNodeStatusUpdater.workflowNodeStatusDone(event.getExperimentID(), event.getNodeID());
+            } else if(event.getMessage().endsWith("PENDING")){
+                workflowNodeStatusUpdater.workflowNodeStatusPending(event.getExperimentID(), event.getNodeID());
+            } else if(event.getMessage().endsWith("ACTIVE")){
+                workflowNodeStatusUpdater.workflowNodeStatusActive(event.getExperimentID(), event.getNodeID());
+            }
+        } else {
+            // Ignore the rest.
+        }
+    }
+
+    private void workflowStarted(Graph graph, boolean forward) {
+        for (InputNode node : GraphUtil.getInputNodes(graph)) {
+            if (forward) {
+                finishNode(node);
+            } else {
+                resetNode(node);
+            }
+        }
+    }
+
+    private void workflowFinished(Graph graph, boolean forward) {
+        for (OutputNode node : GraphUtil.getOutputNodes(graph)) {
+            if (forward) {
+                finishNode(node);
+                finishPredecessorNodes(node);
+            } else {
+                resetNode(node);
+            }
+        }
+    }
+
+    private LinkedList<InputNode> getInputNodes(WSGraph graph) {
+        List<NodeImpl> nodes = graph.getNodes();
+        LinkedList<InputNode> inputNodes = new LinkedList<InputNode>();
+        for (NodeImpl nodeImpl : nodes) {
+            if (nodeImpl instanceof InputNode) {
+                inputNodes.add((InputNode) nodeImpl);
+            }
+        }
+        return inputNodes;
+    }
+
+    private LinkedList<OutputNode> getOutputNodes(WSGraph graph) {
+        List<NodeImpl> nodes = graph.getNodes();
+        LinkedList<OutputNode> outputNodes = new LinkedList<OutputNode>();
+        for (NodeImpl nodeImpl : nodes) {
+            if (nodeImpl instanceof OutputNode) {
+                outputNodes.add((OutputNode) nodeImpl);
+            }
+        }
+        return outputNodes;
+    }
+
+    private void nodeStarted(Node node, boolean forward) {
+        if (forward) {
+            executeNode(node);
+            finishPredecessorNodes(node);
+        } else {
+            resetNode(node);
+        }
+    }
+
+    private void nodeFinished(Node node, boolean forward) {
+        if (forward) {
+            finishNode(node);
+            finishPredecessorNodes(node);
+        } else {
+            executeNode(node);
+        }
+    }
+
+    private void nodeFailed(Node node, boolean forward) {
+        if (forward) {
+            failNode(node);
+            finishPredecessorNodes(node);
+        } else {
+            executeNode(node);
+        }
+    }
+
+    private void executeNode(Node node) {
+        node.setState(NodeExecutionState.EXECUTING);
+    }
+
+    private void finishNode(Node node) {
+        node.setState(NodeExecutionState.FINISHED);
+    }
+
+    private void failNode(Node node) {
+        node.setState(NodeExecutionState.FAILED);
+    }
+
+    private void resetNode(Node node) {
+        node.setState(NodeExecutionState.WAITING);
+        NodeController.getGUI(node).resetTokens();
+    }
+
+    /**
+     * Make preceding nodes done. This helps the monitoring GUI when a user subscribes from the middle of the workflow
+     * execution.
+     * 
+     * @param node
+     */
+    private void finishPredecessorNodes(Node node) {
+        for (Port inputPort : node.getInputPorts()) {
+            for (Edge edge : inputPort.getEdges()) {
+                Port fromPort = edge.getFromPort();
+                if (!(fromPort instanceof EPRPort)) {
+                    Node fromNode = fromPort.getNode();
+                    finishNode(fromNode);
+                    finishPredecessorNodes(fromNode);
+                }
+            }
+        }
+        Port controlInPort = node.getControlInPort();
+        if (controlInPort != null) {
+            for (Node fromNode : controlInPort.getFromNodes()) {
+                finishNode(fromNode);
+                finishPredecessorNodes(fromNode);
+            }
+        }
+    }
+
+    /**
+     * @see org.apache.airavata.wsmg.client.NotificationHandler#handleNotification(java.lang.String)
+     */
+    public void handleNotification(SOAPEnvelope message) {
+        String soapBody = message.getBody().toString();
+        this.handleNotification(soapBody);
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorMessageReceiverInOut.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorMessageReceiverInOut.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorMessageReceiverInOut.java
new file mode 100644
index 0000000..b5623e9
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorMessageReceiverInOut.java
@@ -0,0 +1,262 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+package org.apache.airavata.xbaya.interpretor;
+
+import org.apache.airavata.client.stub.interpretor.NameValue;
+import org.apache.airavata.client.stub.interpretor.WorkflowInterpretorStub;
+
+
+public class WorkflowInterpretorMessageReceiverInOut extends org.apache.axis2.receivers.AbstractInOutMessageReceiver{
+    public static final String MYPROXY_USER = "myproxy.user";
+    public static final String MYPROXY_PASS = "myproxy.password";
+     public void invokeBusinessLogic(org.apache.axis2.context.MessageContext msgContext, org.apache.axis2.context.MessageContext newMsgContext)
+        throws org.apache.axis2.AxisFault{
+
+        try {
+
+        // get the implementation class for the Web Service
+        Object obj = getTheImplementationObject(msgContext);
+
+        WorkflowInterpretorSkeleton skel = (WorkflowInterpretorSkeleton)obj;
+        //Out Envelop
+        org.apache.axiom.soap.SOAPEnvelope envelope = null;
+        //Find the axisOperation that has been set by the Dispatch phase.
+        org.apache.axis2.description.AxisOperation op = msgContext.getOperationContext().getAxisOperation();
+        if (op == null) {
+        throw new org.apache.axis2.AxisFault("Operation is not located, if this is doclit style the SOAP-ACTION should specified via the SOAP Action to use the RawXMLProvider");
+        }
+
+        java.lang.String methodName;
+        if((op.getName() != null) && ((methodName = org.apache.axis2.util.JavaUtils.xmlNameToJava(op.getName().getLocalPart())) != null)){
+
+
+
+            if("launchWorkflow".equals(methodName)){
+
+	                        WorkflowInterpretorStub.LaunchWorkflow wrappedParam =
+                                                             (WorkflowInterpretorStub.LaunchWorkflow)fromOM(
+                                    msgContext.getEnvelope().getBody().getFirstElement(),
+                                    WorkflowInterpretorStub.LaunchWorkflow.class,
+                                    getEnvelopeNamespaces(msgContext.getEnvelope()));
+
+
+                WorkflowInterpretorStub.LaunchWorkflowResponse launchWorkflowResponse = wrapLaunchWorkflowResponse_return(
+
+
+                        skel.launchWorkflow(
+
+                                getWorkflowAsString(wrappedParam)
+                                ,
+                                getTopic(wrappedParam)
+                                ,
+                                getInputs(wrappedParam)
+                        )
+
+                );
+
+                envelope = toEnvelope(getSOAPFactory(msgContext), launchWorkflowResponse, false);
+
+            } else {
+              throw new java.lang.RuntimeException("method not found");
+            }
+
+
+        newMsgContext.setEnvelope(envelope);
+        }
+        }
+        catch (java.lang.Exception e) {
+        throw org.apache.axis2.AxisFault.makeFault(e);
+        }
+        }
+
+        //
+            private  org.apache.axiom.om.OMElement  toOM(WorkflowInterpretorStub.LaunchWorkflow param, boolean optimizeContent)
+            throws org.apache.axis2.AxisFault {
+
+
+                        try{
+                             return param.getOMElement(WorkflowInterpretorStub.LaunchWorkflow.MY_QNAME,
+                                          org.apache.axiom.om.OMAbstractFactory.getOMFactory());
+                        } catch(org.apache.axis2.databinding.ADBException e){
+                            throw org.apache.axis2.AxisFault.makeFault(e);
+                        }
+
+
+            }
+
+            private  org.apache.axiom.om.OMElement  toOM(WorkflowInterpretorStub.LaunchWorkflowResponse param, boolean optimizeContent)
+            throws org.apache.axis2.AxisFault {
+
+
+                        try{
+                             return param.getOMElement(WorkflowInterpretorStub.LaunchWorkflowResponse.MY_QNAME,
+                                          org.apache.axiom.om.OMAbstractFactory.getOMFactory());
+                        } catch(org.apache.axis2.databinding.ADBException e){
+                            throw org.apache.axis2.AxisFault.makeFault(e);
+                        }
+
+
+            }
+
+                    private  org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory, WorkflowInterpretorStub.LaunchWorkflowResponse param, boolean optimizeContent)
+                        throws org.apache.axis2.AxisFault{
+                      try{
+                          org.apache.axiom.soap.SOAPEnvelope emptyEnvelope = factory.getDefaultEnvelope();
+
+                                    emptyEnvelope.getBody().addChild(param.getOMElement(WorkflowInterpretorStub.LaunchWorkflowResponse.MY_QNAME,factory));
+
+
+                         return emptyEnvelope;
+                    } catch(org.apache.axis2.databinding.ADBException e){
+                        throw org.apache.axis2.AxisFault.makeFault(e);
+                    }
+                    }
+
+
+                        private java.lang.String getWorkflowAsString(
+                        WorkflowInterpretorStub.LaunchWorkflow wrappedType){
+
+                                return wrappedType.getWorkflowAsString();
+
+                        }
+
+
+                        private java.lang.String getTopic(
+                       WorkflowInterpretorStub.LaunchWorkflow wrappedType){
+
+                                return wrappedType.getTopic();
+
+                        }
+
+
+                        private java.lang.String getPassword(
+                        WorkflowInterpretorStub.LaunchWorkflow wrappedType){
+
+                                return wrappedType.getPassword();
+
+                        }
+
+
+                        private java.lang.String getUsername(
+                        WorkflowInterpretorStub.LaunchWorkflow wrappedType){
+
+                                return wrappedType.getUsername();
+
+                        }
+
+
+                        private NameValue[] getInputs(
+                        WorkflowInterpretorStub.LaunchWorkflow wrappedType){
+
+                                return wrappedType.getInputs();
+
+                        }
+
+
+                        private NameValue[] getConfigurations(
+                        WorkflowInterpretorStub.LaunchWorkflow wrappedType){
+
+                                return wrappedType.getConfigurations();
+
+                        }
+
+
+
+                        private WorkflowInterpretorStub.LaunchWorkflowResponse wrapLaunchWorkflowResponse_return(
+                        java.lang.String param){
+                            WorkflowInterpretorStub.LaunchWorkflowResponse wrappedElement = new WorkflowInterpretorStub.LaunchWorkflowResponse();
+
+                            wrappedElement.set_return(param);
+
+                            return wrappedElement;
+                        }
+
+                         private WorkflowInterpretorStub.LaunchWorkflowResponse wraplaunchWorkflow(){
+                                WorkflowInterpretorStub.LaunchWorkflowResponse wrappedElement = new WorkflowInterpretorStub.LaunchWorkflowResponse();
+                                return wrappedElement;
+                         }
+
+
+
+        /**
+        *  get the default envelope
+        */
+        private org.apache.axiom.soap.SOAPEnvelope toEnvelope(org.apache.axiom.soap.SOAPFactory factory){
+        return factory.getDefaultEnvelope();
+        }
+
+
+        private  java.lang.Object fromOM(
+        org.apache.axiom.om.OMElement param,
+        java.lang.Class type,
+        java.util.Map extraNamespaces) throws org.apache.axis2.AxisFault{
+
+        try {
+
+                if (WorkflowInterpretorStub.LaunchWorkflow.class.equals(type)){
+
+                           return WorkflowInterpretorStub.LaunchWorkflow.Factory.parse(param.getXMLStreamReaderWithoutCaching());
+
+
+                }
+
+                if (WorkflowInterpretorStub.LaunchWorkflowResponse.class.equals(type)){
+
+                           return WorkflowInterpretorStub.LaunchWorkflowResponse.Factory.parse(param.getXMLStreamReaderWithoutCaching());
+
+
+                }
+
+        } catch (java.lang.Exception e) {
+        throw org.apache.axis2.AxisFault.makeFault(e);
+        }
+           return null;
+        }
+
+
+
+
+
+        /**
+        *  A utility method that copies the namepaces from the SOAPEnvelope
+        */
+        private java.util.Map getEnvelopeNamespaces(org.apache.axiom.soap.SOAPEnvelope env){
+        java.util.Map returnMap = new java.util.HashMap();
+        java.util.Iterator namespaceIterator = env.getAllDeclaredNamespaces();
+        while (namespaceIterator.hasNext()) {
+        org.apache.axiom.om.OMNamespace ns = (org.apache.axiom.om.OMNamespace) namespaceIterator.next();
+        returnMap.put(ns.getPrefix(),ns.getNamespaceURI());
+        }
+        return returnMap;
+        }
+
+        private org.apache.axis2.AxisFault createAxisFault(java.lang.Exception e) {
+        org.apache.axis2.AxisFault f;
+        Throwable cause = e.getCause();
+        if (cause != null) {
+            f = new org.apache.axis2.AxisFault(e.getMessage(), cause);
+        } else {
+            f = new org.apache.axis2.AxisFault(e.getMessage());
+        }
+
+        return f;
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java
new file mode 100644
index 0000000..5f9420c
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/interpretor/WorkflowInterpretorSkeleton.java
@@ -0,0 +1,572 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.interpretor;
+
+import org.apache.airavata.client.AiravataAPIFactory;
+import org.apache.airavata.client.api.AiravataAPI;
+import org.apache.airavata.client.api.exception.AiravataAPIInvocationException;
+import org.apache.airavata.client.api.exception.DescriptorAlreadyExistsException;
+import org.apache.airavata.client.stub.interpretor.NameValue;
+import org.apache.airavata.client.tools.PeriodicExecutorThread;
+import org.apache.airavata.common.exception.ApplicationSettingsException;
+import org.apache.airavata.common.utils.AiravataUtils;
+import org.apache.airavata.common.utils.ServerSettings;
+import org.apache.airavata.common.utils.ServiceUtils;
+import org.apache.airavata.common.workflow.execution.context.WorkflowContextHeaderBuilder;
+import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.schemas.gfac.GlobusHostType;
+import org.apache.airavata.schemas.gfac.GsisshHostType;
+import org.apache.airavata.schemas.gfac.SSHHostType;
+import org.apache.airavata.schemas.wec.ContextHeaderDocument;
+import org.apache.airavata.workflow.model.component.ComponentException;
+import org.apache.airavata.workflow.model.exceptions.WorkflowRuntimeException;
+import org.apache.airavata.workflow.model.graph.GraphException;
+import org.apache.airavata.workflow.model.graph.system.InputNode;
+import org.apache.airavata.workflow.model.ode.ODEClient;
+import org.apache.airavata.workflow.model.wf.Workflow;
+import org.apache.airavata.workflow.model.wf.WorkflowExecutionState;
+import org.apache.airavata.ws.monitor.MonitorException;
+import org.apache.airavata.xbaya.XBayaConfiguration;
+import org.apache.airavata.xbaya.XBayaConstants;
+import org.apache.airavata.xbaya.concurrent.PredicatedTaskRunner;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.impl.llom.util.AXIOMUtil;
+import org.apache.axiom.soap.SOAPHeader;
+import org.apache.axis2.context.ConfigurationContext;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.ServiceLifeCycle;
+import org.apache.xmlbeans.XmlException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.*;
+//import org.apache.airavata.registry.api.AiravataRegistry2;
+
+/**
+ * WorkflowInterpretorSkeleton java skeleton for the axisService
+ */
+public class WorkflowInterpretorSkeleton implements ServiceLifeCycle {
+    private static final Logger log = LoggerFactory.getLogger(WorkflowInterpretorSkeleton.class);
+
+//	public static final String PROXYSERVER = "myproxy.url";
+	public static final String MSGBOX = "msgbox";
+	public static final String GFAC = "gfac";
+	public static final String BROKER = "broker";
+    public static final String MYPROXY_USER = "myproxy.user";
+    public static final String MYPROXY_PASS = "myproxy.pass";
+    public static final String MYPROXY_SERVER = "myproxy.server";
+    public static final String MYPROXY_LIFETIME = "myproxy.life";
+    public static final String TRUSTED_CERT_LOCATION = "trusted.cert.location";
+
+    public static boolean provenance = false;
+    public static final String PROVENANCE = "provenance";
+    public static  String systemUserName = "";
+    public static  String systemUserPW = "";
+    public static boolean runInThread = false;
+    public static final String RUN_IN_THREAD = "runInThread";
+    public static  Boolean gfacEmbeddedMode = true;
+    private static PredicatedTaskRunner runner = null;
+//    public static  JCRComponentRegistry jcrComponentRegistry = null;
+    private static AiravataAPI airavataAPI=null;
+    public static int provenanceWriterThreadPoolSize = 1;
+    public static final String PROVENANCE_WRITER_THREAD_POOL_SIZE = "provenanceWriterThreadPoolSize";
+    public static final int JCR_AVAIALABILITY_WAIT_INTERVAL = 1000 * 10;
+    public static final String GFAC_EMBEDDED = "gfac.embedded";
+    public static  ConfigurationContext configurationContext;
+    public static final String SERVICE_NAME="WorkflowInterpretor";
+    public static boolean notInterrupted = true;
+    public Map<String, WorkflowInterpreterConfiguration> workflowConfigurations=new HashMap<String, WorkflowInterpreterConfiguration>();
+    private WorkflowInterpreterInteractor interactor;
+    private String gateway;
+
+	protected static final String SERVICE_URL = "interpreter_service_url";
+
+	protected static final String JCR_REG = "jcr_registry";
+
+	protected WIServiceThread thread;
+
+    private AiravataAPI getAiravataAPI(){
+        if (airavataAPI==null) {
+			try {
+				systemUserName = ServerSettings.getSystemUser();
+				systemUserPW = ServerSettings.getSystemUserPassword();
+				gateway = ServerSettings.getSystemUserGateway();
+				airavataAPI = AiravataAPIFactory.getAPI(gateway, systemUserName);
+			} catch (ApplicationSettingsException e) {
+				log.error("Unable to read the properties file", e);
+			} catch (AiravataAPIInvocationException e) {
+				log.error("Unable to create Airavata API", e);
+			}
+		}
+		return airavataAPI;
+    }
+
+    private WorkflowInterpreterInteractor getInteractor(){
+    	if (interactor==null){
+        	interactor=new SSWorkflowInterpreterInteractorImpl();
+    	}
+    	return interactor;
+    }
+
+    public void startUp(final ConfigurationContext configctx, AxisService service) {
+    	AiravataUtils.setExecutionAsServer();
+    	new Thread(){
+			@Override
+    		public void run() {
+    			try {
+					Thread.sleep(JCR_AVAIALABILITY_WAIT_INTERVAL);
+				} catch (InterruptedException e1) {
+					e1.printStackTrace();
+				}
+		        try {
+                    // Airavata deployer have to configure these properties,but if user send them alone the incoming message
+                    // We are overwriting those values only for that particular request
+		            configctx.setProperty(MYPROXY_PASS, ServerSettings.getSetting(MYPROXY_PASS));
+		            configctx.setProperty(MYPROXY_USER, ServerSettings.getSetting(MYPROXY_USER));
+		            configctx.setProperty(MYPROXY_LIFETIME,ServerSettings.getSetting(MYPROXY_LIFETIME));
+                    configctx.setProperty(TRUSTED_CERT_LOCATION,ServerSettings.getSetting(TRUSTED_CERT_LOCATION));
+                    configctx.setProperty(MYPROXY_SERVER,ServerSettings.getSetting(MYPROXY_SERVER));
+		            provenanceWriterThreadPoolSize = Integer.parseInt((String) ServerSettings.getSetting(PROVENANCE_WRITER_THREAD_POOL_SIZE));
+		            if("true".equals(ServerSettings.getSetting(PROVENANCE))){
+		                provenance = true;
+		                runner = new PredicatedTaskRunner(provenanceWriterThreadPoolSize);
+		                try {
+                            List<HostDescription> hostList = getDefinedHostDescriptions();
+                            for(HostDescription host:hostList){
+                                // This will avoid the changes user is doing to one of the predefined Hosts during a restart of the system
+                                AiravataAPI registry = getAiravataAPI();
+								if(!registry.getApplicationManager().isHostDescriptorExists(host.getType().getHostName())){
+                                    log.debug("Saving the predefined Host: " + host.getType().getHostName());
+                                    registry.getApplicationManager().addHostDescription(host);
+                                }
+                            }
+		                } catch (DescriptorAlreadyExistsException e) {
+                            e.printStackTrace();
+                        } catch (AiravataAPIInvocationException e) {
+		                    e.printStackTrace();
+
+                        }
+                    }else{
+		                provenance = false;
+		            }
+		            if("true".equals(ServerSettings.getSetting(RUN_IN_THREAD))){
+		                runInThread = true;
+		            }else{
+		                runInThread = false;
+		            }
+
+                     if("true".equals(ServerSettings.getSetting(GFAC_EMBEDDED))){
+		                gfacEmbeddedMode = true;
+		            }else{
+		                gfacEmbeddedMode = false;
+		            }
+
+                     //save the interpreter service url in context
+                    String localAddress = ServiceUtils.generateServiceURLFromConfigurationContext(configctx,SERVICE_NAME);
+ 					configctx.setProperty(SERVICE_URL,new URI(localAddress));
+ 					configctx.setProperty(JCR_REG,getAiravataAPI());
+ 					/*
+					 * Heart beat message to registry
+					 */
+					thread = new WIServiceThread(getAiravataAPI(), configctx);
+					thread.start();
+                } catch (IOException e) {
+                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+                } catch (URISyntaxException e) {
+                    e.printStackTrace();
+                } catch (ApplicationSettingsException e) {
+                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+                }
+                WorkflowInterpretorSkeleton.configurationContext = configctx;
+    		}
+    	}.start();
+
+    }
+
+    public void suspendWorkflow(String experimentId)throws Exception{
+    	if (workflowConfigurations.containsKey(experimentId)){
+    		if (getInteractor().isExecutionPaused(workflowConfigurations.get(experimentId))){
+    			throw new Exception("Experiment '"+experimentId+"' is already paused!!!");
+    		}else{
+    			log.info("Suspending workflow execution "+experimentId+"...");
+    			getInteractor().pauseExecution(workflowConfigurations.get(experimentId));
+    		}
+    	}else{
+    		throw new Exception("Invalid Experiment id: Experiment "+experimentId+" not running");
+    	}
+    }
+
+    public void resumeWorkflow(String experimentId)throws Exception{
+    	if (workflowConfigurations.containsKey(experimentId)){
+    		if (getInteractor().isExecutionPaused(workflowConfigurations.get(experimentId)) || workflowConfigurations.get(experimentId).getWorkflow().getExecutionState()==WorkflowExecutionState.STOPPED){
+    			log.info("Resuming workflow execution "+experimentId+"...");
+    			getInteractor().resumeExecution(workflowConfigurations.get(experimentId));
+
+    		}else{
+    			throw new Exception("Experiment '"+experimentId+"' is not suspended!!!");
+    		}
+    	}else{
+    		//TODO chk to see if the experiment is present in registry if so reload it and resume execution else error
+    		throw new Exception("Invalid Experiment id: Experiment "+experimentId+" not running");
+    	}
+    }
+
+    public void haltWorkflow(String experimentId)throws Exception{
+    	if (workflowConfigurations.containsKey(experimentId)){
+			log.info("Terminating workflow execution "+experimentId+"...");
+			getInteractor().terminateExecution(workflowConfigurations.get(experimentId));
+    	}else{
+    		throw new Exception("Invalid Experiment id: Experiment "+experimentId+" not running");
+    	}
+    }
+
+    /**
+     * @param workflowAsString
+     * @param topic
+     * @param inputs
+     * @return
+     * @throws XMLStreamException
+     */
+	public java.lang.String launchWorkflow(java.lang.String workflowAsString, java.lang.String topic, NameValue[] inputs) throws XMLStreamException {
+        OMElement workflowContext = getWorkflowContextHeader();
+        if(workflowContext == null){
+            workflowContext = AXIOMUtil.stringToOM("<wor:context-header xmlns:wor=\"http://airavata.apache.org/schemas/wec/2012/05\">\n" +
+                "    <wor:soa-service-eprs>\n" +
+                "        <wor:gfac-url></wor:gfac-url>\n" +
+                "        <wor:registry-url></wor:registry-url>\n" +
+                "    </wor:soa-service-eprs>\n" +
+                "    <wor:workflow-monitoring-context>\n" +
+                "        <wor:experiment-id></wor:experiment-id>\n" +
+                "        <wor:workflow-instance-id xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:nil=\"true\" />\n" +
+                "        <wor:event-publish-epr></wor:event-publish-epr>\n" +
+                "        <wor:msg-box-epr></wor:msg-box-epr>\n" +
+                "    </wor:workflow-monitoring-context>\n" +
+                "    <wor:workflow-scheduling-context />\n" +
+                "    <wor:security-context />\n" +
+                "</wor:context-header>");
+        }
+        Map<String, String> configuration = new HashMap<String, String>();
+        WorkflowContextHeaderBuilder workflowContextHeaderBuilder = parseContextHeader(workflowContext, configuration);
+        String user = workflowContextHeaderBuilder.getSubmissionUser();
+
+        String s = null;
+        try {
+             s = setupAndLaunch(workflowAsString, topic, ServerSettings.getSystemUserGateway(),
+                    user,inputs, configuration, runInThread, workflowContextHeaderBuilder);
+        } catch (AiravataAPIInvocationException e) {
+            log.error(e.getMessage());
+        } catch (ApplicationSettingsException e) {
+            log.error(e.getMessage());
+        }
+        return s;
+    }
+
+    private OMElement getWorkflowContextHeader() {
+        MessageContext currentMessageContext = MessageContext.getCurrentMessageContext();
+        SOAPHeader header = currentMessageContext.getEnvelope().getHeader();
+        Iterator<?> childrenWithName = header.getChildrenWithName(new QName("http://airavata.apache.org/schemas/wec/2012/05", "context-header"));
+        if (childrenWithName.hasNext()) {
+            return (OMElement) childrenWithName.next();
+        } else {
+            return null;
+        }
+    }
+
+    private WorkflowContextHeaderBuilder parseContextHeader(OMElement workflowContext, Map<String, String> configuration) throws XMLStreamException {
+        ContextHeaderDocument parse = null;
+        try {
+            parse = ContextHeaderDocument.Factory.parse(workflowContext.toStringWithConsume());
+            String msgBox = parse.getContextHeader().getWorkflowMonitoringContext().getMsgBoxEpr();
+            if(msgBox == null || "".equals(msgBox)){
+                msgBox = getAiravataAPI().getAiravataManager().getMessageBoxServiceURL().toASCIIString();
+            }
+            String msgBroker = parse.getContextHeader().getWorkflowMonitoringContext().getEventPublishEpr();
+            if(msgBroker == null || "".equals(msgBroker)){
+                msgBroker = getAiravataAPI().getAiravataManager().getEventingServiceURL().toASCIIString();
+            }
+            String gfac =  parse.getContextHeader().getSoaServiceEprs().getGfacUrl();
+//            if(gfac == null || "".equals(gfac)){
+//                gfac = getAiravataAPI().getAiravataManager().getGFaCURLs().get(0).toString();
+//            }
+            configuration.put(BROKER, msgBroker);
+            configuration.put(GFAC, gfac);
+            configuration.put(MSGBOX, msgBox);
+        } catch (XmlException e) {
+            log.error(e.getMessage());
+        } catch (AiravataAPIInvocationException e) {
+            log.error(e.getMessage());
+        }
+    	String submissionUser = workflowContext.getAttributeValue(new QName(workflowContext.getNamespace().getNamespaceURI(), "submissionUser"));
+        WorkflowContextHeaderBuilder workflowContextHeaderBuilder = new WorkflowContextHeaderBuilder(parse.getContextHeader());
+        workflowContextHeaderBuilder.setSubmissionUser(submissionUser);
+		return workflowContextHeaderBuilder;
+    }
+
+    public String setupAndLaunch(String workflowAsString, String experimentId, String gatewayId, String username,
+            Map<String,String> inputs,boolean inNewThread,WorkflowContextHeaderBuilder builder) throws AiravataAPIInvocationException{
+    	List<NameValue> inputData=new ArrayList<NameValue>();
+    	for (String inputName : inputs.keySet()) {
+			NameValue input = new NameValue();
+			input.setName(inputName);
+			input.setValue(inputs.get(inputName));
+			inputData.add(input);
+		}
+    	Map<String, String> configuration = new HashMap<String, String>();
+    	configuration.put(BROKER, getAiravataAPI().getAiravataManager().getEventingServiceURL().toASCIIString());
+        configuration.put(MSGBOX, getAiravataAPI().getAiravataManager().getMessageBoxServiceURL().toASCIIString());
+
+    	return setupAndLaunch(workflowAsString, experimentId, gatewayId, username, inputData.toArray(new NameValue[]{}), configuration, inNewThread, builder);
+    }
+
+    private String setupAndLaunch(String workflowAsString, String topic, String gatewayId, String username,
+                                  NameValue[] inputs,Map<String,String>configurations,boolean inNewThread,
+                                  WorkflowContextHeaderBuilder builder) throws AiravataAPIInvocationException{
+        log.debug("Launch is called for topic:"+topic);
+
+        Workflow workflow = null;
+        try {
+            workflow = new Workflow(workflowAsString);
+            log.debug("Workflow Object created");
+        } catch (GraphException e1) {
+            e1.printStackTrace();
+        } catch (ComponentException e1) {
+            e1.printStackTrace();
+        }
+        log.debug("Setting Input values");
+        List<InputNode> inputNodes = new ODEClient().getInputNodes(workflow);
+        for (InputNode inputNode : inputNodes) {
+            for (NameValue input : inputs) {
+                if (inputNode.getID().equals(input.getName())) {
+                    inputNode.setDefaultValue(input.getValue());
+                    break;
+                }
+            }
+            if (inputNode.getDefaultValue() == null) {
+                throw new WorkflowRuntimeException("Could not find a input value for component with name :" + inputNode.getName());
+            }
+
+        }
+        log.debug("Input all set");
+
+        XBayaConfiguration conf = null;
+        try {
+            conf = getConfiguration(configurations);
+            conf.setTopic(topic);
+            conf.setRunWithCrossProduct(true);
+        } catch (URISyntaxException e1) {
+            throw new WorkflowRuntimeException(e1);
+        }
+        WorkflowInterpretorEventListener listener = null;
+        WorkflowInterpreter interpreter = null;
+        AiravataAPI airavataAPI = AiravataAPIFactory.getAPI(gatewayId, username);
+        WorkflowInterpreterConfiguration workflowInterpreterConfiguration = new WorkflowInterpreterConfiguration(workflow, topic, conf.getMessageBoxURL(), conf.getBrokerURL(), airavataAPI, conf, null, null);
+        workflowInterpreterConfiguration.setGfacEmbeddedMode(gfacEmbeddedMode);
+        workflowInterpreterConfiguration.setActOnProvenance(provenance);
+
+        if (builder.getSecurityContext().getAmazonWebservices() != null) {
+            workflowInterpreterConfiguration.setAwsSecretKey(builder.getSecurityContext().getAmazonWebservices().getSecretAccessKey());
+            workflowInterpreterConfiguration.setAwsAccessKey(builder.getSecurityContext().getAmazonWebservices().getAccessKeyId());
+        }
+        // WorkflowInterpreter object should create prior creation of Listener, because listener needs the threadlocal variable
+        interpreter = new WorkflowInterpreter(workflowInterpreterConfiguration, getInteractor());
+        listener = new WorkflowInterpretorEventListener(workflow, conf);
+        try {
+            log.debug("start listener set");
+            listener.start();
+        } catch (MonitorException e1) {
+            e1.printStackTrace();
+        }
+
+        WorkflowContextHeaderBuilder.setCurrentContextHeader(builder.getContextHeader());
+
+        final WorkflowInterpretorEventListener finalListener = listener;
+        conf.setAiravataAPI(getAiravataAPI());
+
+        final WorkflowInterpreter finalInterpreter = interpreter;
+//        interpreter.setActOnProvenance(provenance);
+        interpreter.setProvenanceWriter(runner);
+        final String experimentId = topic;
+        log.debug("Created the interpreter");
+        if(inNewThread){
+            runInThread(finalInterpreter,finalListener,experimentId,builder);
+        }else{
+            executeWorkflow(finalInterpreter, finalListener, experimentId);
+        }
+        log.info("Experiment launched :" + topic);
+        return topic;
+    }
+
+    private void runInThread(final WorkflowInterpreter interpreter,final WorkflowInterpretorEventListener listener,final String experimentId,final WorkflowContextHeaderBuilder builder) {
+        new Thread(new Runnable() {
+
+            public void run() {
+                WorkflowContextHeaderBuilder.setCurrentContextHeader(builder.getContextHeader());
+                executeWorkflow(interpreter, listener, experimentId);
+            }
+        }).start();
+    }
+
+    private void executeWorkflow(WorkflowInterpreter interpreter, WorkflowInterpretorEventListener listener,String experimentId) {
+        try {
+        	workflowConfigurations.put(experimentId,interpreter.getConfig());
+            interpreter.scheduleDynamically();
+            log.debug("Interpreter invoked...");
+        } catch (Exception e) {
+            throw new WorkflowRuntimeException(e);
+        } finally {
+        	if (workflowConfigurations.containsKey(experimentId)){
+        		workflowConfigurations.remove(experimentId);
+        	}
+            /*
+             * stop listener no matter what happens
+             */
+//            try {
+//                if(listener != null)
+//                listener.stop();
+//            } catch (MonitorException e) {
+//                e.printStackTrace();
+//            }
+        }
+    }
+
+    public  XBayaConfiguration getConfiguration(Map<String,String> vals) throws URISyntaxException {
+		XBayaConfiguration configuration = new XBayaConfiguration();
+		configuration.setBrokerURL(new URI(findValue(vals, BROKER, XBayaConstants.DEFAULT_BROKER_URL.toString())));
+		configuration.setGFacURL(new URI(findValue(vals, GFAC, XBayaConstants.DEFAULT_GFAC_URL.toString())));
+		configuration.setMessageBoxURL(new URI(findValue(vals, MSGBOX, XBayaConstants.DEFAULT_MESSAGE_BOX_URL.toString())));
+		configuration.setMyProxyLifetime(XBayaConstants.DEFAULT_MYPROXY_LIFTTIME);
+		configuration.setMyProxyPort(XBayaConstants.DEFAULT_MYPROXY_PORT);
+        //This null check will fix some test failures
+        if (WorkflowInterpretorSkeleton.configurationContext != null) {
+            configuration.setMyProxyServer(findValue(vals, MYPROXY_SERVER, (String) WorkflowInterpretorSkeleton.configurationContext.getProperty(MYPROXY_SERVER)));
+            configuration.setMyProxyPassphrase(findValue(vals, MYPROXY_PASS, (String) WorkflowInterpretorSkeleton.configurationContext.getProperty(MYPROXY_PASS)));
+            configuration.setMyProxyUsername(findValue(vals, MYPROXY_USER, (String) WorkflowInterpretorSkeleton.configurationContext.getProperty(MYPROXY_USER)));
+            configuration.setTrustedCertLocation(findValue(vals, TRUSTED_CERT_LOCATION, (String) WorkflowInterpretorSkeleton.configurationContext.getProperty(TRUSTED_CERT_LOCATION)));
+            configuration.setTrustedCertLocation(findValue(vals, MYPROXY_LIFETIME, (String) WorkflowInterpretorSkeleton.configurationContext.getProperty(MYPROXY_LIFETIME)));
+        }
+		return configuration;
+	}
+
+	private String findValue(Map<String,String> vals, String key, String defaultVal) {
+		if(vals.get(key) != null) {
+            return vals.get(key);
+        }
+		return defaultVal;
+	}
+
+    public void shutDown(ConfigurationContext configctx, AxisService service) {
+        URI gfacURL = (URI) configctx.getProperty(SERVICE_URL);
+        if (getAiravataAPI() != null && thread != null) {
+            AiravataAPI registry = getAiravataAPI();
+            try {
+                registry.getAiravataManager().removeWorkflowInterpreterURI(gfacURL);
+            } catch (AiravataAPIInvocationException e) {
+                e.printStackTrace();
+            }
+            thread.interrupt();
+            try {
+                thread.join();
+            } catch (InterruptedException e) {
+                log.warn("GFacURL update thread is interrupted");
+            }
+        }
+        if (runner != null) {
+            runner.shutDown();
+        }
+
+        notInterrupted = false;
+    }
+
+    private List<HostDescription> getDefinedHostDescriptions() {
+        URL url = this.getClass().getClassLoader().getResource("host.xml");
+        ArrayList<HostDescription> hostDescriptions = new ArrayList<HostDescription>();
+        XMLStreamReader reader = null;
+        try {
+            if (url != null) {
+                reader = XMLInputFactory.newInstance().createXMLStreamReader(url.openStream());
+            } else {
+                throw new RuntimeException("Error retrieving host.xml file. Should reside in " +
+                        "$SERVER_HOME/webapps/axis2/WEB-INF/classes/host.xml");
+            }
+        } catch (XMLStreamException e) {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        } catch (IOException e) {
+            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+        }
+        StAXOMBuilder builder = new StAXOMBuilder(reader);
+        OMElement documentElement = builder.getDocumentElement();
+        Iterator<?> server = documentElement.getChildrenWithName(new QName("server"));
+        while (server.hasNext()) {
+            HostDescription hostDescription = new HostDescription();
+            OMElement next = (OMElement) server.next();
+            if (next.getFirstChildWithName(new QName("gram.endpoint")) != null &&
+                    "globus".equals(next.getFirstChildWithName(new QName("type")).getText())) {
+                hostDescription.getType().changeType(GlobusHostType.type);
+                ((GlobusHostType) hostDescription.getType()).addGlobusGateKeeperEndPoint(next.getFirstChildWithName(new QName("gram.endpoint")).getText());
+                ((GlobusHostType) hostDescription.getType()).addGridFTPEndPoint(next.getFirstChildWithName(new QName("gridftp.endpoint")).getText());
+            } else if("ssh".equals(next.getFirstChildWithName(new QName("type")).getText())) {
+                hostDescription.getType().changeType(SSHHostType.type);
+                if(next.getFirstChildWithName(new QName("hpc.resource")) != null){
+                    if("true".equals(next.getFirstChildWithName(new QName("gram.endpoint")))){
+                        ((SSHHostType) hostDescription.getType()).setHpcResource(true);
+                    }
+                }
+                ((SSHHostType) hostDescription.getType()).setHpcResource(false);
+            } else if("gsissh".equals(next.getFirstChildWithName(new QName("type")).getText())) {
+                hostDescription.getType().changeType(GsisshHostType.type);
+            }
+            (hostDescription.getType()).setHostName(next.getFirstChildWithName(new QName("name")).getText());
+            (hostDescription.getType()).setHostAddress(next.getFirstChildWithName(new QName("host")).getText());
+            hostDescriptions.add(hostDescription);
+        }
+        return hostDescriptions;
+    }
+
+    public static final int URL_UPDATE_INTERVAL = 1000 * 60 * 60 * 3;
+
+    class WIServiceThread extends PeriodicExecutorThread {
+        private ConfigurationContext context = null;
+
+        WIServiceThread(AiravataAPI registry, ConfigurationContext context) {
+            super(registry);
+            this.context = context;
+        }
+
+        @Override
+        protected void updateRegistry(AiravataAPI registry) throws Exception {
+            URI localAddress = (URI) this.context.getProperty(SERVICE_URL);
+            registry.getAiravataManager().addWorkflowInterpreterURI(localAddress);
+            log.debug("Updated Workflow Interpreter service URL in to Repository");
+
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/AsynchronousInvoker.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/AsynchronousInvoker.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/AsynchronousInvoker.java
new file mode 100644
index 0000000..defd8c2
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/AsynchronousInvoker.java
@@ -0,0 +1,118 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.invoker;
+
+import org.apache.airavata.common.utils.XMLUtil;
+import org.apache.airavata.workflow.model.exceptions.WorkflowException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import xsul.wsdl.WsdlDefinitions;
+import xsul.wsif.WSIFMessage;
+import xsul.wsif.WSIFOperation;
+import xsul.xwsif_runtime_async.WSIFAsyncResponsesCorrelator;
+import xsul.xwsif_runtime_async_http.XsulSoapHttpWsaResponsesCorrelator;
+
+public class AsynchronousInvoker extends SimpleInvoker {
+
+    private static final Logger logger = LoggerFactory.getLogger(AsynchronousInvoker.class);
+
+    private String messageBoxURL;
+
+    /**
+     * Constructs an AsynchronousInvoker.
+     * 
+     * @param definitions
+     */
+    public AsynchronousInvoker(WsdlDefinitions definitions) {
+        this(definitions, null);
+    }
+
+    /**
+     * Constructs an AsynchronousInvoker.
+     * 
+     * @param definitions
+     * @param messageBoxURL
+     */
+    public AsynchronousInvoker(WsdlDefinitions definitions, String messageBoxURL) {
+        super(definitions);
+        this.messageBoxURL = messageBoxURL;
+    }
+
+    /**
+     * @see org.apache.airavata.xbaya.invoker.SimpleInvoker#setup()
+     */
+    @Override
+    public void setup() throws WorkflowException {
+        super.setup();
+        /* Set the output message to null to set teh output from async Listener */
+        WSIFAsyncResponsesCorrelator correlator;
+        if (this.messageBoxURL == null || this.messageBoxURL.length() == 0) {
+            correlator = new XsulSoapHttpWsaResponsesCorrelator();
+            String serverLoc = ((XsulSoapHttpWsaResponsesCorrelator) correlator).getServerLocation();
+            logger.debug("using async correlator at " + serverLoc);
+        } else {
+            correlator = new MsgBoxWsaResponsesCorrelator(this.messageBoxURL,this);
+            logger.debug("using message box at " + this.messageBoxURL);
+        }
+        this.client.useAsyncMessaging(correlator);
+    }
+
+     public boolean invoke() throws WorkflowException {
+         final WSIFOperation  operation = this.getOperation();
+         final WSIFMessage inputMessage = this.getInputMessage();
+         this.setOutputMessage(null);
+        try {
+              new Thread() {
+                @Override
+                public void run() {
+                    try {
+                        operation.executeInputOnlyOperation(inputMessage);
+                    } catch (Exception e) {
+                        // Ignore the error.
+                        logger.error("Error invoking GFac Service",e);
+                    }
+                }
+            }.start();
+
+            while(this.getOutputMessage() == null){
+                try {
+                    Thread.sleep(1000);
+                } catch (InterruptedException e) {
+                    logger.error("Error Waiting for the response from backend");
+                }
+            }
+            // Gfac operation failed, so xbaya side throws this exception
+            if("ErrorResponse".equals(XMLUtil.stringToXmlElement3(this.getOutputMessage().toString()).getName())){
+                // Here we do not throw an exception, because if we throw an exception Interpreter will catch it and do the unsubscription,
+                // which is not needed because if there's an gfac side error gfac will send a failure and unsubscription will be done in monitoring
+                // so if we send an exception we are attempting to do two unsubscriptions which will cause a one unsubscription to fail.
+                return false;
+            }
+
+            return true;
+        } catch (RuntimeException e) {
+            String message = "Error in invoking a service.";
+            throw new WorkflowException(message, e);
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/DynamicInvoker.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/DynamicInvoker.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/DynamicInvoker.java
new file mode 100644
index 0000000..5020ef4
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/DynamicInvoker.java
@@ -0,0 +1,167 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.invoker;
+
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import org.apache.airavata.workflow.model.exceptions.WorkflowException;
+
+import xsul.wsif.WSIFMessage;
+import xsul.xwsif_runtime.WSIFClient;
+
+public class DynamicInvoker implements Invoker {
+
+    private URL jarUrl;
+
+    private String className;
+
+    private String operationName;
+
+    private Object[] inputs;
+
+    private Object result;
+
+    /**
+     * Constructs a DynamicInvoker.
+     * 
+     * @param className
+     * @param jarUrl
+     * @param operationName
+     */
+    public DynamicInvoker(String className, URL jarUrl, String operationName, Object[] inputs) {
+        this.className = className;
+        this.jarUrl = jarUrl;
+        this.operationName = operationName;
+        this.inputs = inputs;
+    }
+
+    /**
+     * @see org.apache.airavata.xbaya.invoker.WorkflowInvoker#getOutput(java.lang.String)
+     */
+    public Object getOutput(String name) throws WorkflowException {
+        waitToFinish();
+        return result;
+    }
+
+    /**
+     * @see org.apache.airavata.xbaya.invoker.WorkflowInvoker#invoke()
+     */
+    public boolean invoke() throws WorkflowException {
+        try {
+            Class<?> targetClass = Class.forName(this.className);
+            Object obj = targetClass.newInstance();
+
+            Method[] methods = targetClass.getDeclaredMethods();
+            Method targetMethod = null;
+            for (Method method : methods) {
+                if (this.operationName.equals(method.getName())) {
+                    targetMethod = method;
+                    break;
+                }
+            }
+            if (targetMethod == null) {
+                throw new WorkflowException("Could not find the method using reflection: " + this.operationName);
+            }
+
+            targetMethod.setAccessible(true);
+            this.result = targetMethod.invoke(obj, inputs);
+
+        } catch (Exception e) {
+            throw new WorkflowException(e);
+        }
+        return true;
+    }
+
+    /**
+     * @see org.apache.airavata.xbaya.invoker.WorkflowInvoker#setInput(java.lang.String, java.lang.Object)
+     */
+    public void setInput(String name, Object value) throws WorkflowException {
+
+    }
+
+    /**
+     * @see org.apache.airavata.xbaya.invoker.WorkflowInvoker#setOperation(java.lang.String)
+     */
+    public void setOperation(String operationName) throws WorkflowException {
+        this.operationName = operationName;
+    }
+
+    /**
+     * @see org.apache.airavata.xbaya.invoker.WorkflowInvoker#setup()
+     */
+    public void setup() throws WorkflowException {
+        Class[] parameters = new Class[] { URL.class };
+        URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader();
+        Class sysclass = URLClassLoader.class;
+
+        try {
+            Method method = sysclass.getDeclaredMethod("addURL", parameters);
+            method.setAccessible(true);
+            method.invoke(sysloader, new Object[] { this.jarUrl });
+        } catch (Throwable t) {
+            t.printStackTrace();
+            throw new WorkflowException("Error, could not add URL to system classloader");
+        }
+    }
+
+    /**
+     * @see org.apache.airavata.xbaya.invoker.WorkflowInvoker#waitToFinish()
+     */
+    public void waitToFinish() throws WorkflowException {
+        while (this.result == null) {
+            try {
+                Thread.sleep(200);
+            } catch (InterruptedException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+        }
+
+    }
+
+    /**
+     * @see org.apache.airavata.xbaya.invoker.WorkflowInvoker#getOutputs()
+     */
+    public WSIFMessage getOutputs() throws WorkflowException {
+        waitToFinish();
+        return (WSIFMessage) this.result;
+
+    }
+
+    @Override
+    public WSIFClient getClient() {
+        return null;
+    }
+
+    @Override
+    public WSIFMessage getInputs() throws WorkflowException {
+        return null;
+    }
+
+    @Override
+    public WSIFMessage getFault() throws WorkflowException {
+        return null;
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/airavata/blob/9c47eec8/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/DynamicServiceCreator.java
----------------------------------------------------------------------
diff --git a/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/DynamicServiceCreator.java b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/DynamicServiceCreator.java
new file mode 100644
index 0000000..cc7fc2c
--- /dev/null
+++ b/modules/xbaya-gui/src/main/java/org/apache/airavata/xbaya/invoker/DynamicServiceCreator.java
@@ -0,0 +1,86 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+package org.apache.airavata.xbaya.invoker;
+
+import java.io.File;
+import java.net.URI;
+
+import javax.xml.namespace.QName;
+
+import org.apache.airavata.workflow.model.exceptions.WorkflowException;
+import org.apache.airavata.xbaya.invoker.factory.InvokerFactory;
+
+import xsul.wsdl.WsdlDefinitions;
+import xsul.wsdl.WsdlResolver;
+
+public class DynamicServiceCreator {
+
+    private String dynamicFactoryWSDLLocation;
+
+    private static String classStr = "package org.apache.airavata.xbaya;" +
+
+    "public class DefaultClassName{" +
+
+    "public int operationName(String[] stringArray0){" +
+
+    "return 8;" + "}" + "}";
+
+    /**
+     * Constructs a DynamicServiceCreator.
+     * 
+     * @param dynamicFactoryWSDLLocation
+     */
+    public DynamicServiceCreator(String dynamicFactoryWSDLLocation) {
+        this.dynamicFactoryWSDLLocation = dynamicFactoryWSDLLocation;
+    }
+
+    public void createService(String code) throws WorkflowException {
+        try {
+            WsdlDefinitions definitions = null;
+            if (this.dynamicFactoryWSDLLocation != null && !this.dynamicFactoryWSDLLocation.equals("")) {
+                definitions = WsdlResolver.getInstance().loadWsdl(new File(".").toURI(),
+                        new URI(this.dynamicFactoryWSDLLocation));
+            }
+
+            // Create Invoker
+            // FIXME: Should pass the right leadcontext header for last argument
+            Invoker invoker = InvokerFactory.createInvoker(new QName("http://extreme.indiana.edu",
+                    "ServiceCreatorPortType"), definitions, null, null, null);
+
+            invoker.setup();
+
+            invoker.setOperation("deployServiceFromClass");
+            invoker.setInput("classAsString", code);
+            invoker.invoke();
+            invoker.getOutput("return");
+        } catch (Exception e) {
+            throw new WorkflowException(e);
+        }
+
+    }
+
+    public static void main(String[] args) throws WorkflowException {
+        DynamicServiceCreator c = new DynamicServiceCreator("http://127.0.0.1:8080/axis2/services/ServiceCreator?wsdl");
+        c.createService(classStr);
+    }
+
+}
\ No newline at end of file