Package org.apache.imperius.javaspl.samples.userdefinedmethods

Source Code of org.apache.imperius.javaspl.samples.userdefinedmethods.CommandLineExecution

/*
* 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. 
*/


/**
* @author Prashant Baliga <prabalig@in.ibm.com>
*
*/

package org.apache.imperius.javaspl.samples.userdefinedmethods;

import java.io.IOException;
import java.util.List;
import java.util.logging.Logger;

import org.apache.imperius.spl.core.Expression;
import org.apache.imperius.spl.core.TypeConstants;
import org.apache.imperius.spl.core.TypeInfo;
import org.apache.imperius.spl.parser.exceptions.SPLException;
import org.apache.imperius.spl.parser.util.TypeInfoImpl;
import org.apache.imperius.util.SPLLogger;



public class CommandLineExecution implements Expression
{

  private List inputParams =null;
  private static Logger logger = SPLLogger.getSPLLogger().getLogger();


  public CommandLineExecution(List input, boolean boo)
  {
    System.out.println(" creating sendMail action");
    this.inputParams=input;
  }
  public Object evaluate() throws SPLException
  {
   
    Expression commandExpression=(Expression)this.inputParams.get(0);
    Object command=commandExpression.evaluate();
    System.out.println("command :"+command);

    Runtime runtime=Runtime.getRuntime();
    try{
      runtime.exec((String)command);
      System.out.println("command execution completed :"+command);
      System.out.println("");

     
    }
    catch(IOException e){
      logger.severe(Thread.currentThread().getName()+" "+e.getMessage());
            e.printStackTrace();
    }
   
    return new Boolean(true);
  }




  public String getReferenceTypeName() throws SPLException {
    // TODO Auto-generated method stub
    return null;
  }

  public TypeInfo getType() throws SPLException {
    // TODO Auto-generated method stub
    return new TypeInfoImpl(TypeConstants.booleanType,null,false);
  }

  public boolean isArray() {
    // TODO Auto-generated method stub
    return false;
  }

  public boolean validate() throws SPLException {
    // TODO Auto-generated method stub
    return true;
  }

 

}
TOP

Related Classes of org.apache.imperius.javaspl.samples.userdefinedmethods.CommandLineExecution

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