You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by la...@apache.org on 2013/01/29 04:57:42 UTC

svn commit: r1439743 [1/2] - in /airavata/trunk/modules/gfac-core: ./ src/main/java/org/apache/airavata/gfac/ src/main/java/org/apache/airavata/gfac/context/ src/main/java/org/apache/airavata/gfac/handler/ src/main/java/org/apache/airavata/gfac/notific...

Author: lahiru
Date: Tue Jan 29 03:57:41 2013
New Revision: 1439743

URL: http://svn.apache.org/viewvc?rev=1439743&view=rev
Log:
committing milinda's patch for https://issues.apache.org/jira/browse/AIRAVATA-749.

Added:
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/Constants.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/GFacAPI.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/GFacConfiguration.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/GFacException.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/Scheduler.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/AbstractContext.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/ApplicationContext.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/JobExecutionContext.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/MessageContext.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/SecurityContext.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GFacHandler.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GFacHandlerException.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/GFacNotifier.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/ExecutionFailEvent.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/FinishExecutionEvent.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/FinishScheduleEvent.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/GFacEvent.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/StartExecutionEvent.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/StartScheduleEvent.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/listeners/
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/listeners/LoggingListener.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/listeners/WorkflowTrackingListener.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/GFacProvider.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/GFacProviderException.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/LocalProvider.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/utils/
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/utils/GFacUtils.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/utils/GridFTPContactInfo.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/utils/InputStreamToFileWriter.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/utils/InputUtils.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/utils/LocalProviderUtil.java
    airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/utils/OutputUtils.java
Modified:
    airavata/trunk/modules/gfac-core/pom.xml

Modified: airavata/trunk/modules/gfac-core/pom.xml
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/pom.xml?rev=1439743&r1=1439742&r2=1439743&view=diff
==============================================================================
--- airavata/trunk/modules/gfac-core/pom.xml (original)
+++ airavata/trunk/modules/gfac-core/pom.xml Tue Jan 29 03:57:41 2013
@@ -196,6 +196,13 @@
             <version>1.2.1</version>
         </dependency>
         <!-- unicore dependencies finished -->
+
+        <!-- Guava -->
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+            <version>12.0</version>
+        </dependency>
     </dependencies>
 
 </project>

Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/Constants.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/Constants.java?rev=1439743&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/Constants.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/Constants.java Tue Jan 29 03:57:41 2013
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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.gfac;
+
+public class Constants {
+    public static final String XPATH_EXPR_MYPROXY_SERVER = "/GFac/MyProxy/Server/text()";
+    public static final String XPATH_EXPR_MYPROXY_USER = "/GFac/MyProxy/User/text()";
+    public static final String XPATH_EXPR_MYPROXY_PASSPHRASE = "/GFac/MyProxy/Passphrase/text()";
+    public static final String XPATH_EXPR_MYPROXY_LIFECYCLE = "/GFac/MyProxy/LifeCycle/text()";
+    public static final String XPATH_EXPR_INFLOW_HANDLERS = "/GFac/Handlers/InFlow/Handler";
+    public static final String XPATH_EXPR_OUTFLOW_HANDLERS = "/GFac/Handlers/OutFlow/Handler";
+
+    public static final String GFAC_CONFIG_HANDLER_CLASS_ATTRIBUTE = "class";
+    public static final String NEWLINE = System.getProperty("line.separator");
+    public static final String INPUT_DATA_DIR_VAR_NAME = "inputData";
+    public static final String OUTPUT_DATA_DIR_VAR_NAME = "outputData";
+    public static final int DEFAULT_GSI_FTP_PORT = 2811;
+    public static final String _127_0_0_1 = "127.0.0.1";
+    public static final String LOCALHOST = "localhost";
+}

Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/GFacAPI.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/GFacAPI.java?rev=1439743&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/GFacAPI.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/GFacAPI.java Tue Jan 29 03:57:41 2013
@@ -0,0 +1,173 @@
+/*
+ *
+ * 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.gfac;
+
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.handler.GFacHandler;
+import org.apache.airavata.gfac.handler.GFacHandlerException;
+import org.apache.airavata.gfac.notification.events.ExecutionFailEvent;
+import org.apache.airavata.gfac.notification.events.FinishExecutionEvent;
+import org.apache.airavata.gfac.notification.listeners.LoggingListener;
+import org.apache.airavata.gfac.notification.listeners.WorkflowTrackingListener;
+import org.apache.airavata.gfac.provider.GFacProvider;
+import org.apache.airavata.gfac.provider.GFacProviderException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+public class GFacAPI {
+    private static final Logger log = LoggerFactory.getLogger(GFacAPI.class);
+
+    public static final String PROP_WORKFLOW_INSTANCE_ID = "workflow.instance.id";
+    public static final String PROP_WORKFLOW_NODE_ID = "workflow.node.id";
+    public static final String PROP_BROKER_URL = "broker.url";
+    public static final String PROP_TOPIC = "topic";
+
+    public void submitJob(JobExecutionContext jobExecutionContext) throws GFacException {
+        // We need to check whether this job is submitted as a part of a large workflow. If yes,
+        // we need to setup workflow tracking listerner.
+        String workflowInstanceID = null;
+        if ((workflowInstanceID = (String) jobExecutionContext.getProperty(PROP_WORKFLOW_INSTANCE_ID)) != null) {
+            // This mean we need to register workflow tracking listener.
+            registerWorkflowTrackingListener(workflowInstanceID, jobExecutionContext);
+        }
+        // Register log event listener. This is required in all scenarios.
+        jobExecutionContext.getNotificationService().registerListener(new LoggingListener());
+        schedule(jobExecutionContext);
+    }
+
+    private void schedule(JobExecutionContext jobExecutionContext) throws GFacException {
+        // Scheduler will decide the execution flow of handlers and provider which handles
+        // the job.
+        Scheduler.schedule(jobExecutionContext);
+
+        // Executing in handlers in the order as they have configured in GFac configuration
+        invokeInFlowHandlers(jobExecutionContext);
+
+
+        // After executing the in handlers provider instance should be set to job execution context.
+        // We get the provider instance and execute it.
+        GFacProvider provider = jobExecutionContext.getProvider();
+        if (provider != null) {
+            initProvider(provider, jobExecutionContext);
+            executeProvider(provider, jobExecutionContext);
+            disposeProvider(provider, jobExecutionContext);
+        }
+
+        invokeOutFlowHandlers(jobExecutionContext);
+    }
+
+    private void initProvider(GFacProvider provider, JobExecutionContext jobExecutionContext) throws GFacException {
+        try {
+            provider.initialize(jobExecutionContext);
+        } catch (GFacProviderException e) {
+            throw new GFacException("Error while initializing provider " + provider.getClass().getName() + ".", e);
+        }
+    }
+
+    private void executeProvider(GFacProvider provider, JobExecutionContext jobExecutionContext) throws GFacException {
+        try {
+            provider.execute(jobExecutionContext);
+        } catch (GFacProviderException e) {
+            throw new GFacException("Error while executing provider " + provider.getClass().getName() + " functionality.", e);
+        }
+    }
+
+    private void disposeProvider(GFacProvider provider, JobExecutionContext jobExecutionContext) throws GFacException {
+        try {
+            provider.dispose(jobExecutionContext);
+        } catch (GFacProviderException e) {
+            throw new GFacException("Error while invoking provider " + provider.getClass().getName() + " dispose method.", e);
+        }
+    }
+
+    private void registerWorkflowTrackingListener(String workflowInstanceID, JobExecutionContext jobExecutionContext) {
+        String workflowNodeID = (String) jobExecutionContext.getProperty(PROP_WORKFLOW_NODE_ID);
+        String topic = (String) jobExecutionContext.getProperty(PROP_TOPIC);
+        String brokerUrl = (String) jobExecutionContext.getProperty(PROP_BROKER_URL);
+        jobExecutionContext.getNotificationService().registerListener(
+                new WorkflowTrackingListener(workflowInstanceID, workflowNodeID, brokerUrl, topic));
+
+    }
+
+    private void invokeInFlowHandlers(JobExecutionContext jobExecutionContext) throws GFacException {
+        List<String> handlers = jobExecutionContext.getGFacConfiguration().getInHandlers();
+
+        for (String handlerClassName : handlers) {
+            Class<? extends GFacHandler> handlerClass;
+            GFacHandler handler;
+            try {
+                handlerClass = Class.forName(handlerClassName.trim()).asSubclass(GFacHandler.class);
+                handler = handlerClass.newInstance();
+            } catch (ClassNotFoundException e) {
+                throw new GFacException("Cannot load handler class " + handlerClassName, e);
+            } catch (InstantiationException e) {
+                throw new GFacException("Cannot instantiate handler class " + handlerClassName, e);
+            } catch (IllegalAccessException e) {
+                throw new GFacException("Cannot instantiate handler class " + handlerClassName, e);
+            }
+
+
+            try {
+                handler.invoke(jobExecutionContext);
+                jobExecutionContext.getNotificationService().publish(new FinishExecutionEvent());
+            } catch (GFacHandlerException e) {
+                // TODO: Better error reporting.
+                jobExecutionContext.getNotificationService().publish(new ExecutionFailEvent(e));
+                log.error("Error occurred during in handler " + handlerClassName + " execution.");
+                break;
+            }
+        }
+    }
+
+    private void invokeOutFlowHandlers(JobExecutionContext jobExecutionContext) throws GFacException {
+        List<String> handlers = jobExecutionContext.getGFacConfiguration().getOutHandlers();
+
+        for (String handlerClassName : handlers) {
+            Class<? extends GFacHandler> handlerClass;
+            GFacHandler handler;
+            try {
+                handlerClass = Class.forName(handlerClassName.trim()).asSubclass(GFacHandler.class);
+                handler = handlerClass.newInstance();
+            } catch (ClassNotFoundException e) {
+                throw new GFacException("Cannot load handler class " + handlerClassName, e);
+            } catch (InstantiationException e) {
+                throw new GFacException("Cannot instantiate handler class " + handlerClassName, e);
+            } catch (IllegalAccessException e) {
+                throw new GFacException("Cannot instantiate handler class " + handlerClassName, e);
+            }
+
+
+            try {
+                handler.invoke(jobExecutionContext);
+                jobExecutionContext.getNotificationService().publish(new FinishExecutionEvent());
+            } catch (GFacHandlerException e) {
+                // TODO: Better error reporting.
+                jobExecutionContext.getNotificationService().publish(new ExecutionFailEvent(e));
+                log.error("Error occurred during out handler " + handlerClassName + " execution.");
+                break;
+            }
+        }
+    }
+
+}

Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/GFacConfiguration.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/GFacConfiguration.java?rev=1439743&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/GFacConfiguration.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/GFacConfiguration.java Tue Jan 29 03:57:41 2013
@@ -0,0 +1,208 @@
+package org.apache.airavata.gfac;
+
+import org.apache.airavata.client.api.AiravataAPI;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.*;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+public class GFacConfiguration {
+
+    public static final String TRUSTED_CERT_LOCATION = "trusted.cert.location";
+    public static final String MYPROXY_SERVER = "myproxy.server";
+    public static final String MYPROXY_USER = "myproxy.user";
+    public static final String MYPROXY_PASS = "myproxy.pass";
+    public static final String MYPROXY_LIFE = "myproxy.life";
+
+    private String myProxyServer;
+
+    private String myProxyUser;
+
+    private String myProxyPassphrase;
+
+    private int myProxyLifeCycle;
+
+    private AiravataAPI airavataAPI;
+
+    private String trustedCertLocation;
+
+    // Keep list of full qualified class names of GFac handlers which should invoked before
+    // the provider
+    private List<String> inHandlers = new ArrayList<String>();
+
+    // Keep list of full qualified class names of GFac handlers which should invoked after
+    // the provider
+    private List<String> outHandlers = new ArrayList<String>();
+
+    public GFacConfiguration(AiravataAPI airavataAPI, Properties configurationProperties) {
+        this.airavataAPI = airavataAPI;
+        if (configurationProperties != null) {
+            myProxyUser = configurationProperties.getProperty(MYPROXY_USER);
+            myProxyServer = configurationProperties.getProperty(MYPROXY_SERVER);
+            myProxyPassphrase = configurationProperties.getProperty(MYPROXY_PASS);
+            myProxyLifeCycle = Integer.parseInt(configurationProperties.getProperty(MYPROXY_LIFE));
+            trustedCertLocation = configurationProperties.getProperty(TRUSTED_CERT_LOCATION);
+        } else {
+            throw new NullPointerException("GFac Configuration properties cannot be null.");
+        }
+    }
+
+    public GFacConfiguration(AiravataAPI airavataAPI){
+        this.airavataAPI = airavataAPI;
+    }
+
+    public String getMyProxyServer() {
+        return myProxyServer;
+    }
+
+    public String getMyProxyUser() {
+        return myProxyUser;
+    }
+
+    public String getMyProxyPassphrase() {
+        return myProxyPassphrase;
+    }
+
+    public int getMyProxyLifeCycle() {
+        return myProxyLifeCycle;
+    }
+
+    public AiravataAPI getAiravataAPI() {
+        return airavataAPI;
+    }
+
+    public String getTrustedCertLocation() {
+        return trustedCertLocation;
+    }
+
+    public List<String> getInHandlers() {
+        return inHandlers;
+    }
+
+    public List<String> getOutHandlers() {
+        return outHandlers;
+    }
+
+    public void setMyProxyServer(String myProxyServer) {
+        this.myProxyServer = myProxyServer;
+    }
+
+    public void setMyProxyUser(String myProxyUser) {
+        this.myProxyUser = myProxyUser;
+    }
+
+    public void setMyProxyPassphrase(String myProxyPassphrase) {
+        this.myProxyPassphrase = myProxyPassphrase;
+    }
+
+    public void setMyProxyLifeCycle(int myProxyLifeCycle) {
+        this.myProxyLifeCycle = myProxyLifeCycle;
+    }
+
+    public void setTrustedCertLocation(String trustedCertLocation) {
+        this.trustedCertLocation = trustedCertLocation;
+    }
+
+    public void setInHandlers(List<String> inHandlers) {
+        this.inHandlers = inHandlers;
+    }
+
+    public void setOutHandlers(List<String> outHandlers) {
+        this.outHandlers = outHandlers;
+    }
+
+    /**
+     * Parse GFac configuration file and populate GFacConfiguration object. XML configuration
+     * file for GFac will look like below.
+     *
+     * <GFac>
+     *     <MyProxy>
+     *         <Server></Server>
+     *         <User></User>
+     *         <Passphrase></Passphrase>
+     *         <LifeCycle></LifeCycle>
+     *     </MyProxy>
+     *     <Handlers>
+     *         <InFlow>
+     *             <Handler class="org.apache.airavata.gfac.handler.impl.HadoopDeploymentHandler"/>
+     *         </InFlow>
+     *         <OutFlow>
+     *             <Handler class="org.apache.airavata.gfac.handler.impl.HadoopDeploymentHandler"/>
+     *         </OutFlow>
+     *     </Handlers>
+     * </GFac>
+     *
+     * @param configFile configuration file
+     * @return GFacConfiguration object.
+     */
+    public static GFacConfiguration create(File configFile, AiravataAPI airavataAPI) throws ParserConfigurationException, IOException, SAXException, XPathExpressionException {
+        DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
+        DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
+        Document doc = docBuilder.parse(configFile);
+
+        GFacConfiguration configuration = new GFacConfiguration(airavataAPI);
+
+        configuration.setMyProxyServer(xpathGetText(doc, Constants.XPATH_EXPR_MYPROXY_SERVER));
+        configuration.setMyProxyUser(xpathGetText(doc, Constants.XPATH_EXPR_MYPROXY_USER));
+        configuration.setMyProxyPassphrase(xpathGetText(doc,
+                Constants.XPATH_EXPR_MYPROXY_PASSPHRASE));
+        configuration.setMyProxyLifeCycle(Integer.parseInt(
+                xpathGetText(doc, Constants.XPATH_EXPR_MYPROXY_LIFECYCLE)));
+
+        configuration.setInHandlers(xpathGetAttributeValueList(doc,
+                Constants.XPATH_EXPR_INFLOW_HANDLERS,
+                Constants.GFAC_CONFIG_HANDLER_CLASS_ATTRIBUTE));
+        configuration.setOutHandlers(xpathGetAttributeValueList(doc,
+                Constants.XPATH_EXPR_OUTFLOW_HANDLERS,
+                Constants.GFAC_CONFIG_HANDLER_CLASS_ATTRIBUTE));
+
+        return configuration;
+    }
+
+    private static String xpathGetText(Document doc, String expression) throws XPathExpressionException {
+        XPathFactory xPathFactory = XPathFactory.newInstance();
+        XPath xPath = xPathFactory.newXPath();
+        XPathExpression expr = xPath.compile(expression);
+
+        return (String)expr.evaluate(doc, XPathConstants.STRING);
+    }
+
+    /**
+     * Select matching node set and extract specified attribute value.
+     * @param doc  XML document
+     * @param expression  expression to match node set
+     * @param attribute name of the attribute to extract
+     * @return list of attribute values.
+     * @throws XPathExpressionException
+     */
+    private static List<String> xpathGetAttributeValueList(Document doc, String expression, String attribute) throws XPathExpressionException{
+        XPathFactory xPathFactory = XPathFactory.newInstance();
+        XPath xPath = xPathFactory.newXPath();
+        XPathExpression expr = xPath.compile(expression);
+
+        NodeList nl = (NodeList)expr.evaluate(doc, XPathConstants.NODESET);
+
+        List<String> attributeValues = new ArrayList<String>();
+
+        for(int i = 0; i < nl.getLength(); i++){
+            attributeValues.add(((Element)nl.item(i)).getAttribute(attribute));
+        }
+
+        return attributeValues;
+    }
+
+    public static GFacConfiguration create(Properties configProps){
+        return null;
+    }
+
+}

Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/GFacException.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/GFacException.java?rev=1439743&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/GFacException.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/GFacException.java Tue Jan 29 03:57:41 2013
@@ -0,0 +1,28 @@
+/*
+ *
+ * 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.gfac;
+
+public class GFacException extends Exception {
+    public GFacException(String s, Throwable throwable) {
+        super(s, throwable);
+    }
+}

Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/Scheduler.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/Scheduler.java?rev=1439743&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/Scheduler.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/Scheduler.java Tue Jan 29 03:57:41 2013
@@ -0,0 +1,66 @@
+/*
+ *
+ * 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.gfac;
+
+import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.provider.GFacProvider;
+import org.apache.airavata.gfac.provider.impl.LocalProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * Scheduler decides the execution order of handlers based on application description. In addition
+ * to that scheduler decides which provider to invoke at the end. Scheduler will set
+ * provider instance and in/out handler chains in JobExecutionContext.
+ */
+public class Scheduler {
+    private static Logger log = LoggerFactory.getLogger(Scheduler.class);
+
+    /**
+     * Decide which provider to use and execution sequence of handlers based on job request and
+     * job configuration.
+     * @param jobExecutionContext containing job request as well as all the configurations.
+     */
+    public static void schedule(JobExecutionContext jobExecutionContext) {
+        // Current implementation only support static handler sequence.
+        GFacConfiguration gFacConfiguration = jobExecutionContext.getGFacConfiguration();
+        jobExecutionContext.setInHandlers(gFacConfiguration.getInHandlers());
+        jobExecutionContext.setOutHandlers(gFacConfiguration.getOutHandlers());
+        jobExecutionContext.setProvider(getProvider(jobExecutionContext));
+        // TODO: Selecting the provider based on application description.
+    }
+
+    /**
+     * Figure out which provider to use based on application configuration.
+     * @param jobExecutionContext containing all the required configurations.
+     * @return GFacProvider instance.
+     */
+    private static GFacProvider getProvider(JobExecutionContext jobExecutionContext){
+        HostDescription hostDescription = jobExecutionContext.getApplicationContext().getHostDescription();
+
+        return new LocalProvider();
+    }
+
+
+}

Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/AbstractContext.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/AbstractContext.java?rev=1439743&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/AbstractContext.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/AbstractContext.java Tue Jan 29 03:57:41 2013
@@ -0,0 +1,46 @@
+/*
+ *
+ * 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.gfac.context;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public abstract class AbstractContext {
+
+    protected AbstractContext parent;
+    protected Map<String, Object> properties = new HashMap<String, Object>();
+
+    public Object getProperty(String name) {
+        Object value = properties.get(name);
+        if (value == null) {
+            if(parent != null){
+                return parent.getProperty(name);
+            }
+        }
+
+        return value;
+    }
+
+    public AbstractContext getParent() {
+        return parent;
+    }
+}

Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/ApplicationContext.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/ApplicationContext.java?rev=1439743&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/ApplicationContext.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/ApplicationContext.java Tue Jan 29 03:57:41 2013
@@ -0,0 +1,57 @@
+/*
+ *
+ * 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.gfac.context;
+
+import org.apache.airavata.commons.gfac.type.ApplicationDescription;
+import org.apache.airavata.commons.gfac.type.HostDescription;
+import org.apache.airavata.commons.gfac.type.ServiceDescription;
+
+public class ApplicationContext extends AbstractContext {
+
+    private ApplicationDescription applicationDeploymentDescription;
+    private ServiceDescription serviceDescription;
+    private HostDescription hostDescription;
+
+    public ApplicationDescription getApplicationDeploymentDescription() {
+        return applicationDeploymentDescription;
+    }
+
+    public <T extends ApplicationDescription> void setApplicationDeploymentDescription(T applicationDeploymentDescription) {
+        this.applicationDeploymentDescription = applicationDeploymentDescription;
+    }
+
+    public <T extends ServiceDescription> void setServiceDescription(T serviceDescription) {
+        this.serviceDescription = serviceDescription;
+    }
+
+    public <T extends HostDescription> void setHostDescription(T hostDescription) {
+        this.hostDescription = hostDescription;
+    }
+
+    public ServiceDescription getServiceDescription() {
+        return serviceDescription;
+    }
+
+    public HostDescription getHostDescription() {
+        return hostDescription;
+    }
+}

Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/JobExecutionContext.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/JobExecutionContext.java?rev=1439743&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/JobExecutionContext.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/JobExecutionContext.java Tue Jan 29 03:57:41 2013
@@ -0,0 +1,154 @@
+/*
+ *
+ * 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.gfac.context;
+
+import org.apache.airavata.gfac.GFacConfiguration;
+import org.apache.airavata.gfac.notification.GFacNotifier;
+import org.apache.airavata.gfac.provider.GFacProvider;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class JobExecutionContext extends AbstractContext{
+
+    private GFacConfiguration gfacConfiguration;
+
+    private ApplicationContext applicationContext;
+
+    private MessageContext inMessageContext;
+
+    private MessageContext outMessageContext;
+
+    private GFacNotifier notifier;
+
+    // Keep track of the current path of the message. Before hitting provider its in-path.
+    // After provider its out-path.
+    private boolean inPath = true;
+
+    // Keep list of full qualified class names of GFac handlers which should invoked before
+    // the provider. This is specific to current job being executed.
+    private List<String> inHandlers = new ArrayList<String>();
+
+    // Keep list of full qualified class names of GFac handlers which should invoked after
+    // the provider. This is specific to current job being executed.
+    private List<String> outHandlers = new ArrayList<String>();
+
+    // During the execution of in-flow one of the handlers(Scheduling handler) will
+    // set this and GFac API will get it from the JobExecutionContext and execute the provider.
+    private GFacProvider provider;
+
+    // Service description is used by GFac to mainly specify input/output parameters for a job
+    // and to expose a job as a service to the outside world. This service concept abstract out
+    // a scientific application(or algorithm) as a service. Service name is there to identify to
+    // which service description we should refer during the execution of the current job represented
+    // by this context instance.
+    private String serviceName;
+
+    public JobExecutionContext(GFacConfiguration gFacConfiguration){
+        this.gfacConfiguration = gFacConfiguration;
+        notifier = new GFacNotifier();
+    }
+
+    public ApplicationContext getApplicationContext() {
+        return applicationContext;
+    }
+
+    public void setApplicationContext(ApplicationContext applicationContext) {
+        this.applicationContext = applicationContext;
+    }
+
+    public MessageContext getInMessageContext() {
+        return inMessageContext;
+    }
+
+    public void setInMessageContext(MessageContext inMessageContext) {
+        this.inMessageContext = inMessageContext;
+    }
+
+    public MessageContext getOutMessageContext() {
+        return outMessageContext;
+    }
+
+    public void setOutMessageContext(MessageContext outMessageContext) {
+        this.outMessageContext = outMessageContext;
+    }
+
+    public GFacConfiguration getGFacConfiguration() {
+        return gfacConfiguration;
+    }
+
+    public GFacNotifier getNotificationService(){
+        return notifier;
+    }
+
+    public GFacProvider getProvider() {
+        return provider;
+    }
+
+    public void setProvider(GFacProvider provider) {
+        this.provider = provider;
+    }
+
+    public List<String> getInHandlers() {
+        return inHandlers;
+    }
+
+    public void setInHandlers(List<String> inHandlers) {
+        this.inHandlers = inHandlers;
+    }
+
+    public List<String> getOutHandlers() {
+        return outHandlers;
+    }
+
+    public void setOutHandlers(List<String> outHandlers) {
+        this.outHandlers = outHandlers;
+    }
+
+    public String getServiceName() {
+        return serviceName;
+    }
+
+    public void setServiceName(String serviceName) {
+        this.serviceName = serviceName;
+    }
+
+    public GFacNotifier getNotifier() {
+        return notifier;
+    }
+
+    public boolean isInPath() {
+        return inPath;
+    }
+
+    public boolean isOutPath(){
+        return !inPath;
+    }
+
+    public void setInPath() {
+        this.inPath = true;
+    }
+
+    public void setOutPath(){
+        this.inPath = false;
+    }
+}

Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/MessageContext.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/MessageContext.java?rev=1439743&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/MessageContext.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/MessageContext.java Tue Jan 29 03:57:41 2013
@@ -0,0 +1,50 @@
+/*
+ *
+ * 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.gfac.context;
+
+import org.apache.airavata.commons.gfac.type.ActualParameter;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class MessageContext extends AbstractContext {
+
+    private Map<String, Object> parameters;
+
+    public MessageContext(Map<String, Object> parameters){
+        this.parameters = parameters;
+    }
+
+    public MessageContext(){
+        this.parameters = new HashMap<String, Object>();
+    }
+
+    public Object getParameter(String parameterName) {
+        return parameters.get(parameterName);
+    }
+
+    public void addParameter(String name, Object value){
+        parameters.put(name, value);
+    }
+
+
+}

Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/SecurityContext.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/SecurityContext.java?rev=1439743&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/SecurityContext.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/context/SecurityContext.java Tue Jan 29 03:57:41 2013
@@ -0,0 +1,25 @@
+/*
+ *
+ * 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.gfac.context;
+
+public class SecurityContext extends AbstractContext {
+}

Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GFacHandler.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GFacHandler.java?rev=1439743&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GFacHandler.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GFacHandler.java Tue Jan 29 03:57:41 2013
@@ -0,0 +1,29 @@
+/*
+ *
+ * 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.gfac.handler;
+
+import org.apache.airavata.gfac.context.JobExecutionContext;
+
+public interface GFacHandler {
+
+    public void invoke(JobExecutionContext jobExecutionContext) throws GFacHandlerException;
+}

Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GFacHandlerException.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GFacHandlerException.java?rev=1439743&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GFacHandlerException.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/handler/GFacHandlerException.java Tue Jan 29 03:57:41 2013
@@ -0,0 +1,32 @@
+/*
+ *
+ * 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.gfac.handler;
+
+public class GFacHandlerException extends Exception{
+    public GFacHandlerException(String s) {
+        super(s);
+    }
+
+    public GFacHandlerException(String s, Throwable throwable) {
+        super(s, throwable);
+    }
+}

Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/GFacNotifier.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/GFacNotifier.java?rev=1439743&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/GFacNotifier.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/GFacNotifier.java Tue Jan 29 03:57:41 2013
@@ -0,0 +1,42 @@
+/*
+ *
+ * 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.gfac.notification;
+
+import com.google.common.eventbus.EventBus;
+import org.apache.airavata.gfac.notification.events.GFacEvent;
+
+public class GFacNotifier {
+    private EventBus eventBus;
+
+    public GFacNotifier(){
+        eventBus = new EventBus();
+    }
+
+    public void registerListener(Object listener){
+        eventBus.register(listener);
+    }
+
+    public void publish(GFacEvent event){
+        eventBus.post(event);
+    }
+
+}

Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/ExecutionFailEvent.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/ExecutionFailEvent.java?rev=1439743&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/ExecutionFailEvent.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/ExecutionFailEvent.java Tue Jan 29 03:57:41 2013
@@ -0,0 +1,35 @@
+/*
+ *
+ * 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.gfac.notification.events;
+
+public class ExecutionFailEvent extends GFacEvent {
+    private Throwable cause;
+
+    public ExecutionFailEvent(Throwable cause){
+        this.eventType = ExecutionFailEvent.class.getSimpleName();
+        this.cause = cause;
+    }
+
+    public Throwable getCauseForFailure(){
+        return cause;
+    }
+}

Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/FinishExecutionEvent.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/FinishExecutionEvent.java?rev=1439743&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/FinishExecutionEvent.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/FinishExecutionEvent.java Tue Jan 29 03:57:41 2013
@@ -0,0 +1,29 @@
+/*
+ *
+ * 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.gfac.notification.events;
+
+public class FinishExecutionEvent  extends GFacEvent{
+
+    public FinishExecutionEvent(){
+        this.eventType = FinishExecutionEvent.class.getSimpleName();
+    }
+}

Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/FinishScheduleEvent.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/FinishScheduleEvent.java?rev=1439743&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/FinishScheduleEvent.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/FinishScheduleEvent.java Tue Jan 29 03:57:41 2013
@@ -0,0 +1,29 @@
+/*
+ *
+ * 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.gfac.notification.events;
+
+public class FinishScheduleEvent extends GFacEvent {
+
+    public FinishScheduleEvent(){
+        this.eventType = FinishScheduleEvent.class.getSimpleName();
+    }
+}

Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/GFacEvent.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/GFacEvent.java?rev=1439743&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/GFacEvent.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/GFacEvent.java Tue Jan 29 03:57:41 2013
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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.gfac.notification.events;
+
+import org.apache.airavata.gfac.context.JobExecutionContext;
+
+public abstract class GFacEvent {
+
+    protected JobExecutionContext executionContext;
+
+    protected String eventType;
+
+    public JobExecutionContext getJobExecutionContext(){
+        return executionContext;
+    }
+
+    public String getEventType(){
+        return eventType;
+    }
+}

Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/StartExecutionEvent.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/StartExecutionEvent.java?rev=1439743&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/StartExecutionEvent.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/StartExecutionEvent.java Tue Jan 29 03:57:41 2013
@@ -0,0 +1,29 @@
+/*
+ *
+ * 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.gfac.notification.events;
+
+public class StartExecutionEvent extends GFacEvent {
+
+    public StartExecutionEvent(){
+        this.eventType = StartExecutionEvent.class.getSimpleName();
+    }
+}

Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/StartScheduleEvent.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/StartScheduleEvent.java?rev=1439743&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/StartScheduleEvent.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/events/StartScheduleEvent.java Tue Jan 29 03:57:41 2013
@@ -0,0 +1,29 @@
+/*
+ *
+ * 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.gfac.notification.events;
+
+public class StartScheduleEvent extends GFacEvent {
+
+    public StartScheduleEvent(){
+        this.eventType = StartScheduleEvent.class.getSimpleName();
+    }
+}

Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/listeners/LoggingListener.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/listeners/LoggingListener.java?rev=1439743&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/listeners/LoggingListener.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/listeners/LoggingListener.java Tue Jan 29 03:57:41 2013
@@ -0,0 +1,42 @@
+/*
+ *
+ * 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.gfac.notification.listeners;
+
+import com.google.common.eventbus.Subscribe;
+import org.apache.airavata.gfac.notification.events.ExecutionFailEvent;
+import org.apache.airavata.gfac.notification.events.GFacEvent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class LoggingListener {
+    private static Logger log = LoggerFactory.getLogger("gfac-logginglistener");
+
+    @Subscribe
+    public void logGFacEvent(GFacEvent e){
+        log.info("GFac event of type " + e.getEventType() + " received.");
+    }
+
+    @Subscribe
+    public void logExecutionFail(ExecutionFailEvent e){
+        log.error("Execution failed." + e.getEventType());
+    }
+}

Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/listeners/WorkflowTrackingListener.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/listeners/WorkflowTrackingListener.java?rev=1439743&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/listeners/WorkflowTrackingListener.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/notification/listeners/WorkflowTrackingListener.java Tue Jan 29 03:57:41 2013
@@ -0,0 +1,135 @@
+/*
+ *
+ * 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.gfac.notification.listeners;
+
+import com.google.common.eventbus.Subscribe;
+import org.apache.airavata.gfac.notification.events.*;
+import org.apache.airavata.workflow.tracking.Notifier;
+import org.apache.airavata.workflow.tracking.NotifierFactory;
+import org.apache.airavata.workflow.tracking.common.DurationObj;
+import org.apache.airavata.workflow.tracking.common.InvocationContext;
+import org.apache.airavata.workflow.tracking.common.InvocationEntity;
+import org.apache.airavata.workflow.tracking.common.WorkflowTrackingContext;
+
+import java.net.URI;
+import java.util.Properties;
+
+public class WorkflowTrackingListener {
+
+    private Notifier notifier;
+
+    private String topic;
+
+    private URI workflowID;
+
+    private WorkflowTrackingContext context;
+
+    private InvocationEntity initiator;
+
+    private InvocationEntity receiver;
+
+    private DurationObj duration;
+
+    private org.apache.airavata.workflow.tracking.common.InvocationContext invocationContext;
+
+    public WorkflowTrackingListener(String workflowID, String workflowNodeID, String brokerURL, String topic){
+        this.topic = topic;
+        this.workflowID = URI.create(this.topic);
+        this.notifier = NotifierFactory.createNotifier();
+        URI initiatorWorkflowID = URI.create(workflowID);
+        URI initiatorServiceID = URI.create(topic);
+        String initiatorWorkflowNodeID = workflowNodeID;
+        Integer initiatorWorkflowTimeStep = null;
+        this.context.setTopic(topic);
+
+        this.context = this.notifier.createTrackingContext(new Properties(), brokerURL, initiatorWorkflowID, initiatorServiceID,
+                initiatorWorkflowNodeID, initiatorWorkflowTimeStep);
+        this.initiator = this.notifier.createEntity(initiatorWorkflowID, initiatorServiceID, initiatorWorkflowNodeID,
+                initiatorWorkflowTimeStep);
+
+        URI receiverWorkflowID = this.workflowID;
+        URI receiverServiceID = this.workflowID;
+        String receiverWorkflowNodeID = null;
+        Integer receiverWorkflowTimeStep = null;
+
+        setReceiver(this.notifier.createEntity(receiverWorkflowID, receiverServiceID, receiverWorkflowNodeID,
+                receiverWorkflowTimeStep));
+        // send start workflow
+        this.invocationContext = this.notifier.workflowInvoked(this.context, this.initiator);
+    }
+
+
+
+    @Subscribe
+    public void startExecution(StartExecutionEvent e) {
+        this.duration = this.notifier.computationStarted();
+    }
+
+    @Subscribe
+    public void finishExecution(FinishExecutionEvent e) {
+        this.duration = this.notifier.computationFinished(this.context, this.duration);
+    }
+
+    @Subscribe
+    public void statusChanged(InvocationContext context, String... data) {
+        this.notifier.info(this.context, data);
+    }
+
+    @Subscribe
+    public void startSchedule(StartScheduleEvent e){
+        this.notifier.info(this.context,e.getEventType());
+    }
+
+    @Subscribe
+    public void executionFail(ExecutionFailEvent e) {
+        this.notifier.sendingFault(this.context, this.invocationContext, e.getCauseForFailure().getMessage());
+    }
+
+
+    @Subscribe
+    public void info(InvocationContext context, String... data) {
+        this.notifier.info(this.context, data);
+    }
+
+    @Subscribe
+    public void warning(InvocationContext context, String... data) {
+    }
+
+    @Subscribe
+    public void exception(InvocationContext context, String... data) {
+    }
+
+    @Subscribe
+    public void finishSchedule(FinishScheduleEvent e){
+        this.notifier.info(this.context,e.getEventType());
+    }
+
+
+    public InvocationEntity getReceiver() {
+        return receiver;
+    }
+
+    public void setReceiver(InvocationEntity receiver) {
+        this.receiver = receiver;
+    }
+
+}

Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/GFacProvider.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/GFacProvider.java?rev=1439743&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/GFacProvider.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/GFacProvider.java Tue Jan 29 03:57:41 2013
@@ -0,0 +1,49 @@
+/*
+ *
+ * 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.gfac.provider;
+
+import org.apache.airavata.gfac.context.JobExecutionContext;
+
+public interface GFacProvider {
+
+    /**
+     * Initialize environment required for invoking the execute method of the provider. If environment setup is
+     * done during the in handler execution, validation of environment will go here.
+     * @param jobExecutionContext containing job execution related information.
+     * @throws GFacProviderException in case of a error initializing the environment.
+     */
+    void initialize(JobExecutionContext jobExecutionContext) throws GFacProviderException;
+
+    /**
+     * Invoke the providers intended functionality using information and data in job execution context.
+     * @param jobExecutionContext containing job execution related information.
+     * @throws GFacProviderException in case of a error executing the job.
+     */
+    void execute(JobExecutionContext jobExecutionContext) throws GFacProviderException;
+
+    /**
+     * Cleans up the acquired resources during initialization and execution of the job.
+     * @param jobExecutionContext containing job execution related information.
+     * @throws GFacProviderException in case of a error cleaning resources.
+     */
+    void dispose(JobExecutionContext jobExecutionContext) throws GFacProviderException;
+}

Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/GFacProviderException.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/GFacProviderException.java?rev=1439743&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/GFacProviderException.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/GFacProviderException.java Tue Jan 29 03:57:41 2013
@@ -0,0 +1,55 @@
+/*
+ *
+ * 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.gfac.provider;
+
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.notification.events.ExecutionFailEvent;
+
+public class GFacProviderException extends Exception {
+
+    public GFacProviderException(String message) {
+        super(message);
+    }
+
+    public GFacProviderException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    public GFacProviderException(String message, Throwable cause,JobExecutionContext context) {
+        super(message, cause);
+        sendFaultNotification(message,context,new Exception(cause));
+    }
+
+    public GFacProviderException(String message, JobExecutionContext context) {
+        super(message);
+        sendFaultNotification(message,context,new Exception(message));
+    }
+
+    private void sendFaultNotification(String message,
+			JobExecutionContext executionContext, Exception e,
+			String... additionalExceptiondata) {
+		if (additionalExceptiondata==null || additionalExceptiondata.length==0){
+        	additionalExceptiondata=new String[]{message,e.getLocalizedMessage()};
+        }
+		executionContext.getNotifier().publish(new ExecutionFailEvent(e));
+	}
+}

Added: airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/LocalProvider.java
URL: http://svn.apache.org/viewvc/airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/LocalProvider.java?rev=1439743&view=auto
==============================================================================
--- airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/LocalProvider.java (added)
+++ airavata/trunk/modules/gfac-core/src/main/java/org/apache/airavata/gfac/provider/impl/LocalProvider.java Tue Jan 29 03:57:41 2013
@@ -0,0 +1,177 @@
+/*
+ *
+ * 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.gfac.provider.impl;
+
+import org.apache.airavata.commons.gfac.type.ActualParameter;
+import org.apache.airavata.gfac.Constants;
+import org.apache.airavata.gfac.context.JobExecutionContext;
+import org.apache.airavata.gfac.context.MessageContext;
+import org.apache.airavata.gfac.provider.GFacProvider;
+import org.apache.airavata.gfac.provider.GFacProviderException;
+import org.apache.airavata.gfac.utils.GFacUtils;
+import org.apache.airavata.gfac.utils.InputStreamToFileWriter;
+import org.apache.airavata.gfac.utils.InputUtils;
+import org.apache.airavata.gfac.utils.OutputUtils;
+import org.apache.airavata.schemas.gfac.ApplicationDeploymentDescriptionType;
+import org.apache.airavata.schemas.gfac.InputParameterType;
+import org.apache.airavata.schemas.gfac.NameValuePairType;
+import org.apache.xmlbeans.XmlException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+
+public class LocalProvider implements GFacProvider {
+    private static final Logger log = LoggerFactory.getLogger(LocalProvider.class);
+    private ProcessBuilder builder;
+    private List<String> cmdList;
+
+    public LocalProvider(){
+        cmdList = new ArrayList<String>();
+    }
+
+    public void initialize(JobExecutionContext jobExecutionContext) throws GFacProviderException {
+        ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext().
+                getApplicationDeploymentDescription().getType();
+
+        buildCommand(app.getExecutableLocation(), getInputParameters(jobExecutionContext));
+        initProcessBuilder(app);
+
+        // extra environment variables
+        builder.environment().put(Constants.INPUT_DATA_DIR_VAR_NAME, app.getInputDataDirectory());
+        builder.environment().put(Constants.OUTPUT_DATA_DIR_VAR_NAME, app.getOutputDataDirectory());
+
+        // set working directory
+        builder.directory(new File(app.getStaticWorkingDirectory()));
+
+        // log info
+        log.info("Command = " + InputUtils.buildCommand(cmdList));
+        log.info("Working dir = " + builder.directory());
+        for (String key : builder.environment().keySet()) {
+            log.info("Env[" + key + "] = " + builder.environment().get(key));
+        }
+    }
+
+    public void execute(JobExecutionContext jobExecutionContext) throws GFacProviderException {
+         ApplicationDeploymentDescriptionType app = jobExecutionContext.
+                 getApplicationContext().getApplicationDeploymentDescription().getType();
+
+        try {
+            // running cmd
+            Process process = builder.start();
+
+            Thread standardOutWriter = new InputStreamToFileWriter(process.getInputStream(), app.getStandardOutput());
+            Thread standardErrorWriter = new InputStreamToFileWriter(process.getErrorStream(), app.getStandardError());
+
+            // start output threads
+            standardOutWriter.setDaemon(true);
+            standardErrorWriter.setDaemon(true);
+            standardOutWriter.start();
+            standardErrorWriter.start();
+
+            // wait for the process (application) to finish executing
+            int returnValue = process.waitFor();
+
+            // make sure other two threads are done
+            standardOutWriter.join();
+            standardErrorWriter.join();
+
+            /*
+             * check return value. usually not very helpful to draw conclusions based on return values so don't bother.
+             * just provide warning in the log messages
+             */
+            if (returnValue != 0) {
+                log.error("Process finished with non zero return value. Process may have failed");
+            } else {
+                log.info("Process finished with return value of zero.");
+            }
+
+            StringBuffer buf = new StringBuffer();
+            buf.append("Executed ").append(InputUtils.buildCommand(cmdList))
+                    .append(" on the localHost, working directory = ").append(app.getStaticWorkingDirectory())
+                    .append(" tempDirectory = ").append(app.getScratchWorkingDirectory()).append(" With the status ")
+                    .append(String.valueOf(returnValue));
+
+            log.info(buf.toString());
+
+        } catch (IOException io) {
+            throw new GFacProviderException(io.getMessage(), io,jobExecutionContext);
+        } catch (InterruptedException e) {
+            throw new GFacProviderException(e.getMessage(), e, jobExecutionContext);
+        }
+    }
+
+    public void dispose(JobExecutionContext jobExecutionContext) throws GFacProviderException {
+        ApplicationDeploymentDescriptionType app = jobExecutionContext.getApplicationContext().getApplicationDeploymentDescription().getType();
+
+        try {
+            String stdOutStr = GFacUtils.readFileToString(app.getStandardOutput());
+            String stdErrStr = GFacUtils.readFileToString(app.getStandardError());
+            OutputUtils.fillOutputFromStdout(jobExecutionContext, stdOutStr, stdErrStr);
+        } catch (XmlException e) {
+            throw new GFacProviderException("Cannot read output:" + e.getMessage(), e, jobExecutionContext);
+        } catch (IOException io) {
+            throw new GFacProviderException(io.getMessage(), io, jobExecutionContext);
+        } catch (Exception e){
+        	throw new GFacProviderException("Error in retrieving results",e,jobExecutionContext);
+        }
+    }
+
+    // TODO: Move to right class based on future requirements.
+    private List<String> getInputParameters(JobExecutionContext jobExecutionContext) throws GFacProviderException {
+        List<String> parameters = new ArrayList<String>();
+        MessageContext inMessageContext = jobExecutionContext.getInMessageContext();
+
+        InputParameterType[] inputParamDefinitionArray = jobExecutionContext.getApplicationContext().
+                getServiceDescription().getType().getInputParametersArray();
+        for (InputParameterType inputParam : inputParamDefinitionArray) {
+            String parameterName = inputParam.getParameterName();
+            ActualParameter parameter = (ActualParameter)inMessageContext.getParameter(parameterName);
+            if(parameter == null){
+                throw new GFacProviderException("Cannot find required input parameter " + parameterName + ".");
+            }
+
+            parameters.add(parameter.toString());
+        }
+
+        return parameters;
+    }
+
+    private void buildCommand(String executable, List<String> inputParameterList){
+        cmdList.add(executable);
+        cmdList.addAll(inputParameterList);
+    }
+
+    private void initProcessBuilder(ApplicationDeploymentDescriptionType app){
+        builder = new ProcessBuilder(cmdList);
+
+        NameValuePairType[] env = app.getApplicationEnvironmentArray();
+
+        if(env != null && env.length > 0){
+            Map<String,String> builderEnv = builder.environment();
+            for (NameValuePairType entry : env) {
+                builderEnv.put(entry.getName(), entry.getValue());
+            }
+        }
+    }
+}