* @param genericJarFile jar file.
* @param ejbFiles the hashtable.
*/
private void addGenICGeneratedFiles(File genericJarFile, Hashtable ejbFiles) {
Java genicTask = null; // GenIC task
String genicClass = null; // GenIC class (3 GenIC classes for various versions of JOnAS are supported)
boolean error = false; // true if an error occurs during the GenIC call
if ( nogenic ) {
return;
}
genicTask = (Java) getTask().getProject().createTask("java");
genicTask.setTaskName("genic");
genicTask.setFork(true);
// jonasroot
genicTask.createJvmarg().setValue("-Dinstall.root=" + jonasroot);
// java policy file
String jonasConfigDir = jonasroot + File.separator + "config";
File javaPolicyFile = new File(jonasConfigDir, "java.policy");
if ( javaPolicyFile.exists() ) {
genicTask.createJvmarg().setValue("-Djava.security.policy="
+ javaPolicyFile.toString());
}
// outputdir
try {
outputdir = createTempDir();
} catch (IOException aIOException) {
String msg = "Cannot create temp dir: " + aIOException.getMessage();
throw new BuildException(msg, aIOException);
}
log("Using temporary output directory: " + outputdir, Project.MSG_VERBOSE);
genicTask.createArg().setValue("-d");
genicTask.createArg().setFile(outputdir);
// work around a bug of GenIC 2.5
String key;
File f;
Enumeration keys = ejbFiles.keys();
while ( keys.hasMoreElements() ) {
key = (String)keys.nextElement();
f = new File(outputdir + File.separator + key);
f.getParentFile().mkdirs();
}
log("Worked around a bug of GenIC 2.5.", Project.MSG_VERBOSE);
// classpath
Path classpath = getCombinedClasspath();
if ( classpath == null ) {
classpath = new Path(getTask().getProject());
}
classpath.append(new Path(classpath.getProject(), jonasConfigDir));
classpath.append(new Path(classpath.getProject(), outputdir.toString()));
// try to create the classpath for the correct ORB
if ( orb != null ) {
String orbJar = jonasroot + File.separator + "lib" + File.separator + orb + "_jonas.jar";
classpath.append(new Path(classpath.getProject(), orbJar));
}
log("Using classpath: " + classpath.toString(), Project.MSG_VERBOSE);
genicTask.setClasspath(classpath);
// class name (search in the classpath provided for the ejbjar element)
genicClass = getGenicClassName(classpath);
if ( genicClass == null ) {
log("Cannot find GenIC class in classpath.", Project.MSG_ERR);
throw new BuildException("GenIC class not found, please check the classpath.");
} else {
log("Using '" + genicClass + "' GenIC class." , Project.MSG_VERBOSE);
genicTask.setClassname(genicClass);
}
// keepgenerated
if ( keepgenerated ) {
genicTask.createArg().setValue("-keepgenerated");
}
// nocompil
if ( nocompil ) {
genicTask.createArg().setValue("-nocompil");
}
// novalidation
if ( novalidation ) {
genicTask.createArg().setValue("-novalidation");
}
// javac
if ( javac != null ) {
genicTask.createArg().setValue("-javac");
genicTask.createArg().setLine(javac);
}
// javacopts
if ( javacopts != null && !javacopts.equals("") ) {
genicTask.createArg().setValue("-javacopts");
genicTask.createArg().setLine(javacopts);
}
// rmicopts
if ( rmicopts != null && !rmicopts.equals("") ) {
genicTask.createArg().setValue("-rmicopts");
genicTask.createArg().setLine(rmicopts);
}
// secpropag
if ( secpropag ) {
genicTask.createArg().setValue("-secpropag");
}
// verbose
if ( verbose ) {
genicTask.createArg().setValue("-verbose");
}
// additionalargs
if ( additionalargs != null ) {
genicTask.createArg().setValue(additionalargs);
}
// the generated classes must not be added in the generic JAR!
// is that buggy on old JOnAS (2.4) ??
genicTask.createArg().setValue("-noaddinjar");
// input file to process by GenIC
genicTask.createArg().setValue(genericJarFile.getPath());
// calling GenIC task
log("Calling " + genicClass + " for " + getConfig().descriptorDir + File.separator + descriptorName
+ ".", Project.MSG_VERBOSE);
if ( genicTask.executeJava() != 0 ) {
// the method deleteOnExit() do not work because the directory is not empty
log("Deleting temp output directory '" + outputdir + "'.", Project.MSG_VERBOSE);
deleteAllFiles(outputdir);