📄 borlanddeploymenttool.java
字号:
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */package org.apache.tools.ant.taskdefs.optional.ejb;import java.io.BufferedReader;import java.io.File;import java.io.IOException;import java.io.InputStream;import java.io.InputStreamReader;import java.io.OutputStream;import java.util.Hashtable;import java.util.Iterator;import java.util.Vector;import org.apache.tools.ant.BuildException;import org.apache.tools.ant.Project;import org.apache.tools.ant.taskdefs.ExecTask;import org.apache.tools.ant.taskdefs.Execute;import org.apache.tools.ant.taskdefs.ExecuteStreamHandler;import org.apache.tools.ant.taskdefs.Java;import org.apache.tools.ant.types.Commandline;import org.apache.tools.ant.types.Path;/** * BorlandDeploymentTool is dedicated to the Borland Application Server 4.5 and 4.5.1 * This task generates and compiles the stubs and skeletons for all ejb described into the * Deployment Descriptor, builds the jar file including the support files and verify * whether the produced jar is valid or not. * The supported options are: * <ul> * <li>debug (boolean) : turn on the debug mode for generation of * stubs and skeletons (default:false)</li> * <li>verify (boolean) : turn on the verification at the end of the jar * production (default:true) </li> * <li>verifyargs (String) : add optional argument to verify command * (see vbj com.inprise.ejb.util.Verify)</li> * <li>basdtd (String) : location of the BAS DTD </li> * <li>generateclient (boolean) : turn on the client jar file generation </li> * <li>version (int) : tell what is the Borland appserver version 4 or 5 </li> * </ul> * *<PRE> * * <ejbjar srcdir="${build.classes}" * basejarname="vsmp" * descriptordir="${rsc.dir}/hrmanager"> * <borland destdir="tstlib"> * <classpath refid="classpath" /> * </borland> * <include name="**\ejb-jar.xml"/> * <support dir="${build.classes}"> * <include name="demo\smp\*.class"/> * <include name="demo\helper\*.class"/> * </support> * </ejbjar> *</PRE> * */public class BorlandDeploymentTool extends GenericDeploymentTool implements ExecuteStreamHandler { /** Borland 1.1 ejb id */ public static final String PUBLICID_BORLAND_EJB = "-//Inprise Corporation//DTD Enterprise JavaBeans 1.1//EN"; protected static final String DEFAULT_BAS45_EJB11_DTD_LOCATION = "/com/inprise/j2ee/xml/dtds/ejb-jar.dtd"; protected static final String DEFAULT_BAS_DTD_LOCATION = "/com/inprise/j2ee/xml/dtds/ejb-inprise.dtd"; protected static final String BAS_DD = "ejb-inprise.xml"; protected static final String BES_DD = "ejb-borland.xml"; /** Java2iiop executable **/ protected static final String JAVA2IIOP = "java2iiop"; /** Verify class */ protected static final String VERIFY = "com.inprise.ejb.util.Verify"; /** Instance variable that stores the suffix for the borland jarfile. */ private String jarSuffix = "-ejb.jar"; /** Instance variable that stores the location of the borland DTD file. */ private String borlandDTD; /** Instance variable that determines whether the debug mode is on */ private boolean java2iiopdebug = false; /** store additional param for java2iiop command used to build EJB Stubs */ private String java2iioparams = null; /** Instance variable that determines whether the client jar file is generated */ private boolean generateclient = false; /** Borland Enterprise Server = version 5 */ static final int BES = 5; /** Borland Application Server or Inprise Application Server = version 4 */ static final int BAS = 4; /** borland appserver version 4 or 5 */ private int version = BAS; /** * Instance variable that determines whether it is necessary to verify the * produced jar */ private boolean verify = true; private String verifyArgs = ""; private Hashtable genfiles = new Hashtable(); /** * set the debug mode for java2iiop (default false) * @param debug the setting to use. **/ public void setDebug(boolean debug) { this.java2iiopdebug = debug; } /** * set the verify mode for the produced jar (default true) * @param verify the setting to use. **/ public void setVerify(boolean verify) { this.verify = verify; } /** * Setter used to store the suffix for the generated borland jar file. * @param inString the string to use as the suffix. */ public void setSuffix(String inString) { this.jarSuffix = inString; } /** * sets some additional args to send to verify command * @param args additional command line parameters */ public void setVerifyArgs(String args) { this.verifyArgs = args; } /** * Setter used to store the location of the borland DTD. This can be a file on the system * or a resource on the classpath. * @param inString the string to use as the DTD location. */ public void setBASdtd(String inString) { this.borlandDTD = inString; } /** * setter used to store whether the task will include the generate client task. * (see : BorlandGenerateClient task) * @param b if true generate the client task. */ public void setGenerateclient(boolean b) { this.generateclient = b; } /** * setter used to store the borland appserver version [4 or 5] * @param version app server version 4 or 5 */ public void setVersion(int version) { this.version = version; } /** * If filled, the params are added to the java2iiop command. * (ex: -no_warn_missing_define) * @param params additional params for java2iiop */ public void setJava2iiopParams(String params) { this.java2iioparams = params; } /** * Get the borland descriptor handler. * @param srcDir the source directory. * @return the descriptor. */ protected DescriptorHandler getBorlandDescriptorHandler(final File srcDir) { DescriptorHandler handler = new DescriptorHandler(getTask(), srcDir) { protected void processElement() { if (currentElement.equals("type-storage")) { // Get the filename of vendor specific descriptor String fileNameWithMETA = currentText; //trim the META_INF\ off of the file name String fileName = fileNameWithMETA.substring(META_DIR.length(), fileNameWithMETA.length()); File descriptorFile = new File(srcDir, fileName); ejbFiles.put(fileNameWithMETA, descriptorFile); } } }; handler.registerDTD(PUBLICID_BORLAND_EJB, borlandDTD == null ? DEFAULT_BAS_DTD_LOCATION : borlandDTD); for (Iterator i = getConfig().dtdLocations.iterator(); i.hasNext();) { EjbJar.DTDLocation dtdLocation = (EjbJar.DTDLocation) i.next(); handler.registerDTD(dtdLocation.getPublicId(), dtdLocation.getLocation()); } return handler; } /** * Add any vendor specific files which should be included in the * EJB Jar. * @param ejbFiles the map to add the files to. * @param ddPrefix the prefix to use. */ protected void addVendorFiles(Hashtable ejbFiles, String ddPrefix) { //choose the right vendor DD if (!(version == BES || version == BAS)) { throw new BuildException("version " + version + " is not supported"); } String dd = (version == BES ? BES_DD : BAS_DD); log("vendor file : " + ddPrefix + dd, Project.MSG_DEBUG); File borlandDD = new File(getConfig().descriptorDir, ddPrefix + dd); if (borlandDD.exists()) { log("Borland specific file found " + borlandDD, Project.MSG_VERBOSE); ejbFiles.put(META_DIR + dd , borlandDD); } else { log("Unable to locate borland deployment descriptor. " + "It was expected to be in " + borlandDD.getPath(), Project.MSG_WARN); return; } } /** * Get the vendor specific name of the Jar that will be output. The modification date * of this jar will be checked against the dependent bean classes. */ File getVendorOutputJarFile(String baseName) { return new File(getDestDir(), baseName + jarSuffix); } /** * Verify the produced jar file by invoking the Borland verify tool * @param sourceJar java.io.File representing the produced jar file */ private void verifyBorlandJar(File sourceJar) { if (version == BAS) { verifyBorlandJarV4(sourceJar); return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -