Browse Source

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>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269493 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 24 years ago
parent
commit
e6a50fe317
1 changed files with 32 additions and 1 deletions
  1. +32
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/DDCreatorHelper.java

+ 32
- 1
src/main/org/apache/tools/ant/taskdefs/optional/ejb/DDCreatorHelper.java View File

@@ -54,6 +54,10 @@
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 @@ public class DDCreatorHelper {
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(),
@@ -147,4 +152,30 @@ public class DDCreatorHelper {
}
}
}

/**
* 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;

}
}
}

Loading…
Cancel
Save