ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb DDCreatorHelper.java
Date Tue, 07 Aug 2001 12:39:34 GMT
conor       01/08/07 05:39:34

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/ejb
                        DDCreatorHelper.java
  Log:
  Handle situation where the descriptor is out of date with respect to the
  EJB classes but the descriptor text has not changed.
  
  Submitted by:	Sean Bowman <SBowman@webb.net>
  
  Revision  Changes    Path
  1.5       +32 -1     jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DDCreatorHelper.java
  
  Index: DDCreatorHelper.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DDCreatorHelper.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DDCreatorHelper.java	2001/01/03 14:18:39	1.4
  +++ DDCreatorHelper.java	2001/08/07 12:39:34	1.5
  @@ -54,7 +54,11 @@
   package org.apache.tools.ant.taskdefs.optional.ejb;
   
   import java.io.File;
  +import java.io.FileInputStream;
  +import java.io.ObjectInputStream;
   
  +import javax.ejb.deployment.DeploymentDescriptor;
  +
   /**
    * A helper class which performs the actual work of the ddcreator task.
    *
  @@ -128,7 +132,8 @@
               File serFile = new File(generatedFilesDirectory, serName);
                   
               // do we need to regenerate the file
  -            if (!serFile.exists() || serFile.lastModified() < descriptorFile.lastModified())
{
  +            if (!serFile.exists() || serFile.lastModified() < descriptorFile.lastModified()
  +                || regenerateSerializedFile(serFile)) {
                   
                   String[] args = {"-noexit", 
                                    "-d", serFile.getParent(),
  @@ -145,6 +150,32 @@
                       weblogic.ejb.utils.DDCreator.main(newArgs);
                   }
               }
  +        }
  +    }
  +
  +    /**
  +     * EJBC will fail if the serialized descriptor file does not match the bean classes.
  +     * You can test for this by trying to load the deployment descriptor.  If it fails,
  +     * the serialized file needs to be regenerated because the associated class files
  +     * don't match.
  +     */
  +    private boolean regenerateSerializedFile(File serFile) {
  +        try {
  +
  +            FileInputStream fis = new FileInputStream(serFile);
  +            ObjectInputStream ois = new ObjectInputStream(fis);
  +            DeploymentDescriptor dd = (DeploymentDescriptor) ois.readObject();
  +            fis.close();
  +
  +            // Since the descriptor read properly, everything should be o.k.
  +            return false;
  +
  +        } catch (Exception e) {
  +            
  +            // Weblogic will throw an error if the deployment descriptor does 
  +            // not match the class files.
  +            return true;
  +
           }
       }
   }
  
  
  

Mime
View raw message