|
|||||||||||||||||||
| 30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| StartTask.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 1 |
/*
|
|
| 2 |
* $Id: StartTask.java,v 1.1 2004/12/15 14:18:17 patforna Exp $
|
|
| 3 |
*
|
|
| 4 |
* Copyright (c) 2004 Patric Fornasier, Pawel Kowalski
|
|
| 5 |
* Berne University of Applied Sciences
|
|
| 6 |
* School of Engineering and Information Technology
|
|
| 7 |
* All rights reserved.
|
|
| 8 |
*/
|
|
| 9 |
package bexee.ant;
|
|
| 10 |
|
|
| 11 |
import java.rmi.RemoteException;
|
|
| 12 |
|
|
| 13 |
import javax.xml.rpc.ParameterMode;
|
|
| 14 |
import javax.xml.rpc.ServiceException;
|
|
| 15 |
|
|
| 16 |
import org.apache.axis.client.Call;
|
|
| 17 |
import org.apache.axis.client.Service;
|
|
| 18 |
import org.apache.axis.encoding.XMLType;
|
|
| 19 |
import org.apache.tools.ant.BuildException;
|
|
| 20 |
import org.apache.tools.ant.Task;
|
|
| 21 |
|
|
| 22 |
/**
|
|
| 23 |
* Starts a BPEL process on bexee.
|
|
| 24 |
* <p>
|
|
| 25 |
* Note that this Task is very primitive and supports only service operations
|
|
| 26 |
* that take a string parameter as input and return a string. It is only used
|
|
| 27 |
* for simple demonstration purposes.
|
|
| 28 |
*
|
|
| 29 |
* @version $Revision: 1.1 $, $Date: 2004/12/15 14:18:17 $
|
|
| 30 |
* @author Patric Fornasier
|
|
| 31 |
* @author Pawel Kowalski
|
|
| 32 |
*/
|
|
| 33 |
public class StartTask extends Task { |
|
| 34 |
|
|
| 35 |
private String url;
|
|
| 36 |
|
|
| 37 |
private String operation;
|
|
| 38 |
|
|
| 39 |
private String input;
|
|
| 40 |
|
|
| 41 |
/**
|
|
| 42 |
* Location of the BPEL process Web Service.
|
|
| 43 |
*
|
|
| 44 |
* @param url
|
|
| 45 |
* a <code>URL</code>
|
|
| 46 |
*/
|
|
| 47 | 0 |
public void setUrl(String url) { |
| 48 | 0 |
this.url = url;
|
| 49 |
} |
|
| 50 |
|
|
| 51 |
/**
|
|
| 52 |
* Name of the operation to perform
|
|
| 53 |
*
|
|
| 54 |
* @param operation
|
|
| 55 |
* a <code>String</code>
|
|
| 56 |
*/
|
|
| 57 | 0 |
public void setOperation(String operation) { |
| 58 | 0 |
this.operation = operation;
|
| 59 |
} |
|
| 60 |
|
|
| 61 |
/**
|
|
| 62 |
* The input value to pass to the process.
|
|
| 63 |
*
|
|
| 64 |
* @param input
|
|
| 65 |
* a <code>String</code>
|
|
| 66 |
*/
|
|
| 67 | 0 |
public void setInput(String input) { |
| 68 | 0 |
this.input = input;
|
| 69 |
} |
|
| 70 |
|
|
| 71 |
/**
|
|
| 72 |
* Starts the process on bexee.
|
|
| 73 |
*/
|
|
| 74 | 0 |
public void execute() throws BuildException { |
| 75 |
|
|
| 76 |
// check if the required parameter have been set
|
|
| 77 | 0 |
if (url == null || operation == null || input == null) { |
| 78 | 0 |
throw new BuildException("All of url, operation and value required"); |
| 79 |
} |
|
| 80 |
|
|
| 81 | 0 |
Service service = new Service();
|
| 82 | 0 |
Call call = null;
|
| 83 | 0 |
try {
|
| 84 | 0 |
call = (Call) service.createCall(); |
| 85 | 0 |
call.setTargetEndpointAddress(url); |
| 86 | 0 |
call.setOperation(operation); |
| 87 | 0 |
call.addParameter("x", XMLType.XSD_STRING, ParameterMode.IN);
|
| 88 | 0 |
call.setReturnType(XMLType.XSD_STRING); |
| 89 |
} catch (ServiceException e) {
|
|
| 90 | 0 |
throw new BuildException("Unable to create call", e); |
| 91 |
} |
|
| 92 |
|
|
| 93 | 0 |
try {
|
| 94 | 0 |
String result = (String) call.invoke(new Object[] { input });
|
| 95 | 0 |
log(result); |
| 96 |
} catch (RemoteException e) {
|
|
| 97 | 0 |
throw new BuildException("Unable to invoke service", e); |
| 98 |
} |
|
| 99 |
} |
|
| 100 |
} |
|
||||||||||