ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@locus.apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb WeblogicTOPLinkDeploymentTool.java WeblogicDeploymentTool.java EJBDeploymentTool.java EjbJar.java GenericDeploymentTool.java
Date Sat, 09 Sep 2000 11:48:12 GMT
conor       00/09/09 04:48:12

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/ejb
                        WeblogicDeploymentTool.java EJBDeploymentTool.java
                        EjbJar.java GenericDeploymentTool.java
  Added:       src/main/org/apache/tools/ant/taskdefs/optional/ejb
                        WeblogicTOPLinkDeploymentTool.java
  Log:
  Changes to EJBJar task
  
  Make the descriptordir attribute optional.  If it is not there, then it
  will default to the original functionality by looking srcdir.
  
  Added an optional basejarname attribute.  If this exists, then there is
  no need to prefix your descriptors with the jar name.  If it is not
  used, then it will default to using the original naming convention.
  
  Added a optional weblogicdtd attribute for the location of
  the weblogic DTD file.  If this is not there, then the original
  functionality will be  executed (uses the classpath resource
  /weblogic/ejb/deployment/xml/ejb-jar.dtd as the location of the
  dtd file).
  
  Added a weblogictoplink element to the ejbjar task.  This
  subtask allows you to build TOPLink for WebLogic enabled ejb jar
  files. This subclasses the weblogic element so it uses the same
  attributes with
  the following additions:
      toplinkdescriptor  - this is the name of the xml file to be used by
      (required)           TOPLINK/ejbc.  This does not require the
                           naming prefix as the naming standard
                           (suggested by The ObjectPeople/WebGain) for
                           these files is incompatible with the current
                           naming convention of the ejbjar task.
  
      toplinkdtd         - the location of the TOPLink DTD file.  If this
      (optional)           is not provided, the web address is used
                           (Unfortunately, this cannot be picked up like
                           the weblogic DTD)
  
  Submitted by:	John Hall <jhall@solant.com>
  
  Revision  Changes    Path
  1.4       +39 -13    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java
  
  Index: WeblogicDeploymentTool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- WeblogicDeploymentTool.java	2000/08/25 11:56:15	1.3
  +++ WeblogicDeploymentTool.java	2000/09/09 11:48:11	1.4
  @@ -67,14 +67,19 @@
   public class WeblogicDeploymentTool extends GenericDeploymentTool {
       protected static final String WL_DD     = "weblogic-ejb-jar.xml";
       protected static final String WL_CMP_DD = "weblogic-cmp-rdbms-jar.xml";
  +    protected static final String WL_DTD     = "/weblogic/ejb/deployment/xml/ejb-jar.dtd";
  +    protected static final String WL_HTTP_DTD     = "http://www.bea.com/servers/wls510/dtd/weblogic-ejb-jar.dtd";
   
       /** Instance variable that stores the suffix for the weblogic jarfile. */
       private String jarSuffix = ".jar";
   
  +    /** Instance variable that stores the location of the weblogic DTD file. */
  +    private String weblogicDTD;
  +
       private Path classpath;
   
       /** Instance variable that determines whether generic ejb jars are kept. */
  -    private boolean keepgeneric = false;
  +    private boolean keepGeneric = false;
       
       /**
        * Set the classpath to be used for this compilation.
  @@ -92,17 +97,39 @@
       }
   
       /**
  -     * Setter used to store the value of keepgeneric
  +     * Setter used to store the value of keepGeneric
        * @param inValue a string, either 'true' or 'false'.
        */
  -    public void setKeepgeneric(String inValue) {
  -        this.keepgeneric = Boolean.valueOf(inValue).booleanValue();
  +    public void setKeepgeneric(boolean inValue) {
  +        this.keepGeneric = inValue;
       }
       
  +    /**
  +     * Setter used to store the location of the weblogic 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 setWeblogicdtd(String inString) {
  +        this.weblogicDTD = inString;
  +    }
  +
       protected DescriptorHandler getDescriptorHandler(File srcDir) {
           DescriptorHandler handler = new DescriptorHandler(srcDir);
  -        handler.registerResourceDTD("-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans
1.1//EN",
  -                                    "/weblogic/ejb/deployment/xml/ejb-jar.dtd");
  +        if (weblogicDTD != null) {
  +            // is the DTD a local file?
  +            File dtdFile = new File(weblogicDTD);
  +            if (dtdFile.exists()) {
  +                handler.registerFileDTD("-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans
1.1//EN",
  +                                        dtdFile);
  +            } else {
  +                handler.registerResourceDTD("-//Sun Microsystems, Inc.//DTD Enterprise
JavaBeans 1.1//EN",
  +                                            weblogicDTD);
  +            }                                            
  +        } else {
  +            handler.registerResourceDTD("-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans
1.1//EN",
  +                                        WL_DTD);
  +        }
  +        
           return handler;                                    
       }
   
  @@ -110,10 +137,10 @@
        * Add any vendor specific files which should be included in the 
        * EJB Jar.
        */
  -    protected void addVendorFiles(Hashtable ejbFiles, File srcdir, File descriptorDir,
String baseName) {
  -        // Then the weblogic deployment descriptor
  -        File weblogicDD = new File(descriptorDir,
  -                              baseName + getBasenameTerminator() + WL_DD);
  +    protected void addVendorFiles(Hashtable ejbFiles, String baseName) {
  +        String ddPrefix = (usingBaseJarName() ? "" : baseName + getBaseNameTerminator());
  +
  +        File weblogicDD = new File(getDescriptorDir(), ddPrefix + WL_DD);
   
           if (weblogicDD.exists()) {
               ejbFiles.put(META_DIR + WL_DD,
  @@ -121,8 +148,7 @@
           }
   
           // The the weblogic cmp deployment descriptor
  -        File weblogicCMPDD = new File(descriptorDir,
  -                              baseName + getBasenameTerminator() + WL_CMP_DD);
  +        File weblogicCMPDD = new File(getDescriptorDir(), ddPrefix + WL_CMP_DD);
   
           if (weblogicCMPDD.exists()) {
               ejbFiles.put(META_DIR + WL_CMP_DD,
  @@ -188,7 +214,7 @@
           super.writeJar(baseName, genericJarFile, files);
           
           buildWeblogicJar(genericJarFile, jarFile);
  -        if (!keepgeneric) {
  +        if (!keepGeneric) {
                getTask().log("deleting generic jar " + genericJarFile.toString(),
                              Project.MSG_VERBOSE);
                genericJarFile.delete();
  
  
  
  1.3       +4 -3      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/EJBDeploymentTool.java
  
  Index: EJBDeploymentTool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/EJBDeploymentTool.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EJBDeploymentTool.java	2000/08/25 11:56:14	1.2
  +++ EJBDeploymentTool.java	2000/09/09 11:48:11	1.3
  @@ -63,13 +63,13 @@
   
   public interface EJBDeploymentTool {
       /**
  -     * Process a deployment descriptor, generating the necessary vendor specifi
  +     * Process a deployment descriptor, generating the necessary vendor specific
        * deployment files.
        *
        * @param descriptorFilename the name of the deployment descriptor
        * @param saxParser a SAX parser which can be used to parse the deployment descriptor.

        */
  -    public void processDescriptor(File srcDir, File descriptorDir, String descriptorFilename,
SAXParser saxParser) 
  +    public void processDescriptor(String descriptorFilename, SAXParser saxParser) 
           throws BuildException;
       
       /**
  @@ -86,5 +86,6 @@
       /**
        * Configure this tool for use in the ejbjar task.
        */
  -    public void configure(String basenameTerminator, boolean flatDestDir);     
  +    public void configure(File srcDir, File descriptorDir, String basenameTerminator, 
  +                          String baseJarName, boolean flatDestDir);     
   }
  
  
  
  1.7       +52 -38    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/EjbJar.java
  
  Index: EjbJar.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/EjbJar.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- EjbJar.java	2000/08/25 11:56:15	1.6
  +++ EjbJar.java	2000/09/09 11:48:11	1.7
  @@ -79,7 +79,7 @@
    * parsing them to locate the names of the classes which should be placed in
    * the jar.  The classnames are translated to java.io.Files by replacing periods
    * with File.separatorChar and resolving the generated filename as a relative
  - * path under the srcdir attribute.  All necessary files are then assembled into
  + * path under the srcDir attribute.  All necessary files are then assembled into
    * a jarfile.  One jarfile is constructed for each deployment descriptor found.
    * </p>
    *
  @@ -87,15 +87,15 @@
    * 5.1 jars. The weblogic deployment descriptors, used in constructing the 
    * Weblogic jar, are located based on a simple naming convention. The name of the
    * standard deployment descriptor is taken upto the first instance of a String,
  - * specified by the attribute basenameTerminator, and then the regular Weblogic
  - * descriptor name is appended. For example if basenameTerminator is set to '-',
  + * specified by the attribute baseNameTerminator, and then the regular Weblogic
  + * descriptor name is appended. For example if baseNameTerminator is set to '-',
    * its default value, and a standard descriptor is called Foo-ejb-jar.xml then
    * the files Foo-weblogic-ejb-jar.xml and Foo-weblogic-cmp-rdbms-jar.xml will be
    * looked for, and if found, included in the jarfile.</p>
    *
    * <p>Attributes and setter methods are provided to support optional generation
    * of Weblogic5.1 jars, optional deletion of generic jar files, setting alternate
  - * values for basenameTerminator, and setting the strings to append to the names
  + * values for baseNameTerminator, and setting the strings to append to the names
    * of the generated jarfiles.</p>
    *
    * @author <a href="mailto:tfennell@sapient.com">Tim Fennell</a>
  @@ -103,25 +103,28 @@
   public class EjbJar extends MatchingTask {
   
       /** Stores a handle to the directory under which to search for class files */
  -    private File srcdir = null;
  +    private File srcDir;
   
       /** Stores a handle to the directory under which to search for deployment descriptors
*/
  -    private File descriptordir = null;
  +    private File descriptorDir;
   
       /** Stores a handle to the directory to put the Jar files in */
  -    private File destdir = null;
  +    private File destDir;
   
  +    /** Stores a handle to the destination EJB Jar file */
  +    private String baseJarName;
  + 
       /**
        * Instance variable that determines whether to use a package structure
        * of a flat directory as the destination for the jar files.
        */
  -    private boolean flatdestdir = false;
  +    private boolean flatDestDir = false;
       
       /** Instance variable that marks the end of the 'basename' */
  -    private String basenameTerminator = "-";
  +    private String baseNameTerminator = "-";
   
       /** Instance variable that stores the suffix for the generated jarfile. */
  -    private String genericjarsuffix = "-generic.jar";
  +    private String genericJarSuffix = "-generic.jar";
   
       /**
        * The list of deployment tools we are going to run.
  @@ -135,20 +138,35 @@
           return tool;
       }
   
  +    public WeblogicTOPLinkDeploymentTool createWeblogictoplink() {
  +        WeblogicTOPLinkDeploymentTool tool = new WeblogicTOPLinkDeploymentTool();
  +        tool.setTask(this);
  +        deploymentTools.add(tool);
  +        return tool;
  +    }
  +
       /**
  -     * Setter used to store the value of srcdir prior to execute() being called.
  +     * Setter used to store the value of srcDir prior to execute() being called.
        * @param inDir the source directory.
        */
       public void setSrcdir(File inDir) {
  -        this.srcdir = inDir;
  +        this.srcDir = inDir;
       }
   
       /**
  -     * Setter used to store the value of descriptordir prior to execute() being called.
  +     * Setter used to store the value of descriptorDir prior to execute() being called.
        * @param inDir the directory containing the deployment descriptors.
        */
       public void setDescriptordir(File inDir) {
  -        this.descriptordir = inDir;
  +        this.descriptorDir = inDir;
  +    }
  +
  +    /**
  +     * Setter used to store the value of descriptorDir prior to execute() being called.
  +     * @param inDir the directory containing the deployment descriptors.
  +     */
  +    public void setBasejarname(String inValue) {
  +        this.baseJarName = inValue;
       }
   
       /**
  @@ -157,15 +175,15 @@
        * @param inFile the destination directory.
        */
       public void setDestdir(File inDir) {
  -        this.destdir = inDir;
  +        this.destDir = inDir;
       }
   
       /**
  -     * Setter used to store the value of flatdestdir.
  +     * Setter used to store the value of flatDestDir.
        * @param inValue a string, either 'true' or 'false'.
        */
       public void setFlatdestdir(boolean inValue) {
  -        this.flatdestdir = inValue;
  +        this.flatDestDir = inValue;
       }
        
       /**
  @@ -173,15 +191,15 @@
        * @param inString the string to use as the suffix.
        */
       public void setGenericjarsuffix(String inString) {
  -        this.genericjarsuffix = inString;
  +        this.genericJarSuffix = inString;
       }
   
       /**
  -     * Setter used to store the value of basenameTerminator
  +     * Setter used to store the value of baseNameTerminator
        * @param inValue a string which marks the end of the basename.
        */
  -    public void setBasenameTerminator(String inValue) {
  -        if (inValue != null) this.basenameTerminator = inValue;
  +    public void setBasenameterminator(String inValue) {
  +        this.baseNameTerminator = inValue;
       }
   
       /**
  @@ -196,25 +214,27 @@
        *            that a major problem occurred within this task.
        */
       public void execute() throws BuildException {
  -        if (srcdir == null) {
  -            throw new BuildException("The srcdir attribute must be specified");
  -        }
  -        if (descriptordir == null) {
  -            throw new BuildException("The descriptordir attribute must be specified");
  +        if (srcDir == null) {
  +            throw new BuildException("The srcDir attribute must be specified");
           }
           
           if (deploymentTools.size() == 0) {
               GenericDeploymentTool genericTool = new GenericDeploymentTool();
  -            genericTool.setDestdir(destdir);
  +            genericTool.setDestdir(destDir);
               genericTool.setTask(this);
  -            genericTool.setGenericjarsuffix(genericjarsuffix);
  +            genericTool.setGenericJarSuffix(genericJarSuffix);
   
               deploymentTools.add(genericTool);
           }
           
  +        File scanDir = descriptorDir;
  +        if (scanDir == null) {
  +            scanDir = srcDir;
  +        }
  +        
           for (Iterator i = deploymentTools.iterator(); i.hasNext(); ) {
               EJBDeploymentTool tool = (EJBDeploymentTool)i.next();
  -            tool.configure(basenameTerminator, flatdestdir);
  +            tool.configure(srcDir, scanDir, baseNameTerminator, baseJarName, flatDestDir);
               tool.validateConfigured();
           }
           
  @@ -224,7 +244,8 @@
               saxParserFactory.setValidating(true);
               SAXParser saxParser = saxParserFactory.newSAXParser();
       
  -            DirectoryScanner ds = getDirectoryScanner(descriptordir);
  +            
  +            DirectoryScanner ds = getDirectoryScanner(scanDir);
               ds.scan();
               String[] files = ds.getIncludedFiles();
       
  @@ -238,7 +259,7 @@
                   // process the deployment descriptor in each tool
                   for (Iterator i = deploymentTools.iterator(); i.hasNext(); ) {
                       EJBDeploymentTool tool = (EJBDeploymentTool)i.next();
  -                    processDescriptor(files[index], saxParser, tool);
  +                    tool.processDescriptor(files[index], saxParser);
                   }
               }    
           }
  @@ -254,13 +275,6 @@
               throw new BuildException(msg, pce);
           }
       } // end of execute()
  -
  -    
  -    private void processDescriptor(String descriptorFilename, SAXParser saxParser,
  -                                   EJBDeploymentTool tool) {
  -
  -        tool.processDescriptor(srcdir, descriptordir, descriptorFilename, saxParser);
  -    }
   }
   
   
  
  
  
  1.3       +76 -30    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
  
  Index: GenericDeploymentTool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- GenericDeploymentTool.java	2000/08/25 11:56:15	1.2
  +++ GenericDeploymentTool.java	2000/09/09 11:48:11	1.3
  @@ -72,9 +72,18 @@
       protected static final String META_DIR  = "META-INF/";
       protected static final String EJB_DD    = "ejb-jar.xml";
   
  +    /** Stores a handle to the directory of the source tree */
  +    private File srcDir;
  +
  +    /** Stores a handle to the directory of the deployment descriptors */
  +    private File descriptorDir;
  +
       /** Stores a handle to the directory to put the Jar files in */
  -    private File destDir = null;
  +    private File destDir;
       
  +    /** Instance variable that stores the jar file name when not using the naming standard
*/
  +    private String baseJarName;
  +
       /**
        * Instance variable that determines whether to use a package structure
        * of a flat directory as the destination for the jar files.
  @@ -82,10 +91,10 @@
       private boolean flatDestDir = false;
       
       /** Instance variable that marks the end of the 'basename' */
  -    private String basenameTerminator = "-";
  +    private String baseNameTerminator = "-";
   
       /** Instance variable that stores the suffix for the generated jarfile. */
  -    private String genericjarsuffix = "-generic.jar";
  +    private String genericJarSuffix = "-generic.jar";
   
       /**
        * The task to which this tool belongs.
  @@ -125,24 +134,57 @@
   
       /**
        * Get the basename terminator.
  +     */
  +    protected String getBaseNameTerminator() {
  +        return baseNameTerminator;
  +    }
  +    
  +    /**
  +     * Get the base jar name.
        */
  -    protected String getBasenameTerminator() {
  -        return basenameTerminator;
  +    protected String getBaseJarName() {
  +        return baseJarName;
       }
       
       /**
  +     * Get the source dir.
  +     */
  +    protected File getSrcDir() {
  +        return srcDir;
  +    }
  +    
  +    /**
  +     * Get the meta-inf dir.
  +     * 
  +     */
  +    protected File getDescriptorDir() {
  +        return descriptorDir;
  +    }
  +
  +    /**
  +     * Returns true, if the meta-inf dir is being explicitly set, false otherwise.
  +     */
  +    protected boolean usingBaseJarName() {
  +        return baseJarName != null;
  +    }
  +    
  +    /**
        * Setter used to store the suffix for the generated jar file.
        * @param inString the string to use as the suffix.
        */
  -    public void setGenericjarsuffix(String inString) {
  -        this.genericjarsuffix = inString;
  +    public void setGenericJarSuffix(String inString) {
  +        this.genericJarSuffix = inString;
       }
   
       /**
        * Configure this tool for use in the ejbjar task.
        */
  -    public void configure(String basenameTerminator, boolean flatDestDir) {
  -        this.basenameTerminator = basenameTerminator;
  +    public void configure(File srcDir, File descriptorDir, String baseNameTerminator, 
  +                          String baseJarName, boolean flatDestDir) {
  +        this.srcDir = srcDir;
  +        this.descriptorDir = descriptorDir;
  +        this.baseJarName = baseJarName;
  +        this.baseNameTerminator = baseNameTerminator;
           this.flatDestDir = flatDestDir;
       }
   
  @@ -191,8 +233,7 @@
           return new DescriptorHandler(srcDir);
       }
       
  -    public void processDescriptor(File srcDir, File descriptorDir,
  -                                  String descriptorFilename, SAXParser saxParser) {
  +    public void processDescriptor(String descriptorFileName, SAXParser saxParser) {
           try {
               DescriptorHandler handler = getDescriptorHandler(srcDir);
               
  @@ -202,7 +243,7 @@
                */
               saxParser.parse(new InputSource
                               (new FileInputStream
  -                             (new File(descriptorDir, descriptorFilename))),
  +                            (new File(getDescriptorDir(), descriptorFileName))),
                               handler);
                               
               Hashtable ejbFiles = handler.getFiles();
  @@ -210,25 +251,30 @@
               String baseName = "";
               
               // Work out what the base name is
  -            int lastSeparatorIndex = descriptorFilename.lastIndexOf(File.separator);
  -            int endBaseName = -1;
  -            if (lastSeparatorIndex != -1) {
  -                endBaseName = descriptorFilename.indexOf(basenameTerminator, 
  -                                                         lastSeparatorIndex);
  -            }
  -            else {
  -                endBaseName = descriptorFilename.indexOf(basenameTerminator);
  -            }
  -            
  -            if (endBaseName != -1) {
  -                baseName = descriptorFilename.substring(0, endBaseName);
  +            if (baseJarName != null) {
  +                baseName = baseJarName;
  +            } else {
  +                int lastSeparatorIndex = descriptorFileName.lastIndexOf(File.separator);
  +                int endBaseName = -1;
  +                if (lastSeparatorIndex != -1) {
  +                    endBaseName = descriptorFileName.indexOf(baseNameTerminator, 
  +                                                             lastSeparatorIndex);
  +                }
  +                else {
  +                    endBaseName = descriptorFileName.indexOf(baseNameTerminator);
  +                }
  +
  +                if (endBaseName != -1) {
  +                    baseName = descriptorFileName.substring(0, endBaseName);
  +                }
  +                baseName = descriptorFileName.substring(0, endBaseName);
               }
   
               // First the regular deployment descriptor
               ejbFiles.put(META_DIR + EJB_DD,
  -                         new File(descriptorDir, descriptorFilename));
  +                         new File(getDescriptorDir(), descriptorFileName));
                            
  -            addVendorFiles(ejbFiles, srcDir, descriptorDir, baseName);
  +            addVendorFiles(ejbFiles, baseName);
   
               // Lastly create File object for the Jar files. If we are using
               // a flat destination dir, then we need to redefine baseName!
  @@ -281,7 +327,7 @@
           }
           catch (SAXException se) {
               String msg = "SAXException while parsing '"
  -                + descriptorFilename.toString()
  +                + descriptorFileName.toString()
                   + "'. This probably indicates badly-formed XML."
                   + "  Details: "
                   + se.getMessage();
  @@ -289,7 +335,7 @@
           }
           catch (IOException ioe) {
               String msg = "IOException while parsing'"
  -                + descriptorFilename.toString()
  +                + descriptorFileName.toString()
                   + "'.  This probably indicates that the descriptor"
                   + " doesn't exist. Details: "
                   + ioe.getMessage();
  @@ -301,7 +347,7 @@
        * Add any vendor specific files which should be included in the 
        * EJB Jar.
        */
  -    protected void addVendorFiles(Hashtable ejbFiles, File srcDir, File descriptorDir,
String baseName) {
  +    protected void addVendorFiles(Hashtable ejbFiles, String baseName) {
       }
   
   
  @@ -310,7 +356,7 @@
        * of this jar will be checked against the dependent bean classes.
        */
       File getVendorOutputJarFile(String baseName) {
  -        return new File(destDir, baseName + genericjarsuffix);
  +        return new File(destDir, baseName + genericJarSuffix);
       }
   
       /**
  
  
  
  1.1                  jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicTOPLinkDeploymentTool.java
  
  Index: WeblogicTOPLinkDeploymentTool.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package org.apache.tools.ant.taskdefs.optional.ejb;
  
  import java.io.*;
  import java.util.*;
  
  import org.apache.tools.ant.BuildException;
  import org.apache.tools.ant.Project;
  
  public class WeblogicTOPLinkDeploymentTool extends WeblogicDeploymentTool {
  
      private static final String TL_DTD_LOC = "http://www.objectpeople.com/tlwl/dtd/toplink-cmp_2_5_1.dtd";
  
      private String toplinkDescriptor;
      private String toplinkDTD;
      
      /**
       * Setter used to store the name of the toplink descriptor.
       * @param inString the string to use as the descriptor name.
       */
      public void setToplinkdescriptor(String inString) {
          this.toplinkDescriptor = inString;
      }
  
      /**
       * Setter used to store the location of the toplink DTD file.
       * This is expected to be an URL (file or otherwise). If running this on NT using a
file URL, the safest 
       * thing would be to not use a drive spec in the URL and make sure the file resides
on the drive that 
       * ANT is running from.  This will keep the setting in the build XML platform independent.
       * @param inString the string to use as the DTD location.
       */
      public void setToplinkdtd(String inString) {
          this.toplinkDTD = inString;
      }
  
      protected DescriptorHandler getDescriptorHandler(File srcDir) {
          DescriptorHandler handler = super.getDescriptorHandler(srcDir);
          if (toplinkDTD != null) {
              handler.registerResourceDTD("-//The Object People, Inc.//DTD TOPLink for WebLogic
CMP 2.5.1//EN",
                                          toplinkDTD);
          } else {
              handler.registerResourceDTD("-//The Object People, Inc.//DTD TOPLink for WebLogic
CMP 2.5.1//EN",
                                          TL_DTD_LOC);
          }
          return handler;                                    
      }
  
      /**
       * Add any vendor specific files which should be included in the 
       * EJB Jar.
       */
      protected void addVendorFiles(Hashtable ejbFiles, String baseName) {
          super.addVendorFiles(ejbFiles, baseName);
          // Then the toplink deployment descriptor
  
          // Setup a naming standard here?.
  
          File toplinkDD = new File(getDescriptorDir(), toplinkDescriptor);
  
          if (toplinkDD.exists()) {
              ejbFiles.put(META_DIR + toplinkDescriptor,
                           toplinkDD);
          }
      }
      
      /**
       * Called to validate that the tool parameters have been configured.
       *
       */
      public void validateConfigured() throws BuildException {
          super.validateConfigured();
          if (toplinkDescriptor == null) {
              throw new BuildException( "The toplinkdescriptor attribute must be specified"
);
          }
      }
  }
  
  
  

Mime
View raw message