[14982] | 1 | /*
|
---|
| 2 | * Copyright 2001-2004 The Apache Software Foundation
|
---|
| 3 | *
|
---|
| 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
| 5 | * you may not use this file except in compliance with the License.
|
---|
| 6 | * You may obtain a copy of the License at
|
---|
| 7 | *
|
---|
| 8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
| 9 | *
|
---|
| 10 | * Unless required by applicable law or agreed to in writing, software
|
---|
| 11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
| 13 | * See the License for the specific language governing permissions and
|
---|
| 14 | * limitations under the License.
|
---|
| 15 | *
|
---|
| 16 | */
|
---|
| 17 |
|
---|
| 18 |
|
---|
| 19 | package org.apache.tools.ant.taskdefs.optional.ejb;
|
---|
| 20 |
|
---|
| 21 |
|
---|
| 22 | import java.io.BufferedReader;
|
---|
| 23 | import java.io.File;
|
---|
| 24 | import java.io.IOException;
|
---|
| 25 | import java.io.InputStream;
|
---|
| 26 | import java.io.InputStreamReader;
|
---|
| 27 | import java.io.OutputStream;
|
---|
| 28 | import java.util.Hashtable;
|
---|
| 29 | import java.util.Iterator;
|
---|
| 30 | import java.util.Vector;
|
---|
| 31 | import org.apache.tools.ant.BuildException;
|
---|
| 32 | import org.apache.tools.ant.Project;
|
---|
| 33 | import org.apache.tools.ant.taskdefs.ExecTask;
|
---|
| 34 | import org.apache.tools.ant.taskdefs.Execute;
|
---|
| 35 | import org.apache.tools.ant.taskdefs.ExecuteStreamHandler;
|
---|
| 36 | import org.apache.tools.ant.taskdefs.Java;
|
---|
| 37 | import org.apache.tools.ant.types.Commandline;
|
---|
| 38 | import org.apache.tools.ant.types.Path;
|
---|
| 39 |
|
---|
| 40 |
|
---|
| 41 | /**
|
---|
| 42 | * BorlandDeploymentTool is dedicated to the Borland Application Server 4.5 and 4.5.1
|
---|
| 43 | * This task generates and compiles the stubs and skeletons for all ejb described into the
|
---|
| 44 | * Deployment Descriptor, builds the jar file including the support files and verify
|
---|
| 45 | * whether the produced jar is valid or not.
|
---|
| 46 | * The supported options are:
|
---|
| 47 | * <ul>
|
---|
| 48 | * <li>debug (boolean) : turn on the debug mode for generation of
|
---|
| 49 | * stubs and skeletons (default:false)</li>
|
---|
| 50 | * <li>verify (boolean) : turn on the verification at the end of the jar
|
---|
| 51 | * production (default:true) </li>
|
---|
| 52 | * <li>verifyargs (String) : add optional argument to verify command
|
---|
| 53 | * (see vbj com.inprise.ejb.util.Verify)</li>
|
---|
| 54 | * <li>basdtd (String) : location of the BAS DTD </li>
|
---|
| 55 | * <li>generateclient (boolean) : turn on the client jar file generation </li>
|
---|
| 56 | * <li>version (int) : tell what is the Borland appserver version 4 or 5 </li>
|
---|
| 57 | * </ul>
|
---|
| 58 | *
|
---|
| 59 | *<PRE>
|
---|
| 60 | *
|
---|
| 61 | * <ejbjar srcdir="${build.classes}"
|
---|
| 62 | * basejarname="vsmp"
|
---|
| 63 | * descriptordir="${rsc.dir}/hrmanager">
|
---|
| 64 | * <borland destdir="tstlib">
|
---|
| 65 | * <classpath refid="classpath" />
|
---|
| 66 | * </borland>
|
---|
| 67 | * <include name="**\ejb-jar.xml"/>
|
---|
| 68 | * <support dir="${build.classes}">
|
---|
| 69 | * <include name="demo\smp\*.class"/>
|
---|
| 70 | * <include name="demo\helper\*.class"/>
|
---|
| 71 | * </support>
|
---|
| 72 | * </ejbjar>
|
---|
| 73 | *</PRE>
|
---|
| 74 | *
|
---|
| 75 | */
|
---|
| 76 | public class BorlandDeploymentTool extends GenericDeploymentTool
|
---|
| 77 | implements ExecuteStreamHandler {
|
---|
| 78 | public static final String PUBLICID_BORLAND_EJB
|
---|
| 79 | = "-//Inprise Corporation//DTD Enterprise JavaBeans 1.1//EN";
|
---|
| 80 |
|
---|
| 81 | protected static final String DEFAULT_BAS45_EJB11_DTD_LOCATION
|
---|
| 82 | = "/com/inprise/j2ee/xml/dtds/ejb-jar.dtd";
|
---|
| 83 |
|
---|
| 84 | protected static final String DEFAULT_BAS_DTD_LOCATION
|
---|
| 85 | = "/com/inprise/j2ee/xml/dtds/ejb-inprise.dtd";
|
---|
| 86 |
|
---|
| 87 | protected static final String BAS_DD = "ejb-inprise.xml";
|
---|
| 88 | protected static final String BES_DD = "ejb-borland.xml";
|
---|
| 89 |
|
---|
| 90 |
|
---|
| 91 | /** Java2iiop executable **/
|
---|
| 92 | protected static final String JAVA2IIOP = "java2iiop";
|
---|
| 93 |
|
---|
| 94 | /** Verify class */
|
---|
| 95 | protected static final String VERIFY = "com.inprise.ejb.util.Verify";
|
---|
| 96 |
|
---|
| 97 | /** Instance variable that stores the suffix for the borland jarfile. */
|
---|
| 98 | private String jarSuffix = "-ejb.jar";
|
---|
| 99 |
|
---|
| 100 | /** Instance variable that stores the location of the borland DTD file. */
|
---|
| 101 | private String borlandDTD;
|
---|
| 102 |
|
---|
| 103 | /** Instance variable that determines whether the debug mode is on */
|
---|
| 104 | private boolean java2iiopdebug = false;
|
---|
| 105 |
|
---|
| 106 | /** store additional param for java2iiop command used to build EJB Stubs */
|
---|
| 107 | private String java2iioparams = null;
|
---|
| 108 |
|
---|
| 109 | /** Instance variable that determines whether the client jar file is generated */
|
---|
| 110 | private boolean generateclient = false;
|
---|
| 111 |
|
---|
| 112 | /** Borland Enterprise Server = version 5 */
|
---|
| 113 | static final int BES = 5;
|
---|
| 114 | /** Borland Application Server or Inprise Application Server = version 4 */
|
---|
| 115 | static final int BAS = 4;
|
---|
| 116 |
|
---|
| 117 | /** borland appserver version 4 or 5 */
|
---|
| 118 | private int version = BAS;
|
---|
| 119 |
|
---|
| 120 |
|
---|
| 121 | /**
|
---|
| 122 | * Instance variable that determines whether it is necessary to verify the
|
---|
| 123 | * produced jar
|
---|
| 124 | */
|
---|
| 125 | private boolean verify = true;
|
---|
| 126 | private String verifyArgs = "";
|
---|
| 127 |
|
---|
| 128 | private Hashtable _genfiles = new Hashtable();
|
---|
| 129 |
|
---|
| 130 | /**
|
---|
| 131 | * set the debug mode for java2iiop (default false)
|
---|
| 132 | **/
|
---|
| 133 | public void setDebug(boolean debug) {
|
---|
| 134 | this.java2iiopdebug = debug;
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 | /**
|
---|
| 138 | * set the verify mode for the produced jar (default true)
|
---|
| 139 | **/
|
---|
| 140 | public void setVerify(boolean verify) {
|
---|
| 141 | this.verify = verify;
|
---|
| 142 | }
|
---|
| 143 |
|
---|
| 144 |
|
---|
| 145 | /**
|
---|
| 146 | * Setter used to store the suffix for the generated borland jar file.
|
---|
| 147 | * @param inString the string to use as the suffix.
|
---|
| 148 | */
|
---|
| 149 | public void setSuffix(String inString) {
|
---|
| 150 | this.jarSuffix = inString;
|
---|
| 151 | }
|
---|
| 152 |
|
---|
| 153 |
|
---|
| 154 | /**
|
---|
| 155 | * sets some additional args to send to verify command
|
---|
| 156 | * @param args additional command line parameters
|
---|
| 157 | */
|
---|
| 158 | public void setVerifyArgs(String args) {
|
---|
| 159 | this.verifyArgs = args;
|
---|
| 160 | }
|
---|
| 161 |
|
---|
| 162 | /**
|
---|
| 163 | * Setter used to store the location of the borland DTD. This can be a file on the system
|
---|
| 164 | * or a resource on the classpath.
|
---|
| 165 | * @param inString the string to use as the DTD location.
|
---|
| 166 | */
|
---|
| 167 | public void setBASdtd(String inString) {
|
---|
| 168 | this.borlandDTD = inString;
|
---|
| 169 | }
|
---|
| 170 |
|
---|
| 171 |
|
---|
| 172 | /**
|
---|
| 173 | * setter used to store whether the task will include the generate client task.
|
---|
| 174 | * (see : BorlandGenerateClient task)
|
---|
| 175 | */
|
---|
| 176 | public void setGenerateclient(boolean b) {
|
---|
| 177 | this.generateclient = b;
|
---|
| 178 | }
|
---|
| 179 |
|
---|
| 180 | /**
|
---|
| 181 | * setter used to store the borland appserver version [4 or 5]
|
---|
| 182 | * @param version app server version 4 or 5
|
---|
| 183 | */
|
---|
| 184 | public void setVersion(int version) {
|
---|
| 185 | this.version = version;
|
---|
| 186 | }
|
---|
| 187 |
|
---|
| 188 | /**
|
---|
| 189 | * If filled, the params are added to the java2iiop command.
|
---|
| 190 | * (ex: -no_warn_missing_define)
|
---|
| 191 | * @param params additional params for java2iiop
|
---|
| 192 | */
|
---|
| 193 | public void setJava2iiopParams(String params) {
|
---|
| 194 | this.java2iioparams = params;
|
---|
| 195 | }
|
---|
| 196 |
|
---|
| 197 |
|
---|
| 198 | protected DescriptorHandler getBorlandDescriptorHandler(final File srcDir) {
|
---|
| 199 | DescriptorHandler handler =
|
---|
| 200 | new DescriptorHandler(getTask(), srcDir) {
|
---|
| 201 | protected void processElement() {
|
---|
| 202 | if (currentElement.equals("type-storage")) {
|
---|
| 203 | // Get the filename of vendor specific descriptor
|
---|
| 204 | String fileNameWithMETA = currentText;
|
---|
| 205 | //trim the META_INF\ off of the file name
|
---|
| 206 | String fileName
|
---|
| 207 | = fileNameWithMETA.substring(META_DIR.length(),
|
---|
| 208 | fileNameWithMETA.length());
|
---|
| 209 | File descriptorFile = new File(srcDir, fileName);
|
---|
| 210 |
|
---|
| 211 | ejbFiles.put(fileNameWithMETA, descriptorFile);
|
---|
| 212 | }
|
---|
| 213 | }
|
---|
| 214 | };
|
---|
| 215 | handler.registerDTD(PUBLICID_BORLAND_EJB,
|
---|
| 216 | borlandDTD == null ? DEFAULT_BAS_DTD_LOCATION : borlandDTD);
|
---|
| 217 |
|
---|
| 218 | for (Iterator i = getConfig().dtdLocations.iterator(); i.hasNext();) {
|
---|
| 219 | EjbJar.DTDLocation dtdLocation = (EjbJar.DTDLocation) i.next();
|
---|
| 220 | handler.registerDTD(dtdLocation.getPublicId(), dtdLocation.getLocation());
|
---|
| 221 | }
|
---|
| 222 | return handler;
|
---|
| 223 | }
|
---|
| 224 |
|
---|
| 225 | /**
|
---|
| 226 | * Add any vendor specific files which should be included in the
|
---|
| 227 | * EJB Jar.
|
---|
| 228 | */
|
---|
| 229 | protected void addVendorFiles(Hashtable ejbFiles, String ddPrefix) {
|
---|
| 230 |
|
---|
| 231 | //choose the right vendor DD
|
---|
| 232 | if (!(version == BES || version == BAS)) {
|
---|
| 233 | throw new BuildException("version " + version + " is not supported");
|
---|
| 234 | }
|
---|
| 235 |
|
---|
| 236 | String dd = (version == BES ? BES_DD : BAS_DD);
|
---|
| 237 |
|
---|
| 238 | log("vendor file : " + ddPrefix + dd, Project.MSG_DEBUG);
|
---|
| 239 |
|
---|
| 240 | File borlandDD = new File(getConfig().descriptorDir, ddPrefix + dd);
|
---|
| 241 | if (borlandDD.exists()) {
|
---|
| 242 | log("Borland specific file found " + borlandDD, Project.MSG_VERBOSE);
|
---|
| 243 | ejbFiles.put(META_DIR + dd , borlandDD);
|
---|
| 244 | } else {
|
---|
| 245 | log("Unable to locate borland deployment descriptor. "
|
---|
| 246 | + "It was expected to be in "
|
---|
| 247 | + borlandDD.getPath(), Project.MSG_WARN);
|
---|
| 248 | return;
|
---|
| 249 | }
|
---|
| 250 | }
|
---|
| 251 |
|
---|
| 252 | /**
|
---|
| 253 | * Get the vendor specific name of the Jar that will be output. The modification date
|
---|
| 254 | * of this jar will be checked against the dependent bean classes.
|
---|
| 255 | */
|
---|
| 256 | File getVendorOutputJarFile(String baseName) {
|
---|
| 257 | return new File(getDestDir(), baseName + jarSuffix);
|
---|
| 258 | }
|
---|
| 259 |
|
---|
| 260 | /**
|
---|
| 261 | * Verify the produced jar file by invoking the Borland verify tool
|
---|
| 262 | * @param sourceJar java.io.File representing the produced jar file
|
---|
| 263 | */
|
---|
| 264 | private void verifyBorlandJar(File sourceJar) {
|
---|
| 265 | if (version == BAS) {
|
---|
| 266 | verifyBorlandJarV4(sourceJar);
|
---|
| 267 | return;
|
---|
| 268 | }
|
---|
| 269 | if (version == BES) {
|
---|
| 270 | verifyBorlandJarV5(sourceJar);
|
---|
| 271 | return;
|
---|
| 272 | }
|
---|
| 273 | log("verify jar skipped because the version is invalid ["
|
---|
| 274 | + version + "]", Project.MSG_WARN);
|
---|
| 275 | }
|
---|
| 276 |
|
---|
| 277 | /**
|
---|
| 278 | * Verify the produced jar file by invoking the Borland iastool tool
|
---|
| 279 | * @param sourceJar java.io.File representing the produced jar file
|
---|
| 280 | */
|
---|
| 281 | private void verifyBorlandJarV5(File sourceJar) {
|
---|
| 282 | log("verify BES " + sourceJar, Project.MSG_INFO);
|
---|
| 283 | try {
|
---|
| 284 | org.apache.tools.ant.taskdefs.ExecTask execTask = null;
|
---|
| 285 | execTask = (ExecTask) getTask().getProject().createTask("exec");
|
---|
| 286 | execTask.setDir(new File("."));
|
---|
| 287 | execTask.setExecutable("iastool");
|
---|
| 288 | //classpath
|
---|
| 289 | if (getCombinedClasspath() != null) {
|
---|
| 290 | execTask.createArg().setValue("-VBJclasspath");
|
---|
| 291 | execTask.createArg().setValue(getCombinedClasspath().toString());
|
---|
| 292 | }
|
---|
| 293 |
|
---|
| 294 | if (java2iiopdebug) {
|
---|
| 295 | execTask.createArg().setValue("-debug");
|
---|
| 296 | }
|
---|
| 297 | execTask.createArg().setValue("-verify");
|
---|
| 298 | execTask.createArg().setValue("-src");
|
---|
| 299 | // ejb jar file to verify
|
---|
| 300 | execTask.createArg().setValue(sourceJar.getPath());
|
---|
| 301 | log("Calling iastool", Project.MSG_VERBOSE);
|
---|
| 302 | execTask.execute();
|
---|
| 303 | } catch (Exception e) {
|
---|
| 304 | // Have to catch this because of the semantics of calling main()
|
---|
| 305 | String msg = "Exception while calling generateclient Details: "
|
---|
| 306 | + e.toString();
|
---|
| 307 | throw new BuildException(msg, e);
|
---|
| 308 | }
|
---|
| 309 | }
|
---|
| 310 |
|
---|
| 311 | /**
|
---|
| 312 | * Verify the produced jar file by invoking the Borland verify tool
|
---|
| 313 | * @param sourceJar java.io.File representing the produced jar file
|
---|
| 314 | */
|
---|
| 315 | private void verifyBorlandJarV4(File sourceJar) {
|
---|
| 316 | org.apache.tools.ant.taskdefs.Java javaTask = null;
|
---|
| 317 | log("verify BAS " + sourceJar, Project.MSG_INFO);
|
---|
| 318 | try {
|
---|
| 319 | String args = verifyArgs;
|
---|
| 320 | args += " " + sourceJar.getPath();
|
---|
| 321 |
|
---|
| 322 | javaTask = (Java) getTask().getProject().createTask("java");
|
---|
| 323 | javaTask.setTaskName("verify");
|
---|
| 324 | javaTask.setClassname(VERIFY);
|
---|
| 325 | Commandline.Argument arguments = javaTask.createArg();
|
---|
| 326 | arguments.setLine(args);
|
---|
| 327 | Path classpath = getCombinedClasspath();
|
---|
| 328 | if (classpath != null) {
|
---|
| 329 | javaTask.setClasspath(classpath);
|
---|
| 330 | javaTask.setFork(true);
|
---|
| 331 | }
|
---|
| 332 |
|
---|
| 333 | log("Calling " + VERIFY + " for " + sourceJar.toString(),
|
---|
| 334 | Project.MSG_VERBOSE);
|
---|
| 335 | javaTask.execute();
|
---|
| 336 | } catch (Exception e) {
|
---|
| 337 | //TO DO : delete the file if it is not a valid file.
|
---|
| 338 | String msg = "Exception while calling " + VERIFY + " Details: "
|
---|
| 339 | + e.toString();
|
---|
| 340 | throw new BuildException(msg, e);
|
---|
| 341 | }
|
---|
| 342 | }
|
---|
| 343 |
|
---|
| 344 |
|
---|
| 345 | /**
|
---|
| 346 | * Generate the client jar corresponding to the jar file passed as parameter
|
---|
| 347 | * the method uses the BorlandGenerateClient task.
|
---|
| 348 | * @param sourceJar java.io.File representing the produced jar file
|
---|
| 349 | */
|
---|
| 350 | private void generateClient(File sourceJar) {
|
---|
| 351 | getTask().getProject().addTaskDefinition("internal_bas_generateclient",
|
---|
| 352 | org.apache.tools.ant.taskdefs.optional.ejb.BorlandGenerateClient.class);
|
---|
| 353 |
|
---|
| 354 | org.apache.tools.ant.taskdefs.optional.ejb.BorlandGenerateClient gentask = null;
|
---|
| 355 | log("generate client for " + sourceJar, Project.MSG_INFO);
|
---|
| 356 | try {
|
---|
| 357 | Project project = getTask().getProject();
|
---|
| 358 | gentask
|
---|
| 359 | = (BorlandGenerateClient) project.createTask("internal_bas_generateclient");
|
---|
| 360 | gentask.setEjbjar(sourceJar);
|
---|
| 361 | gentask.setDebug(java2iiopdebug);
|
---|
| 362 | Path classpath = getCombinedClasspath();
|
---|
| 363 | if (classpath != null) {
|
---|
| 364 | gentask.setClasspath(classpath);
|
---|
| 365 | }
|
---|
| 366 | gentask.setVersion(version);
|
---|
| 367 | gentask.setTaskName("generate client");
|
---|
| 368 | gentask.execute();
|
---|
| 369 | } catch (Exception e) {
|
---|
| 370 | //TO DO : delete the file if it is not a valid file.
|
---|
| 371 | String msg = "Exception while calling " + VERIFY + " Details: "
|
---|
| 372 | + e.toString();
|
---|
| 373 | throw new BuildException(msg, e);
|
---|
| 374 | }
|
---|
| 375 | }
|
---|
| 376 |
|
---|
| 377 | /**
|
---|
| 378 | * Generate stubs & skeleton for each home found into the DD
|
---|
| 379 | * Add all the generate class file into the ejb files
|
---|
| 380 | * @param ithomes : iterator on home class
|
---|
| 381 | */
|
---|
| 382 | private void buildBorlandStubs(Iterator ithomes) {
|
---|
| 383 | Execute execTask = null;
|
---|
| 384 |
|
---|
| 385 | execTask = new Execute(this);
|
---|
| 386 | Project project = getTask().getProject();
|
---|
| 387 | execTask.setAntRun(project);
|
---|
| 388 | execTask.setWorkingDirectory(project.getBaseDir());
|
---|
| 389 |
|
---|
| 390 | Commandline commandline = new Commandline();
|
---|
| 391 | commandline.setExecutable(JAVA2IIOP);
|
---|
| 392 | //debug ?
|
---|
| 393 | if (java2iiopdebug) {
|
---|
| 394 | commandline.createArgument().setValue("-VBJdebug");
|
---|
| 395 | }
|
---|
| 396 | //set the classpath
|
---|
| 397 | commandline.createArgument().setValue("-VBJclasspath");
|
---|
| 398 | commandline.createArgument().setPath(getCombinedClasspath());
|
---|
| 399 | //list file
|
---|
| 400 | commandline.createArgument().setValue("-list_files");
|
---|
| 401 | //no TIE classes
|
---|
| 402 | commandline.createArgument().setValue("-no_tie");
|
---|
| 403 |
|
---|
| 404 | if (java2iioparams != null) {
|
---|
| 405 | log("additional " + java2iioparams + " to java2iiop ", 0);
|
---|
| 406 | commandline.createArgument().setValue(java2iioparams);
|
---|
| 407 | }
|
---|
| 408 |
|
---|
| 409 |
|
---|
| 410 | //root dir
|
---|
| 411 | commandline.createArgument().setValue("-root_dir");
|
---|
| 412 | commandline.createArgument().setValue(getConfig().srcDir.getAbsolutePath());
|
---|
| 413 | //compiling order
|
---|
| 414 | commandline.createArgument().setValue("-compile");
|
---|
| 415 | //add the home class
|
---|
| 416 | while (ithomes.hasNext()) {
|
---|
| 417 | commandline.createArgument().setValue(ithomes.next().toString());
|
---|
| 418 | }
|
---|
| 419 |
|
---|
| 420 | try {
|
---|
| 421 | log("Calling java2iiop", Project.MSG_VERBOSE);
|
---|
| 422 | log(commandline.describeCommand(), Project.MSG_DEBUG);
|
---|
| 423 | execTask.setCommandline(commandline.getCommandline());
|
---|
| 424 | int result = execTask.execute();
|
---|
| 425 | if (Execute.isFailure(result)) {
|
---|
| 426 | String msg = "Failed executing java2iiop (ret code is "
|
---|
| 427 | + result + ")";
|
---|
| 428 | throw new BuildException(msg, getTask().getLocation());
|
---|
| 429 | }
|
---|
| 430 | } catch (java.io.IOException e) {
|
---|
| 431 | log("java2iiop exception :" + e.getMessage(), Project.MSG_ERR);
|
---|
| 432 | throw new BuildException(e, getTask().getLocation());
|
---|
| 433 | }
|
---|
| 434 | }
|
---|
| 435 |
|
---|
| 436 | /**
|
---|
| 437 | * Method used to encapsulate the writing of the JAR file. Iterates over the
|
---|
| 438 | * filenames/java.io.Files in the Hashtable stored on the instance variable
|
---|
| 439 | * ejbFiles.
|
---|
| 440 | */
|
---|
| 441 | protected void writeJar(String baseName, File jarFile, Hashtable files, String publicId)
|
---|
| 442 | throws BuildException {
|
---|
| 443 | //build the home classes list.
|
---|
| 444 | Vector homes = new Vector();
|
---|
| 445 | Iterator it = files.keySet().iterator();
|
---|
| 446 | while (it.hasNext()) {
|
---|
| 447 | String clazz = (String) it.next();
|
---|
| 448 | if (clazz.endsWith("Home.class")) {
|
---|
| 449 | //remove .class extension
|
---|
| 450 | String home = toClass(clazz);
|
---|
| 451 | homes.add(home);
|
---|
| 452 | log(" Home " + home, Project.MSG_VERBOSE);
|
---|
| 453 | }
|
---|
| 454 | }
|
---|
| 455 |
|
---|
| 456 | buildBorlandStubs(homes.iterator());
|
---|
| 457 |
|
---|
| 458 | //add the gen files to the collection
|
---|
| 459 | files.putAll(_genfiles);
|
---|
| 460 |
|
---|
| 461 | super.writeJar(baseName, jarFile, files, publicId);
|
---|
| 462 |
|
---|
| 463 | if (verify) {
|
---|
| 464 | verifyBorlandJar(jarFile);
|
---|
| 465 | }
|
---|
| 466 |
|
---|
| 467 | if (generateclient) {
|
---|
| 468 | generateClient(jarFile);
|
---|
| 469 | }
|
---|
| 470 | }
|
---|
| 471 |
|
---|
| 472 | /**
|
---|
| 473 | * convert a class file name : A/B/C/toto.class
|
---|
| 474 | * into a class name: A.B.C.toto
|
---|
| 475 | */
|
---|
| 476 | private String toClass(String filename) {
|
---|
| 477 | //remove the .class
|
---|
| 478 | String classname = filename.substring(0, filename.lastIndexOf(".class"));
|
---|
| 479 | classname = classname.replace('\\', '.');
|
---|
| 480 | return classname;
|
---|
| 481 | }
|
---|
| 482 |
|
---|
| 483 | /**
|
---|
| 484 | * convert a file name : A/B/C/toto.java
|
---|
| 485 | * into a class name: A/B/C/toto.class
|
---|
| 486 | */
|
---|
| 487 | private String toClassFile(String filename) {
|
---|
| 488 | //remove the .class
|
---|
| 489 | String classfile = filename.substring(0, filename.lastIndexOf(".java"));
|
---|
| 490 | classfile = classfile + ".class";
|
---|
| 491 | return classfile;
|
---|
| 492 | }
|
---|
| 493 |
|
---|
| 494 | // implementation of org.apache.tools.ant.taskdefs.ExecuteStreamHandler interface
|
---|
| 495 |
|
---|
| 496 | public void start() throws IOException { }
|
---|
| 497 | public void stop() { }
|
---|
| 498 | public void setProcessInputStream(OutputStream param1) throws IOException { }
|
---|
| 499 |
|
---|
| 500 | /**
|
---|
| 501 | *
|
---|
| 502 | * @param is
|
---|
| 503 | * @exception java.io.IOException
|
---|
| 504 | */
|
---|
| 505 | public void setProcessOutputStream(InputStream is) throws IOException {
|
---|
| 506 | try {
|
---|
| 507 | BufferedReader reader = new BufferedReader(new InputStreamReader(is));
|
---|
| 508 | String javafile;
|
---|
| 509 | while ((javafile = reader.readLine()) != null) {
|
---|
| 510 | if (javafile.endsWith(".java")) {
|
---|
| 511 | String classfile = toClassFile(javafile);
|
---|
| 512 | String key = classfile.substring(getConfig().srcDir.getAbsolutePath().length() + 1);
|
---|
| 513 | _genfiles.put(key, new File(classfile));
|
---|
| 514 | }
|
---|
| 515 | }
|
---|
| 516 | reader.close();
|
---|
| 517 | } catch (Exception e) {
|
---|
| 518 | String msg = "Exception while parsing java2iiop output. Details: " + e.toString();
|
---|
| 519 | throw new BuildException(msg, e);
|
---|
| 520 | }
|
---|
| 521 | }
|
---|
| 522 |
|
---|
| 523 | public void setProcessErrorStream(InputStream is) throws IOException {
|
---|
| 524 | BufferedReader reader = new BufferedReader(new InputStreamReader(is));
|
---|
| 525 | String s = reader.readLine();
|
---|
| 526 | if (s != null) {
|
---|
| 527 | log("[java2iiop] " + s, Project.MSG_ERR);
|
---|
| 528 | }
|
---|
| 529 | }
|
---|
| 530 | }
|
---|
| 531 |
|
---|