1.1 --- a/bpel.project/antsrc/org/netbeans/modules/bpel/project/antlib.xml Fri May 11 13:30:46 2007 +0000
1.2 +++ b/bpel.project/antsrc/org/netbeans/modules/bpel/project/antlib.xml Fri May 11 13:40:22 2007 +0000
1.3 @@ -17,8 +17,7 @@
1.4 Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
1.5 Microsystems, Inc. All Rights Reserved.
1.6 -->
1.7 - <antlib>
1.8 - <typedef name="BpelProjectJBIGen" classname="org.netbeans.modules.bpel.project.anttasks.IDEGenerateJBIDescriptor"/>
1.9 - <typedef name="BpelProjectValidate" classname="org.netbeans.modules.bpel.project.anttasks.IDEValidateBPELProject"/>
1.10 -
1.11 - </antlib>
1.12 +<antlib>
1.13 + <typedef name="BpelProjectJBIGen" classname="org.netbeans.modules.bpel.project.anttasks.IDEGenerateJBIDescriptor"/>
1.14 + <typedef name="BpelProjectValidate" classname="org.netbeans.modules.bpel.project.anttasks.IDEValidateBPELProject"/>
1.15 +</antlib>
2.1 --- a/bpel.project/antsrc/org/netbeans/modules/bpel/project/anttasks/DependentProjectsFileExtractor.java Fri May 11 13:30:46 2007 +0000
2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
2.3 @@ -1,499 +0,0 @@
2.4 -/*
2.5 - * The contents of this file are subject to the terms of the Common Development
2.6 - * and Distribution License (the License). You may not use this file except in
2.7 - * compliance with the License.
2.8 - *
2.9 - * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
2.10 - * or http://www.netbeans.org/cddl.txt.
2.11 - *
2.12 - * When distributing Covered Code, include this CDDL Header Notice in each file
2.13 - * and include the License file at http://www.netbeans.org/cddl.txt.
2.14 - * If applicable, add the following below the CDDL Header, with the fields
2.15 - * enclosed by brackets [] replaced by your own identifying information:
2.16 - * "Portions Copyrighted [year] [name of copyright owner]"
2.17 - *
2.18 - * The Original Software is NetBeans. The Initial Developer of the Original
2.19 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
2.20 - * Microsystems, Inc. All Rights Reserved.
2.21 - */
2.22 -
2.23 -package org.netbeans.modules.bpel.project.anttasks;
2.24 -
2.25 -import java.io.BufferedInputStream;
2.26 -import java.io.BufferedOutputStream;
2.27 -import java.io.File;
2.28 -import java.io.FileFilter;
2.29 -import java.io.FileInputStream;
2.30 -import java.io.FileOutputStream;
2.31 -import java.io.FileReader;
2.32 -import java.util.ArrayList;
2.33 -import java.util.Iterator;
2.34 -import java.util.List;
2.35 -import java.util.StringTokenizer;
2.36 -
2.37 -import org.apache.tools.ant.BuildException;
2.38 -import org.apache.tools.ant.Task;
2.39 -
2.40 -/*
2.41 -import org.netbeans.modules.compapp.models.bpelmodel.BPELDocument;
2.42 -import org.netbeans.modules.compapp.models.bpelmodel.BPELDocumentParseFactory;
2.43 -import org.netbeans.modules.compapp.models.bpelmodel.BPELParseContext;
2.44 -import org.netbeans.modules.compapp.models.bpelmodel.Import;
2.45 -import org.netbeans.modules.compapp.models.bpelmodel.ProjectBasedWSDLResolver;
2.46 -import org.netbeans.modules.compapp.models.bpelmodel.ProjectBasedWSDLResolverFactory;
2.47 -import org.netbeans.modules.compapp.models.bpelmodel.ProjectBasedXSDResolver;
2.48 -import org.netbeans.modules.compapp.models.bpelmodel.ProjectBasedXSDResolverFactory;
2.49 -import org.netbeans.modules.compapp.models.wsdlmodel.FastWSDLDefinitions;
2.50 -import org.netbeans.modules.compapp.models.wsdlmodel.FastWSDLDefinitionsFactory;
2.51 -*/
2.52 -
2.53 -/**
2.54 - * @author radval
2.55 - *
2.56 - * Ant task to extract wsdl/xsd from dependent projects.
2.57 - */
2.58 -public class DependentProjectsFileExtractor extends Task {
2.59 -
2.60 - private static final String WSDL_FILE_EXTENSION = "wsdl";
2.61 -
2.62 - private static final String XSD_FILE_EXTENSION = "xsd";
2.63 -
2.64 - private static final String BPEL_FILE_EXTENSION = "bpel";
2.65 -
2.66 -
2.67 - private String mBuildDirectory;
2.68 -
2.69 - private String mProjectDirectory;
2.70 -
2.71 - private String mProjectClassPath;
2.72 -
2.73 - private String mSourceDirectory;
2.74 -
2.75 - private File mProjectSrcDir;
2.76 -
2.77 - private File mBuildDir;
2.78 -
2.79 - private List mDependentProjectSourceDirs;
2.80 -
2.81 -
2.82 - // private static ProjectFileFilter projectFileFilter = new ProjectFileFilter();
2.83 -
2.84 - // private static BpelFileFilter bpelFileFilter = new BpelFileFilter();
2.85 -
2.86 - public void setBuildDirectory(String buildDirectory) {
2.87 - this.mBuildDirectory = buildDirectory;
2.88 - }
2.89 -
2.90 - public void setSourceDirectory(String srcDir) {
2.91 - this.mSourceDirectory = srcDir;
2.92 - }
2.93 -
2.94 - public void setProjectClassPath(String projectClassPath) {
2.95 - this.mProjectClassPath = projectClassPath;
2.96 - }
2.97 -
2.98 - public void setProjectDirectory(String srcDir) {
2.99 - this.mProjectDirectory = srcDir;
2.100 - }
2.101 -
2.102 - public void execute() throws BuildException {
2.103 -/*
2.104 - if(this.mBuildDirectory == null
2.105 - || this.mBuildDirectory.trim().equals("")) {
2.106 - throw new BuildException("Missing build directory.");
2.107 - }
2.108 -
2.109 - if(this.mProjectDirectory == null) {
2.110 - throw new BuildException("No project directory is set.");
2.111 - }
2.112 -
2.113 - File projectDirectory = null;
2.114 -
2.115 - //create file object for project source directory
2.116 - try {
2.117 - projectDirectory = new File(this.mProjectDirectory);
2.118 - } catch(Exception ex) {
2.119 - throw new BuildException("Failed to get File object for project directory "+ this.mProjectDirectory, ex);
2.120 - }
2.121 -
2.122 -// create file object for project source directory
2.123 - try {
2.124 - this.mProjectSrcDir = new File(this.mSourceDirectory);
2.125 - } catch(Exception ex) {
2.126 - throw new BuildException("Failed to get File object for project source directory "+ this.mSourceDirectory, ex);
2.127 - }
2.128 -
2.129 -// read project classpath
2.130 - //TODO: refactor this to use wsdl classpath
2.131 - this.mDependentProjectSourceDirs = new ArrayList();
2.132 - if(this.mProjectClassPath != null
2.133 - && !this.mProjectClassPath.trim().equals("")
2.134 - && !this.mProjectClassPath.trim().equals("${javac.classpath}")) {
2.135 - StringTokenizer st = new StringTokenizer(this.mProjectClassPath, ";");
2.136 - while (st.hasMoreTokens()) {
2.137 - String spath = st.nextToken();
2.138 - try {
2.139 -
2.140 - File sFile = new File(projectDirectory.getCanonicalPath() + File.separator + spath);
2.141 -
2.142 - File srcFolder = new File(sFile.getParentFile().getParentFile().getCanonicalFile(), "src");
2.143 - this.mDependentProjectSourceDirs.add(srcFolder);
2.144 - } catch(Exception ex) {
2.145 - throw new BuildException("Failed to create File object for dependent project path "+ spath);
2.146 - }
2.147 - }
2.148 - }
2.149 -
2.150 - this.mBuildDir = new File(this.mBuildDirectory);
2.151 -
2.152 -// Iterator it = this.mDependentProjectSourceDirs.iterator();
2.153 -// while(it.hasNext()) {
2.154 -// File pDir = (File) it.next();
2.155 -// processDirectory(pDir, this.mBuildDir, this.mProjectSrcDir);
2.156 -// }
2.157 - ArrayList projectSourceDirs = new ArrayList();
2.158 - projectSourceDirs.add(this.mProjectSrcDir);
2.159 - processBpelFiles(projectSourceDirs, this.mDependentProjectSourceDirs);
2.160 -*/
2.161 - }
2.162 -/*
2.163 - private void processBpelFiles(List projectSourceDirs,
2.164 - List dependProjectSourceDirs) {
2.165 -
2.166 - Iterator it = projectSourceDirs.iterator();
2.167 - while(it.hasNext()) {
2.168 - File srcDir = (File) it.next();
2.169 - processBpelFiles(srcDir, dependProjectSourceDirs);
2.170 - }
2.171 - }
2.172 -
2.173 - private void processBpelFiles(File dir, List depedentProjectSourceDirs) {
2.174 - File[] children = dir.listFiles(bpelFileFilter);
2.175 - for(int i = 0; i < children.length; i++) {
2.176 - File child = children[i];
2.177 - if(child.isDirectory()) {
2.178 - processBpelFiles(child, depedentProjectSourceDirs);
2.179 - } else {
2.180 - //load existing bpel file
2.181 - BPELDocument document = loadExistingBusinessProcess(child);
2.182 - if(document != null) {
2.183 - List imports = document.getDocumentProcess().getImports();
2.184 -
2.185 - Iterator it = imports.iterator();
2.186 - while(it.hasNext()) {
2.187 - Import imp = (Import) it.next();
2.188 - //is this imported file already available in current project
2.189 - //the we do nothing
2.190 - boolean isExists = isFileAvailableInCurrentProject(imp, this.mProjectSrcDir);
2.191 - if(isExists) {
2.192 - continue;
2.193 - } else {
2.194 - extractImportedFileFromDepedentProject(imp, this.mDependentProjectSourceDirs);
2.195 - }
2.196 - }
2.197 - }
2.198 - }
2.199 - }
2.200 - }
2.201 -
2.202 - private boolean isFileAvailableInCurrentProject(Import imp, File dir) {
2.203 - boolean result = false;
2.204 - String location = imp.getLocation();
2.205 -
2.206 - File[] children = dir.listFiles(projectFileFilter);
2.207 - for(int i =0; i < children.length; i++) {
2.208 - File child = children[i];
2.209 - if(child.isDirectory()) {
2.210 - result = isFileAvailableInCurrentProject(imp, child);
2.211 - } else if(location.equals(child.getName())) {
2.212 - result = true;
2.213 - }
2.214 -
2.215 - if(result) {
2.216 - break;
2.217 - }
2.218 - }
2.219 -
2.220 - return result;
2.221 - }
2.222 -
2.223 - private void extractImportedFileFromDepedentProject(Import imp, List dependentProjectSourceDirs) {
2.224 - Iterator it = dependentProjectSourceDirs.iterator();
2.225 - while(it.hasNext()) {
2.226 - File dDir = (File) it.next();
2.227 - extractImportedFileFromDepedentProject(imp, dDir);
2.228 - }
2.229 -
2.230 - }
2.231 -
2.232 - private void extractImportedFileFromDepedentProject(Import imp, File dependentProjectSourceDir) {
2.233 - String location = imp.getLocation();
2.234 - boolean isWsdlFile = false;
2.235 - if(Import.WSDL_IMPORT_TYPE.equals(location)) {
2.236 - extractWsdlFromDependentProject(imp, dependentProjectSourceDir);
2.237 - } else {
2.238 - extractXsdFromDepedentProject(imp, dependentProjectSourceDir);
2.239 - }
2.240 -
2.241 - }
2.242 -
2.243 - private void extractWsdlFromDependentProject(Import imp, File dSrcDir) {
2.244 - String fileName = imp.getLocation();
2.245 - File[] children = dSrcDir.listFiles(projectFileFilter);
2.246 - for(int i =0; i < children.length; i++) {
2.247 - File from = children[i];
2.248 - if(from.isDirectory()) {
2.249 - extractWsdlFromDependentProject(imp, from);
2.250 - } else if(from.getName().equals(fileName)) {
2.251 - File to = new File(this.mBuildDir, from.getName());
2.252 - //if file exists log to user, it means we are trying to import
2.253 - //same file in two different bpel.
2.254 - if(to.exists()) {
2.255 - //throw new BuildException("Can not extract file "+ to + " to " + buildDir + ", A file already exist with this name.");
2.256 - this.log("Skipping File "+ to.getName() + ", a file with this name has already been extracted in "+ mBuildDir);
2.257 - continue;
2.258 - }
2.259 -
2.260 - try {
2.261 - writeToFile(from, to);
2.262 -
2.263 - //now load fastwsdl definitions
2.264 - //and also look for import within a wsdl
2.265 - FastWSDLDefinitions def =
2.266 - FastWSDLDefinitionsFactory.getInstance().newFastWSDLDefinitions(from.getAbsolutePath(), true);
2.267 - if(def.getParseErrorMessage() != null) {
2.268 - throw new BuildException(def.getParseErrorMessage());
2.269 - }
2.270 - Iterator it = def.getImports().iterator();
2.271 - while(it.hasNext()) {
2.272 - Import im = (Import) it.next();
2.273 - //TODO: we need to also look for files in any dependent project
2.274 - //of this dependent project
2.275 - extractImportedFileFromDepedentProject(im, dSrcDir);
2.276 - }
2.277 - } catch(Exception ex) {
2.278 - throw new BuildException("Error writing to file "+ to, ex);
2.279 - }
2.280 - }
2.281 - }
2.282 - }
2.283 -
2.284 - private void extractXsdFromDepedentProject(Import imp, File dSrcDir) {
2.285 - String fileName = imp.getLocation();
2.286 - File[] children = dSrcDir.listFiles(projectFileFilter);
2.287 - for(int i =0; i < children.length; i++) {
2.288 - File from = children[i];
2.289 - if(from.isDirectory()) {
2.290 - extractXsdFromDepedentProject(imp, from);
2.291 - } else if(from.getName().equals(fileName)) {
2.292 - File to = new File(this.mBuildDir, from.getName());
2.293 - //if file exists log to user, it means we are trying to import
2.294 - //same file in two different bpel.
2.295 - if(to.exists()) {
2.296 - //throw new BuildException("Can not extract file "+ to + " to " + buildDir + ", A file already exist with this name.");
2.297 - this.log("Skipping File "+ to.getName() + ", a file with this name has already been extracted in "+ mBuildDir);
2.298 - continue;
2.299 - }
2.300 -
2.301 - try {
2.302 - writeToFile(from, to);
2.303 -
2.304 -// //now load fastxsd
2.305 -// //and also look for import within an xsd
2.306 -// FastWSDLDefinitions def =
2.307 -// FastWSDLDefinitionsFactory.getInstance().newFastWSDLDefinitions(from.getAbsolutePath(), true);
2.308 -// if(def.getParseErrorMessage() != null) {
2.309 -// throw new BuildException(def.getParseErrorMessage());
2.310 -// }
2.311 -// Iterator it = def.getImports().iterator();
2.312 -// while(it.hasNext()) {
2.313 -// Import im = (Import) it.next();
2.314 -// //TODO: we need to also look for files in any dependent project
2.315 -// //of this dependent project
2.316 -// extractImportedFileFromDepedentProject(im, dSrcDir);
2.317 -// }
2.318 -
2.319 -// File projectDir = dSrcDir.getParentFile();
2.320 -// findProjectClasspath(projectDir);
2.321 - } catch(Exception ex) {
2.322 - throw new BuildException("Error writing to file "+ to, ex);
2.323 - }
2.324 - }
2.325 - }
2.326 - }
2.327 -
2.328 - private void extractFileFromDepedentProject(String fileName, File dSrcDir) {
2.329 - File[] children = dSrcDir.listFiles(projectFileFilter);
2.330 - for(int i =0; i < children.length; i++) {
2.331 - File from = children[i];
2.332 - if(from.isDirectory()) {
2.333 - extractFileFromDepedentProject(fileName, from);
2.334 - } else if(from.getName().equals(fileName)) {
2.335 - File to = new File(this.mBuildDir, from.getName());
2.336 - //if file exists log to user, it means we are trying to import
2.337 - //same file in two different bpel.
2.338 - if(to.exists()) {
2.339 - //throw new BuildException("Can not extract file "+ to + " to " + buildDir + ", A file already exist with this name.");
2.340 - this.log("Skipping File "+ to.getName() + ", a file with this name has already been extracted in "+ mBuildDir);
2.341 - continue;
2.342 - }
2.343 -
2.344 - try {
2.345 - writeToFile(from, to);
2.346 - } catch(Exception ex) {
2.347 - throw new BuildException("Error writing to file "+ to, ex);
2.348 - }
2.349 - }
2.350 - }
2.351 - }
2.352 -
2.353 - private void processDirectory(File depedentProjectSrcDir, File buildDir, File sourceDirectory) {
2.354 - File[] children = depedentProjectSrcDir.listFiles(projectFileFilter);
2.355 - for(int i =0; i < children.length; i++) {
2.356 - File from = children[i];
2.357 -
2.358 - File to = new File(buildDir, from.getName());
2.359 - //if file exists throw exception
2.360 - if(to.exists()) {
2.361 - //throw new BuildException("Can not extract file "+ to + " to " + buildDir + ", A file already exist with this name.");
2.362 - this.log("Skipping File "+ to.getName() + ", a file with this name has already been extracted in "+ buildDir);
2.363 - continue;
2.364 - } else if(isFileExist(sourceDirectory, to.getName())) {
2.365 - this.log("Skipping File "+ to.getName() + ", a file with this name already exists in project source directory "+ sourceDirectory);
2.366 - continue;
2.367 - }
2.368 -
2.369 - try {
2.370 - writeToFile(from, to);
2.371 - } catch(Exception ex) {
2.372 - throw new BuildException("Error writing to file "+ to, ex);
2.373 - }
2.374 - }
2.375 -
2.376 -
2.377 - }
2.378 -
2.379 - private boolean isFileExist(File SourceDirectory, String fileName) {
2.380 - boolean result = false;
2.381 - File[] children = SourceDirectory.listFiles(projectFileFilter);
2.382 - for(int i = 0; i < children.length; i++) {
2.383 - File child = children[i];
2.384 - if(child.getName().equals(fileName)) {
2.385 - result = true;
2.386 - break;
2.387 - }
2.388 - }
2.389 -
2.390 - return result;
2.391 - }
2.392 -
2.393 - private void writeToFile(File from, File to) throws Exception {
2.394 - BufferedInputStream bIn = new BufferedInputStream( new FileInputStream(from));
2.395 - BufferedOutputStream bOut = new BufferedOutputStream(new FileOutputStream(to));
2.396 -
2.397 - byte[] buf = new byte[10000];
2.398 -
2.399 - int state = 0;
2.400 -
2.401 - while(state != -1) {
2.402 - state = bIn.read(buf);
2.403 - bOut.write(buf);
2.404 - }
2.405 -
2.406 - bOut.flush();
2.407 - bOut.close();
2.408 - }
2.409 -
2.410 - private BPELDocument loadExistingBusinessProcess(File bpelFile) throws BuildException {
2.411 - BPELDocument document = null;
2.412 - try {
2.413 - FileReader fReader = new FileReader(new File(bpelFile.getPath()));
2.414 - BPELParseContext parseContext = new BPELParseContext.DefaultParseContext();
2.415 - ProjectBasedWSDLResolver wsdlLoader = ProjectBasedWSDLResolverFactory.getInstance().newWSDLResolver(bpelFile.toURI().toString(), parseContext);
2.416 - parseContext.setWSDLResolver(wsdlLoader);
2.417 -
2.418 - ProjectBasedXSDResolver xsdResolver = ProjectBasedXSDResolverFactory.getInstance().newXSDResolver(bpelFile.toURI().toString(), parseContext);
2.419 - parseContext.setXSDResolver(xsdResolver);
2.420 -
2.421 - //do not load imported schemas
2.422 - parseContext.setLoadOnlyPartnersAndImports(true);
2.423 - parseContext.setLoadImportedWsdls(false);
2.424 - parseContext.setLoadImportedXsds(false);
2.425 - parseContext.getWSDLParseContext().setParseInlineSchema(false);
2.426 - parseContext.getWSDLParseContext().setParseImportedSchemas(false);
2.427 - parseContext.getWSDLParseContext().setEnableEvents(false);
2.428 - parseContext.setEnableEvents(false);
2.429 -
2.430 - document = BPELDocumentParseFactory.getInstance().load(fReader, parseContext);
2.431 -
2.432 - } catch (Exception ex) {
2.433 - throw new BuildException ("Failed to load bpel process " + bpelFile.getPath(), ex);
2.434 - }
2.435 - return document;
2.436 - }
2.437 -
2.438 -// private String findProjectClasspath(File projectDir) {
2.439 -// String projectClasspath = null;
2.440 -//
2.441 -// Project project = new Project();
2.442 -// project.init();
2.443 -// File buildFile = new File(projectDir, "build.xml");
2.444 -// ProjectHelper pHelper = ProjectHelper.getProjectHelper();
2.445 -// pHelper.parse(project, buildFile);
2.446 -//
2.447 -// //now look for "javac.classpath"
2.448 -// projectClasspath = project.getProperty("javac.classpath");
2.449 -//
2.450 -// System.out.println("project classpath "+ projectClasspath );
2.451 -// return projectClasspath;
2.452 -// }
2.453 -
2.454 - static class ProjectFileFilter implements FileFilter {
2.455 -
2.456 - public boolean accept(File pathname) {
2.457 - boolean result = false;
2.458 - if(pathname.isDirectory()) {
2.459 - return true;
2.460 - }
2.461 -
2.462 - String fileName = pathname.getName();
2.463 - String fileExtension = null;
2.464 - int dotIndex = fileName.lastIndexOf('.');
2.465 - if(dotIndex != -1) {
2.466 - fileExtension = fileName.substring(dotIndex +1);
2.467 - }
2.468 -
2.469 - if(fileExtension != null
2.470 - && (fileExtension.equalsIgnoreCase(WSDL_FILE_EXTENSION) || fileExtension.equalsIgnoreCase(XSD_FILE_EXTENSION))) {
2.471 - result = true;
2.472 - }
2.473 -
2.474 - return result;
2.475 - }
2.476 - }
2.477 -
2.478 - static class BpelFileFilter implements FileFilter {
2.479 -
2.480 - public boolean accept(File pathname) {
2.481 - boolean result = false;
2.482 - if(pathname.isDirectory()) {
2.483 - return true;
2.484 - }
2.485 -
2.486 - String fileName = pathname.getName();
2.487 - String fileExtension = null;
2.488 - int dotIndex = fileName.lastIndexOf('.');
2.489 - if(dotIndex != -1) {
2.490 - fileExtension = fileName.substring(dotIndex +1);
2.491 - }
2.492 -
2.493 - if(fileExtension != null
2.494 - && (fileExtension.equalsIgnoreCase(BPEL_FILE_EXTENSION))) {
2.495 - result = true;
2.496 - }
2.497 -
2.498 - return result;
2.499 - }
2.500 - }
2.501 -*/
2.502 -}
3.1 --- a/bpel.project/antsrc/org/netbeans/modules/bpel/project/anttasks/ExternalProjectsFileExtractor.java Fri May 11 13:30:46 2007 +0000
3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
3.3 @@ -1,508 +0,0 @@
3.4 -/*
3.5 - * The contents of this file are subject to the terms of the Common Development
3.6 - * and Distribution License (the License). You may not use this file except in
3.7 - * compliance with the License.
3.8 - *
3.9 - * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
3.10 - * or http://www.netbeans.org/cddl.txt.
3.11 - *
3.12 - * When distributing Covered Code, include this CDDL Header Notice in each file
3.13 - * and include the License file at http://www.netbeans.org/cddl.txt.
3.14 - * If applicable, add the following below the CDDL Header, with the fields
3.15 - * enclosed by brackets [] replaced by your own identifying information:
3.16 - * "Portions Copyrighted [year] [name of copyright owner]"
3.17 - *
3.18 - * The Original Software is NetBeans. The Initial Developer of the Original
3.19 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
3.20 - * Microsystems, Inc. All Rights Reserved.
3.21 - */
3.22 -
3.23 -package org.netbeans.modules.bpel.project.anttasks;
3.24 -
3.25 -import java.io.BufferedInputStream;
3.26 -import java.io.BufferedOutputStream;
3.27 -import java.io.File;
3.28 -import java.io.FileFilter;
3.29 -import java.io.FileInputStream;
3.30 -import java.io.FileOutputStream;
3.31 -import java.io.FileReader;
3.32 -import java.io.InputStream;
3.33 -import java.util.ArrayList;
3.34 -import java.util.Enumeration;
3.35 -import java.util.Iterator;
3.36 -import java.util.List;
3.37 -import java.util.StringTokenizer;
3.38 -import java.util.jar.JarFile;
3.39 -import java.util.zip.ZipEntry;
3.40 -
3.41 -import org.apache.tools.ant.BuildException;
3.42 -import org.apache.tools.ant.Task;
3.43 -
3.44 -/*
3.45 -import org.netbeans.modules.compapp.models.bpelmodel.BPELDocument;
3.46 -import org.netbeans.modules.compapp.models.bpelmodel.BPELDocumentParseFactory;
3.47 -import org.netbeans.modules.compapp.models.bpelmodel.BPELParseContext;
3.48 -import org.netbeans.modules.compapp.models.bpelmodel.Import;
3.49 -import org.netbeans.modules.compapp.models.bpelmodel.ProjectBasedWSDLResolver;
3.50 -import org.netbeans.modules.compapp.models.bpelmodel.ProjectBasedWSDLResolverFactory;
3.51 -import org.netbeans.modules.compapp.models.bpelmodel.ProjectBasedXSDResolver;
3.52 -import org.netbeans.modules.compapp.models.bpelmodel.ProjectBasedXSDResolverFactory;
3.53 -import org.netbeans.modules.compapp.models.wsdlmodel.FastWSDLDefinitions;
3.54 -import org.netbeans.modules.compapp.models.wsdlmodel.FastWSDLDefinitionsFactory;
3.55 -*/
3.56 -
3.57 -/**
3.58 - * @author radval
3.59 - *
3.60 - * Ant task to extract wsdl/xsd from dependent projects.
3.61 - */
3.62 -public class ExternalProjectsFileExtractor extends Task {
3.63 -
3.64 - private static final String WSDL_FILE_EXTENSION = "wsdl";
3.65 -
3.66 - private static final String XSD_FILE_EXTENSION = "xsd";
3.67 -
3.68 - private static final String BPEL_FILE_EXTENSION = "bpel";
3.69 -
3.70 -
3.71 - private String mBuildDirectory;
3.72 -
3.73 - private String mProjectDirectory;
3.74 -
3.75 - private String mProjectClassPath;
3.76 -
3.77 - private String mSourceDirectory;
3.78 -
3.79 - private File mProjectSrcDir;
3.80 -
3.81 - private File mBuildDir;
3.82 -
3.83 - private List mDependentProjectArtifactJars;
3.84 -
3.85 -
3.86 - // private static ProjectFileFilter projectFileFilter = new ProjectFileFilter();
3.87 -
3.88 - // private static BpelFileFilter bpelFileFilter = new BpelFileFilter();
3.89 -
3.90 - public void setBuildDirectory(String buildDirectory) {
3.91 - this.mBuildDirectory = buildDirectory;
3.92 - }
3.93 -
3.94 - public void setSourceDirectory(String srcDir) {
3.95 - this.mSourceDirectory = srcDir;
3.96 - }
3.97 -
3.98 - public void setProjectClassPath(String projectClassPath) {
3.99 - this.mProjectClassPath = projectClassPath;
3.100 - }
3.101 -
3.102 - public void setProjectDirectory(String srcDir) {
3.103 - this.mProjectDirectory = srcDir;
3.104 - }
3.105 -
3.106 - public void execute() throws BuildException {
3.107 -/*
3.108 - if(this.mBuildDirectory == null
3.109 - || this.mBuildDirectory.trim().equals("")) {
3.110 - throw new BuildException("Missing build directory.");
3.111 - }
3.112 -
3.113 - if(this.mProjectDirectory == null) {
3.114 - throw new BuildException("No project directory is set.");
3.115 - }
3.116 -
3.117 - File projectDirectory = null;
3.118 -
3.119 - //create file object for project source directory
3.120 - try {
3.121 - projectDirectory = new File(this.mProjectDirectory);
3.122 - } catch(Exception ex) {
3.123 - throw new BuildException("Failed to get File object for project directory "+ this.mProjectDirectory, ex);
3.124 - }
3.125 -
3.126 -// create file object for project source directory
3.127 - try {
3.128 - this.mProjectSrcDir = new File(this.mSourceDirectory);
3.129 - } catch(Exception ex) {
3.130 - throw new BuildException("Failed to get File object for project source directory "+ this.mSourceDirectory, ex);
3.131 - }
3.132 -
3.133 -// read project classpath
3.134 - //TODO: refactor this to use wsdl classpath
3.135 - this.mDependentProjectArtifactJars = new ArrayList();
3.136 - if(this.mProjectClassPath != null
3.137 - && !this.mProjectClassPath.trim().equals("")
3.138 - && !this.mProjectClassPath.trim().equals("${javac.classpath}")) {
3.139 - StringTokenizer st = new StringTokenizer(this.mProjectClassPath, ";");
3.140 - while (st.hasMoreTokens()) {
3.141 - String spath = st.nextToken();
3.142 - try {
3.143 -
3.144 - File jarFile = new File(projectDirectory.getCanonicalPath() + File.separator + spath);
3.145 - this.mDependentProjectArtifactJars.add(jarFile);
3.146 - } catch(Exception ex) {
3.147 - throw new BuildException("Failed to create File object for dependent project path "+ spath);
3.148 - }
3.149 - }
3.150 - }
3.151 -
3.152 - this.mBuildDir = new File(this.mBuildDirectory);
3.153 -
3.154 - ArrayList projectSourceDirs = new ArrayList();
3.155 - projectSourceDirs.add(this.mProjectSrcDir);
3.156 - processBpelFiles(projectSourceDirs);
3.157 -*/
3.158 - }
3.159 -/*
3.160 - private void processBpelFiles(List projectSourceDirs) {
3.161 -
3.162 - Iterator it = projectSourceDirs.iterator();
3.163 - while(it.hasNext()) {
3.164 - File srcDir = (File) it.next();
3.165 - processBpelFiles(srcDir);
3.166 - }
3.167 - }
3.168 -
3.169 - private void processBpelFiles(File dir) {
3.170 - File[] children = dir.listFiles(bpelFileFilter);
3.171 - for(int i = 0; i < children.length; i++) {
3.172 - File child = children[i];
3.173 - if(child.isDirectory()) {
3.174 - processBpelFiles(child);
3.175 - } else {
3.176 - //load existing bpel file
3.177 - BPELDocument document = loadExistingBusinessProcess(child);
3.178 - if(document != null) {
3.179 - List imports = document.getDocumentProcess().getImports();
3.180 -
3.181 - Iterator it = imports.iterator();
3.182 - while(it.hasNext()) {
3.183 - Import imp = (Import) it.next();
3.184 - String location = imp.getLocation();
3.185 - String importType = imp.getImportType();
3.186 - if(importType == null || importType.trim().equals("")) {
3.187 - throw new BuildException("Missing importType "+ imp + " in "+ child);
3.188 - }
3.189 -
3.190 - if(location == null || location.trim().equals("")) {
3.191 - throw new BuildException("Missing location "+ imp + " in "+ child);
3.192 - }
3.193 -
3.194 - //is this imported file already available in current project
3.195 - //the we do nothing
3.196 - boolean isExists = isFileAvailableInCurrentProject(imp, this.mProjectSrcDir);
3.197 - if(isExists) {
3.198 - continue;
3.199 - } else {
3.200 - extractImportedFileFromDepedentProject(imp, this.mDependentProjectArtifactJars);
3.201 - }
3.202 - }
3.203 - }
3.204 - }
3.205 - }
3.206 - }
3.207 -
3.208 - private boolean isFileAvailableInCurrentProject(Import imp, File dir) {
3.209 - boolean result = false;
3.210 - String location = imp.getLocation();
3.211 -
3.212 - File[] children = dir.listFiles(projectFileFilter);
3.213 - for(int i =0; i < children.length; i++) {
3.214 - File child = children[i];
3.215 - if(child.isDirectory()) {
3.216 - result = isFileAvailableInCurrentProject(imp, child);
3.217 - } else if(location.equals(child.getName())) {
3.218 - result = true;
3.219 - }
3.220 -
3.221 - if(result) {
3.222 - break;
3.223 - }
3.224 - }
3.225 -
3.226 - return result;
3.227 - }
3.228 -
3.229 - private void extractImportedFileFromDepedentProject(Import imp,
3.230 - List dependentProjectArtifactJars) {
3.231 - Iterator it = dependentProjectArtifactJars.iterator();
3.232 - while(it.hasNext()) {
3.233 - File jarFile = (File) it.next();
3.234 - try {
3.235 - JarFile seJarFile = new JarFile(jarFile);
3.236 - extractImportedFileFromDepedentProject(imp, seJarFile);
3.237 - } catch(Exception ex) {
3.238 - throw new BuildException(ex);
3.239 - }
3.240 -
3.241 - }
3.242 -
3.243 - }
3.244 -
3.245 - private void extractImportedFileFromDepedentProject(Import imp, JarFile jarFile) {
3.246 - String importType = imp.getImportType();
3.247 - boolean isWsdlFile = false;
3.248 - if(Import.WSDL_IMPORT_TYPE.equals(importType)) {
3.249 - extractWsdlFromDependentProject(imp, jarFile);
3.250 - } else {
3.251 - extractXsdFromDepedentProject(imp, jarFile);
3.252 - }
3.253 -
3.254 - }
3.255 -
3.256 - private void extractWsdlAndOtherImportedFiles(ZipEntry from, JarFile seJarFile) {
3.257 - File to = new File(this.mBuildDir, from.getName());
3.258 - //if file exists log to user, it means we are trying to import
3.259 - //same file in two different bpel.
3.260 - if(to.exists()) {
3.261 - //throw new BuildException("Can not extract file "+ to + " to " + buildDir + ", A file already exist with this name.");
3.262 - this.log("Skipping File "+ from + ", a file with this name has already been extracted in "+ mBuildDir);
3.263 - return;
3.264 - }
3.265 -
3.266 - try {
3.267 - writeToFile(seJarFile.getInputStream(from), to);
3.268 -
3.269 - //now load fastwsdl definitions
3.270 - //and also look for import within a wsdl
3.271 - FastWSDLDefinitions def =
3.272 - FastWSDLDefinitionsFactory.getInstance().newFastWSDLDefinitions(seJarFile.getInputStream(from), true);
3.273 - if(def.getParseErrorMessage() != null) {
3.274 - throw new BuildException(def.getParseErrorMessage());
3.275 - }
3.276 - Iterator it = def.getImports().iterator();
3.277 - while(it.hasNext()) {
3.278 - Import im = (Import) it.next();
3.279 - String location = im.getLocation();
3.280 - String importType = im.getImportType();
3.281 - if(importType == null || importType.trim().equals("")) {
3.282 - throw new BuildException("Missing importType "+ im + " in "+ from);
3.283 - }
3.284 -
3.285 - if(location == null || location.trim().equals("")) {
3.286 - throw new BuildException("Missing location "+ im + " in "+ from);
3.287 - }
3.288 -
3.289 - extractImportedFileFromDepedentProject(im, seJarFile);
3.290 - }
3.291 - } catch(Exception ex) {
3.292 - throw new BuildException("Error writing to file "+ to, ex);
3.293 - }
3.294 - }
3.295 -
3.296 - private void extractXsdAndOtherImportedFiles(ZipEntry from, JarFile seJarFile) {
3.297 - File to = new File(this.mBuildDir, from.getName());
3.298 - //if file exists log to user, it means we are trying to import
3.299 - //same file in two different bpel.
3.300 - if(to.exists()) {
3.301 - //throw new BuildException("Can not extract file "+ to + " to " + buildDir + ", A file already exist with this name.");
3.302 - this.log("Skipping File "+ to.getName() + ", a file with this name has already been extracted in "+ mBuildDir);
3.303 - return;
3.304 - }
3.305 - //TODO: look into xsd imports and also copy those
3.306 - throw new BuildException("Need to implement: look into xsd imports and also copy those");
3.307 -// try {
3.308 -// InputStream zipIn = seJarFile.getInputStream(from);
3.309 -// writeToFile(zipIn, to);
3.310 -//
3.311 -// //now load fastxsd definitions
3.312 -// //and also look for import within a xsd
3.313 -// FastWSDLDefinitions def =
3.314 -// FastWSDLDefinitionsFactory.getInstance().newFastWSDLDefinitions(zipIn, true);
3.315 -// if(def.getParseErrorMessage() != null) {
3.316 -// throw new BuildException(def.getParseErrorMessage());
3.317 -// }
3.318 -// Iterator it = def.getImports().iterator();
3.319 -// while(it.hasNext()) {
3.320 -// Import im = (Import) it.next();
3.321 -// extractImportedFileFromDepedentProject(im, seJarFile);
3.322 -// }
3.323 -// } catch(Exception ex) {
3.324 -// throw new BuildException("Error writing to file "+ to, ex);
3.325 -// }
3.326 - }
3.327 -
3.328 - private void extractWsdlFromDependentProject(Import imp, JarFile seJarFile) {
3.329 - String wsdlFileName = imp.getLocation();
3.330 - try {
3.331 - if(seJarFile != null) {
3.332 - Enumeration enumeration = seJarFile.entries();
3.333 - while(enumeration.hasMoreElements() == true) {
3.334 - ZipEntry entry = (ZipEntry) enumeration.nextElement();
3.335 - if(entry != null) {
3.336 - String fileName = entry.getName();
3.337 - //file name matches
3.338 - if((fileName.equals(wsdlFileName))) {
3.339 - extractWsdlAndOtherImportedFiles(entry, seJarFile);
3.340 - }
3.341 - }
3.342 - }
3.343 - }
3.344 -
3.345 - } catch(Exception ex) {
3.346 - throw new BuildException(ex);
3.347 - }
3.348 - }
3.349 -
3.350 - private void extractXsdFromDepedentProject(Import imp, JarFile seJarFile) {
3.351 - String wsdlFileName = imp.getLocation();
3.352 - try {
3.353 - if(seJarFile != null) {
3.354 - Enumeration enumeration = seJarFile.entries();
3.355 - while(enumeration.hasMoreElements() == true) {
3.356 - ZipEntry entry = (ZipEntry) enumeration.nextElement();
3.357 - if(entry != null) {
3.358 - String fileName = entry.getName().toLowerCase();
3.359 - //file name matches
3.360 - if((fileName.equals(wsdlFileName))) {
3.361 - extractXsdAndOtherImportedFiles(entry, seJarFile);
3.362 - }
3.363 - }
3.364 - }
3.365 - }
3.366 -
3.367 - } catch(Exception ex) {
3.368 - throw new BuildException(ex);
3.369 - }
3.370 - }
3.371 -
3.372 - private void processDirectory(File depedentProjectSrcDir, File buildDir, File sourceDirectory) {
3.373 - File[] children = depedentProjectSrcDir.listFiles(projectFileFilter);
3.374 - for(int i =0; i < children.length; i++) {
3.375 - File from = children[i];
3.376 -
3.377 - File to = new File(buildDir, from.getName());
3.378 - //if file exists throw exception
3.379 - if(to.exists()) {
3.380 - //throw new BuildException("Can not extract file "+ to + " to " + buildDir + ", A file already exist with this name.");
3.381 - this.log("Skipping File "+ to.getName() + ", a file with this name has already been extracted in "+ buildDir);
3.382 - continue;
3.383 - } else if(isFileExist(sourceDirectory, to.getName())) {
3.384 - this.log("Skipping File "+ to.getName() + ", a file with this name already exists in project source directory "+ sourceDirectory);
3.385 - continue;
3.386 - }
3.387 -
3.388 - try {
3.389 - writeToFile(from, to);
3.390 - } catch(Exception ex) {
3.391 - throw new BuildException("Error writing to file "+ to, ex);
3.392 - }
3.393 - }
3.394 -
3.395 -
3.396 - }
3.397 -
3.398 - private boolean isFileExist(File SourceDirectory, String fileName) {
3.399 - boolean result = false;
3.400 - File[] children = SourceDirectory.listFiles(projectFileFilter);
3.401 - for(int i = 0; i < children.length; i++) {
3.402 - File child = children[i];
3.403 - if(child.getName().equals(fileName)) {
3.404 - result = true;
3.405 - break;
3.406 - }
3.407 - }
3.408 -
3.409 - return result;
3.410 - }
3.411 -
3.412 - private void writeToFile(InputStream from, File to) throws Exception {
3.413 - BufferedInputStream bIn = new BufferedInputStream(from);
3.414 - BufferedOutputStream bOut = new BufferedOutputStream(new FileOutputStream(to));
3.415 - int buffersize = 1024;
3.416 - byte[] buf = new byte[buffersize];
3.417 -
3.418 - int count = 0;
3.419 -
3.420 - while(( count = bIn.read(buf, 0, buffersize)) != -1) {
3.421 - bOut.write(buf,0, count);
3.422 - }
3.423 -
3.424 - bOut.flush();
3.425 - bOut.close();
3.426 - bIn.close();
3.427 -
3.428 - }
3.429 -
3.430 - private void writeToFile(File from, File to) throws Exception {
3.431 - writeToFile(new FileInputStream(from), to);
3.432 - }
3.433 -
3.434 - private BPELDocument loadExistingBusinessProcess(File bpelFile) throws BuildException {
3.435 - BPELDocument document = null;
3.436 - try {
3.437 - FileReader fReader = new FileReader(new File(bpelFile.getPath()));
3.438 - BPELParseContext parseContext = new BPELParseContext.DefaultParseContext();
3.439 - ProjectBasedWSDLResolver wsdlLoader = ProjectBasedWSDLResolverFactory.getInstance().newWSDLResolver(bpelFile.toURI().toString(), parseContext);
3.440 -
3.441 - parseContext.setWSDLResolver(wsdlLoader);
3.442 -
3.443 - ProjectBasedXSDResolver xsdResolver = ProjectBasedXSDResolverFactory.getInstance().newXSDResolver(bpelFile.toURI().toString(), parseContext);
3.444 - parseContext.setXSDResolver(xsdResolver);
3.445 -
3.446 - //do not load imported schemas
3.447 - parseContext.setLoadOnlyPartnersAndImports(true);
3.448 - parseContext.setLoadImportedWsdls(false);
3.449 - parseContext.setLoadImportedXsds(false);
3.450 - parseContext.getWSDLParseContext().setParseInlineSchema(false);
3.451 - parseContext.getWSDLParseContext().setParseImportedSchemas(false);
3.452 - parseContext.getWSDLParseContext().setEnableEvents(false);
3.453 - parseContext.setEnableEvents(false);
3.454 -
3.455 - document = BPELDocumentParseFactory.getInstance().load(fReader, parseContext);
3.456 -
3.457 - } catch (Exception ex) {
3.458 - throw new BuildException ("Failed to load bpel process " + bpelFile.getPath(), ex);
3.459 - }
3.460 - return document;
3.461 - }
3.462 -
3.463 - static class ProjectFileFilter implements FileFilter {
3.464 -
3.465 - public boolean accept(File pathname) {
3.466 - boolean result = false;
3.467 - if(pathname.isDirectory()) {
3.468 - return true;
3.469 - }
3.470 -
3.471 - String fileName = pathname.getName();
3.472 - String fileExtension = null;
3.473 - int dotIndex = fileName.lastIndexOf('.');
3.474 - if(dotIndex != -1) {
3.475 - fileExtension = fileName.substring(dotIndex +1);
3.476 - }
3.477 -
3.478 - if(fileExtension != null
3.479 - && (fileExtension.equalsIgnoreCase(WSDL_FILE_EXTENSION) || fileExtension.equalsIgnoreCase(XSD_FILE_EXTENSION))) {
3.480 - result = true;
3.481 - }
3.482 -
3.483 - return result;
3.484 - }
3.485 - }
3.486 -
3.487 - static class BpelFileFilter implements FileFilter {
3.488 -
3.489 - public boolean accept(File pathname) {
3.490 - boolean result = false;
3.491 - if(pathname.isDirectory()) {
3.492 - return true;
3.493 - }
3.494 -
3.495 - String fileName = pathname.getName();
3.496 - String fileExtension = null;
3.497 - int dotIndex = fileName.lastIndexOf('.');
3.498 - if(dotIndex != -1) {
3.499 - fileExtension = fileName.substring(dotIndex +1);
3.500 - }
3.501 -
3.502 - if(fileExtension != null
3.503 - && (fileExtension.equalsIgnoreCase(BPEL_FILE_EXTENSION))) {
3.504 - result = true;
3.505 - }
3.506 -
3.507 - return result;
3.508 - }
3.509 - }
3.510 -*/
3.511 -}
4.1 --- a/bpel.project/antsrc/org/netbeans/modules/bpel/project/anttasks/GenerateJBIDescriptor.java Fri May 11 13:30:46 2007 +0000
4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
4.3 @@ -1,132 +0,0 @@
4.4 -/*
4.5 - * The contents of this file are subject to the terms of the Common Development
4.6 - * and Distribution License (the License). You may not use this file except in
4.7 - * compliance with the License.
4.8 - *
4.9 - * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
4.10 - * or http://www.netbeans.org/cddl.txt.
4.11 - *
4.12 - * When distributing Covered Code, include this CDDL Header Notice in each file
4.13 - * and include the License file at http://www.netbeans.org/cddl.txt.
4.14 - * If applicable, add the following below the CDDL Header, with the fields
4.15 - * enclosed by brackets [] replaced by your own identifying information:
4.16 - * "Portions Copyrighted [year] [name of copyright owner]"
4.17 - *
4.18 - * The Original Software is NetBeans. The Initial Developer of the Original
4.19 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
4.20 - * Microsystems, Inc. All Rights Reserved.
4.21 - */
4.22 -
4.23 -package org.netbeans.modules.bpel.project.anttasks;
4.24 -
4.25 -import java.io.File;
4.26 -import java.util.ArrayList;
4.27 -import java.util.StringTokenizer;
4.28 -
4.29 -import org.netbeans.modules.bpel.project.CommandlineBpelProjectXmlCatalogProvider;
4.30 -
4.31 -import org.apache.tools.ant.BuildException;
4.32 -import org.apache.tools.ant.Task;
4.33 -
4.34 -import org.apache.tools.ant.types.Reference;
4.35 -
4.36 -/**
4.37 - * Generates JBI Descriptor
4.38 - * @author Sreenivasan Genipudi
4.39 - */
4.40 -public class GenerateJBIDescriptor extends Task {
4.41 - // Member variable representing source directory
4.42 - private String mSourceDirectory = null;
4.43 - // Member variable representing build directory
4.44 - private String mBuildDirectory = null;
4.45 - // Member variable representing project classpath
4.46 - private String mProjectClassPath= null;
4.47 -
4.48 -
4.49 - /**
4.50 - * Constructor
4.51 - */
4.52 - public GenerateJBIDescriptor() {
4.53 - }
4.54 -
4.55 - /**
4.56 - * Set the build directory
4.57 - * @param buildDir build directory
4.58 - */
4.59 - public void setBuildDirectory(String buildDir) {
4.60 - mBuildDirectory = buildDir;
4.61 - }
4.62 - /**
4.63 - * Set the source directory
4.64 - * @param srcDir source directory
4.65 - */
4.66 - public void setSourceDirectory(String srcDir) {
4.67 - this.mSourceDirectory = srcDir;
4.68 - }
4.69 - /**
4.70 - * Set the classpath reference
4.71 - * @param ref Classpath Reference
4.72 - */
4.73 - public void setClasspathRef(Reference ref) {
4.74 - }
4.75 -
4.76 - /**
4.77 - * Get the source directory
4.78 - * @return String value of the source directory
4.79 - */
4.80 - public String getSourceDirectory() {
4.81 - return this.mSourceDirectory;
4.82 - }
4.83 -
4.84 - /**
4.85 - * Set the project classpath
4.86 - * @param projectClassPath Set the project classpath
4.87 - */
4.88 - public void setProjectClassPath(String projectClassPath) {
4.89 - this.mProjectClassPath = projectClassPath;
4.90 - }
4.91 -
4.92 - /**
4.93 - * generate JBI xml
4.94 - * @throws org.apache.tools.ant.BuildException
4.95 - */
4.96 - public void execute() throws BuildException {
4.97 -
4.98 - if(this.mSourceDirectory == null) {
4.99 - throw new BuildException("No directory is set for source files.");
4.100 - }
4.101 -
4.102 - File sourceDirectory = new File(this.mSourceDirectory);
4.103 -
4.104 - //read project classpath
4.105 - //TODO: refactor this to use wsdl classpath
4.106 - ArrayList projectDirs = new ArrayList();
4.107 - if(this.mProjectClassPath != null
4.108 - && !this.mProjectClassPath.trim().equals("")
4.109 - && !this.mProjectClassPath.trim().equals("${javac.classpath}")) {
4.110 - StringTokenizer st = new StringTokenizer(this.mProjectClassPath, ";");
4.111 - while (st.hasMoreTokens()) {
4.112 - String spath = st.nextToken();
4.113 - try {
4.114 -
4.115 - File sFile = new File(sourceDirectory.getParentFile().getCanonicalPath() + File.separator + spath);
4.116 -
4.117 - File srcFolder = new File(sFile.getParentFile().getParentFile().getCanonicalFile(), "src");
4.118 - projectDirs.add(srcFolder);
4.119 - } catch(Exception ex) {
4.120 - throw new BuildException("Failed to create File object for dependent project path "+ spath);
4.121 - }
4.122 - }
4.123 - }
4.124 -
4.125 - //find the owner project
4.126 - if(sourceDirectory != null) {
4.127 - ArrayList srcList = new ArrayList();
4.128 - srcList.add(sourceDirectory);
4.129 - CommandlineBpelProjectXmlCatalogProvider.getInstance().setSourceDirectory(this.mSourceDirectory);
4.130 - JBIGenerator generator = new JBIGenerator(projectDirs, srcList);
4.131 - generator.generate(new File(mBuildDirectory));
4.132 - }
4.133 - }
4.134 -
4.135 -}
5.1 --- a/bpel.project/antsrc/org/netbeans/modules/bpel/project/anttasks/GenerateJBIDescriptorTask.java Fri May 11 13:30:46 2007 +0000
5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
5.3 @@ -1,179 +0,0 @@
5.4 -/*
5.5 - * The contents of this file are subject to the terms of the Common Development
5.6 - * and Distribution License (the License). You may not use this file except in
5.7 - * compliance with the License.
5.8 - *
5.9 - * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
5.10 - * or http://www.netbeans.org/cddl.txt.
5.11 - *
5.12 - * When distributing Covered Code, include this CDDL Header Notice in each file
5.13 - * and include the License file at http://www.netbeans.org/cddl.txt.
5.14 - * If applicable, add the following below the CDDL Header, with the fields
5.15 - * enclosed by brackets [] replaced by your own identifying information:
5.16 - * "Portions Copyrighted [year] [name of copyright owner]"
5.17 - *
5.18 - * The Original Software is NetBeans. The Initial Developer of the Original
5.19 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
5.20 - * Microsystems, Inc. All Rights Reserved.
5.21 - */
5.22 -package org.netbeans.modules.bpel.project.anttasks;
5.23 -
5.24 -import org.apache.tools.ant.BuildException;
5.25 -import org.apache.tools.ant.Task;
5.26 -import org.apache.tools.ant.AntClassLoader;
5.27 -import org.apache.tools.ant.types.Path;
5.28 -import org.apache.tools.ant.types.Reference;
5.29 -
5.30 -import java.lang.reflect.Method;
5.31 -
5.32 -import java.util.logging.Level;
5.33 -import java.util.logging.Logger;
5.34 -
5.35 -
5.36 -/**
5.37 - * Ant task wrapper which invokes the JBI Generation task
5.38 - * @author Sreenivasan Genipudi
5.39 - */
5.40 -public class GenerateJBIDescriptorTask extends org.apache.tools.ant.Task{
5.41 - // Member variable representing source directory
5.42 - /**
5.43 - * Source directory
5.44 - */
5.45 - private String mSourceDirectory = null;
5.46 - // Member variable representing build directory
5.47 - /**
5.48 - * Build directory
5.49 - */
5.50 - private String mBuildDirectory = null;
5.51 - // Member variable representing project classpath
5.52 - /**
5.53 - * Project classpath
5.54 - */
5.55 - private String mProjectClassPath= null;
5.56 - /**
5.57 - * Custom classloader used to invoke the JBI Generation task
5.58 - */
5.59 - private AntClassLoader m_myClassLoader = null;
5.60 - /**
5.61 - * Classpath Reference
5.62 - */
5.63 - private Reference m_ref = null;
5.64 -
5.65 - /**
5.66 - * Logger instance
5.67 - */
5.68 - private Logger logger = Logger.getLogger(GenerateJBIDescriptorTask.class.getName());
5.69 - /**
5.70 - * Constructor
5.71 - */
5.72 - public GenerateJBIDescriptorTask() {
5.73 - }
5.74 -
5.75 - /**
5.76 - * Set the classpath reference
5.77 - * @param ref Classpath Reference
5.78 - */
5.79 - public void setClasspathRef(Reference ref) {
5.80 - this.m_ref = ref;
5.81 - }
5.82 -
5.83 - /**
5.84 - * Set the build directory
5.85 - * @param buildDir build directory
5.86 - */
5.87 - public void setBuildDirectory(String buildDir) {
5.88 - mBuildDirectory = buildDir;
5.89 - }
5.90 - /**
5.91 - * Set the source directory
5.92 - * @param srcDir source directory
5.93 - */
5.94 - public void setSourceDirectory(String srcDir) {
5.95 - this.mSourceDirectory = srcDir;
5.96 - }
5.97 -
5.98 - /**
5.99 - * Get the source directory
5.100 - * @return String value of the source directory
5.101 - */
5.102 - public String getSourceDirectory() {
5.103 - return this.mSourceDirectory;
5.104 - }
5.105 -
5.106 - /**
5.107 - * Set the project classpath
5.108 - * @param projectClassPath Project classpath
5.109 - */
5.110 - public void setProjectClassPath(String projectClassPath) {
5.111 - this.mProjectClassPath = projectClassPath;
5.112 - }
5.113 -
5.114 -
5.115 - /**
5.116 - * Invoke the task that generates the JBI.xml
5.117 - */
5.118 - public void execute() throws BuildException {
5.119 - try {
5.120 - m_myClassLoader = new AntClassLoader();
5.121 - initClassLoader();
5.122 - Class antTaskClass = Class.forName("org.netbeans.modules.bpel.project.anttasks.GenerateJBIDescriptor", true,m_myClassLoader );
5.123 - Thread.currentThread().setContextClassLoader(m_myClassLoader);
5.124 - // m_myClassLoader.forceLoadClass("org.netbeans.modules.bpel.project.anttasks.BPELCatalogModel");
5.125 - // m_myClassLoader.forceLoadClass("org.openide.util.Lookup");
5.126 - Object genJBIInstObj = antTaskClass.newInstance();
5.127 -
5.128 - Method driver = antTaskClass.getMethod("setBuildDirectory",
5.129 - new Class[] { java.lang.String.class });
5.130 - Object[] param = new Object[] {
5.131 - this.mBuildDirectory
5.132 - };
5.133 - driver.invoke(genJBIInstObj,
5.134 - param);
5.135 -
5.136 - driver = antTaskClass.getMethod("setSourceDirectory",
5.137 - new Class[] { java.lang.String.class });
5.138 - param = new Object[] {
5.139 - this.mSourceDirectory
5.140 - };
5.141 - driver.invoke(genJBIInstObj,
5.142 - param);
5.143 -
5.144 - driver = antTaskClass.getMethod("setProjectClassPath",
5.145 - new Class[] { java.lang.String.class });
5.146 - param = new Object[] {
5.147 - this.mProjectClassPath
5.148 - };
5.149 - driver.invoke(genJBIInstObj,
5.150 - param);
5.151 -
5.152 - driver = antTaskClass.getMethod("execute",
5.153 - null);
5.154 - driver.invoke(genJBIInstObj, null);
5.155 -
5.156 - }catch (Exception ex) {
5.157 - logger.log(Level.FINE, "Compilation Errors found", ex);
5.158 - throw new BuildException("Compilation Errors found");
5.159 - }
5.160 - }
5.161 -
5.162 - /**
5.163 - * Set the custom classloader and make the parent first reference
5.164 - * by the classloader to False
5.165 - */
5.166 - private void initClassLoader() {
5.167 - Path path = new Path(getProject());
5.168 - path.setRefid(m_ref);
5.169 -
5.170 - Path parentPath = new Path(getProject());
5.171 - ClassLoader cl = this.getClass().getClassLoader();
5.172 - if (cl instanceof AntClassLoader) {
5.173 - parentPath.setPath(((AntClassLoader)cl).getClasspath());
5.174 - ((AntClassLoader)cl).setParent(null);
5.175 - parentPath.add(path);
5.176 - path = parentPath;
5.177 - }
5.178 - m_myClassLoader.setClassPath(path);
5.179 - m_myClassLoader.setParent(null);
5.180 - m_myClassLoader.setParentFirst(false);
5.181 - }
5.182 -}
6.1 --- a/bpel.project/antsrc/org/netbeans/modules/bpel/project/anttasks/GenerateJBIXMLTest.java Fri May 11 13:30:46 2007 +0000
6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
6.3 @@ -1,111 +0,0 @@
6.4 -/*
6.5 - * The contents of this file are subject to the terms of the Common Development
6.6 - * and Distribution License (the License). You may not use this file except in
6.7 - * compliance with the License.
6.8 - *
6.9 - * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
6.10 - * or http://www.netbeans.org/cddl.txt.
6.11 - *
6.12 - * When distributing Covered Code, include this CDDL Header Notice in each file
6.13 - * and include the License file at http://www.netbeans.org/cddl.txt.
6.14 - * If applicable, add the following below the CDDL Header, with the fields
6.15 - * enclosed by brackets [] replaced by your own identifying information:
6.16 - * "Portions Copyrighted [year] [name of copyright owner]"
6.17 - *
6.18 - * The Original Software is NetBeans. The Initial Developer of the Original
6.19 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
6.20 - * Microsystems, Inc. All Rights Reserved.
6.21 - */
6.22 -package org.netbeans.modules.bpel.project.anttasks;
6.23 -
6.24 -import javax.xml.namespace.QName;
6.25 -import java.io.File;
6.26 -
6.27 -import org.apache.tools.ant.BuildException;
6.28 -import org.apache.tools.ant.types.Path;
6.29 -import org.apache.tools.ant.types.Reference;
6.30 -
6.31 -import org.netbeans.modules.xml.xam.dom.NamedComponentReference;
6.32 -import org.netbeans.modules.xml.wsdl.model.extensions.bpel.Role;
6.33 -import org.netbeans.modules.xml.wsdl.model.extensions.bpel.PartnerLinkType;
6.34 -import org.netbeans.modules.bpel.model.api.BpelModel;
6.35 -import org.netbeans.modules.bpel.model.api.PartnerLink;
6.36 -import org.netbeans.modules.bpel.model.api.references.WSDLReference;
6.37 -
6.38 -public class GenerateJBIXMLTest {
6.39 - private ClassLoader m_contextClassLoader = null;
6.40 - private BPELCatalogModel m_bpelCtlgModel = null;
6.41 - public GenerateJBIXMLTest() {
6.42 - }
6.43 -
6.44 - public void setContextClassLoader(ClassLoader cl) {
6.45 - m_contextClassLoader = cl;
6.46 - }
6.47 -
6.48 - public void setBPELCatalogModel(Object bpelCtlgMdl ) {
6.49 - m_bpelCtlgModel =(BPELCatalogModel) bpelCtlgMdl;
6.50 - m_bpelCtlgModel = m_bpelCtlgModel.getDefault();
6.51 - }
6.52 -
6.53 - public void execute() {
6.54 - System.setProperty("org.openide.util.Lookup","org.netbeans.modules.bpel.project.anttasks.MyLookup" );
6.55 - File sourceFile = new File("C:/Documents and Settings/sgenipudi/BpelModule7/src/echo_1.bpel");
6.56 - Thread.currentThread().setContextClassLoader(m_contextClassLoader);
6.57 -
6.58 - BpelModel bpelModel = null;
6.59 - try {
6.60 - bpelModel = BPELCatalogModel.getDefault().getBPELModel(sourceFile.toURI());
6.61 - }catch (Exception ex) {
6.62 - throw new BuildException("Creation of Bpel model failed!", ex);
6.63 - }
6.64 -// System.out.println("Gettng partner links!");
6.65 - PartnerLink[] pLinks = bpelModel.getProcess().getPartnerLinkContainer().getPartnerLinks();
6.66 -// System.out.println("Got partner links!");
6.67 - for (int index =0; index < pLinks.length; index++) {
6.68 - String partnerLinkName = pLinks[index].getName();
6.69 - WSDLReference partnerLinkTypeWSDLRef = pLinks[index].getPartnerLinkType();
6.70 - QName partnerLinkQName = pLinks[index].getPartnerLinkType().getQName();
6.71 - String partnerLinkQNameNSPrefix = partnerLinkQName.getPrefix();
6.72 - String partnerLinkQNameLocalPart = partnerLinkQName.getLocalPart();
6.73 - String partnerLinkNameSpaceURI = partnerLinkQName.getNamespaceURI();
6.74 - PartnerLinkType pLTypeForPLinkType = (PartnerLinkType)partnerLinkTypeWSDLRef.get();
6.75 - if (pLTypeForPLinkType != null) {
6.76 - Role pLTypeForPLinkTypeRole1 = pLTypeForPLinkType.getRole1();
6.77 - if (pLTypeForPLinkTypeRole1 != null) {
6.78 - NamedComponentReference nmrRole1 = pLTypeForPLinkTypeRole1.getPortType();
6.79 - if (nmrRole1 != null ) {
6.80 - QName portTypeQName1 = nmrRole1.getQName();
6.81 - if (portTypeQName1 != null) {
6.82 -// System.out.println("Port Type1 = "+portTypeQName1.getLocalPart()+ " Prefix = "+portTypeQName1.getPrefix()+ "Port Type1 = "+portTypeQName1.getNamespaceURI());
6.83 - }
6.84 - }
6.85 - }
6.86 -
6.87 -
6.88 -
6.89 - Role pLTypeForPLinkTypeRole2 = pLTypeForPLinkType.getRole2();
6.90 - if (pLTypeForPLinkTypeRole2 != null) {
6.91 - NamedComponentReference nmrRole2 = pLTypeForPLinkTypeRole2.getPortType();
6.92 - if (nmrRole2 != null ) {
6.93 - QName portTypeQName2 = nmrRole2.getQName();
6.94 - if (portTypeQName2 != null) {
6.95 -// System.out.println("Port Type2 = "+portTypeQName2.getLocalPart()+ " Prefix = "+portTypeQName2.getPrefix()+ "Port Type = "+portTypeQName2.getNamespaceURI());
6.96 - }
6.97 - }
6.98 - }
6.99 - }
6.100 -// System.out.println("Partner Link Name = "+partnerLinkQNameLocalPart+ " Prefix = "+partnerLinkQNameNSPrefix + "partnerLinkQNameLocalPart = "+partnerLinkQNameLocalPart +" partnerLinkNameSpaceURI = "+partnerLinkNameSpaceURI);
6.101 - WSDLReference partnerMyRoleWSDLRef = pLinks[index].getMyRole();
6.102 -// System.out.println(" My ROLE = "+partnerMyRoleWSDLRef.getQName().getLocalPart()+" Prefix = "+partnerMyRoleWSDLRef.getQName().getPrefix()+" Namepsace URI "+partnerMyRoleWSDLRef.getQName().getNamespaceURI());
6.103 - partnerMyRoleWSDLRef = pLinks[index].getPartnerRole();
6.104 - if (partnerMyRoleWSDLRef != null) {
6.105 - QName qName = partnerMyRoleWSDLRef.getQName();
6.106 - if (qName != null) {
6.107 -// System.out.println(" Partner ROLE = "+partnerMyRoleWSDLRef.getQName().getLocalPart()+" Prefix = "+partnerMyRoleWSDLRef.getQName().getPrefix()+" Namepsace URI "+partnerMyRoleWSDLRef.getQName().getNamespaceURI());
6.108 - }
6.109 - }
6.110 -
6.111 - }
6.112 -
6.113 - }
6.114 -}
7.1 --- a/bpel.project/antsrc/org/netbeans/modules/bpel/project/anttasks/IDEValidateBPELProject.java Fri May 11 13:30:46 2007 +0000
7.2 +++ b/bpel.project/antsrc/org/netbeans/modules/bpel/project/anttasks/IDEValidateBPELProject.java Fri May 11 13:40:22 2007 +0000
7.3 @@ -68,7 +68,6 @@
7.4 import java.util.logging.Logger;
7.5
7.6 /**
7.7 - * Validates BPEL Module
7.8 * @author Sreenivasan Genipudi
7.9 */
7.10 public class IDEValidateBPELProject extends Task {
8.1 --- a/bpel.project/antsrc/org/netbeans/modules/bpel/project/anttasks/MyLookup.java Fri May 11 13:30:46 2007 +0000
8.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
8.3 @@ -1,55 +0,0 @@
8.4 -/*
8.5 - * The contents of this file are subject to the terms of the Common Development
8.6 - * and Distribution License (the License). You may not use this file except in
8.7 - * compliance with the License.
8.8 - *
8.9 - * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
8.10 - * or http://www.netbeans.org/cddl.txt.
8.11 - *
8.12 - * When distributing Covered Code, include this CDDL Header Notice in each file
8.13 - * and include the License file at http://www.netbeans.org/cddl.txt.
8.14 - * If applicable, add the following below the CDDL Header, with the fields
8.15 - * enclosed by brackets [] replaced by your own identifying information:
8.16 - * "Portions Copyrighted [year] [name of copyright owner]"
8.17 - *
8.18 - * The Original Software is NetBeans. The Initial Developer of the Original
8.19 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
8.20 - * Microsystems, Inc. All Rights Reserved.
8.21 - */
8.22 -package org.netbeans.modules.bpel.project.anttasks;
8.23 -
8.24 -import org.openide.util.Lookup;
8.25 -import org.openide.util.lookup.AbstractLookup;
8.26 -import org.openide.util.lookup.Lookups;
8.27 -
8.28 -
8.29 -public class MyLookup extends Lookup {
8.30 - static Lookup mylookup = null;
8.31 - static MyLookup m_instance = null;
8.32 -
8.33 - public MyLookup() {
8.34 -
8.35 - }
8.36 - private static Lookup getInstance(){
8.37 - if (m_instance == null ) {
8.38 - m_instance = new MyLookup();
8.39 - }
8.40 - if (mylookup == null) {
8.41 - mylookup = Lookups.metaInfServices(m_instance.getClass().getClassLoader());
8.42 - }
8.43 - return mylookup;
8.44 - }
8.45 -
8.46 - public Object lookup(Class clazz) {
8.47 - return getInstance().lookup(clazz);
8.48 - }
8.49 -
8.50 - public Lookup.Result lookup(Lookup.Template template) {
8.51 - return getInstance().lookup(template);
8.52 - }
8.53 -
8.54 - public Lookup.Item lookupItem(Lookup.Template template) {
8.55 - return getInstance().lookupItem(template);
8.56 - }
8.57 -
8.58 -}
9.1 --- a/bpel.project/antsrc/org/netbeans/modules/bpel/project/anttasks/ValidateBPEL.java Fri May 11 13:30:46 2007 +0000
9.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
9.3 @@ -1,78 +0,0 @@
9.4 -/*
9.5 - * The contents of this file are subject to the terms of the Common Development
9.6 - * and Distribution License (the License). You may not use this file except in
9.7 - * compliance with the License.
9.8 - *
9.9 - * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
9.10 - * or http://www.netbeans.org/cddl.txt.
9.11 - *
9.12 - * When distributing Covered Code, include this CDDL Header Notice in each file
9.13 - * and include the License file at http://www.netbeans.org/cddl.txt.
9.14 - * If applicable, add the following below the CDDL Header, with the fields
9.15 - * enclosed by brackets [] replaced by your own identifying information:
9.16 - * "Portions Copyrighted [year] [name of copyright owner]"
9.17 - *
9.18 - * The Original Software is NetBeans. The Initial Developer of the Original
9.19 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
9.20 - * Microsystems, Inc. All Rights Reserved.
9.21 - */
9.22 -package org.netbeans.modules.bpel.project.anttasks;
9.23 -
9.24 -import java.io.File;
9.25 -
9.26 -import java.net.URI;
9.27 -
9.28 -import java.util.Collection;
9.29 -
9.30 -import java.util.Iterator;
9.31 -
9.32 -import org.netbeans.modules.xml.xam.spi.ValidationResult;
9.33 -import org.netbeans.modules.bpel.model.api.BpelModel;
9.34 -import org.netbeans.modules.xml.xam.spi.Validator;
9.35 -import org.netbeans.modules.bpel.model.spi.BpelModelFactory;
9.36 -import org.netbeans.modules.xml.xam.spi.Validation;
9.37 -import org.netbeans.modules.xml.xam.spi.ValidationResult;
9.38 -import org.netbeans.modules.xml.xam.spi.Validator;
9.39 -import org.netbeans.modules.xml.xam.spi.Validation;
9.40 -import org.netbeans.modules.xml.xam.spi.Validation.ValidationType;
9.41 -import org.netbeans.modules.xml.xam.spi.Validator.ResultItem;
9.42 -import org.openide.util.lookup.Lookups;
9.43 -
9.44 -/**
9.45 - * Class used for validating the BPEL files
9.46 - * @author Sreenivasan Genipudi
9.47 - */
9.48 -public class ValidateBPEL {
9.49 - /**
9.50 - * Constructor
9.51 - */
9.52 - public ValidateBPEL() {
9.53 -
9.54 - }
9.55 -
9.56 - /**
9.57 - * Validate the BPEL
9.58 - * @param bpelFileUri Bpel File URI
9.59 - * @return Collection of results
9.60 - */
9.61 - public Collection validate(URI bpelFileUri) {
9.62 -
9.63 - BpelModel model = null;
9.64 - try {
9.65 - model = BPELCatalogModel.getDefault().getBPELModel(bpelFileUri);
9.66 - }catch (Exception ex) {
9.67 - ex.printStackTrace();
9.68 - throw new RuntimeException(" Error while trying to create BPEL Model ",ex);
9.69 - }
9.70 - //Validator validator = (Validator) Lookups.metaInfServices(getClass().getClassLoader()).lookup(Validator.class);
9.71 - Validation validation = new Validation();
9.72 - validation.validate((org.netbeans.modules.xml.xam.Model)model, ValidationType.COMPLETE);
9.73 - Collection col =validation.getValidationResult();
9.74 - //Collection col = validation.getValidationResult();
9.75 - for (Iterator itr = col.iterator(); itr.hasNext();) {
9.76 - ResultItem resultItem = (ResultItem) itr.next();
9.77 -// System.out.println(resultItem.getDescription());
9.78 - }
9.79 - return col;
9.80 - }
9.81 -}
10.1 --- a/bpel.project/antsrc/org/netbeans/modules/bpel/project/anttasks/ValidateBPELProject.java Fri May 11 13:30:46 2007 +0000
10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
10.3 @@ -1,475 +0,0 @@
10.4 -/*
10.5 - * The contents of this file are subject to the terms of the Common Development
10.6 - * and Distribution License (the License). You may not use this file except in
10.7 - * compliance with the License.
10.8 - *
10.9 - * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
10.10 - * or http://www.netbeans.org/cddl.txt.
10.11 - *
10.12 - * When distributing Covered Code, include this CDDL Header Notice in each file
10.13 - * and include the License file at http://www.netbeans.org/cddl.txt.
10.14 - * If applicable, add the following below the CDDL Header, with the fields
10.15 - * enclosed by brackets [] replaced by your own identifying information:
10.16 - * "Portions Copyrighted [year] [name of copyright owner]"
10.17 - *
10.18 - * The Original Software is NetBeans. The Initial Developer of the Original
10.19 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
10.20 - * Microsystems, Inc. All Rights Reserved.
10.21 - */
10.22 -package org.netbeans.modules.bpel.project.anttasks;
10.23 -
10.24 -import java.io.File;
10.25 -
10.26 -import java.io.FileReader;
10.27 -import java.io.PrintWriter;
10.28 -import java.io.StringWriter;
10.29 -
10.30 -import java.net.URI;
10.31 -
10.32 -import java.util.ArrayList;
10.33 -import java.util.Collection;
10.34 -import java.util.Iterator;
10.35 -import java.util.List;
10.36 -import java.util.StringTokenizer;
10.37 -
10.38 -import java.net.URI;
10.39 -
10.40 -import java.util.Collection;
10.41 -
10.42 -import java.util.HashMap;
10.43 -import java.util.Iterator;
10.44 -
10.45 -import java.util.Map;
10.46 -
10.47 -import org.netbeans.modules.xml.xam.Component;
10.48 -import org.netbeans.modules.xml.xam.dom.AbstractDocumentComponent;
10.49 -import org.netbeans.modules.xml.xam.spi.ValidationResult;
10.50 -import org.netbeans.modules.bpel.model.api.BpelModel;
10.51 -import org.netbeans.modules.xml.xam.spi.Validator;
10.52 -import org.netbeans.modules.bpel.model.spi.BpelModelFactory;
10.53 -import org.netbeans.modules.xml.xam.spi.Validation;
10.54 -import org.netbeans.modules.xml.xam.spi.ValidationResult;
10.55 -import org.netbeans.modules.xml.xam.spi.Validator;
10.56 -import org.netbeans.modules.xml.xam.spi.Validation;
10.57 -import org.netbeans.modules.xml.xam.spi.Validation.ValidationType;
10.58 -import org.netbeans.modules.xml.xam.spi.Validator.ResultItem;
10.59 -import org.openide.util.lookup.Lookups;
10.60 -import org.apache.tools.ant.Task;
10.61 -import org.apache.tools.ant.types.Reference;
10.62 -import org.apache.tools.ant.BuildException;
10.63 -
10.64 -import org.netbeans.modules.bpel.model.api.BpelModel;
10.65 -import org.netbeans.modules.bpel.project.CommandlineBpelProjectXmlCatalogProvider;
10.66 -import org.netbeans.modules.xml.xam.spi.Validation;
10.67 -import org.netbeans.modules.xml.xam.spi.Validator;
10.68 -
10.69 -import org.xml.sax.ErrorHandler;
10.70 -import org.xml.sax.Locator;
10.71 -import org.xml.sax.SAXException;
10.72 -import org.xml.sax.SAXParseException;
10.73 -
10.74 -import java.util.logging.Level;
10.75 -import java.util.logging.Logger;
10.76 -
10.77 -/**
10.78 - * Validates BPEL Module
10.79 - * @author Sreenivasan Genipudi
10.80 - */
10.81 -public class ValidateBPELProject extends Task {
10.82 - //Member variable representing source directory
10.83 - /**
10.84 - * Source directory
10.85 - */
10.86 - private String mSourceDirectory;
10.87 - //Member variable representing project classpath
10.88 - /**
10.89 - * Project classpath
10.90 - */
10.91 - private String mProjectClassPath;
10.92 - //Member variable representing build directory
10.93 - /**
10.94 - * Build directory
10.95 - */
10.96 - private String mBuildDirectory;
10.97 - //Member variable representing dependent project files directory
10.98 - /**
10.99 - * List fo dependent project files
10.100 - */
10.101 - private String mBuildDependentProjectFilesDirectory;
10.102 - //Member variable representing dependent project directories
10.103 - /**
10.104 - * Dependent project directories
10.105 - */
10.106 - private List mDependentProjectDirs;
10.107 - //Member variable representing source dir
10.108 - private File mSourceDir;
10.109 - //Member variable representing build dir
10.110 - private File mBuildDir;
10.111 - //Member variable representing map of file names to BPEL file
10.112 - // used to check if the file was changed since lasttime the
10.113 - // file was validated.
10.114 - private Map mBpelFileNamesToFileInBuildDir = new HashMap();
10.115 -
10.116 - private boolean isFoundErrors = false;
10.117 -
10.118 - private boolean mAllowBuildWithError = false;
10.119 - /**
10.120 - * Logger instance
10.121 - */
10.122 - private Logger logger = Logger.getLogger(ValidateBPELProject.class.getName());
10.123 -
10.124 - /**
10.125 - * Constructor
10.126 - */
10.127 - public ValidateBPELProject() {
10.128 - }
10.129 -
10.130 -
10.131 - /**
10.132 - * Set the source directory
10.133 - * @param srcDir Source directory
10.134 - */
10.135 - public void setSourceDirectory(String srcDir) {
10.136 - this.mSourceDirectory = srcDir;
10.137 - }
10.138 -
10.139 - /**
10.140 - * Set the build directory
10.141 - * @param buildDir build directory
10.142 - */
10.143 - public void setBuildDirectory(String buildDir) {
10.144 - this.mBuildDirectory = buildDir;
10.145 - }
10.146 - /**
10.147 - * Run validation
10.148 - * @param srcDir source directory
10.149 - */
10.150 - public void setRunValidation(String flag) {
10.151 - setAllowBuildWithError(flag);
10.152 - mAllowBuildWithError = !mAllowBuildWithError;
10.153 - }
10.154 -
10.155 - /**
10.156 - * Run validation
10.157 - * @param srcDir source directory
10.158 - */
10.159 - public void setAllowBuildWithError(String flag) {
10.160 - if (flag != null) {
10.161 - if (flag.equals("false")) {
10.162 - mAllowBuildWithError = false;
10.163 - } else if (flag.equals("true")) {
10.164 - mAllowBuildWithError = true;
10.165 - }
10.166 - }
10.167 -
10.168 - }
10.169 -
10.170 -
10.171 - /**
10.172 - * Set the classpath reference
10.173 - * @param ref Classpath Reference
10.174 - */
10.175 - public void setClasspathRef(Reference ref) {
10.176 -
10.177 - }
10.178 -
10.179 - /**
10.180 - * Set the project classpath
10.181 - * @param projectClassPath Project classpath
10.182 - */
10.183 - public void setProjectClassPath(String projectClassPath) {
10.184 - this.mProjectClassPath = projectClassPath;
10.185 - }
10.186 -
10.187 - /**
10.188 - * Set the dependent project files directory
10.189 - * @param dependentProjectFilesDir dependent project files directory
10.190 - */
10.191 - public void setBuildDependentProjectDir(String dependentProjectFilesDir) {
10.192 - this.mBuildDependentProjectFilesDirectory = dependentProjectFilesDir;
10.193 - }
10.194 -
10.195 - public boolean isFoundErrors() {
10.196 - return this.isFoundErrors;
10.197 - }
10.198 -
10.199 - /**
10.200 - * Validate the BPEL Model
10.201 - */
10.202 - public void execute() throws BuildException {
10.203 -
10.204 - if(this.mSourceDirectory == null) {
10.205 - throw new BuildException("No directory is set for source files.");
10.206 - }
10.207 -
10.208 - if(this.mBuildDirectory == null) {
10.209 - throw new BuildException("No build directory is set.");
10.210 - }
10.211 -
10.212 - if(this.mBuildDependentProjectFilesDirectory == null) {
10.213 - throw new BuildException("No dependentProjectFiles directory is set.");
10.214 - }
10.215 -
10.216 -
10.217 - //create file object for project source directory
10.218 - try {
10.219 - this.mSourceDir = new File(this.mSourceDirectory);
10.220 - CommandlineBpelProjectXmlCatalogProvider.getInstance().setSourceDirectory(this.mSourceDirectory);
10.221 -
10.222 - } catch(Exception ex) {
10.223 - throw new BuildException("Failed to get File object for project source directory "+ this.mSourceDirectory, ex);
10.224 - }
10.225 -
10.226 - //create file object for project build directory
10.227 - try {
10.228 - this.mBuildDir = new File(this.mBuildDirectory);
10.229 - } catch(Exception ex) {
10.230 - throw new BuildException("Failed to get File object for project build directory "+ this.mBuildDirectory, ex);
10.231 - }
10.232 -
10.233 -
10.234 - //read project classpath
10.235 - //TODO: refactor this to use wsdl classpath. also we are assuming that source
10.236 - //are in src we should look into project properties. but this is done like
10.237 - //this in all icanpro projects??
10.238 - ArrayList projectDirs = new ArrayList();
10.239 - if(this.mProjectClassPath != null
10.240 - && !this.mProjectClassPath.trim().equals("")
10.241 - && !this.mProjectClassPath.trim().equals("${javac.classpath}")) {
10.242 - StringTokenizer st = new StringTokenizer(this.mProjectClassPath, ";");
10.243 - while (st.hasMoreTokens()) {
10.244 - String spath = st.nextToken();
10.245 - try {
10.246 -
10.247 - File sFile = new File(mSourceDir.getParentFile().getCanonicalPath() + File.separator + spath);
10.248 -
10.249 - File srcFolder = new File(sFile.getParentFile().getParentFile().getCanonicalFile(), "src");
10.250 - projectDirs.add(srcFolder);
10.251 - } catch(Exception ex) {
10.252 - throw new BuildException("Failed to create File object for dependent project path "+ spath);
10.253 - }
10.254 - }
10.255 - }
10.256 -
10.257 - processBpelFilesFolderInBuildDir(this.mBuildDir);
10.258 - this.mDependentProjectDirs = projectDirs;
10.259 -
10.260 - ArrayList sourceDirs = new ArrayList();
10.261 - sourceDirs.add(this.mSourceDir);
10.262 -
10.263 - processSourceDirs(sourceDirs);
10.264 -
10.265 - // if(foundValidationErrors) {
10.266 - // throw new BuildException("Found compilation errors in project files.");
10.267 - // }
10.268 - }
10.269 -
10.270 - private void processBpelFilesFolderInBuildDir(File folder) {
10.271 - File files[] = folder.listFiles(new Util.BpelFileFilter());
10.272 - for(int i =0; i < files.length; i++) {
10.273 - File file = files[i];
10.274 - if(file.isFile()) {
10.275 - processBpelFilesInBuildDir(file);
10.276 - } else {
10.277 - processBpelFilesFolderInBuildDir(file);
10.278 - }
10.279 - }
10.280 - }
10.281 -
10.282 - private void processBpelFilesInBuildDir(File bpelFile) {
10.283 - //always get relative path from build directory.
10.284 - //this relative path later is compared with relative path of
10.285 - //a file from source dir
10.286 - //(for a same file both should be equal)
10.287 - //example : c:\bpelproject\build\bank\bank.bpel
10.288 - //and c:\bpelproject\src\bank\bank.bpel
10.289 - //so relative path will be bank\bank.bpel
10.290 - //from build as well as from src directory.
10.291 - String relativePath = RelativePath.getRelativePath(this.mBuildDir, bpelFile);
10.292 - this.mBpelFileNamesToFileInBuildDir.put(relativePath, bpelFile);
10.293 - }
10.294 -
10.295 - private void processSourceDirs(List sourceDirs) {
10.296 - Iterator it = sourceDirs.iterator();
10.297 - while(it.hasNext()) {
10.298 - File sourceDir = (File) it.next();
10.299 - processSourceDir(sourceDir);
10.300 - }
10.301 -
10.302 - }
10.303 -
10.304 - private void processSourceDir(File sourceDir) {
10.305 - processFileObject(sourceDir);
10.306 - }
10.307 -
10.308 - private void processFileObject(File file) {
10.309 - if (file.isDirectory()) {
10.310 - processFolder(file);
10.311 - } else {
10.312 - //processFile(file);
10.313 - }
10.314 - }
10.315 -
10.316 - private void processFolder(File fileDir) {
10.317 - File[] bpelFiles = fileDir.listFiles(new Util.BpelFileFilter());
10.318 - processBpelFiles(bpelFiles);
10.319 - }
10.320 -
10.321 - private void processFile(File file) {
10.322 - String fileName = file.getName();
10.323 - String fileExtension = null;
10.324 - int dotIndex = fileName.lastIndexOf('.');
10.325 - if(dotIndex != -1) {
10.326 - fileExtension = fileName.substring(dotIndex +1);
10.327 - }
10.328 -
10.329 - if (fileExtension != null) {
10.330 - if(fileExtension.equalsIgnoreCase("bpel")) {
10.331 - processBpelFile(file);
10.332 - }
10.333 - }
10.334 -
10.335 - }
10.336 -
10.337 - private void processBpelFiles(File[]bpelFiles) {
10.338 - for (int i = 0; i < bpelFiles.length; i++) {
10.339 - if(bpelFiles[i].isFile()) {
10.340 - processBpelFile(bpelFiles[i]);
10.341 - } else {
10.342 - processFolder(bpelFiles[i]);
10.343 - }
10.344 - }
10.345 - }
10.346 -
10.347 - private void processBpelFile(File bpelFile) {
10.348 - if(isBpelFileModified(bpelFile)) {
10.349 - loadAndValidateExistingBusinessProcess(bpelFile);
10.350 - }
10.351 - }
10.352 -
10.353 - private boolean isBpelFileModified(File bpelFile) {
10.354 - boolean modified = true;
10.355 - String relativePath = RelativePath.getRelativePath(this.mSourceDir, bpelFile);
10.356 -
10.357 - File bpelFileInBuildDir = (File) this.mBpelFileNamesToFileInBuildDir.get(relativePath);
10.358 -
10.359 - if(bpelFileInBuildDir != null) {
10.360 - if(bpelFileInBuildDir.lastModified() == bpelFile.lastModified()) {
10.361 - modified = false;
10.362 - }
10.363 -
10.364 - }
10.365 -
10.366 - return modified;
10.367 - }
10.368 -
10.369 - private void validateBPEL(File bpel) throws BuildException {
10.370 - BpelModel model = null;
10.371 - try {
10.372 - model = BPELCatalogModel.getDefault().getBPELModel(bpel.toURI());
10.373 - }catch (Exception ex) {
10.374 - // ex.printStackTrace();
10.375 - throw new RuntimeException(" Error while trying to create BPEL Model ",ex);
10.376 - }
10.377 - //Validator validator = (Validator) Lookups.metaInfServices(getClass().getClassLoader()).lookup(Validator.class);
10.378 - Validation validation = new Validation();
10.379 - validation.validate((org.netbeans.modules.xml.xam.Model)model, ValidationType.COMPLETE);
10.380 - Collection col =validation.getValidationResult();
10.381 - boolean isError = false;
10.382 - //Collection col = validation.getValidationResult();
10.383 - for (Iterator itr = col.iterator(); itr.hasNext();) {
10.384 - ResultItem resultItem = (ResultItem) itr.next();
10.385 - logValidationErrors(bpel, resultItem);
10.386 - if(resultItem.getType() == Validator.ResultType.ERROR) {
10.387 - isError = true;
10.388 - }
10.389 - }
10.390 -
10.391 - if(isError) {
10.392 - this.isFoundErrors = true;
10.393 - }
10.394 - }
10.395 -
10.396 - private void logValidationErrors(File bpelFile, ResultItem resultItem) {
10.397 -
10.398 - int lineNumber = 0;
10.399 - int columnNumber = 0;
10.400 - String errorDescription = resultItem.getDescription();
10.401 - String msgType = resultItem.getType().name();
10.402 - Component component = resultItem.getComponents();
10.403 - File file = null;
10.404 - if(component != null) {
10.405 - lineNumber = ModelUtil.getLineNumber(component);
10.406 - columnNumber = ModelUtil.getColumnNumber(component);
10.407 - file = (File) component.getModel().getModelSource().getLookup().lookup(File.class);
10.408 - showError(file,columnNumber, lineNumber,errorDescription,msgType );
10.409 -
10.410 -
10.411 - }else {
10.412 - columnNumber = resultItem.getColumnNumber();
10.413 - lineNumber = resultItem.getLineNumber();
10.414 - file =(File)resultItem.getModel().getModelSource().getLookup().lookup(File.class);
10.415 - showError(file,columnNumber, lineNumber,errorDescription ,msgType);
10.416 - }
10.417 -
10.418 - }
10.419 -
10.420 - private void showError(File file, int columnNumber, int lineNumber, String errorDescription, String msgType) {
10.421 -
10.422 - StringBuffer lineNumStr = new StringBuffer(5);
10.423 - StringBuffer columnNumStr = new StringBuffer(5);
10.424 -
10.425 - if(lineNumber != -1) {
10.426 - lineNumStr.append(":");
10.427 - lineNumStr.append(lineNumber);
10.428 - lineNumStr.append(":");
10.429 -
10.430 - }
10.431 -
10.432 - if(columnNumber != -1) {
10.433 - columnNumStr.append(" column:");
10.434 - columnNumStr.append(columnNumber);
10.435 - columnNumStr.append(" ");
10.436 - }
10.437 -
10.438 -
10.439 - msgType = msgType + ": ";
10.440 -
10.441 - StringBuffer msg = new StringBuffer(100);
10.442 - if(file != null) {
10.443 - msg.append(file.getPath());
10.444 - }
10.445 -
10.446 - msg.append(lineNumStr);
10.447 - msg.append(columnNumStr);
10.448 - msg.append(msgType);
10.449 - msg.append(errorDescription);
10.450 -
10.451 -
10.452 -// System.out.println(msg.toString());
10.453 - }
10.454 -
10.455 - private void loadAndValidateExistingBusinessProcess(File bpelFile) throws BuildException {
10.456 - try {
10.457 - validateBPEL(bpelFile);
10.458 -
10.459 - } catch (Throwable ex) {
10.460 -// System.out.println("Validation has errors on "+bpelFile.getAbsolutePath());
10.461 - logger.log(Level.SEVERE, "Validation has errors on "+bpelFile.getAbsolutePath() );
10.462 -// System.out.println("Error Message - "+ ex.getMessage());
10.463 -
10.464 - if ( ex.getMessage() != null) {
10.465 - logger.severe( ex.getMessage());
10.466 - }
10.467 - if (!mAllowBuildWithError) {
10.468 - StringWriter writer = new StringWriter();
10.469 - PrintWriter pWriter = new PrintWriter(writer);
10.470 - ex.printStackTrace(pWriter);
10.471 - throw new BuildException(ex);
10.472 - }
10.473 - // logValidationErrors(ToDoEvent.Severity.ERROR, bpelFile, "Error compiling bpel process \n"+ writer.toString(), "please check if bpel file is valid", 1, 1 );
10.474 - }
10.475 -
10.476 - }
10.477 -
10.478 -}
11.1 --- a/bpel.project/antsrc/org/netbeans/modules/bpel/project/anttasks/ValidateBPELProjectTask.java Fri May 11 13:30:46 2007 +0000
11.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
11.3 @@ -1,233 +0,0 @@
11.4 -/*
11.5 - * The contents of this file are subject to the terms of the Common Development
11.6 - * and Distribution License (the License). You may not use this file except in
11.7 - * compliance with the License.
11.8 - *
11.9 - * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
11.10 - * or http://www.netbeans.org/cddl.txt.
11.11 - *
11.12 - * When distributing Covered Code, include this CDDL Header Notice in each file
11.13 - * and include the License file at http://www.netbeans.org/cddl.txt.
11.14 - * If applicable, add the following below the CDDL Header, with the fields
11.15 - * enclosed by brackets [] replaced by your own identifying information:
11.16 - * "Portions Copyrighted [year] [name of copyright owner]"
11.17 - *
11.18 - * The Original Software is NetBeans. The Initial Developer of the Original
11.19 - * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
11.20 - * Microsystems, Inc. All Rights Reserved.
11.21 - */
11.22 -package org.netbeans.modules.bpel.project.anttasks;
11.23 -
11.24 -import java.io.File;
11.25 -import java.io.PrintWriter;
11.26 -import java.io.StringWriter;
11.27 -
11.28 -import java.lang.reflect.Method;
11.29 -
11.30 -import java.net.URI;
11.31 -
11.32 -import java.util.List;
11.33 -
11.34 -import org.apache.tools.ant.AntClassLoader;
11.35 -import org.apache.tools.ant.BuildException;
11.36 -import org.apache.tools.ant.Task;
11.37 -import org.apache.tools.ant.types.Path;
11.38 -import org.apache.tools.ant.types.Reference;
11.39 -import java.util.logging.Level;
11.40 -import java.util.logging.Logger;
11.41 -/**
11.42 - * Ant task wrapper invokes Validate BPEL Model
11.43 - * @author Sreenivasan Genipudi
11.44 - */
11.45 -public class ValidateBPELProjectTask extends Task {
11.46 - /**
11.47 - * Constructor
11.48 - */
11.49 - public ValidateBPELProjectTask() {
11.50 - }
11.51 -
11.52 - /**
11.53 - * Constants
11.54 - */
11.55 - private static final String BPEL_EXT = ".bpel";
11.56 - private static final String WSDL_EXT = ".wsdl";
11.57 - private static final String XSD_EXT = ".xsd";
11.58 - /**
11.59 - * Logger instance
11.60 - */
11.61 - private Logger logger = Logger.getLogger(ValidateBPELProjectTask.class.getName());
11.62 - // Member variable representing source directory
11.63 - /**
11.64 - * Source directory
11.65 - */
11.66 - private String mSourceDirectory = null;
11.67 - // Member variable representing build directory
11.68 - /**
11.69 - * Build directory
11.70 - */
11.71 - private String mBuildDirectory = null;
11.72 - // Member variable representing project classpath
11.73 - /**
11.74 - * Project classpath
11.75 - */
11.76 - private String mProjectClassPath= null;
11.77 - /**
11.78 - * Dependent project directories
11.79 - */
11.80 - private List mDependentProjectDirs;
11.81 - /**
11.82 - * Custom classloader to invoke Validate BPEL
11.83 - */
11.84 - private AntClassLoader m_myClassLoader = null;
11.85 - /**
11.86 - * classpath reference
11.87 - */
11.88 - private Reference m_ref = null;
11.89 - private String mBuildDependentProjectFilesDirectory;
11.90 - private boolean mbRunValidation = true;
11.91 - private boolean mAllowBuildWithError = false;
11.92 -
11.93 - public void setBuildDependentProjectDir(String dependentProjectFilesDir) {
11.94 - this.mBuildDependentProjectFilesDirectory = dependentProjectFilesDir;
11.95 - }
11.96 - public void setClasspathRef(Reference ref) {
11.97 - this.m_ref = ref;
11.98 - }
11.99 - public void setBuildDirectory(String buildDir) {
11.100 - mBuildDirectory = buildDir;
11.101 - }
11.102 - /**
11.103 - * Set the source directory
11.104 - * @param srcDir source directory
11.105 - */
11.106 - public void setSourceDirectory(String srcDir) {
11.107 - this.mSourceDirectory = srcDir;
11.108 - }
11.109 - /**
11.110 - * Run validation
11.111 - * @param srcDir source directory
11.112 - */
11.113 - public void setRunValidation(String flag) {
11.114 - setAllowBuildWithError(flag);
11.115 - mAllowBuildWithError = !mAllowBuildWithError;
11.116 - }
11.117 -
11.118 - /**
11.119 - * Get the source directory
11.120 - * @return String value of the source directory
11.121 - */
11.122 - public String getSourceDirectory() {
11.123 - return this.mSourceDirectory;
11.124 - }
11.125 -
11.126 - /**
11.127 - * Set the project classpath
11.128 - * @param projectClassPath
11.129 - */
11.130 - public void setProjectClassPath(String projectClassPath) {
11.131 - this.mProjectClassPath = projectClassPath;
11.132 - }
11.133 -
11.134 - /**
11.135 - * Run validation
11.136 - * @param srcDir source directory
11.137 - */
11.138 - public void setAllowBuildWithError(String flag) {
11.139 - if (flag != null) {
11.140 - if (flag.equals("false")) {
11.141 - mAllowBuildWithError = false;
11.142 - } else if (flag.equals("true")) {
11.143 - mAllowBuildWithError = true;
11.144 - }
11.145 - }
11.146 -
11.147 - }
11.148 -
11.149 -
11.150 - /**
11.151 - * Invoke validate BPEL Model
11.152 - */
11.153 - public void execute() throws BuildException {
11.154 - try {
11.155 - m_myClassLoader = new AntClassLoader();
11.156 - initClassLoader();
11.157 - Class antTaskClass = Class.forName("org.netbeans.modules.bpel.project.anttasks.ValidateBPELProject", true,m_myClassLoader );
11.158 - Thread.currentThread().setContextClassLoader(m_myClassLoader);
11.159 -
11.160 - Object validateBPELObj = antTaskClass.newInstance();
11.161 -
11.162 -
11.163 - Method driver = antTaskClass.getMethod("setBuildDirectory",
11.164 - new Class[] { java.lang.String.class });
11.165 - Object[] param = new Object[] {
11.166 - this.mBuildDirectory
11.167 - };
11.168 - driver.invoke(validateBPELObj,
11.169 - param);
11.170 -
11.171 - driver = antTaskClass.getMethod("setSourceDirectory",
11.172 - new Class[] { java.lang.String.class });
11.173 - param = new Object[] {
11.174 - this.mSourceDirectory
11.175 - };
11.176 - driver.invoke(validateBPELObj,
11.177 - param);
11.178 -
11.179 - driver = antTaskClass.getMethod("setProjectClassPath",
11.180 - new Class[] { java.lang.String.class });
11.181 - param = new Object[] {
11.182 - this.mProjectClassPath
11.183 - };
11.184 - driver.invoke(validateBPELObj,
11.185 - param);
11.186 -
11.187 - driver = antTaskClass.getMethod("setBuildDependentProjectDir",
11.188 - new Class[] { java.lang.String.class });
11.189 - param = new Object[] {
11.190 - this.mBuildDependentProjectFilesDirectory
11.191 - };
11.192 - driver.invoke(validateBPELObj,
11.193 - param);
11.194 -
11.195 - driver = antTaskClass.getMethod("execute",
11.196 - null);
11.197 - driver.invoke(validateBPELObj, null);
11.198 -
11.199 - driver = antTaskClass.getMethod("isFoundErrors",
11.200 - null);
11.201 -
11.202 - Boolean isErrors = (Boolean) driver.invoke(validateBPELObj, null);
11.203 - if(isErrors.booleanValue()) {
11.204 - throw new BuildException("Found validation errors.");
11.205 - }
11.206 -
11.207 - }catch (Throwable ex) {
11.208 - // ex.printStackTrace();
11.209 - if (!mAllowBuildWithError ) {
11.210 - logger.log(Level.FINE, "Validation has errors!!",ex );
11.211 - throw new BuildException("Found compilation errors.");
11.212 - }
11.213 - }
11.214 - }
11.215 -
11.216 - /**
11.217 - * Create custom classloader ( Ant classloader) with
11.218 - * parentFirst = false
11.219 - */
11.220 - private void initClassLoader() {
11.221 - Path path = new Path(getProject());
11.222 - path.setRefid(m_ref);
11.223 -
11.224 - Path parentPath = new Path(getProject());
11.225 - ClassLoader cl = this.getClass().getClassLoader();
11.226 - if (cl instanceof AntClassLoader) {
11.227 - parentPath.setPath(((AntClassLoader)cl).getClasspath());
11.228 - ((AntClassLoader)cl).setParent(null);
11.229 - parentPath.add(path);
11.230 - path = parentPath;
11.231 - }
11.232 - m_myClassLoader.setClassPath(path);
11.233 - m_myClassLoader.setParent(null);
11.234 - m_myClassLoader.setParentFirst(false);
11.235 - }
11.236 -}
12.1 --- a/bpel.project/src/org/netbeans/modules/bpel/project/BpelproActionProvider.java Fri May 11 13:30:46 2007 +0000
12.2 +++ b/bpel.project/src/org/netbeans/modules/bpel/project/BpelproActionProvider.java Fri May 11 13:40:22 2007 +0000
12.3 @@ -163,15 +163,15 @@
12.4 //// }
12.5
12.6
12.7 -// if build command then build any depedent project
12.8 +// if build command then build any depedent project
12.9 if(command.equals(COMMAND_BUILD)) {
12.10 - try {
12.11 - buildDependentProjectsAndRunTask(targetNames, p);
12.12 - } catch (IOException e) {
12.13 + try {
12.14 + buildDependentProjectsAndRunTask(targetNames, p);
12.15 + } catch (IOException e) {
12.16 ErrorManager.getDefault().notify(e);
12.17 }
12.18 } else {
12.19 - runTask(targetNames, p);
12.20 + runTask(targetNames, p);
12.21 }
12.22
12.23
12.24 @@ -179,8 +179,8 @@
12.25 }
12.26
12.27 private void runTask(String[] targetNames, Properties p) {
12.28 - try {
12.29 - ActionUtils.runTarget(findBuildXml(), targetNames, p);
12.30 + try {
12.31 + ActionUtils.runTarget(findBuildXml(), targetNames, p);
12.32 }
12.33 catch (IOException e) {
12.34 ErrorManager.getDefault().notify(e);
12.35 @@ -188,7 +188,7 @@
12.36 }
12.37
12.38 private void buildDependentProjectsAndRunTask(String[] targetNames, Properties p) throws IOException {
12.39 - IcanproProjectProperties app = this.project.getProjectProperties();
12.40 + IcanproProjectProperties app = this.project.getProjectProperties();
12.41 List items = (List) app.get(IcanproProjectProperties.JAVAC_CLASSPATH);
12.42 ArrayList artifacts = new ArrayList();
12.43
12.44 @@ -197,30 +197,30 @@
12.45 AntArtifact aa = (AntArtifact) vi.getObject();
12.46 String loc = aa.getProject().getProjectDirectory().getPath() + "/" + aa.getArtifactLocation().getPath();
12.47 File asa = new File(loc);
12.48 - log(" Dependent Project artifact jar: "+ loc + ", [" + (asa.exists()?"exist":"missing") + "]");
12.49 + log("Dependent Project artifact jar: "+ loc + ", [" + (asa.exists()?"exist":"missing") + "]");
12.50 if (! asa.exists()) {
12.51 - artifacts.add(aa);
12.52 + artifacts.add(aa);
12.53 }
12.54 }
12.55
12.56 if(artifacts.size() != 0) {
12.57 - //use AntTaskListener which invokes the target on
12.58 - //current project build script after all the depedent projects
12.59 - //are build
12.60 - AntTaskListener antTaskListener = new AntTaskListener(targetNames, p);
12.61 - antTaskListener.setTotalTasks(artifacts.size());
12.62 - Iterator it = artifacts.iterator();
12.63 - while(it.hasNext()) {
12.64 - AntArtifact aa = (AntArtifact) it.next();
12.65 - String loc = aa.getProject().getProjectDirectory().getPath() + "/" + aa.getArtifactLocation().getPath();
12.66 - log(" Building dependent project "+ loc + "...");
12.67 - ExecutorTask task = ActionUtils.runTarget(aa.getScriptFile(), new String[] { aa.getTargetName() }, null);
12.68 - task.addTaskListener(antTaskListener);
12.69 - }
12.70 + //use AntTaskListener which invokes the target on
12.71 + //current project build script after all the depedent projects
12.72 + //are build
12.73 + AntTaskListener antTaskListener = new AntTaskListener(targetNames, p);
12.74 + antTaskListener.setTotalTasks(artifacts.size());
12.75 + Iterator it = artifacts.iterator();
12.76 + while(it.hasNext()) {
12.77 + AntArtifact aa = (AntArtifact) it.next();
12.78 + String loc = aa.getProject().getProjectDirectory().getPath() + "/" + aa.getArtifactLocation().getPath();
12.79 + log("Building dependent project "+ loc + "...");
12.80 + ExecutorTask task = ActionUtils.runTarget(aa.getScriptFile(), new String[] { aa.getTargetName() }, null);
12.81 + task.addTaskListener(antTaskListener);
12.82 + }
12.83 } else {
12.84 - //no need to build depedent projects
12.85 - //directly invoke target on current project build script;
12.86 - runTask(targetNames, p);
12.87 + //no need to build depedent projects
12.88 + //directly invoke target on current project build script;
12.89 + runTask(targetNames, p);
12.90 }
12.91 }
12.92
12.93 @@ -246,25 +246,25 @@
12.94 }
12.95
12.96 class AntTaskListener implements TaskListener {
12.97 - int totalTaskCount;
12.98 - int finishedTaskCount = 0;
12.99 - private String[] mTargetNames;
12.100 - private Properties mProperties;
12.101 + int totalTaskCount;
12.102 + int finishedTaskCount = 0;
12.103 + private String[] mTargetNames;
12.104 + private Properties mProperties;
12.105
12.106 - public AntTaskListener(String[] targetNames, Properties p) {
12.107 - this.mTargetNames = targetNames;
12.108 - this.mProperties = p;
12.109 - }
12.110 + public AntTaskListener(String[] targetNames, Properties p) {
12.111 + this.mTargetNames = targetNames;
12.112 + this.mProperties = p;
12.113 + }
12.114
12.115 - public void setTotalTasks(int total) {
12.116 - this.totalTaskCount = total;
12.117 - }
12.118 + public void setTotalTasks(int total) {
12.119 + this.totalTaskCount = total;
12.120 + }
12.121
12.122 - public void taskFinished(Task task) {
12.123 - finishedTaskCount++;
12.124 - if(finishedTaskCount == totalTaskCount) {
12.125 - runTask(this.mTargetNames, this.mProperties);
12.126 - }
12.127 - }
12.128 + public void taskFinished(Task task) {
12.129 + finishedTaskCount++;
12.130 + if(finishedTaskCount == totalTaskCount) {
12.131 + runTask(this.mTargetNames, this.mProperties);
12.132 + }
12.133 + }
12.134 }
12.135 }
13.1 --- a/bpel.project/src/org/netbeans/modules/bpel/project/resources/build.xsl Fri May 11 13:30:46 2007 +0000
13.2 +++ b/bpel.project/src/org/netbeans/modules/bpel/project/resources/build.xsl Fri May 11 13:40:22 2007 +0000
13.3 @@ -115,13 +115,7 @@
13.4
13.5 <target name="pre-init">
13.6 <xsl:attribute name="depends">-check-netbeans-home,-init-caps</xsl:attribute>
13.7 -
13.8 - <echo>netbeans.home: ${netbeans.home}</echo>
13.9 - <echo>netbeans.user: ${netbeans.user}</echo>
13.10 </target>
13.11 -
13.12 </project>
13.13 -
13.14 </xsl:template>
13.15 -
13.16 </xsl:stylesheet>
14.1 --- a/bpel.samples/resources/AsynchronousSample/AsynchronousSample/build.xml Fri May 11 13:30:46 2007 +0000
14.2 +++ b/bpel.samples/resources/AsynchronousSample/AsynchronousSample/build.xml Fri May 11 13:40:22 2007 +0000
14.3 @@ -70,7 +70,5 @@
14.4 <property name="from.commandline" value="true"/>
14.5 </target>
14.6 <target name="pre-init" depends="-check-netbeans-home,-init-caps">
14.7 - <echo>netbeans.home: ${netbeans.home}</echo>
14.8 - <echo>netbeans.user: ${netbeans.user}</echo>
14.9 </target>
14.10 </project>
15.1 --- a/bpel.samples/resources/SynchronousSample/SynchronousSample/build.xml Fri May 11 13:30:46 2007 +0000
15.2 +++ b/bpel.samples/resources/SynchronousSample/SynchronousSample/build.xml Fri May 11 13:40:22 2007 +0000
15.3 @@ -70,7 +70,5 @@
15.4 <property name="from.commandline" value="true"/>
15.5 </target>
15.6 <target name="pre-init" depends="-check-netbeans-home,-init-caps">
15.7 - <echo>netbeans.home: ${netbeans.home}</echo>
15.8 - <echo>netbeans.user: ${netbeans.user}</echo>
15.9 </target>
15.10 </project>
16.1 --- a/bpel.samples/resources/TravelReservationService/TravelReservationService/build.xml Fri May 11 13:30:46 2007 +0000
16.2 +++ b/bpel.samples/resources/TravelReservationService/TravelReservationService/build.xml Fri May 11 13:40:22 2007 +0000
16.3 @@ -70,7 +70,5 @@
16.4 <property name="from.commandline" value="true"/>
16.5 </target>
16.6 <target name="pre-init" depends="-check-netbeans-home,-init-caps">
16.7 - <echo>netbeans.home: ${netbeans.home}</echo>
16.8 - <echo>netbeans.user: ${netbeans.user}</echo>
16.9 </target>
16.10 </project>