|
|||||||||||||||||||
| 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 | |||||||||||||||
| DeployTask.java | 0% | 0% | 0% | 0% |
|
||||||||||||||
| 1 |
/*
|
|
| 2 |
* $Id: DeployTask.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.io.File;
|
|
| 12 |
import java.util.ArrayList;
|
|
| 13 |
import java.util.Iterator;
|
|
| 14 |
import java.util.List;
|
|
| 15 |
import java.util.Vector;
|
|
| 16 |
|
|
| 17 |
import org.apache.tools.ant.BuildException;
|
|
| 18 |
import org.apache.tools.ant.DirectoryScanner;
|
|
| 19 |
import org.apache.tools.ant.Task;
|
|
| 20 |
import org.apache.tools.ant.types.FileSet;
|
|
| 21 |
import org.apache.tools.ant.util.FileUtils;
|
|
| 22 |
|
|
| 23 |
import bexee.admin.Admin;
|
|
| 24 |
import bexee.admin.AdminException;
|
|
| 25 |
|
|
| 26 |
/**
|
|
| 27 |
* Deploys a BPEL process to bexee.
|
|
| 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 DeployTask extends Task { |
|
| 34 |
|
|
| 35 |
private String url;
|
|
| 36 |
|
|
| 37 |
private File bpel;
|
|
| 38 |
|
|
| 39 |
private File wsdl;
|
|
| 40 |
|
|
| 41 |
private Vector partnerWSDL = new Vector(); |
|
| 42 |
|
|
| 43 |
/**
|
|
| 44 |
* BPEL file to deploy.
|
|
| 45 |
*
|
|
| 46 |
* @param bpel
|
|
| 47 |
* a <code>File</code>
|
|
| 48 |
*/
|
|
| 49 | 0 |
public void setBpel(File bpel) { |
| 50 | 0 |
this.bpel = bpel;
|
| 51 |
} |
|
| 52 |
|
|
| 53 |
/**
|
|
| 54 |
* Location of the Manager Web Service.
|
|
| 55 |
*
|
|
| 56 |
* @param url
|
|
| 57 |
* a <code>URL</code>
|
|
| 58 |
*/
|
|
| 59 | 0 |
public void setUrl(String url) { |
| 60 | 0 |
this.url = url;
|
| 61 |
} |
|
| 62 |
|
|
| 63 |
/**
|
|
| 64 |
* WSDL file describing the BPEL process.
|
|
| 65 |
*
|
|
| 66 |
* @param wsdl
|
|
| 67 |
* a <code>File</code>
|
|
| 68 |
*/
|
|
| 69 | 0 |
public void setWSDL(File wsdl) { |
| 70 | 0 |
this.wsdl = wsdl;
|
| 71 |
} |
|
| 72 |
|
|
| 73 |
/**
|
|
| 74 |
* Additional WSDL files describing partner Web Services.
|
|
| 75 |
*
|
|
| 76 |
* @param set
|
|
| 77 |
* <code>FileSet</code>
|
|
| 78 |
*/
|
|
| 79 | 0 |
public void addPartnerWSDL(FileSet set) { |
| 80 | 0 |
partnerWSDL.addElement(set); |
| 81 |
} |
|
| 82 |
|
|
| 83 |
/**
|
|
| 84 |
* Deploys the process to bexee.
|
|
| 85 |
*/
|
|
| 86 | 0 |
public void execute() throws BuildException { |
| 87 |
|
|
| 88 |
// check if the required parameter have been set
|
|
| 89 | 0 |
if (url == null || bpel == null || wsdl == null) { |
| 90 | 0 |
throw new BuildException("All of url, bpel and wsdl are required"); |
| 91 |
} |
|
| 92 |
|
|
| 93 |
// get partner wsdl files if any available
|
|
| 94 | 0 |
List partnerWSDL = getPartnerWSDL(); |
| 95 |
|
|
| 96 |
// create admin client with url to Manager service
|
|
| 97 | 0 |
Admin admin = new Admin(url);
|
| 98 |
|
|
| 99 |
// deploy to Manager
|
|
| 100 | 0 |
try {
|
| 101 | 0 |
String result = admin.deploy(bpel, wsdl, partnerWSDL); |
| 102 | 0 |
log(result); |
| 103 |
} catch (AdminException e) {
|
|
| 104 | 0 |
throw new BuildException(e); |
| 105 |
} |
|
| 106 |
} |
|
| 107 |
|
|
| 108 |
/**
|
|
| 109 |
* Helper method to get partner WSDL files.
|
|
| 110 |
*/
|
|
| 111 | 0 |
private List getPartnerWSDL() {
|
| 112 |
|
|
| 113 | 0 |
List result = new ArrayList();
|
| 114 |
|
|
| 115 |
// get partner wsdl files
|
|
| 116 | 0 |
FileUtils fileUtils = FileUtils.newFileUtils(); |
| 117 | 0 |
for (Iterator iter = partnerWSDL.iterator(); iter.hasNext();) {
|
| 118 |
|
|
| 119 | 0 |
FileSet fs = (FileSet) iter.next(); |
| 120 | 0 |
DirectoryScanner ds = fs.getDirectoryScanner(getProject()); |
| 121 |
|
|
| 122 | 0 |
String[] files = ds.getIncludedFiles(); |
| 123 | 0 |
File dir = fs.getDir(getProject()); |
| 124 | 0 |
for (int i = 0; i < files.length; i++) { |
| 125 | 0 |
String name = files[i]; |
| 126 | 0 |
if (!name.equals("")) { |
| 127 | 0 |
File file = fileUtils.resolveFile(dir, name); |
| 128 | 0 |
result.add(file); |
| 129 |
} |
|
| 130 |
} |
|
| 131 |
} |
|
| 132 |
|
|
| 133 | 0 |
return result;
|
| 134 |
} |
|
| 135 |
} |
|
||||||||||