From 17e5ca87217a81f888ded1b2d9dac971503ac796 Mon Sep 17 00:00:00 2001
From: Magesh Umasankar In this situation, the if-modified-since header is set so that the file is
* only fetched if it is newer than the local file (or there is no local file)
* This flag is only valid on HTTP connections, it is ignored in other cases.
- * When the flag is set, the local copy of the downloaded file will also
- * have its timestamp set to the remote file time.
+ * When the flag is set, the local copy of the downloaded file will also
+ * have its timestamp set to the remote file time.
* Functionality is currently provided for standard EJB1.1 jars and Weblogic
- * 5.1 jars. The weblogic deployment descriptors, used in constructing the
+ * 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
@@ -106,23 +106,23 @@ import org.apache.tools.ant.types.FileSet;
* @author Tim Fennell
*/
public class EjbJar extends MatchingTask {
-
+
public static class DTDLocation {
private String publicId = null;
private String location = null;
-
+
public void setPublicId(String publicId) {
this.publicId = publicId;
}
-
+
public void setLocation(String location) {
this.location = location;
}
-
+
public String getPublicId() {
return publicId;
}
-
+
public String getLocation() {
return location;
}
@@ -138,7 +138,7 @@ public class EjbJar extends MatchingTask {
/** Stores a handle to the directory under which to search for deployment descriptors */
public File descriptorDir;
-
+
/** Instance variable that marks the end of the 'basename' */
public String baseNameTerminator = "-";
@@ -150,28 +150,28 @@ public class EjbJar extends MatchingTask {
* of a flat directory as the destination for the jar files.
*/
public boolean flatDestDir = false;
-
+
/**
* The classpath to use when loading classes
*/
public Path classpath;
-
+
/**
* A Fileset of support classes
*/
public List supportFileSets = new ArrayList();
-
+
/**
* The list of configured DTD locations
*/
public ArrayList dtdLocations = new ArrayList();
-
+
/**
* The naming scheme used to determine the generated jar name
* from the descriptor information
*/
public NamingScheme namingScheme;
-
+
/**
* The Manifest file
*/
@@ -196,7 +196,7 @@ public class EjbJar extends MatchingTask {
deployment descriptor tools are provided. Normally each deployment tool
will specify the desitination dir itself. */
private File destDir;
-
+
/** Instance variable that stores the suffix for the generated jarfile. */
private String genericJarSuffix = "-generic.jar";
@@ -235,7 +235,7 @@ public class EjbJar extends MatchingTask {
/**
* Create a nested element used to configure a deployment tool for iPlanet
- * Application Server.
+ * Application Server.
*
* @return the deployment tool instance to be configured.
*/
@@ -279,7 +279,7 @@ public class EjbJar extends MatchingTask {
*
* This classpath is used to locate the super classes and interfaces
* of the classes that will make up the EJB jar.
- *
+ *
* @return the path to be configured.
*/
public Path createClasspath() {
@@ -296,7 +296,7 @@ public class EjbJar extends MatchingTask {
public DTDLocation createDTD() {
DTDLocation dtdLocation = new DTDLocation();
config.dtdLocations.add(dtdLocation);
-
+
return dtdLocation;
}
@@ -310,7 +310,7 @@ public class EjbJar extends MatchingTask {
config.supportFileSets.add(supportFileSet);
return supportFileSet;
}
-
+
/**
* Set the Manifest file to use when jarring.
@@ -327,7 +327,7 @@ public class EjbJar extends MatchingTask {
/**
* Set the srcdir attribute. The source directory is the directory that contains
- * the classes that will be added to the EJB jar. Typically this will include the
+ * the classes that will be added to the EJB jar. Typically this will include the
* home and remote interfaces and the bean class.
*
* @param inDir the source directory.
@@ -342,7 +342,7 @@ public class EjbJar extends MatchingTask {
* The descriptor directory contains the EJB deployment descriptors. These are XML
* files that declare the properties of a bean in a particular deployment scenario. Such
* properties include, for example, the transactional nature of the bean and the security
- * access control to the bean's methods.
+ * access control to the bean's methods.
*
* @param inDir the directory containing the deployment descriptors.
*/
@@ -352,8 +352,8 @@ public class EjbJar extends MatchingTask {
/**
* Set the base name of the EJB jar that is to be created if it is not to be
- * determined from the name of the deployment descriptor files.
- *
+ * determined from the name of the deployment descriptor files.
+ *
* @param inValue the basename that will be used when writing the jar file containing
* the EJB
*/
@@ -364,9 +364,9 @@ public class EjbJar extends MatchingTask {
config.namingScheme.setValue(NamingScheme.BASEJARNAME);
}
else if (!config.namingScheme.getValue().equals(NamingScheme.BASEJARNAME)) {
- throw new BuildException("The basejarname attribute is not compatible with the " +
+ throw new BuildException("The basejarname attribute is not compatible with the " +
config.namingScheme.getValue() + " naming scheme");
- }
+ }
}
/**
@@ -379,22 +379,22 @@ public class EjbJar extends MatchingTask {
config.namingScheme = namingScheme;
if (!config.namingScheme.getValue().equals(NamingScheme.BASEJARNAME) &&
config.baseJarName != null) {
- throw new BuildException("The basejarname attribute is not compatible with the " +
+ throw new BuildException("The basejarname attribute is not compatible with the " +
config.namingScheme.getValue() + " naming scheme");
- }
+ }
}
-
+
/**
* Set the destination directory.
- *
+ *
* The EJB jar files will be written into this directory. The jar files that exist in
- * this directory are also used when determining if the contents of the jar file
+ * this directory are also used when determining if the contents of the jar file
* have changed.
*
* Note that this parameter is only used if no deployment tools are specified. Typically
* each deployment tool will specify its own destination directory.
- *
+ *
* @param inFile the destination directory.
*/
public void setDestdir(File inDir) {
@@ -402,7 +402,7 @@ public class EjbJar extends MatchingTask {
}
/**
- * Set the classpath to use when resolving classes for inclusion in the jar.
+ * Set the classpath to use when resolving classes for inclusion in the jar.
*
* @param classpath the classpath to use.
*/
@@ -413,26 +413,26 @@ public class EjbJar extends MatchingTask {
/**
* Set the flat dest dir flag.
*
- * This flag controls whether the destination jars are written out in the
- * destination directory with the same hierarchal structure from which
- * the deployment descriptors have been read. If this is set to true the
+ * This flag controls whether the destination jars are written out in the
+ * destination directory with the same hierarchal structure from which
+ * the deployment descriptors have been read. If this is set to true the
* generated EJB jars are written into the root of the destination directory,
* otherwise they are written out in the same relative position as the deployment
* descriptors in the descriptor directory.
- *
+ *
* @param inValue the new value of the flatdestdir flag.
*/
public void setFlatdestdir(boolean inValue) {
config.flatDestDir = inValue;
}
-
+
/**
* Set the suffix for the generated jar file.
* When generic jars are generated, they have a suffix which is appended to the
* the bean name to create the name of the jar file. Note that this suffix includes
- * the extension fo te jar file and should therefore end with an appropriate
+ * the extension fo te jar file and should therefore end with an appropriate
* extension such as .jar or .ear
- *
+ *
* @param inString the string to use as the suffix.
*/
public void setGenericjarsuffix(String inString) {
@@ -443,7 +443,7 @@ public class EjbJar extends MatchingTask {
* Set the baseNameTerminator.
*
* The basename terminator is the string which terminates the bean name. The convention
- * used by this task is that bean descriptors are named as the BeanName with some suffix.
+ * used by this task is that bean descriptors are named as the BeanName with some suffix.
* The baseNameTerminator string separates the bean name and the suffix and is used to
* determine the bean name.
*
@@ -468,19 +468,19 @@ public class EjbJar extends MatchingTask {
}
else if (config.namingScheme.getValue().equals(NamingScheme.BASEJARNAME) &&
config.baseJarName == null) {
- throw new BuildException("The basejarname attribute must be specified " +
+ throw new BuildException("The basejarname attribute must be specified " +
"with the basejarname naming scheme");
}
- }
+ }
/**
* Invoked by Ant after the task is prepared, when it is ready to execute
- * this task.
+ * this task.
*
- * This will configure all of the nested deployment tools to allow them to
- * process the jar. If no deployment tools have been configured a generic
+ * This will configure all of the nested deployment tools to allow them to
+ * process the jar. If no deployment tools have been configured a generic
* tool is created to handle the jar.
- *
+ *
* A parser is configured and then each descriptor found is passed to all
* the deployment tool elements for processing.
*
@@ -490,7 +490,7 @@ public class EjbJar extends MatchingTask {
*/
public void execute() throws BuildException {
validateConfig();
-
+
if (deploymentTools.size() == 0) {
GenericDeploymentTool genericTool = new GenericDeploymentTool();
genericTool.setTask(this);
@@ -498,27 +498,27 @@ public class EjbJar extends MatchingTask {
genericTool.setGenericJarSuffix(genericJarSuffix);
deploymentTools.add(genericTool);
}
-
+
for (Iterator i = deploymentTools.iterator(); i.hasNext(); ) {
EJBDeploymentTool tool = (EJBDeploymentTool)i.next();
tool.configure(config);
tool.validateConfigured();
}
-
+
try {
// Create the parser using whatever parser the system dictates
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
saxParserFactory.setValidating(true);
SAXParser saxParser = saxParserFactory.newSAXParser();
-
-
+
+
DirectoryScanner ds = getDirectoryScanner(config.descriptorDir);
ds.scan();
String[] files = ds.getIncludedFiles();
-
+
log(files.length + " deployment descriptors located.",
Project.MSG_VERBOSE);
-
+
// Loop through the files. Each file represents one deployment
// descriptor, and hence one bean in our model.
for (int index = 0; index < files.length; ++index) {
@@ -527,7 +527,7 @@ public class EjbJar extends MatchingTask {
EJBDeploymentTool tool = (EJBDeploymentTool)i.next();
tool.processDescriptor(files[index], saxParser);
}
- }
+ }
}
catch (SAXException se) {
String msg = "SAXException while creating parser."
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java
index a58c108f1..e8c17dec7 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbc.java
@@ -80,23 +80,23 @@ import org.xml.sax.InputSource;
import org.xml.sax.AttributeList;
/**
- * Utility class to compile EJB stubs and skeletons for the iPlanet Application
+ * Utility class to compile EJB stubs and skeletons for the iPlanet Application
* Server (iAS). The class will read a standard EJB descriptor (as well as an
- * EJB descriptor specific to iPlanet Application Server) to identify one or
- * more EJBs to process. It will search for EJB "source" classes (the remote
+ * EJB descriptor specific to iPlanet Application Server) to identify one or
+ * more EJBs to process. It will search for EJB "source" classes (the remote
* interface, home interface, and EJB implementation class) and the EJB stubs
- * and skeletons in the specified destination directory. Only if the stubs and
+ * and skeletons in the specified destination directory. Only if the stubs and
* skeletons cannot be found or if they're out of date will the iPlanet
* Application Server ejbc utility be run.
*
* Because this class (and it's assorted inner classes) may be bundled into the
- * iPlanet Application Server distribution at some point (and removed from the
- * Ant distribution), the class has been written to be independent of all
- * Ant-specific classes. It is also for this reason (and to avoid cluttering
- * the Apache Ant source files) that this utility has been packaged into a
+ * iPlanet Application Server distribution at some point (and removed from the
+ * Ant distribution), the class has been written to be independent of all
+ * Ant-specific classes. It is also for this reason (and to avoid cluttering
+ * the Apache Ant source files) that this utility has been packaged into a
* single source file.
*
- * For more information on Ant Tasks for iPlanet Application Server, see the
+ * For more information on Ant Tasks for iPlanet Application Server, see the
*
* For each EJB specified, this task will locate the three classes that comprise
* the EJB. If these class files cannot be located in the
- * I was using AWT to make it independent from the JDK-version. Please don't
- * ask me for a Swing-version:I am very familiar with Swing and I really think
+ * I was using AWT to make it independent from the JDK-version. Please don't
+ * ask me for a Swing-version:I am very familiar with Swing and I really think
* that it's not necessary for such a simple gui!
*
- * It is completely developed in VAJ using the visual composition editor.
+ * It is completely developed in VAJ using the visual composition editor.
* About 90% of the code is generated by VAJ,
* but in fact I did a lot of code-beautification ;-).
*
@@ -111,7 +111,7 @@ import org.apache.tools.ant.Project;
*/
public class VAJAntToolGUI extends Frame {
/**
- * Members
+ * Members
*/
private VAJBuildLogger logger = new VAJBuildLogger();
private String lineSeparator = "\r\n";
@@ -138,7 +138,7 @@ public class VAJAntToolGUI extends Frame {
// Project name
private Label iProjectLabel = null;
private Label iProjectText = null;
- // XML-file
+ // XML-file
private Label iBuildFileLabel = null;
private TextField iBuildFileTextField = null;
private boolean iConnPtoP2Aligning = false;
@@ -151,7 +151,7 @@ public class VAJAntToolGUI extends Frame {
private List iTargetList = null;
// Command-buttons
private Button iBuildButton = null;
- private Button iReloadButton = null;
+ private Button iReloadButton = null;
private Button iCloseButton = null;
/**
* log-Window
@@ -180,7 +180,7 @@ public class VAJAntToolGUI extends Frame {
private Button iAboutOkButton = null;
/**
- * This internal BuildLogger, to be honest, is just a BuildListener.
+ * This internal BuildLogger, to be honest, is just a BuildListener.
* It does nearly the same as the DefaultLogger, but uses the Loggin-Window for output.
*/
private class VAJBuildLogger implements BuildListener {
@@ -203,7 +203,7 @@ public class VAJAntToolGUI extends Frame {
getStopButton().setEnabled(false);
getBuildButton().setEnabled(true);
getBuildButton().requestFocus();
-
+
Throwable error = event.getException();
if (error == null) {
@@ -235,7 +235,7 @@ public class VAJAntToolGUI extends Frame {
error.printStackTrace(System.err);
}
}
-
+
/**
* Fired before any targets are started.
*/
@@ -300,7 +300,7 @@ public class VAJAntToolGUI extends Frame {
public void taskStarted(BuildEvent event) {
}
}
-
+
/**
* Eventhandler to handle all AWT-events
*/
@@ -320,7 +320,7 @@ public class VAJAntToolGUI extends Frame {
getBuildFileTextField().setText(getFileDialog().getDirectory() + getFileDialog().getFile());
}
}
- // dispose and exit application
+ // dispose and exit application
if (e.getSource() == VAJAntToolGUI.this.getCloseButton()) {
dispose();
System.exit(0);
@@ -344,21 +344,21 @@ public class VAJAntToolGUI extends Frame {
}
}
// MenuItems
- if (e.getSource() == VAJAntToolGUI.this.getSaveMenuItem())
+ if (e.getSource() == VAJAntToolGUI.this.getSaveMenuItem())
saveBuildInfo();
- if (e.getSource() == VAJAntToolGUI.this.getAboutMenuItem())
+ if (e.getSource() == VAJAntToolGUI.this.getAboutMenuItem())
getAboutDialog().show();
- if (e.getSource() == VAJAntToolGUI.this.getShowLogMenuItem())
+ if (e.getSource() == VAJAntToolGUI.this.getShowLogMenuItem())
getMessageFrame().show();
/* #### About dialog #### */
- if (e.getSource() == VAJAntToolGUI.this.getAboutOkButton())
+ if (e.getSource() == VAJAntToolGUI.this.getAboutOkButton())
getAboutDialog().dispose();
/* #### Log frame #### */
if (e.getSource() == VAJAntToolGUI.this.getMessageOkButton())
getMessageFrame().dispose();
- if (e.getSource() == VAJAntToolGUI.this.getMessageClearLogButton())
+ if (e.getSource() == VAJAntToolGUI.this.getMessageClearLogButton())
getMessageTextArea().setText("");
- if (e.getSource() == VAJAntToolGUI.this.getMessageOkButton())
+ if (e.getSource() == VAJAntToolGUI.this.getMessageOkButton())
getMessageFrame().dispose();
}
catch (Throwable exc) {
@@ -371,36 +371,36 @@ public class VAJAntToolGUI extends Frame {
*/
public void itemStateChanged(ItemEvent e) {
try {
- if (e.getSource() == VAJAntToolGUI.this.getTargetList())
+ if (e.getSource() == VAJAntToolGUI.this.getTargetList())
getBuildButton().setEnabled(true);
- if (e.getSource() == VAJAntToolGUI.this.getMessageOutputLevelChoice())
+ if (e.getSource() == VAJAntToolGUI.this.getMessageOutputLevelChoice())
getBuildInfo().setOutputMessageLevel(getMessageOutputLevelChoice().getSelectedIndex());
- if (e.getSource() == VAJAntToolGUI.this.getTargetList())
+ if (e.getSource() == VAJAntToolGUI.this.getTargetList())
getBuildInfo().setTarget(getTargetList().getSelectedItem());
}
catch (Throwable exc) {
handleException(exc);
}
}
-
+
/**
* PropertyChangeListener method
*/
public void propertyChange(java.beans.PropertyChangeEvent evt) {
- if (evt.getSource() == VAJAntToolGUI.this.getBuildInfo() && (evt.getPropertyName().equals("projectName")))
+ if (evt.getSource() == VAJAntToolGUI.this.getBuildInfo() && (evt.getPropertyName().equals("projectName")))
connectProjectNameToLabel();
- if (evt.getSource() == VAJAntToolGUI.this.getBuildInfo() && (evt.getPropertyName().equals("buildFileName")))
+ if (evt.getSource() == VAJAntToolGUI.this.getBuildInfo() && (evt.getPropertyName().equals("buildFileName")))
connectBuildFileNameToTextField();
}
-
+
/**
* TextListener method
*/
public void textValueChanged(TextEvent e) {
- if (e.getSource() == VAJAntToolGUI.this.getBuildFileTextField())
+ if (e.getSource() == VAJAntToolGUI.this.getBuildFileTextField())
connectTextFieldToBuildFileName();
}
-
+
/**
* WindowListener methods
*/
@@ -410,9 +410,9 @@ public class VAJAntToolGUI extends Frame {
dispose();
System.exit(0);
}
- if (e.getSource() == VAJAntToolGUI.this.getAboutDialog())
+ if (e.getSource() == VAJAntToolGUI.this.getAboutDialog())
getAboutDialog().dispose();
- if (e.getSource() == VAJAntToolGUI.this.getMessageFrame())
+ if (e.getSource() == VAJAntToolGUI.this.getMessageFrame())
getMessageFrame().dispose();
}
catch (Throwable exc) {
@@ -426,7 +426,7 @@ public class VAJAntToolGUI extends Frame {
public void windowIconified(WindowEvent e) {};
public void windowOpened(WindowEvent e) {};
}
-
+
/**
* AntMake default-constructor.
*/
@@ -438,7 +438,7 @@ public class VAJAntToolGUI extends Frame {
* AntMake constructor called by VAJAntTool integration.
* @param buildInfo VAJBuildInfo
*/
-
+
public VAJAntToolGUI(VAJBuildInfo newBuildInfo) {
super();
setBuildInfo(newBuildInfo);
@@ -503,12 +503,12 @@ public class VAJAntToolGUI extends Frame {
* external build of a .jar-file
*/
private void executeTarget() {
- try {
+ try {
getMessageFrame().show();
getBuildInfo().executeProject(logger);
}
catch (Throwable exc) {
- logger.logException( exc );
+ logger.logException( exc );
}
return;
}
@@ -1293,7 +1293,7 @@ public class VAJAntToolGUI extends Frame {
getMessageTextArea().append(lineSeparator + lineSeparator + trace);
getMessageFrame().show();
-
+
}
/**
* Initializes connections
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJBuildInfo.java b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJBuildInfo.java
index df7d73404..29abf46f8 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJBuildInfo.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJBuildInfo.java
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * 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
@@ -17,15 +17,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
+ * 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
+ * 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"
@@ -54,7 +54,7 @@
package org.apache.tools.ant.taskdefs.optional.ide;
-
+
import java.util.Vector;
import java.util.Enumeration;
import java.util.StringTokenizer;
@@ -80,7 +80,7 @@ import org.apache.tools.ant.BuildEvent;
* execute target)
* - manages a seperate thread for Ant project execution
* this allows interrupting a running build from a GUI
- *
+ *
* @author Wolf Siberski, TUI Infotec GmbH
*/
@@ -102,7 +102,7 @@ class VAJBuildInfo implements Runnable {
private class InterruptedChecker implements BuildListener {
// the real listener
BuildListener wrappedListener;
-
+
/**
* Can only be constructed as wrapper around a real listener
* @param listener the real listener
@@ -182,11 +182,10 @@ class VAJBuildInfo implements Runnable {
checkInterrupted();
}
}
-
-
+
// name of the VA project this BuildInfo belongs to
private String vajProjectName = "";
-
+
// name of the Ant build file
private String buildFileName = "";
@@ -208,30 +207,30 @@ class VAJBuildInfo implements Runnable {
// Support for bound properties
protected transient PropertyChangeSupport propertyChange;
- // thread for Ant build execution
+ // thread for Ant build execution
private Thread buildThread;
// the listener used to log output.
private BuildListener projectLogger;
-
+
/**
- * The addPropertyChangeListener method was generated to support the
+ * The addPropertyChangeListener method was generated to support the
* propertyChange field.
*/
public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
getPropertyChange().addPropertyChangeListener(listener);
}
-
+
/**
* Returns the BuildInfo information as String. The BuildInfo can
* be rebuilt from that String by calling parse().
* @return java.lang.String
*/
public String asDataString() {
- String result = getOutputMessageLevel() + "|" + getBuildFileName()
+ String result = getOutputMessageLevel() + "|" + getBuildFileName()
+ "|" + getTarget();
- for ( Enumeration e = getProjectTargets().elements();
+ for ( Enumeration e = getProjectTargets().elements();
e.hasMoreElements(); ) {
result = result + "|" + e.nextElement();
}
@@ -286,14 +285,14 @@ class VAJBuildInfo implements Runnable {
}
return project;
}
-
+
/**
* return a list of all targets in the current buildfile
*/
public Vector getProjectTargets() {
return projectTargets;
}
-
+
/**
* Accessor for the propertyChange field.
*/
@@ -373,13 +372,13 @@ class VAJBuildInfo implements Runnable {
}
/**
- * The removePropertyChangeListener method was generated
+ * The removePropertyChangeListener method was generated
* to support the propertyChange field.
*/
public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
getPropertyChange().removePropertyChangeListener(listener);
}
-
+
/**
* Sets the build file name
* @param buildFileName build file name
@@ -390,7 +389,7 @@ class VAJBuildInfo implements Runnable {
setProjectInitialized(false);
firePropertyChange("buildFileName", oldValue, buildFileName);
}
-
+
/**
* Sets the log level (value must be one of the constants in Project)
* @param outputMessageLevel log level.
@@ -398,7 +397,7 @@ class VAJBuildInfo implements Runnable {
public void setOutputMessageLevel(int newOutputMessageLevel) {
int oldValue = outputMessageLevel;
outputMessageLevel = newOutputMessageLevel;
- firePropertyChange("outputMessageLevel",
+ firePropertyChange("outputMessageLevel",
new Integer(oldValue), new Integer(outputMessageLevel));
}
@@ -410,7 +409,7 @@ class VAJBuildInfo implements Runnable {
int level = Integer.parseInt( outputMessageLevel );
setOutputMessageLevel( level );
}
-
+
/**
* sets the initialized flag
*/
@@ -461,7 +460,7 @@ class VAJBuildInfo implements Runnable {
/**
- * cancels a build.
+ * cancels a build.
*/
public void cancelBuild() {
buildThread.interrupt();
@@ -484,7 +483,7 @@ class VAJBuildInfo implements Runnable {
} catch (Error err) {
error = err;
throw err;
- }
+ }
}
/**
@@ -501,7 +500,7 @@ class VAJBuildInfo implements Runnable {
if (!isProjectInitialized()) {
initProject();
}
-
+
project.addBuildListener( ic );
project.executeTarget(target);
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java
index 57911f642..a22a2617e 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJExport.java
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * 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
@@ -17,15 +17,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
+ * 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", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
+ * 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"
@@ -51,7 +51,7 @@
* information on the Apache Software Foundation, please see
*
- * Example:
- *
* Note that remote files of date 1/1/1970 (GMT) are treated as 'no timestamp', and
* web servers often serve files with a timestamp in the future by replacing their timestamp
- * with that of the current time. Also, inter-computer clock differences can cause no end of
- * grief.
+ * with that of the current time. Also, inter-computer clock differences can cause no end of
+ * grief.
* @param v "true" to enable file time fetching
*/
public void setUseTimestamp(boolean v) {
@@ -334,95 +330,92 @@ public class Get extends Task {
this.pword = p;
}
- /*********************************************************************
- * BASE 64 encoding of a String or an array of bytes.
- *
- * Based on RFC 1421.
- *
- * @author
- * Unknown
- * @author
- * Gautam Guliani
- *********************************************************************/
-
- class Base64Converter
- {
-
- public final char [ ] alphabet = {
- 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', // 0 to 7
- 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', // 8 to 15
- 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', // 16 to 23
- 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', // 24 to 31
- 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', // 32 to 39
- 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', // 40 to 47
- 'w', 'x', 'y', 'z', '0', '1', '2', '3', // 48 to 55
- '4', '5', '6', '7', '8', '9', '+', '/' }; // 56 to 63
-
-
- public String encode ( String s )
- {
- return encode ( s.getBytes ( ) );
- }
-
- public String encode ( byte [ ] octetString )
- {
- int bits24;
- int bits6;
-
- char [ ] out
- = new char [ ( ( octetString.length - 1 ) / 3 + 1 ) * 4 ];
-
- int outIndex = 0;
- int i = 0;
-
- while ( ( i + 3 ) <= octetString.length ) {
- // store the octets
- bits24=( octetString [ i++ ] & 0xFF ) << 16;
- bits24 |=( octetString [ i++ ] & 0xFF ) << 8;
-
- bits6=( bits24 & 0x00FC0000 )>> 18;
- out [ outIndex++ ] = alphabet [ bits6 ];
- bits6 = ( bits24 & 0x0003F000 ) >> 12;
- out [ outIndex++ ] = alphabet [ bits6 ];
- bits6 = ( bits24 & 0x00000FC0 ) >> 6;
- out [ outIndex++ ] = alphabet [ bits6 ];
- bits6 = ( bits24 & 0x0000003F );
- out [ outIndex++ ] = alphabet [ bits6 ];
- }
-
- if ( octetString.length - i == 2 )
- {
- // store the octets
- bits24 = ( octetString [ i ] & 0xFF ) << 16;
- bits24 |=( octetString [ i + 1 ] & 0xFF ) << 8;
- bits6=( bits24 & 0x00FC0000 )>> 18;
- out [ outIndex++ ] = alphabet [ bits6 ];
- bits6 = ( bits24 & 0x0003F000 ) >> 12;
- out [ outIndex++ ] = alphabet [ bits6 ];
- bits6 = ( bits24 & 0x00000FC0 ) >> 6;
- out [ outIndex++ ] = alphabet [ bits6 ];
-
- // padding
- out [ outIndex++ ] = '=';
- }
- else if ( octetString.length - i == 1 )
- {
- // store the octets
- bits24 = ( octetString [ i ] & 0xFF ) << 16;
- bits6=( bits24 & 0x00FC0000 )>> 18;
- out [ outIndex++ ] = alphabet [ bits6 ];
- bits6 = ( bits24 & 0x0003F000 ) >> 12;
- out [ outIndex++ ] = alphabet [ bits6 ];
-
- // padding
- out [ outIndex++ ] = '=';
- out [ outIndex++ ] = '=';
- }
-
- return new String ( out );
- }
+ /*********************************************************************
+ * BASE 64 encoding of a String or an array of bytes.
+ *
+ * Based on RFC 1421.
+ *
+ * @author
+ * Unknown
+ * @author
+ * Gautam Guliani
+ *********************************************************************/
+
+ class Base64Converter
+ {
+
+ public final char [ ] alphabet = {
+ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', // 0 to 7
+ 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', // 8 to 15
+ 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', // 16 to 23
+ 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', // 24 to 31
+ 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', // 32 to 39
+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', // 40 to 47
+ 'w', 'x', 'y', 'z', '0', '1', '2', '3', // 48 to 55
+ '4', '5', '6', '7', '8', '9', '+', '/' }; // 56 to 63
+
+
+ public String encode ( String s )
+ {
+ return encode ( s.getBytes ( ) );
+ }
- }
+ public String encode ( byte [ ] octetString )
+ {
+ int bits24;
+ int bits6;
+
+ char [ ] out
+ = new char [ ( ( octetString.length - 1 ) / 3 + 1 ) * 4 ];
+
+ int outIndex = 0;
+ int i = 0;
+
+ while ( ( i + 3 ) <= octetString.length ) {
+ // store the octets
+ bits24=( octetString [ i++ ] & 0xFF ) << 16;
+ bits24 |=( octetString [ i++ ] & 0xFF ) << 8;
+
+ bits6=( bits24 & 0x00FC0000 )>> 18;
+ out [ outIndex++ ] = alphabet [ bits6 ];
+ bits6 = ( bits24 & 0x0003F000 ) >> 12;
+ out [ outIndex++ ] = alphabet [ bits6 ];
+ bits6 = ( bits24 & 0x00000FC0 ) >> 6;
+ out [ outIndex++ ] = alphabet [ bits6 ];
+ bits6 = ( bits24 & 0x0000003F );
+ out [ outIndex++ ] = alphabet [ bits6 ];
+ }
+ if ( octetString.length - i == 2 )
+ {
+ // store the octets
+ bits24 = ( octetString [ i ] & 0xFF ) << 16;
+ bits24 |=( octetString [ i + 1 ] & 0xFF ) << 8;
+ bits6=( bits24 & 0x00FC0000 )>> 18;
+ out [ outIndex++ ] = alphabet [ bits6 ];
+ bits6 = ( bits24 & 0x0003F000 ) >> 12;
+ out [ outIndex++ ] = alphabet [ bits6 ];
+ bits6 = ( bits24 & 0x00000FC0 ) >> 6;
+ out [ outIndex++ ] = alphabet [ bits6 ];
+
+ // padding
+ out [ outIndex++ ] = '=';
+ }
+ else if ( octetString.length - i == 1 )
+ {
+ // store the octets
+ bits24 = ( octetString [ i ] & 0xFF ) << 16;
+ bits6=( bits24 & 0x00FC0000 )>> 18;
+ out [ outIndex++ ] = alphabet [ bits6 ];
+ bits6 = ( bits24 & 0x0003F000 ) >> 12;
+ out [ outIndex++ ] = alphabet [ bits6 ];
+
+ // padding
+ out [ outIndex++ ] = '=';
+ out [ outIndex++ ] = '=';
+ }
+ return new String ( out );
+ }
+ }
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/Javac.java b/src/main/org/apache/tools/ant/taskdefs/Javac.java
index 881cf9a4c..df51a5a4b 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Javac.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Javac.java
@@ -134,7 +134,7 @@ public class Javac extends MatchingTask {
private String source;
private String debugLevel;
-
+
/**
* Get the value of debugLevel.
* @return value of debugLevel.
@@ -158,7 +158,7 @@ public class Javac extends MatchingTask {
public String getSource() {
return source;
}
-
+
/**
* Set the value of source.
* @param v Value to assign to source.
@@ -500,7 +500,7 @@ public class Javac extends MatchingTask {
* Is this a forked invocation of JDK's javac?
*/
public boolean isForkedJavac() {
- return !"false".equals(fork) ||
+ return !"false".equals(fork) ||
"extJavac".equals(project.getProperty("build.compiler"));
}
@@ -534,7 +534,7 @@ public class Javac extends MatchingTask {
* Adds an implementation specific command line argument.
*/
public ImplementationSpecificArgument createCompilerArg() {
- ImplementationSpecificArgument arg =
+ ImplementationSpecificArgument arg =
new ImplementationSpecificArgument();
implementationSpecificArgs.addElement(arg);
return arg;
@@ -546,10 +546,10 @@ public class Javac extends MatchingTask {
*/
public String[] getCurrentCompilerArgs() {
Vector args = new Vector();
- for (Enumeration enum = implementationSpecificArgs.elements();
+ for (Enumeration enum = implementationSpecificArgs.elements();
enum.hasMoreElements();
) {
- String[] curr =
+ String[] curr =
((ImplementationSpecificArgument) enum.nextElement()).getParts();
for (int i=0; iIPlanetDeploymentTool
and IPlanetEjbcTask
classes.
*
* @see IPlanetDeploymentTool
@@ -105,692 +105,692 @@ import org.xml.sax.AttributeList;
*/
public class IPlanetEjbc {
- /* Constants used for the "beantype" attribute */
- private final static String ENTITY_BEAN = "entity";
- private final static String STATELESS_SESSION = "stateless";
- private final static String STATEFUL_SESSION = "stateful";
-
- /* Filenames of the standard EJB descriptor and the iAS-specific descriptor */
- private File stdDescriptor;
- private File iasDescriptor;
-
- /*
- * Directory where "source" EJB files are stored and where stubs and
- * skeletons will also be written.
- */
- private File destDirectory;
-
- /* Classpath used when the iAS ejbc is called */
- private String classpath;
- private String[] classpathElements;
-
- /* Options passed to the iAS ejbc */
- private boolean retainSource = false;
- private boolean debugOutput = false;
-
- /* iAS installation directory (used if ejbc isn't on user's PATH) */
- private File iasHomeDir;
-
- /* Parser and handler used to process both EJB descriptor files */
- private SAXParser parser;
- private EjbcHandler handler = new EjbcHandler();
-
- /*
- * This Hashtable maintains a list of EJB class files processed by the ejbc
- * utility (both "source" class files as well as stubs and skeletons). The
- * key for the Hashtable is a String representing the path to the class file
- * (relative to the destination directory). The value for the Hashtable is
- * a File object which reference the actual class file.
- */
- private Hashtable ejbFiles = new Hashtable();
-
- /* Value of the display-name element read from the standard EJB descriptor */
- private String displayName;
-
- /**
- * Constructs an instance which may be used to process EJB descriptors and
- * generate EJB stubs and skeletons, if needed.
- *
- * @param stdDescriptor File referencing a standard EJB descriptor.
- * @param iasDescriptor File referencing an iAS-specific EJB descriptor.
- * @param destDirectory File referencing the base directory where both
- * EJB "source" files are found and where stubs and
- * skeletons will be written.
- * @param classpath String representation of the classpath to be used
- * by the iAS ejbc utility.
- * @param parser SAXParser to be used to process both of the EJB
- * descriptors.
- */
- public IPlanetEjbc(File stdDescriptor,
- File iasDescriptor,
- File destDirectory,
- String classpath,
- SAXParser parser) {
- this.stdDescriptor = stdDescriptor;
- this.iasDescriptor = iasDescriptor;
- this.destDirectory = destDirectory;
- this.classpath = classpath;
- this.parser = parser;
-
- /*
- * Parse the classpath into it's individual elements and store the
- * results in the "classpathElements" instance variable.
- */
- List elements = new ArrayList();
- if (classpath != null) {
- StringTokenizer st = new StringTokenizer(classpath,
- File.pathSeparator);
- while (st.hasMoreTokens()) {
- elements.add(st.nextToken());
- }
- classpathElements
- = (String[])elements.toArray(new String[elements.size()]);
- }
- }
+ /* Constants used for the "beantype" attribute */
+ private final static String ENTITY_BEAN = "entity";
+ private final static String STATELESS_SESSION = "stateless";
+ private final static String STATEFUL_SESSION = "stateful";
+
+ /* Filenames of the standard EJB descriptor and the iAS-specific descriptor */
+ private File stdDescriptor;
+ private File iasDescriptor;
+
+ /*
+ * Directory where "source" EJB files are stored and where stubs and
+ * skeletons will also be written.
+ */
+ private File destDirectory;
+
+ /* Classpath used when the iAS ejbc is called */
+ private String classpath;
+ private String[] classpathElements;
+
+ /* Options passed to the iAS ejbc */
+ private boolean retainSource = false;
+ private boolean debugOutput = false;
+
+ /* iAS installation directory (used if ejbc isn't on user's PATH) */
+ private File iasHomeDir;
+
+ /* Parser and handler used to process both EJB descriptor files */
+ private SAXParser parser;
+ private EjbcHandler handler = new EjbcHandler();
+
+ /*
+ * This Hashtable maintains a list of EJB class files processed by the ejbc
+ * utility (both "source" class files as well as stubs and skeletons). The
+ * key for the Hashtable is a String representing the path to the class file
+ * (relative to the destination directory). The value for the Hashtable is
+ * a File object which reference the actual class file.
+ */
+ private Hashtable ejbFiles = new Hashtable();
+
+ /* Value of the display-name element read from the standard EJB descriptor */
+ private String displayName;
+
+ /**
+ * Constructs an instance which may be used to process EJB descriptors and
+ * generate EJB stubs and skeletons, if needed.
+ *
+ * @param stdDescriptor File referencing a standard EJB descriptor.
+ * @param iasDescriptor File referencing an iAS-specific EJB descriptor.
+ * @param destDirectory File referencing the base directory where both
+ * EJB "source" files are found and where stubs and
+ * skeletons will be written.
+ * @param classpath String representation of the classpath to be used
+ * by the iAS ejbc utility.
+ * @param parser SAXParser to be used to process both of the EJB
+ * descriptors.
+ */
+ public IPlanetEjbc(File stdDescriptor,
+ File iasDescriptor,
+ File destDirectory,
+ String classpath,
+ SAXParser parser) {
+ this.stdDescriptor = stdDescriptor;
+ this.iasDescriptor = iasDescriptor;
+ this.destDirectory = destDirectory;
+ this.classpath = classpath;
+ this.parser = parser;
+
+ /*
+ * Parse the classpath into it's individual elements and store the
+ * results in the "classpathElements" instance variable.
+ */
+ List elements = new ArrayList();
+ if (classpath != null) {
+ StringTokenizer st = new StringTokenizer(classpath,
+ File.pathSeparator);
+ while (st.hasMoreTokens()) {
+ elements.add(st.nextToken());
+ }
+ classpathElements
+ = (String[])elements.toArray(new String[elements.size()]);
+ }
+ }
/**
- * Sets whether or not the Java source files which are generated by the
- * ejbc process should be retained or automatically deleted.
- *
- * @param retainsource A boolean indicating if the Java source files for
- * the stubs and skeletons should be retained.
+ * Sets whether or not the Java source files which are generated by the
+ * ejbc process should be retained or automatically deleted.
+ *
+ * @param retainsource A boolean indicating if the Java source files for
+ * the stubs and skeletons should be retained.
*/
- public void setRetainSource(boolean retainSource) {
- this.retainSource = retainSource;
- }
+ public void setRetainSource(boolean retainSource) {
+ this.retainSource = retainSource;
+ }
/**
* Sets whether or not debugging output will be generated when ejbc is
- * executed.
- *
- * @param debugOutput A boolean indicating if debugging output should be
- * generated
+ * executed.
+ *
+ * @param debugOutput A boolean indicating if debugging output should be
+ * generated
*/
- public void setDebugOutput(boolean debugOutput) {
- this.debugOutput = debugOutput;
- }
+ public void setDebugOutput(boolean debugOutput) {
+ this.debugOutput = debugOutput;
+ }
/**
* Registers the location of a local DTD file or resource. By registering
- * a local DTD, EJB descriptors can be parsed even when the remote servers
- * which contain the "public" DTDs cannot be accessed.
+ * a local DTD, EJB descriptors can be parsed even when the remote servers
+ * which contain the "public" DTDs cannot be accessed.
*
* @param publicID The public DTD identifier found in an XML document.
- * @param location The file or resource name for the appropriate DTD stored
- * on the local machine.
+ * @param location The file or resource name for the appropriate DTD stored
+ * on the local machine.
*/
- public void registerDTD(String publicID, String location) {
- handler.registerDTD(publicID, location);
- }
+ public void registerDTD(String publicID, String location) {
+ handler.registerDTD(publicID, location);
+ }
/**
* Setter method used to store the "home" directory of the user's iAS
- * installation. The directory specified should typically be
- * [install-location]/iplanet/ias6/ias
.
- *
+ * installation. The directory specified should typically be
+ * [install-location]/iplanet/ias6/ias
.
+ *
* @param iashome The home directory for the user's iAS installation.
*/
- public void setIasHomeDir(File iasHomeDir) {
- this.iasHomeDir = iasHomeDir;
- }
-
- /**
- * Returns a Hashtable which contains a list of EJB class files processed by
- * the ejbc utility (both "source" class files as well as stubs and
- * skeletons). The key for the Hashtable is a String representing the path
- * to the class file (relative to the destination directory). The value for
- * the Hashtable is a File object which reference the actual class file.
- *
- * @return The list of EJB files processed by the ejbc utility.
- */
- public Hashtable getEjbFiles() {
- return ejbFiles;
- }
-
- /**
- * Returns the display-name element read from the standard EJB descriptor.
- *
- * @return The EJB-JAR display name.
- */
- public String getDisplayName() {
- return displayName;
- }
-
- /**
- * Returns the list of CMP descriptors referenced in the EJB descriptors.
- *
- * @return An array of CMP descriptors.
- */
- public String[] getCmpDescriptors() {
- List returnList = new ArrayList();
-
- EjbInfo[] ejbs = handler.getEjbs();
-
- for (int i = 0; i < ejbs.length ; i++) {
- List descriptors = (List) ejbs[i].getCmpDescriptors();
- returnList.addAll(descriptors);
- }
-
- return (String[]) returnList.toArray(new String[returnList.size()]);
- }
-
- /**
- * Main application method for the iPlanet Application Server ejbc utility.
- * If the application is run with no commandline arguments, a usage
- * statement is printed for the user.
- *
- * @param args The commandline arguments passed to the application.
- */
- public static void main(String[] args) {
- File stdDescriptor;
- File iasDescriptor;
- File destDirectory = null;
- String classpath = null;
- SAXParser parser = null;
- boolean debug = false;
- boolean retainSource = false;
- IPlanetEjbc ejbc;
-
- if ((args.length < 2) || (args.length > 8)) {
- usage();
- return;
- }
-
- stdDescriptor = new File(args[args.length - 2]);
- iasDescriptor = new File(args[args.length - 1]);
-
- for (int i = 0; i < args.length - 2; i++) {
- if (args[i].equals("-classpath")) {
- classpath = args[++i];
- } else if (args[i].equals("-d")) {
- destDirectory = new File(args[++i]);
- } else if (args[i].equals("-debug")) {
- debug = true;
- } else if (args[i].equals("-keepsource")) {
- retainSource = true;
- } else {
- usage();
- return;
- }
- }
-
- /* If the -classpath flag isn't specified, use the system classpath */
- if (classpath == null) {
- Properties props = System.getProperties();
- classpath = props.getProperty("java.class.path");
- }
-
- /*
- * If the -d flag isn't specified, use the working directory as the
- * destination directory
- */
- if (destDirectory == null) {
- Properties props = System.getProperties();
- destDirectory = new File(props.getProperty("user.dir"));
- }
-
- /* Construct a SAXParser used to process the descriptors */
- SAXParserFactory parserFactory = SAXParserFactory.newInstance();
- parserFactory.setValidating(true);
- try {
- parser = parserFactory.newSAXParser();
- } catch (Exception e) {
- // SAXException or ParserConfigurationException may be thrown
- System.out.println("An exception was generated while trying to ");
- System.out.println("create a new SAXParser.");
- e.printStackTrace();
- return;
- }
-
- /* Build and populate an instance of the ejbc utility */
- ejbc = new IPlanetEjbc(stdDescriptor, iasDescriptor, destDirectory,
- classpath, parser);
- ejbc.setDebugOutput(debug);
- ejbc.setRetainSource(retainSource);
-
- /* Execute the ejbc utility -- stubs/skeletons are rebuilt, if needed */
- try {
- ejbc.execute();
- } catch (IOException e) {
- System.out.println("An IOException has occurred while reading the "
- + "XML descriptors (" + e.getMessage() + ").");
- return;
- } catch (SAXException e) {
- System.out.println("A SAXException has occurred while reading the "
- + "XML descriptors (" + e.getMessage() + ").");
- return;
- } catch (IPlanetEjbc.EjbcException e) {
- System.out.println("An error has occurred while executing the ejbc "
- + "utility (" + e.getMessage() + ").");
- return;
- }
- }
-
- /**
- * Print a usage statement.
- */
- private static void usage() {
- System.out.println("java org.apache.tools.ant.taskdefs.optional.ejb.IPlanetEjbc \\");
- System.out.println(" [OPTIONS] [EJB 1.1 descriptor] [iAS EJB descriptor]");
- System.out.println("");
- System.out.println("Where OPTIONS are:");
- System.out.println(" -debug -- for additional debugging output");
- System.out.println(" -keepsource -- to retain Java source files generated");
- System.out.println(" -classpath [classpath] -- classpath used for compilation");
- System.out.println(" -d [destination directory] -- directory for compiled classes");
- System.out.println("");
- System.out.println("If a classpath is not specified, the system classpath");
- System.out.println("will be used. If a destination directory is not specified,");
- System.out.println("the current working directory will be used (classes will");
- System.out.println("still be placed in subfolders which correspond to their");
- System.out.println("package name).");
- System.out.println("");
- System.out.println("The EJB home interface, remote interface, and implementation");
- System.out.println("class must be found in the destination directory. In");
- System.out.println("addition, the destination will look for the stubs and skeletons");
- System.out.println("in the destination directory to ensure they are up to date.");
- }
-
- /**
- * Compiles the stub and skeletons for the specified EJBs, if they need to
- * be updated.
- *
- * @throws EjbcException If the ejbc utility cannot be correctly configured
- * or if one or more of the EJB "source" classes
- * cannot be found in the destination directory
+ public void setIasHomeDir(File iasHomeDir) {
+ this.iasHomeDir = iasHomeDir;
+ }
+
+ /**
+ * Returns a Hashtable which contains a list of EJB class files processed by
+ * the ejbc utility (both "source" class files as well as stubs and
+ * skeletons). The key for the Hashtable is a String representing the path
+ * to the class file (relative to the destination directory). The value for
+ * the Hashtable is a File object which reference the actual class file.
+ *
+ * @return The list of EJB files processed by the ejbc utility.
+ */
+ public Hashtable getEjbFiles() {
+ return ejbFiles;
+ }
+
+ /**
+ * Returns the display-name element read from the standard EJB descriptor.
+ *
+ * @return The EJB-JAR display name.
+ */
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ /**
+ * Returns the list of CMP descriptors referenced in the EJB descriptors.
+ *
+ * @return An array of CMP descriptors.
+ */
+ public String[] getCmpDescriptors() {
+ List returnList = new ArrayList();
+
+ EjbInfo[] ejbs = handler.getEjbs();
+
+ for (int i = 0; i < ejbs.length ; i++) {
+ List descriptors = (List) ejbs[i].getCmpDescriptors();
+ returnList.addAll(descriptors);
+ }
+
+ return (String[]) returnList.toArray(new String[returnList.size()]);
+ }
+
+ /**
+ * Main application method for the iPlanet Application Server ejbc utility.
+ * If the application is run with no commandline arguments, a usage
+ * statement is printed for the user.
+ *
+ * @param args The commandline arguments passed to the application.
+ */
+ public static void main(String[] args) {
+ File stdDescriptor;
+ File iasDescriptor;
+ File destDirectory = null;
+ String classpath = null;
+ SAXParser parser = null;
+ boolean debug = false;
+ boolean retainSource = false;
+ IPlanetEjbc ejbc;
+
+ if ((args.length < 2) || (args.length > 8)) {
+ usage();
+ return;
+ }
+
+ stdDescriptor = new File(args[args.length - 2]);
+ iasDescriptor = new File(args[args.length - 1]);
+
+ for (int i = 0; i < args.length - 2; i++) {
+ if (args[i].equals("-classpath")) {
+ classpath = args[++i];
+ } else if (args[i].equals("-d")) {
+ destDirectory = new File(args[++i]);
+ } else if (args[i].equals("-debug")) {
+ debug = true;
+ } else if (args[i].equals("-keepsource")) {
+ retainSource = true;
+ } else {
+ usage();
+ return;
+ }
+ }
+
+ /* If the -classpath flag isn't specified, use the system classpath */
+ if (classpath == null) {
+ Properties props = System.getProperties();
+ classpath = props.getProperty("java.class.path");
+ }
+
+ /*
+ * If the -d flag isn't specified, use the working directory as the
+ * destination directory
+ */
+ if (destDirectory == null) {
+ Properties props = System.getProperties();
+ destDirectory = new File(props.getProperty("user.dir"));
+ }
+
+ /* Construct a SAXParser used to process the descriptors */
+ SAXParserFactory parserFactory = SAXParserFactory.newInstance();
+ parserFactory.setValidating(true);
+ try {
+ parser = parserFactory.newSAXParser();
+ } catch (Exception e) {
+ // SAXException or ParserConfigurationException may be thrown
+ System.out.println("An exception was generated while trying to ");
+ System.out.println("create a new SAXParser.");
+ e.printStackTrace();
+ return;
+ }
+
+ /* Build and populate an instance of the ejbc utility */
+ ejbc = new IPlanetEjbc(stdDescriptor, iasDescriptor, destDirectory,
+ classpath, parser);
+ ejbc.setDebugOutput(debug);
+ ejbc.setRetainSource(retainSource);
+
+ /* Execute the ejbc utility -- stubs/skeletons are rebuilt, if needed */
+ try {
+ ejbc.execute();
+ } catch (IOException e) {
+ System.out.println("An IOException has occurred while reading the "
+ + "XML descriptors (" + e.getMessage() + ").");
+ return;
+ } catch (SAXException e) {
+ System.out.println("A SAXException has occurred while reading the "
+ + "XML descriptors (" + e.getMessage() + ").");
+ return;
+ } catch (IPlanetEjbc.EjbcException e) {
+ System.out.println("An error has occurred while executing the ejbc "
+ + "utility (" + e.getMessage() + ").");
+ return;
+ }
+ }
+
+ /**
+ * Print a usage statement.
+ */
+ private static void usage() {
+ System.out.println("java org.apache.tools.ant.taskdefs.optional.ejb.IPlanetEjbc \\");
+ System.out.println(" [OPTIONS] [EJB 1.1 descriptor] [iAS EJB descriptor]");
+ System.out.println("");
+ System.out.println("Where OPTIONS are:");
+ System.out.println(" -debug -- for additional debugging output");
+ System.out.println(" -keepsource -- to retain Java source files generated");
+ System.out.println(" -classpath [classpath] -- classpath used for compilation");
+ System.out.println(" -d [destination directory] -- directory for compiled classes");
+ System.out.println("");
+ System.out.println("If a classpath is not specified, the system classpath");
+ System.out.println("will be used. If a destination directory is not specified,");
+ System.out.println("the current working directory will be used (classes will");
+ System.out.println("still be placed in subfolders which correspond to their");
+ System.out.println("package name).");
+ System.out.println("");
+ System.out.println("The EJB home interface, remote interface, and implementation");
+ System.out.println("class must be found in the destination directory. In");
+ System.out.println("addition, the destination will look for the stubs and skeletons");
+ System.out.println("in the destination directory to ensure they are up to date.");
+ }
+
+ /**
+ * Compiles the stub and skeletons for the specified EJBs, if they need to
+ * be updated.
+ *
+ * @throws EjbcException If the ejbc utility cannot be correctly configured
+ * or if one or more of the EJB "source" classes
+ * cannot be found in the destination directory
* @throws IOException If the parser encounters a problem reading the XML
- * file
- * @throws SAXException If the parser encounters a problem processing the
- * XML descriptor (it may wrap another exception)
+ * file
+ * @throws SAXException If the parser encounters a problem processing the
+ * XML descriptor (it may wrap another exception)
*/
- public void execute() throws EjbcException, IOException, SAXException {
+ public void execute() throws EjbcException, IOException, SAXException {
- checkConfiguration(); // Throws EjbcException if unsuccessful
+ checkConfiguration(); // Throws EjbcException if unsuccessful
- EjbInfo[] ejbs = getEjbs(); // Returns list of EJBs for processing
+ EjbInfo[] ejbs = getEjbs(); // Returns list of EJBs for processing
+
+ for (int i = 0; i < ejbs.length ; i++) {
+ log("EJBInfo...");
+ log(ejbs[i].toString());
+ }
- for (int i = 0; i < ejbs.length ; i++) {
- log("EJBInfo...");
- log(ejbs[i].toString());
- }
-
- for (int i=0; i < ejbs.length; i++) {
- EjbInfo ejb = ejbs[i];
+ for (int i=0; i < ejbs.length; i++) {
+ EjbInfo ejb = ejbs[i];
- ejb.checkConfiguration(destDirectory); // Throws EjbcException
+ ejb.checkConfiguration(destDirectory); // Throws EjbcException
- if (ejb.mustBeRecompiled(destDirectory)) {
- log(ejb.getName() + " must be recompiled using ejbc.");
+ if (ejb.mustBeRecompiled(destDirectory)) {
+ log(ejb.getName() + " must be recompiled using ejbc.");
- String[] arguments = buildArgumentList(ejb);
- callEjbc(arguments);
+ String[] arguments = buildArgumentList(ejb);
+ callEjbc(arguments);
- } else {
- log(ejb.getName() + " is up to date.");
- }
- }
- }
+ } else {
+ log(ejb.getName() + " is up to date.");
+ }
+ }
+ }
- /**
+ /**
* Executes the iPlanet Application Server ejbc command-line utility.
- *
- * @param arguments Command line arguments to be passed to the ejbc utility.
+ *
+ * @param arguments Command line arguments to be passed to the ejbc utility.
*/
- private void callEjbc(String[] arguments) {
-
- /* Concatenate all of the command line arguments into a single String */
- StringBuffer args = new StringBuffer();
- for (int i = 0; i < arguments.length; i++) {
- args.append(arguments[i]).append(" ");
- }
-
- /* If an iAS home directory is specified, prepend it to the commmand */
- String command;
- if (iasHomeDir == null) {
- command = "";
- } else {
- command = iasHomeDir.toString() + File.separator + "bin"
- + File.separator;
- }
- command += "ejbc ";
-
- log(command + args);
-
- /*
- * Use the Runtime object to execute an external command. Use the
- * RedirectOutput inner class to direct the standard and error output
- * from the command to the JRE's standard output
- */
- try {
- Process p = Runtime.getRuntime().exec(command + args);
- RedirectOutput output = new RedirectOutput(p.getInputStream());
- RedirectOutput error = new RedirectOutput(p.getErrorStream());
- output.start();
- error.start();
- p.waitFor();
- p.destroy();
- } catch (IOException e) {
- log("An IOException has occurred while trying to execute ejbc.");
- e.printStackTrace();
- } catch (InterruptedException e) {
- // Do nothing
- }
- }
+ private void callEjbc(String[] arguments) {
+
+ /* Concatenate all of the command line arguments into a single String */
+ StringBuffer args = new StringBuffer();
+ for (int i = 0; i < arguments.length; i++) {
+ args.append(arguments[i]).append(" ");
+ }
+
+ /* If an iAS home directory is specified, prepend it to the commmand */
+ String command;
+ if (iasHomeDir == null) {
+ command = "";
+ } else {
+ command = iasHomeDir.toString() + File.separator + "bin"
+ + File.separator;
+ }
+ command += "ejbc ";
+
+ log(command + args);
+
+ /*
+ * Use the Runtime object to execute an external command. Use the
+ * RedirectOutput inner class to direct the standard and error output
+ * from the command to the JRE's standard output
+ */
+ try {
+ Process p = Runtime.getRuntime().exec(command + args);
+ RedirectOutput output = new RedirectOutput(p.getInputStream());
+ RedirectOutput error = new RedirectOutput(p.getErrorStream());
+ output.start();
+ error.start();
+ p.waitFor();
+ p.destroy();
+ } catch (IOException e) {
+ log("An IOException has occurred while trying to execute ejbc.");
+ e.printStackTrace();
+ } catch (InterruptedException e) {
+ // Do nothing
+ }
+ }
/**
* Verifies that the user selections are valid.
- *
- * @throws EjbcException If the user selections are invalid.
+ *
+ * @throws EjbcException If the user selections are invalid.
*/
- protected void checkConfiguration() throws EjbcException {
-
- String msg = "";
-
- if (stdDescriptor == null) {
- msg += "A standard XML descriptor file must be specified. ";
- }
- if (iasDescriptor == null) {
- msg += "An iAS-specific XML descriptor file must be specified. ";
- }
- if (classpath == null) {
- msg += "A classpath must be specified. ";
- }
- if (parser == null) {
- msg += "An XML parser must be specified. ";
- }
-
- if (destDirectory == null) {
- msg += "A destination directory must be specified. ";
- } else if (!destDirectory.exists()) {
- msg += "The destination directory specified does not exist. ";
- } else if (!destDirectory.isDirectory()) {
- msg += "The destination specified is not a directory. ";
- }
-
- if (msg.length() > 0) {
- throw new EjbcException(msg);
- }
- }
+ protected void checkConfiguration() throws EjbcException {
+
+ String msg = "";
+
+ if (stdDescriptor == null) {
+ msg += "A standard XML descriptor file must be specified. ";
+ }
+ if (iasDescriptor == null) {
+ msg += "An iAS-specific XML descriptor file must be specified. ";
+ }
+ if (classpath == null) {
+ msg += "A classpath must be specified. ";
+ }
+ if (parser == null) {
+ msg += "An XML parser must be specified. ";
+ }
+
+ if (destDirectory == null) {
+ msg += "A destination directory must be specified. ";
+ } else if (!destDirectory.exists()) {
+ msg += "The destination directory specified does not exist. ";
+ } else if (!destDirectory.isDirectory()) {
+ msg += "The destination specified is not a directory. ";
+ }
+
+ if (msg.length() > 0) {
+ throw new EjbcException(msg);
+ }
+ }
/**
* Parses the EJB descriptors and returns a list of EJBs which may need to
- * be compiled.
- *
- * @return An array of objects which describe the EJBs to be
- * processed.
+ * be compiled.
+ *
+ * @return An array of objects which describe the EJBs to be
+ * processed.
* @throws IOException If the parser encounters a problem reading the XML
- * files
- * @throws SAXException If the parser encounters a problem processing the
- * XML descriptor (it may wrap another exception)
- */
- private EjbInfo[] getEjbs() throws IOException, SAXException {
- EjbInfo[] ejbs = null;
+ * files
+ * @throws SAXException If the parser encounters a problem processing the
+ * XML descriptor (it may wrap another exception)
+ */
+ private EjbInfo[] getEjbs() throws IOException, SAXException {
+ EjbInfo[] ejbs = null;
- /*
- * The EJB information is gathered from the standard XML EJB descriptor
- * and the iAS-specific XML EJB descriptor using a SAX parser.
- */
+ /*
+ * The EJB information is gathered from the standard XML EJB descriptor
+ * and the iAS-specific XML EJB descriptor using a SAX parser.
+ */
- parser.parse(stdDescriptor, handler);
- parser.parse(iasDescriptor, handler);
- ejbs = handler.getEjbs();
+ parser.parse(stdDescriptor, handler);
+ parser.parse(iasDescriptor, handler);
+ ejbs = handler.getEjbs();
- return ejbs;
- }
+ return ejbs;
+ }
/**
* Based on this object's instance variables as well as the EJB to be
- * processed, the correct flags and parameters are set for the ejbc
- * command-line utility.
- * @param ejb The EJB for which stubs and skeletons will be compiled.
- * @return An array of Strings which are the command-line parameters for
- * for the ejbc utility.
- */
+ * processed, the correct flags and parameters are set for the ejbc
+ * command-line utility.
+ * @param ejb The EJB for which stubs and skeletons will be compiled.
+ * @return An array of Strings which are the command-line parameters for
+ * for the ejbc utility.
+ */
private String[] buildArgumentList(EjbInfo ejb) {
- List arguments = new ArrayList();
+ List arguments = new ArrayList();
- /* OPTIONAL COMMAND LINE PARAMETERS */
+ /* OPTIONAL COMMAND LINE PARAMETERS */
- if (debugOutput) {
- arguments.add("-debug");
- }
+ if (debugOutput) {
+ arguments.add("-debug");
+ }
- /* No beantype flag is needed for an entity bean */
- if (ejb.getBeantype().equals(STATELESS_SESSION)) {
- arguments.add("-sl");
- } else if (ejb.getBeantype().equals(STATEFUL_SESSION)) {
- arguments.add("-sf");
- }
+ /* No beantype flag is needed for an entity bean */
+ if (ejb.getBeantype().equals(STATELESS_SESSION)) {
+ arguments.add("-sl");
+ } else if (ejb.getBeantype().equals(STATEFUL_SESSION)) {
+ arguments.add("-sf");
+ }
- if (ejb.getIiop()) {
- arguments.add("-iiop");
- }
+ if (ejb.getIiop()) {
+ arguments.add("-iiop");
+ }
- if (ejb.getCmp()) {
- arguments.add("-cmp");
- }
+ if (ejb.getCmp()) {
+ arguments.add("-cmp");
+ }
- if (retainSource) {
- arguments.add("-gs");
- }
+ if (retainSource) {
+ arguments.add("-gs");
+ }
- if (ejb.getHasession()) {
- arguments.add("-fo");
- }
+ if (ejb.getHasession()) {
+ arguments.add("-fo");
+ }
- /* REQUIRED COMMAND LINE PARAMETERS */
+ /* REQUIRED COMMAND LINE PARAMETERS */
- arguments.add("-classpath");
- arguments.add(classpath);
+ arguments.add("-classpath");
+ arguments.add(classpath);
- arguments.add("-d");
- arguments.add(destDirectory.toString());
+ arguments.add("-d");
+ arguments.add(destDirectory.toString());
- arguments.add(ejb.getHome().getQualifiedClassName());
- arguments.add(ejb.getRemote().getQualifiedClassName());
- arguments.add(ejb.getImplementation().getQualifiedClassName());
+ arguments.add(ejb.getHome().getQualifiedClassName());
+ arguments.add(ejb.getRemote().getQualifiedClassName());
+ arguments.add(ejb.getImplementation().getQualifiedClassName());
- /* Convert the List into an Array and return it */
- return (String[])arguments.toArray(new String[arguments.size()]);
- }
+ /* Convert the List into an Array and return it */
+ return (String[])arguments.toArray(new String[arguments.size()]);
+ }
/**
* Convenience method used to print messages to the user if debugging
- * messages are enabled.
- *
- * @param msg The String to print to standard output.
- */
- private void log(String msg) {
- if (debugOutput) {
- System.out.println(msg);
- }
- }
-
-
- /* Inner classes follow */
-
-
- /**
- * This inner class is used to signal any problems during the execution of
- * the ejbc compiler.
- *
- * @author Greg Nelson
- * greg@netscape.com
- */
- public class EjbcException extends Exception {
-
- /**
- * Constructs an exception with the given descriptive message.
- *
- * @param msg Description of the exception which has occurred.
- */
- public EjbcException(String msg) {
- super(msg);
- }
- } // End of EjbcException inner class
-
-
- /**
- * This inner class is an XML document handler that can be used to parse EJB
- * descriptors (both the standard EJB descriptor as well as the iAS-specific
- * descriptor that stores additional values for iAS). Once the descriptors
- * have been processed, the list of EJBs found can be obtained by calling
- * the getEjbs()
method.
- *
- * @see EjbInfo
- * @author Greg Nelson
- * greg@netscape.com
- */
+ * messages are enabled.
+ *
+ * @param msg The String to print to standard output.
+ */
+ private void log(String msg) {
+ if (debugOutput) {
+ System.out.println(msg);
+ }
+ }
+
+
+ /* Inner classes follow */
+
+
+ /**
+ * This inner class is used to signal any problems during the execution of
+ * the ejbc compiler.
+ *
+ * @author Greg Nelson
+ * greg@netscape.com
+ */
+ public class EjbcException extends Exception {
+
+ /**
+ * Constructs an exception with the given descriptive message.
+ *
+ * @param msg Description of the exception which has occurred.
+ */
+ public EjbcException(String msg) {
+ super(msg);
+ }
+ } // End of EjbcException inner class
+
+
+ /**
+ * This inner class is an XML document handler that can be used to parse EJB
+ * descriptors (both the standard EJB descriptor as well as the iAS-specific
+ * descriptor that stores additional values for iAS). Once the descriptors
+ * have been processed, the list of EJBs found can be obtained by calling
+ * the getEjbs()
method.
+ *
+ * @see EjbInfo
+ * @author Greg Nelson
+ * greg@netscape.com
+ */
private class EjbcHandler extends HandlerBase {
- /*
- * Two Maps are used to track local DTDs that will be used in case the
- * remote copies of these DTDs cannot be accessed. The key for the Map
- * is the DTDs public ID and the value is the local location for the DTD
- */
- private Map resourceDtds = new HashMap();
- private Map fileDtds = new HashMap();
+ /*
+ * Two Maps are used to track local DTDs that will be used in case the
+ * remote copies of these DTDs cannot be accessed. The key for the Map
+ * is the DTDs public ID and the value is the local location for the DTD
+ */
+ private Map resourceDtds = new HashMap();
+ private Map fileDtds = new HashMap();
- private Map ejbs = new HashMap(); // List of EJBs found in XML
- private EjbInfo currentEjb; // One item within the Map
+ private Map ejbs = new HashMap(); // List of EJBs found in XML
+ private EjbInfo currentEjb; // One item within the Map
private boolean iasDescriptor = false; // Is doc iAS or EJB descriptor
- private String currentLoc = ""; // Tracks current element
- private String currentText; // Tracks current text data
- private String ejbType; // "session" or "entity"
-
- /**
- * Constructs a new instance of the handler and registers local copies
- * of the standard EJB 1.1 descriptor DTD as well as iAS's EJB
- * descriptor DTD.
- */
- public EjbcHandler() {
- final String PUBLICID_EJB11 =
- "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN";
- final String PUBLICID_IPLANET_EJB_60 =
- "-//Sun Microsystems, Inc.//DTD iAS Enterprise JavaBeans 1.0//EN";
-
-
- final String DEFAULT_IAS60_EJB11_DTD_LOCATION =
- "ejb-jar_1_1.dtd";
- final String DEFAULT_IAS60_DTD_LOCATION =
- "IASEjb_jar_1_0.dtd";
-
- registerDTD(PUBLICID_EJB11, DEFAULT_IAS60_EJB11_DTD_LOCATION);
- registerDTD(PUBLICID_IPLANET_EJB_60, DEFAULT_IAS60_DTD_LOCATION);
- }
-
- /**
- * Returns the list of EJB objects found during the processing of the
- * standard EJB 1.1 descriptor and iAS-specific EJB descriptor.
- *
- * @return An array of EJBs which were found during the descriptor
- * parsing.
- */
- public EjbInfo[] getEjbs() {
- return (EjbInfo[])ejbs.values().toArray(new EjbInfo[ejbs.size()]);
- }
-
- /**
- * Returns the value of the display-name element found in the standard
- * EJB 1.1 descriptor.
- *
- * @return String display-name value.
- */
- public String getDisplayName() {
- return displayName;
- }
-
- /**
- * Registers a local DTD that will be used when parsing an EJB
- * descriptor. When the DTD's public identifier is found in an XML
- * document, the parser will reference the local DTD rather than the
- * remote DTD. This enables XML documents to be processed even when the
- * public DTD isn't available.
- *
- * @param publicID The DTD's public identifier.
- * @param location The location of the local DTD copy -- the location
- * may either be a resource found on the classpath or a
- * local file.
- */
- public void registerDTD(String publicID, String location) {
- log("Registering: " + location);
- if ((publicID == null) || (location == null)) {
- return;
- }
-
- if (ClassLoader.getSystemResource(location) != null) {
- log("Found resource: " + location);
- resourceDtds.put(publicID, location);
- } else {
- File dtdFile = new File(location);
- if (dtdFile.exists() && dtdFile.isFile()) {
- log("Found file: " + location);
- fileDtds.put(publicID, location);
- }
- }
- }
-
- /**
- * Resolves an external entity found during XML processing. If a public
- * ID is found that has been registered with the handler, an
- * InputSource
will be returned which refers to the local copy.
- * If the public ID hasn't been registered or if an error occurs, the
- * superclass implementation is used.
- *
- * @param publicId The DTD's public identifier.
- * @param systemId The location of the DTD, as found in the XML document.
- */
- public InputSource resolveEntity(String publicId, String systemId)
- throws SAXException {
- InputStream inputStream = null;
-
-
- try {
-
- /* Search the resource Map and (if not found) file Map */
-
- String location = (String)resourceDtds.get(publicId);
- if (location != null) {
- inputStream
- = ClassLoader.getSystemResource(location).openStream();
- } else {
- location = (String)fileDtds.get(publicId);
- if (location != null) {
- inputStream = new FileInputStream(location);
- }
- }
- } catch (IOException e) {
- return super.resolveEntity(publicId, systemId);
- }
-
- if (inputStream == null) {
- return super.resolveEntity(publicId, systemId);
- } else {
- return new InputSource(inputStream);
- }
- }
-
- /**
- * Receive notification that the start of an XML element has been found.
- *
- * @param name String name of the element found.
- * @param atts AttributeList of the attributes included with the element
- * (if any).
- * @throws SAXException If the parser cannot process the document.
- */
- public void startElement(String name, AttributeList atts)
+ private String currentLoc = ""; // Tracks current element
+ private String currentText; // Tracks current text data
+ private String ejbType; // "session" or "entity"
+
+ /**
+ * Constructs a new instance of the handler and registers local copies
+ * of the standard EJB 1.1 descriptor DTD as well as iAS's EJB
+ * descriptor DTD.
+ */
+ public EjbcHandler() {
+ final String PUBLICID_EJB11 =
+ "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN";
+ final String PUBLICID_IPLANET_EJB_60 =
+ "-//Sun Microsystems, Inc.//DTD iAS Enterprise JavaBeans 1.0//EN";
+
+
+ final String DEFAULT_IAS60_EJB11_DTD_LOCATION =
+ "ejb-jar_1_1.dtd";
+ final String DEFAULT_IAS60_DTD_LOCATION =
+ "IASEjb_jar_1_0.dtd";
+
+ registerDTD(PUBLICID_EJB11, DEFAULT_IAS60_EJB11_DTD_LOCATION);
+ registerDTD(PUBLICID_IPLANET_EJB_60, DEFAULT_IAS60_DTD_LOCATION);
+ }
+
+ /**
+ * Returns the list of EJB objects found during the processing of the
+ * standard EJB 1.1 descriptor and iAS-specific EJB descriptor.
+ *
+ * @return An array of EJBs which were found during the descriptor
+ * parsing.
+ */
+ public EjbInfo[] getEjbs() {
+ return (EjbInfo[])ejbs.values().toArray(new EjbInfo[ejbs.size()]);
+ }
+
+ /**
+ * Returns the value of the display-name element found in the standard
+ * EJB 1.1 descriptor.
+ *
+ * @return String display-name value.
+ */
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ /**
+ * Registers a local DTD that will be used when parsing an EJB
+ * descriptor. When the DTD's public identifier is found in an XML
+ * document, the parser will reference the local DTD rather than the
+ * remote DTD. This enables XML documents to be processed even when the
+ * public DTD isn't available.
+ *
+ * @param publicID The DTD's public identifier.
+ * @param location The location of the local DTD copy -- the location
+ * may either be a resource found on the classpath or a
+ * local file.
+ */
+ public void registerDTD(String publicID, String location) {
+ log("Registering: " + location);
+ if ((publicID == null) || (location == null)) {
+ return;
+ }
+
+ if (ClassLoader.getSystemResource(location) != null) {
+ log("Found resource: " + location);
+ resourceDtds.put(publicID, location);
+ } else {
+ File dtdFile = new File(location);
+ if (dtdFile.exists() && dtdFile.isFile()) {
+ log("Found file: " + location);
+ fileDtds.put(publicID, location);
+ }
+ }
+ }
+
+ /**
+ * Resolves an external entity found during XML processing. If a public
+ * ID is found that has been registered with the handler, an
+ * InputSource
will be returned which refers to the local copy.
+ * If the public ID hasn't been registered or if an error occurs, the
+ * superclass implementation is used.
+ *
+ * @param publicId The DTD's public identifier.
+ * @param systemId The location of the DTD, as found in the XML document.
+ */
+ public InputSource resolveEntity(String publicId, String systemId)
+ throws SAXException {
+ InputStream inputStream = null;
+
+
+ try {
+
+ /* Search the resource Map and (if not found) file Map */
+
+ String location = (String)resourceDtds.get(publicId);
+ if (location != null) {
+ inputStream
+ = ClassLoader.getSystemResource(location).openStream();
+ } else {
+ location = (String)fileDtds.get(publicId);
+ if (location != null) {
+ inputStream = new FileInputStream(location);
+ }
+ }
+ } catch (IOException e) {
+ return super.resolveEntity(publicId, systemId);
+ }
+
+ if (inputStream == null) {
+ return super.resolveEntity(publicId, systemId);
+ } else {
+ return new InputSource(inputStream);
+ }
+ }
+
+ /**
+ * Receive notification that the start of an XML element has been found.
+ *
+ * @param name String name of the element found.
+ * @param atts AttributeList of the attributes included with the element
+ * (if any).
+ * @throws SAXException If the parser cannot process the document.
+ */
+ public void startElement(String name, AttributeList atts)
throws SAXException {
- /*
- * I need to "push" the element onto the String (currentLoc) which
- * always represents the current location in the XML document.
- */
- currentLoc += "\\" + name;
+ /*
+ * I need to "push" the element onto the String (currentLoc) which
+ * always represents the current location in the XML document.
+ */
+ currentLoc += "\\" + name;
- /* A new element has started, so reset the text being captured */
- currentText = "";
+ /* A new element has started, so reset the text being captured */
+ currentText = "";
if (currentLoc.equals("\\ejb-jar")) {
iasDescriptor = false;
@@ -801,47 +801,47 @@ public class IPlanetEjbc {
if ((name.equals("session")) || (name.equals("entity"))) {
ejbType = name;
}
- }
-
- /**
- * Receive notification that character data has been found in the XML
- * document
- *
- * @param ch Array of characters which have been found in the document.
- * @param start Starting index of the data found in the document.
- * @param len The number of characters found in the document.
- * @throws SAXException If the parser cannot process the document.
- */
- public void characters(char[] ch, int start, int len)
- throws SAXException {
+ }
+
+ /**
+ * Receive notification that character data has been found in the XML
+ * document
+ *
+ * @param ch Array of characters which have been found in the document.
+ * @param start Starting index of the data found in the document.
+ * @param len The number of characters found in the document.
+ * @throws SAXException If the parser cannot process the document.
+ */
+ public void characters(char[] ch, int start, int len)
+ throws SAXException {
currentText += new String(ch).substring(start, start + len);
}
- /**
- * Receive notification that the end of an XML element has been found.
- *
- * @param name String name of the element.
- * @throws SAXException If the parser cannot process the document.
- */
+ /**
+ * Receive notification that the end of an XML element has been found.
+ *
+ * @param name String name of the element.
+ * @throws SAXException If the parser cannot process the document.
+ */
public void endElement(String name) throws SAXException {
-
- /*
- * If this is a standard EJB 1.1 descriptor, we are looking for one
- * set of data, while if this is an iAS-specific descriptor, we're
- * looking for different set of data. Hand the processing off to
- * the appropriate method.
- */
+
+ /*
+ * If this is a standard EJB 1.1 descriptor, we are looking for one
+ * set of data, while if this is an iAS-specific descriptor, we're
+ * looking for different set of data. Hand the processing off to
+ * the appropriate method.
+ */
if (iasDescriptor) {
iasCharacters(currentText);
} else {
stdCharacters(currentText);
}
- /*
- * I need to "pop" the element off the String (currentLoc) which
- * always represents my current location in the XML document.
- */
+ /*
+ * I need to "pop" the element off the String (currentLoc) which
+ * always represents my current location in the XML document.
+ */
int nameLength = name.length() + 1; // Add one for the "\"
int locLength = currentLoc.length();
@@ -849,20 +849,20 @@ public class IPlanetEjbc {
currentLoc = currentLoc.substring(0, locLength - nameLength);
}
- /**
- * Receive notification that character data has been found in a standard
- * EJB 1.1 descriptor. We're interested in retrieving the home
- * interface, remote interface, implementation class, the type of bean,
- * and if the bean uses CMP.
- *
- * @param value String data found in the XML document.
- */
+ /**
+ * Receive notification that character data has been found in a standard
+ * EJB 1.1 descriptor. We're interested in retrieving the home
+ * interface, remote interface, implementation class, the type of bean,
+ * and if the bean uses CMP.
+ *
+ * @param value String data found in the XML document.
+ */
private void stdCharacters(String value) {
- if (currentLoc.equals("\\ejb-jar\\display-name")) {
- displayName = value;
- return;
- }
+ if (currentLoc.equals("\\ejb-jar\\display-name")) {
+ displayName = value;
+ return;
+ }
String base = "\\ejb-jar\\enterprise-beans\\" + ejbType;
@@ -885,16 +885,16 @@ public class IPlanetEjbc {
}
}
- /**
- * Receive notification that character data has been found in an
- * iAS-specific descriptor. We're interested in retrieving data
- * indicating whether the bean must support RMI/IIOP access, whether
- * the bean must provide highly available stubs and skeletons (in the
- * case of stateful session beans), and if this bean uses additional
- * CMP XML descriptors (in the case of entity beans with CMP).
- *
- * @param value String data found in the XML document.
- */
+ /**
+ * Receive notification that character data has been found in an
+ * iAS-specific descriptor. We're interested in retrieving data
+ * indicating whether the bean must support RMI/IIOP access, whether
+ * the bean must provide highly available stubs and skeletons (in the
+ * case of stateful session beans), and if this bean uses additional
+ * CMP XML descriptors (in the case of entity beans with CMP).
+ *
+ * @param value String data found in the XML document.
+ */
private void iasCharacters(String value) {
String base = "\\ias-ejb-jar\\enterprise-beans\\" + ejbType;
@@ -909,72 +909,72 @@ public class IPlanetEjbc {
} else if (currentLoc.equals(base + "\\failover-required")) {
currentEjb.setHasession(value);
} else if (currentLoc.equals(base + "\\persistence-manager"
- + "\\properties-file-location")) {
- currentEjb.addCmpDescriptor(value);
- }
+ + "\\properties-file-location")) {
+ currentEjb.addCmpDescriptor(value);
+ }
}
} // End of EjbcHandler inner class
- /**
- * This inner class represents an EJB that will be compiled using ejbc.
- *
- * @author Greg Nelson
- * greg@netscape.com
- */
+ /**
+ * This inner class represents an EJB that will be compiled using ejbc.
+ *
+ * @author Greg Nelson
+ * greg@netscape.com
+ */
private class EjbInfo {
- private String name; // EJB's display name
- private Classname home; // EJB's home interface name
- private Classname remote; // EJB's remote interface name
- private Classname implementation; // EJB's implementation class
+ private String name; // EJB's display name
+ private Classname home; // EJB's home interface name
+ private Classname remote; // EJB's remote interface name
+ private Classname implementation; // EJB's implementation class
private String beantype = "entity"; // or "stateful" or "stateless"
- private boolean cmp = false; // Does this EJB support CMP?
- private boolean iiop = false; // Does this EJB support IIOP?
- private boolean hasession = false; // Does this EJB require failover?
- private List cmpDescriptors = new ArrayList(); // CMP descriptor list
-
- /**
- * Construct a new EJBInfo object with the given name.
- *
- * @param name The display name for the EJB.
- */
- public EjbInfo(String name) {
+ private boolean cmp = false; // Does this EJB support CMP?
+ private boolean iiop = false; // Does this EJB support IIOP?
+ private boolean hasession = false; // Does this EJB require failover?
+ private List cmpDescriptors = new ArrayList(); // CMP descriptor list
+
+ /**
+ * Construct a new EJBInfo object with the given name.
+ *
+ * @param name The display name for the EJB.
+ */
+ public EjbInfo(String name) {
this.name = name;
}
- /**
- * Returns the display name of the EJB. If a display name has not been
- * set, it returns the EJB implementation classname (if the
- * implementation class is not set, it returns "[unnamed]").
- *
- * @return The display name for the EJB.
- */
+ /**
+ * Returns the display name of the EJB. If a display name has not been
+ * set, it returns the EJB implementation classname (if the
+ * implementation class is not set, it returns "[unnamed]").
+ *
+ * @return The display name for the EJB.
+ */
public String getName() {
- if (name == null) {
- if (implementation == null) {
- return "[unnamed]";
- } else {
- return implementation.getClassName();
- }
- }
+ if (name == null) {
+ if (implementation == null) {
+ return "[unnamed]";
+ } else {
+ return implementation.getClassName();
+ }
+ }
return name;
}
- /*
- * Below are getter's and setter's for each of the instance variables.
- * Note that (in addition to supporting setters with the same type as
- * the instance variable) a setter is provided with takes a String
- * argument -- this are provided so the XML document handler can set
- * the EJB values using the Strings it parses.
- */
+ /*
+ * Below are getter's and setter's for each of the instance variables.
+ * Note that (in addition to supporting setters with the same type as
+ * the instance variable) a setter is provided with takes a String
+ * argument -- this are provided so the XML document handler can set
+ * the EJB values using the Strings it parses.
+ */
public void setHome(String home) {
setHome(new Classname(home));
}
- public void setHome(Classname home) {
- this.home = home;
- }
+ public void setHome(Classname home) {
+ this.home = home;
+ }
public Classname getHome() {
return home;
@@ -984,9 +984,9 @@ public class IPlanetEjbc {
setRemote(new Classname(remote));
}
- public void setRemote(Classname remote) {
- this.remote = remote;
- }
+ public void setRemote(Classname remote) {
+ this.remote = remote;
+ }
public Classname getRemote() {
return remote;
@@ -996,9 +996,9 @@ public class IPlanetEjbc {
setImplementation(new Classname(implementation));
}
- public void setImplementation(Classname implementation) {
- this.implementation = implementation;
- }
+ public void setImplementation(Classname implementation) {
+ this.implementation = implementation;
+ }
public Classname getImplementation() {
return implementation;
@@ -1048,442 +1048,441 @@ public class IPlanetEjbc {
return hasession;
}
- public void addCmpDescriptor(String descriptor) {
- cmpDescriptors.add(descriptor);
- }
-
- public List getCmpDescriptors() {
- return cmpDescriptors;
- }
-
- /**
- * Verifies that the EJB is valid--if it is invalid, an exception is
- * thrown
- *
- *
- * @param buildDir The directory where the EJB remote interface, home
- * interface, and implementation class must be found.
- * @throws EjbcException If the EJB is invalid.
- */
- private void checkConfiguration(File buildDir) throws EjbcException {
-
- /* Check that the specified instance variables are valid */
- if (home == null) {
- throw new EjbcException("A home interface was not found "
- + "for the " + name + " EJB.");
- }
- if (remote == null) {
- throw new EjbcException("A remote interface was not found "
- + "for the " + name + " EJB.");
- }
- if (implementation == null) {
- throw new EjbcException("An EJB implementation class was not "
- + "found for the " + name + " EJB.");
- }
-
- if ((!beantype.equals(ENTITY_BEAN))
- && (!beantype.equals(STATELESS_SESSION))
- && (!beantype.equals(STATEFUL_SESSION))) {
- throw new EjbcException("The beantype found (" + beantype + ") "
- + "isn't valid in the " + name + " EJB.");
- }
-
- if (cmp && (!beantype.equals(ENTITY_BEAN))) {
- System.out.println("CMP stubs and skeletons may not be generated"
- + " for a Session Bean -- the \"cmp\" attribute will be"
- + " ignoredfor the " + name + " EJB.");
- }
-
- if (hasession && (!beantype.equals(STATEFUL_SESSION))) {
- System.out.println("Highly available stubs and skeletons may "
- + "only be generated for a Stateful Session Bean -- the "
- + "\"hasession\" attribute will be ignored for the "
- + name + " EJB.");
- }
-
- /* Check that the EJB "source" classes all exist */
- if (!remote.getClassFile(buildDir).exists()) {
- throw new EjbcException("The remote interface "
- + remote.getQualifiedClassName() + " could not be "
- + "found.");
- }
- if (!home.getClassFile(buildDir).exists()) {
- throw new EjbcException("The home interface "
- + home.getQualifiedClassName() + " could not be "
- + "found.");
- }
- if (!implementation.getClassFile(buildDir).exists()) {
- throw new EjbcException("The EJB implementation class "
- + implementation.getQualifiedClassName() + " could "
- + "not be found.");
- }
- }
-
- /**
- * Determines if the ejbc utility needs to be run or not. If the stubs
- * and skeletons can all be found in the destination directory AND all
- * of their timestamps are more recent than the EJB source classes
- * (home, remote, and implementation classes), the method returns
- * false
. Otherwise, the method returns true
.
- *
- * @param destDir The directory where the EJB source classes, stubs and
- * skeletons are located.
- * @return A boolean indicating whether or not the ejbc utility needs to
- * be run to bring the stubs and skeletons up to date.
- */
- public boolean mustBeRecompiled(File destDir) {
-
- long sourceModified = sourceClassesModified(destDir);
-
- long destModified = destClassesModified(destDir);
-
- return (destModified < sourceModified);
- }
-
- /**
- * Examines each of the EJB source classes (home, remote, and
- * implementation) and returns the modification timestamp for the
- * "oldest" class.
- *
- * @param classpath The classpath to be used to find the source EJB
- * classes. If null
, the system classpath
- * is used.
- * @return The modification timestamp for the "oldest" EJB source class.
- * @throws BuildException If one of the EJB source classes cannot be
- * found on the classpath.
- */
- private long sourceClassesModified(File buildDir) {
- long latestModified; // The timestamp of the "newest" class
- long modified; // Timestamp for a given class
- File remoteFile; // File for the remote interface class
- File homeFile; // File for the home interface class
- File implFile; // File for the EJB implementation class
-
- /* Check the timestamp on the remote interface */
- remoteFile = remote.getClassFile(buildDir);
- modified = remoteFile.lastModified();
- if (modified == -1) {
- System.out.println("The class "
- + remote.getQualifiedClassName() + " couldn't "
- + "be found on the classpath");
- return -1;
- }
- latestModified = modified;
-
- /* Check the timestamp on the home interface */
- homeFile = home.getClassFile(buildDir);
- modified = homeFile.lastModified();
- if (modified == -1) {
- System.out.println("The class "
- + home.getQualifiedClassName() + " couldn't be "
- + "found on the classpath");
- return -1;
- }
- latestModified = Math.max(latestModified, modified);
-
- /* Check the timestamp on the EJB implementation class.
- *
- * Note that if ONLY the implementation class has changed, it's not
- * necessary to rebuild the EJB stubs and skeletons. For this
- * reason, we ensure the file exists (using lastModified above), but
- * we DON'T compare it's timestamp with the timestamps of the home
- * and remote interfaces (because it's irrelevant in determining if
- * ejbc must be run)
- */
- implFile = implementation.getClassFile(buildDir);
- modified = implFile.lastModified();
- if (modified == -1) {
- System.out.println("The class "
- + implementation.getQualifiedClassName()
- + " couldn't be found on the classpath");
- return -1;
- }
-
- String pathToFile = remote.getQualifiedClassName();
- pathToFile = pathToFile.replace('.', File.separatorChar) + ".class";
- ejbFiles.put(pathToFile, remoteFile);
-
- pathToFile = home.getQualifiedClassName();
- pathToFile = pathToFile.replace('.', File.separatorChar) + ".class";
- ejbFiles.put(pathToFile, homeFile);
-
- pathToFile = implementation.getQualifiedClassName();
- pathToFile = pathToFile.replace('.', File.separatorChar) + ".class";
- ejbFiles.put(pathToFile, implFile);
-
- return latestModified;
- }
-
- /**
- * Examines each of the EJB stubs and skeletons in the destination
- * directory and returns the modification timestamp for the "oldest"
- * class. If one of the stubs or skeletons cannot be found, -1
- *
is returned.
- *
- * @param dest The directory in which the EJB stubs and skeletons are
- * stored.
- * @return The modification timestamp for the "oldest" EJB stub or
- * skeleton. If one of the classes cannot be found, -1
- *
is returned.
- * @throws BuildException If the canonical path of the destination
- * directory cannot be found.
- */
- private long destClassesModified(File destDir) {
- String[] classnames = classesToGenerate(); // List of all stubs & skels
- long destClassesModified = new Date().getTime(); // Earliest mod time
- boolean allClassesFound = true; // Has each been found?
-
- /*
- * Loop through each stub/skeleton class that must be generated, and
- * determine (if all exist) which file has the most recent timestamp
- */
- for (int i=0; i < classnames.length; i++) {
-
- String pathToClass =
- classnames[i].replace('.', File.separatorChar) + ".class";
- File classFile = new File(destDir, pathToClass);
-
- /*
- * Add each stub/skeleton class to the list of EJB files. Note
- * that each class is added even if it doesn't exist now.
- */
- ejbFiles.put(pathToClass, classFile);
-
- allClassesFound = allClassesFound && classFile.exists();
-
- if (allClassesFound) {
- long fileMod = classFile.lastModified();
-
- /* Keep track of the oldest modification timestamp */
- destClassesModified = Math.min(destClassesModified, fileMod);
- }
- }
-
- return (allClassesFound) ? destClassesModified : -1;
- }
-
- /**
- * Builds an array of class names which represent the stubs and
- * skeletons which need to be generated for a given EJB. The class
- * names are fully qualified. Nine classes are generated for all EJBs
- * while an additional six classes are generated for beans requiring
- * RMI/IIOP access.
- *
- * @return An array of Strings representing the fully-qualified class
- * names for the stubs and skeletons to be generated.
- */
- private String[] classesToGenerate() {
- String[] classnames = (iiop) ? new String[15] : new String[9];
-
- final String remotePkg = remote.getPackageName() + ".";
- final String remoteClass = remote.getClassName();
- final String homePkg = home.getPackageName() + ".";
- final String homeClass = home.getClassName();
- final String implPkg = implementation.getPackageName() + ".";
- final String implFullClass = implementation.getQualifiedWithUnderscores();
- int index = 0;
-
- String fullPath;
-
- classnames[index++] = implPkg + "ejb_fac_" + implFullClass;
- classnames[index++] = implPkg + "ejb_home_" + implFullClass;
- classnames[index++] = implPkg + "ejb_skel_" + implFullClass;
- classnames[index++] = remotePkg + "ejb_kcp_skel_" + remoteClass;
- classnames[index++] = homePkg + "ejb_kcp_skel_" + homeClass;
- classnames[index++] = remotePkg + "ejb_kcp_stub_" + remoteClass;
- classnames[index++] = homePkg + "ejb_kcp_stub_" + homeClass;
- classnames[index++] = remotePkg + "ejb_stub_" + remoteClass;
- classnames[index++] = homePkg + "ejb_stub_" + homeClass;
-
- if (!iiop) {
- return classnames;
- }
-
- classnames[index++] = remotePkg + "_" + remoteClass + "_Stub";
- classnames[index++] = homePkg + "_" + homeClass + "_Stub";
- classnames[index++] = remotePkg + "_ejb_RmiCorbaBridge_"
- + remoteClass + "_Tie";
- classnames[index++] = homePkg + "_ejb_RmiCorbaBridge_" + homeClass
- + "_Tie";
- classnames[index++] = remotePkg + "ejb_RmiCorbaBridge_"
- + remoteClass;
- classnames[index++] = homePkg + "ejb_RmiCorbaBridge_" + homeClass;
-
- return classnames;
- }
-
- /**
- * Convenience method which creates a String representation of all the
- * instance variables of an EjbInfo object.
- *
- * @return A String representing the EjbInfo instance.
- */
- public String toString() {
- String s = "EJB name: " + name
- + "\n\r home: " + home
- + "\n\r remote: " + remote
- + "\n\r impl: " + implementation
- + "\n\r beantype: " + beantype
- + "\n\r cmp: " + cmp
- + "\n\r iiop: " + iiop
- + "\n\r hasession: " + hasession;
-
- Iterator i = cmpDescriptors.iterator();
- while (i.hasNext()) {
- s += "\n\r CMP Descriptor: " + i.next();
- }
-
- return s;
- }
-
- } // End of EjbInfo inner class
-
- /**
- * Convenience class used to represent the fully qualified name of a Java
- * class. It provides an easy way to retrieve components of the class name
- * in a format that is convenient for building iAS stubs and skeletons.
- *
- * @author Greg Nelson greg@netscape.com
- */
- private class Classname {
- private String qualifiedName; // Fully qualified name of the Java class
- private String packageName; // Name of the package for this class
- private String className; // Name of the class without the package
-
- /**
- * This constructor builds an object which represents the name of a Java
- * class.
- *
- * @param qualifiedName String representing the fully qualified class
- * name of the Java class.
- */
- public Classname(String qualifiedName) {
- if (qualifiedName == null) {
- return;
- }
-
- this.qualifiedName = qualifiedName;
-
- int index = qualifiedName.lastIndexOf('.');
- if (index == -1) {
- className = qualifiedName;
- packageName = "";
- } else {
- packageName = qualifiedName.substring(0, index);
- className = qualifiedName.substring(index + 1);
- }
- }
-
- /**
- * Gets the fully qualified name of the Java class.
- *
- * @return String representing the fully qualified class name.
- */
- public String getQualifiedClassName() {
- return qualifiedName;
- }
-
- /**
- * Gets the package name for the Java class.
- *
- * @return String representing the package name for the class.
- */
- public String getPackageName() {
- return packageName;
- }
-
- /**
- * Gets the Java class name without the package structure.
- *
- * @return String representing the name for the class.
- */
- public String getClassName() {
- return className;
- }
-
- /**
- * Gets the fully qualified name of the Java class with underscores
- * separating the components of the class name rather than periods.
- * This format is used in naming some of the stub and skeleton classes
- * for the iPlanet Application Server.
- *
- * @return String representing the fully qualified class name using
- * underscores instead of periods.
- */
- public String getQualifiedWithUnderscores() {
- return qualifiedName.replace('.', '_');
- }
-
- /**
- * Returns a File which references the class relative to the specified
- * directory. Note that the class file may or may not exist.
- *
- * @param directory A File referencing the base directory containing
- * class files.
- * @return File referencing this class.
- */
- public File getClassFile(File directory) {
- String pathToFile = qualifiedName.replace('.', File.separatorChar)
- + ".class";
- return new File(directory, pathToFile);
- }
-
- /**
- * String representation of this class name. It returns the fully
- * qualified class name.
- *
- * @return String representing the fully qualified class name.
- */
- public String toString() {
- return getQualifiedClassName();
- }
- } // End of Classname inner class
-
-
- /**
- * Thread class used to redirect output from an InputStream
to
- * the JRE standard output. This class may be used to redirect output from
- * an external process to the standard output.
- *
- * @author Greg Nelson greg@netscape.com
- */
- private class RedirectOutput extends Thread {
- InputStream stream; // Stream to read and redirect to standard output
-
- /**
- * Constructs a new instance that will redirect output from the
- * specified stream to the standard output.
- *
- * @param stream InputStream which will be read and redirected to the
- * standard output.
- */
- public RedirectOutput(InputStream stream) {
- this.stream = stream;
- }
-
- /**
- * Reads text from the input stream and redirects it to standard output
- * using a separate thread.
- */
- public void run() {
- BufferedReader reader = new BufferedReader(
- new InputStreamReader(stream));
- String text;
- try {
- while ((text = reader.readLine()) != null) {
- System.out.println(text);
- }
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- try {
- reader.close();
- } catch (IOException e) {
- // Do nothing
- }
- }
- }
- } // End of RedirectOutput inner class
-
-}
-
\ No newline at end of file
+ public void addCmpDescriptor(String descriptor) {
+ cmpDescriptors.add(descriptor);
+ }
+
+ public List getCmpDescriptors() {
+ return cmpDescriptors;
+ }
+
+ /**
+ * Verifies that the EJB is valid--if it is invalid, an exception is
+ * thrown
+ *
+ *
+ * @param buildDir The directory where the EJB remote interface, home
+ * interface, and implementation class must be found.
+ * @throws EjbcException If the EJB is invalid.
+ */
+ private void checkConfiguration(File buildDir) throws EjbcException {
+
+ /* Check that the specified instance variables are valid */
+ if (home == null) {
+ throw new EjbcException("A home interface was not found "
+ + "for the " + name + " EJB.");
+ }
+ if (remote == null) {
+ throw new EjbcException("A remote interface was not found "
+ + "for the " + name + " EJB.");
+ }
+ if (implementation == null) {
+ throw new EjbcException("An EJB implementation class was not "
+ + "found for the " + name + " EJB.");
+ }
+
+ if ((!beantype.equals(ENTITY_BEAN))
+ && (!beantype.equals(STATELESS_SESSION))
+ && (!beantype.equals(STATEFUL_SESSION))) {
+ throw new EjbcException("The beantype found (" + beantype + ") "
+ + "isn't valid in the " + name + " EJB.");
+ }
+
+ if (cmp && (!beantype.equals(ENTITY_BEAN))) {
+ System.out.println("CMP stubs and skeletons may not be generated"
+ + " for a Session Bean -- the \"cmp\" attribute will be"
+ + " ignoredfor the " + name + " EJB.");
+ }
+
+ if (hasession && (!beantype.equals(STATEFUL_SESSION))) {
+ System.out.println("Highly available stubs and skeletons may "
+ + "only be generated for a Stateful Session Bean -- the "
+ + "\"hasession\" attribute will be ignored for the "
+ + name + " EJB.");
+ }
+
+ /* Check that the EJB "source" classes all exist */
+ if (!remote.getClassFile(buildDir).exists()) {
+ throw new EjbcException("The remote interface "
+ + remote.getQualifiedClassName() + " could not be "
+ + "found.");
+ }
+ if (!home.getClassFile(buildDir).exists()) {
+ throw new EjbcException("The home interface "
+ + home.getQualifiedClassName() + " could not be "
+ + "found.");
+ }
+ if (!implementation.getClassFile(buildDir).exists()) {
+ throw new EjbcException("The EJB implementation class "
+ + implementation.getQualifiedClassName() + " could "
+ + "not be found.");
+ }
+ }
+
+ /**
+ * Determines if the ejbc utility needs to be run or not. If the stubs
+ * and skeletons can all be found in the destination directory AND all
+ * of their timestamps are more recent than the EJB source classes
+ * (home, remote, and implementation classes), the method returns
+ * false
. Otherwise, the method returns true
.
+ *
+ * @param destDir The directory where the EJB source classes, stubs and
+ * skeletons are located.
+ * @return A boolean indicating whether or not the ejbc utility needs to
+ * be run to bring the stubs and skeletons up to date.
+ */
+ public boolean mustBeRecompiled(File destDir) {
+
+ long sourceModified = sourceClassesModified(destDir);
+
+ long destModified = destClassesModified(destDir);
+
+ return (destModified < sourceModified);
+ }
+
+ /**
+ * Examines each of the EJB source classes (home, remote, and
+ * implementation) and returns the modification timestamp for the
+ * "oldest" class.
+ *
+ * @param classpath The classpath to be used to find the source EJB
+ * classes. If null
, the system classpath
+ * is used.
+ * @return The modification timestamp for the "oldest" EJB source class.
+ * @throws BuildException If one of the EJB source classes cannot be
+ * found on the classpath.
+ */
+ private long sourceClassesModified(File buildDir) {
+ long latestModified; // The timestamp of the "newest" class
+ long modified; // Timestamp for a given class
+ File remoteFile; // File for the remote interface class
+ File homeFile; // File for the home interface class
+ File implFile; // File for the EJB implementation class
+
+ /* Check the timestamp on the remote interface */
+ remoteFile = remote.getClassFile(buildDir);
+ modified = remoteFile.lastModified();
+ if (modified == -1) {
+ System.out.println("The class "
+ + remote.getQualifiedClassName() + " couldn't "
+ + "be found on the classpath");
+ return -1;
+ }
+ latestModified = modified;
+
+ /* Check the timestamp on the home interface */
+ homeFile = home.getClassFile(buildDir);
+ modified = homeFile.lastModified();
+ if (modified == -1) {
+ System.out.println("The class "
+ + home.getQualifiedClassName() + " couldn't be "
+ + "found on the classpath");
+ return -1;
+ }
+ latestModified = Math.max(latestModified, modified);
+
+ /* Check the timestamp on the EJB implementation class.
+ *
+ * Note that if ONLY the implementation class has changed, it's not
+ * necessary to rebuild the EJB stubs and skeletons. For this
+ * reason, we ensure the file exists (using lastModified above), but
+ * we DON'T compare it's timestamp with the timestamps of the home
+ * and remote interfaces (because it's irrelevant in determining if
+ * ejbc must be run)
+ */
+ implFile = implementation.getClassFile(buildDir);
+ modified = implFile.lastModified();
+ if (modified == -1) {
+ System.out.println("The class "
+ + implementation.getQualifiedClassName()
+ + " couldn't be found on the classpath");
+ return -1;
+ }
+
+ String pathToFile = remote.getQualifiedClassName();
+ pathToFile = pathToFile.replace('.', File.separatorChar) + ".class";
+ ejbFiles.put(pathToFile, remoteFile);
+
+ pathToFile = home.getQualifiedClassName();
+ pathToFile = pathToFile.replace('.', File.separatorChar) + ".class";
+ ejbFiles.put(pathToFile, homeFile);
+
+ pathToFile = implementation.getQualifiedClassName();
+ pathToFile = pathToFile.replace('.', File.separatorChar) + ".class";
+ ejbFiles.put(pathToFile, implFile);
+
+ return latestModified;
+ }
+
+ /**
+ * Examines each of the EJB stubs and skeletons in the destination
+ * directory and returns the modification timestamp for the "oldest"
+ * class. If one of the stubs or skeletons cannot be found, -1
+ *
is returned.
+ *
+ * @param dest The directory in which the EJB stubs and skeletons are
+ * stored.
+ * @return The modification timestamp for the "oldest" EJB stub or
+ * skeleton. If one of the classes cannot be found, -1
+ *
is returned.
+ * @throws BuildException If the canonical path of the destination
+ * directory cannot be found.
+ */
+ private long destClassesModified(File destDir) {
+ String[] classnames = classesToGenerate(); // List of all stubs & skels
+ long destClassesModified = new Date().getTime(); // Earliest mod time
+ boolean allClassesFound = true; // Has each been found?
+
+ /*
+ * Loop through each stub/skeleton class that must be generated, and
+ * determine (if all exist) which file has the most recent timestamp
+ */
+ for (int i=0; i < classnames.length; i++) {
+
+ String pathToClass =
+ classnames[i].replace('.', File.separatorChar) + ".class";
+ File classFile = new File(destDir, pathToClass);
+
+ /*
+ * Add each stub/skeleton class to the list of EJB files. Note
+ * that each class is added even if it doesn't exist now.
+ */
+ ejbFiles.put(pathToClass, classFile);
+
+ allClassesFound = allClassesFound && classFile.exists();
+
+ if (allClassesFound) {
+ long fileMod = classFile.lastModified();
+
+ /* Keep track of the oldest modification timestamp */
+ destClassesModified = Math.min(destClassesModified, fileMod);
+ }
+ }
+
+ return (allClassesFound) ? destClassesModified : -1;
+ }
+
+ /**
+ * Builds an array of class names which represent the stubs and
+ * skeletons which need to be generated for a given EJB. The class
+ * names are fully qualified. Nine classes are generated for all EJBs
+ * while an additional six classes are generated for beans requiring
+ * RMI/IIOP access.
+ *
+ * @return An array of Strings representing the fully-qualified class
+ * names for the stubs and skeletons to be generated.
+ */
+ private String[] classesToGenerate() {
+ String[] classnames = (iiop) ? new String[15] : new String[9];
+
+ final String remotePkg = remote.getPackageName() + ".";
+ final String remoteClass = remote.getClassName();
+ final String homePkg = home.getPackageName() + ".";
+ final String homeClass = home.getClassName();
+ final String implPkg = implementation.getPackageName() + ".";
+ final String implFullClass = implementation.getQualifiedWithUnderscores();
+ int index = 0;
+
+ String fullPath;
+
+ classnames[index++] = implPkg + "ejb_fac_" + implFullClass;
+ classnames[index++] = implPkg + "ejb_home_" + implFullClass;
+ classnames[index++] = implPkg + "ejb_skel_" + implFullClass;
+ classnames[index++] = remotePkg + "ejb_kcp_skel_" + remoteClass;
+ classnames[index++] = homePkg + "ejb_kcp_skel_" + homeClass;
+ classnames[index++] = remotePkg + "ejb_kcp_stub_" + remoteClass;
+ classnames[index++] = homePkg + "ejb_kcp_stub_" + homeClass;
+ classnames[index++] = remotePkg + "ejb_stub_" + remoteClass;
+ classnames[index++] = homePkg + "ejb_stub_" + homeClass;
+
+ if (!iiop) {
+ return classnames;
+ }
+
+ classnames[index++] = remotePkg + "_" + remoteClass + "_Stub";
+ classnames[index++] = homePkg + "_" + homeClass + "_Stub";
+ classnames[index++] = remotePkg + "_ejb_RmiCorbaBridge_"
+ + remoteClass + "_Tie";
+ classnames[index++] = homePkg + "_ejb_RmiCorbaBridge_" + homeClass
+ + "_Tie";
+ classnames[index++] = remotePkg + "ejb_RmiCorbaBridge_"
+ + remoteClass;
+ classnames[index++] = homePkg + "ejb_RmiCorbaBridge_" + homeClass;
+
+ return classnames;
+ }
+
+ /**
+ * Convenience method which creates a String representation of all the
+ * instance variables of an EjbInfo object.
+ *
+ * @return A String representing the EjbInfo instance.
+ */
+ public String toString() {
+ String s = "EJB name: " + name
+ + "\n\r home: " + home
+ + "\n\r remote: " + remote
+ + "\n\r impl: " + implementation
+ + "\n\r beantype: " + beantype
+ + "\n\r cmp: " + cmp
+ + "\n\r iiop: " + iiop
+ + "\n\r hasession: " + hasession;
+
+ Iterator i = cmpDescriptors.iterator();
+ while (i.hasNext()) {
+ s += "\n\r CMP Descriptor: " + i.next();
+ }
+
+ return s;
+ }
+
+ } // End of EjbInfo inner class
+
+ /**
+ * Convenience class used to represent the fully qualified name of a Java
+ * class. It provides an easy way to retrieve components of the class name
+ * in a format that is convenient for building iAS stubs and skeletons.
+ *
+ * @author Greg Nelson greg@netscape.com
+ */
+ private class Classname {
+ private String qualifiedName; // Fully qualified name of the Java class
+ private String packageName; // Name of the package for this class
+ private String className; // Name of the class without the package
+
+ /**
+ * This constructor builds an object which represents the name of a Java
+ * class.
+ *
+ * @param qualifiedName String representing the fully qualified class
+ * name of the Java class.
+ */
+ public Classname(String qualifiedName) {
+ if (qualifiedName == null) {
+ return;
+ }
+
+ this.qualifiedName = qualifiedName;
+
+ int index = qualifiedName.lastIndexOf('.');
+ if (index == -1) {
+ className = qualifiedName;
+ packageName = "";
+ } else {
+ packageName = qualifiedName.substring(0, index);
+ className = qualifiedName.substring(index + 1);
+ }
+ }
+
+ /**
+ * Gets the fully qualified name of the Java class.
+ *
+ * @return String representing the fully qualified class name.
+ */
+ public String getQualifiedClassName() {
+ return qualifiedName;
+ }
+
+ /**
+ * Gets the package name for the Java class.
+ *
+ * @return String representing the package name for the class.
+ */
+ public String getPackageName() {
+ return packageName;
+ }
+
+ /**
+ * Gets the Java class name without the package structure.
+ *
+ * @return String representing the name for the class.
+ */
+ public String getClassName() {
+ return className;
+ }
+
+ /**
+ * Gets the fully qualified name of the Java class with underscores
+ * separating the components of the class name rather than periods.
+ * This format is used in naming some of the stub and skeleton classes
+ * for the iPlanet Application Server.
+ *
+ * @return String representing the fully qualified class name using
+ * underscores instead of periods.
+ */
+ public String getQualifiedWithUnderscores() {
+ return qualifiedName.replace('.', '_');
+ }
+
+ /**
+ * Returns a File which references the class relative to the specified
+ * directory. Note that the class file may or may not exist.
+ *
+ * @param directory A File referencing the base directory containing
+ * class files.
+ * @return File referencing this class.
+ */
+ public File getClassFile(File directory) {
+ String pathToFile = qualifiedName.replace('.', File.separatorChar)
+ + ".class";
+ return new File(directory, pathToFile);
+ }
+
+ /**
+ * String representation of this class name. It returns the fully
+ * qualified class name.
+ *
+ * @return String representing the fully qualified class name.
+ */
+ public String toString() {
+ return getQualifiedClassName();
+ }
+ } // End of Classname inner class
+
+
+ /**
+ * Thread class used to redirect output from an InputStream
to
+ * the JRE standard output. This class may be used to redirect output from
+ * an external process to the standard output.
+ *
+ * @author Greg Nelson greg@netscape.com
+ */
+ private class RedirectOutput extends Thread {
+ InputStream stream; // Stream to read and redirect to standard output
+
+ /**
+ * Constructs a new instance that will redirect output from the
+ * specified stream to the standard output.
+ *
+ * @param stream InputStream which will be read and redirected to the
+ * standard output.
+ */
+ public RedirectOutput(InputStream stream) {
+ this.stream = stream;
+ }
+
+ /**
+ * Reads text from the input stream and redirects it to standard output
+ * using a separate thread.
+ */
+ public void run() {
+ BufferedReader reader = new BufferedReader(
+ new InputStreamReader(stream));
+ String text;
+ try {
+ while ((text = reader.readLine()) != null) {
+ System.out.println(text);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ // Do nothing
+ }
+ }
+ }
+ } // End of RedirectOutput inner class
+
+}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java
index 494abcb44..33180a7e6 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/IPlanetEjbcTask.java
@@ -67,34 +67,34 @@ import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.BuildException;
/**
- * Task to compile EJB stubs and skeletons for the iPlanet Application Server.
+ * Task to compile EJB stubs and skeletons for the iPlanet Application Server.
* The EJBs to be processed are specified by the EJB 1.1 standard XML
- * descriptor, and additional attributes are obtained from the iPlanet Application
- * Server-specific XML descriptor. Since the XML descriptors can include
- * multiple EJBs, this is a convenient way of specifying many EJBs in a single
+ * descriptor, and additional attributes are obtained from the iPlanet Application
+ * Server-specific XML descriptor. Since the XML descriptors can include
+ * multiple EJBs, this is a convenient way of specifying many EJBs in a single
* Ant task. The following attributes are allowed:
*
*
* [install-location]/iplanet/ias6/ias
- *
directory). If omitted, the ejbc utility
+ * directory). If omitted, the ejbc utility
* must be on the user's system path.
* dest
- * directory, the task will fail. The task will also attempt to locate the EJB
- * stubs and skeletons in this directory. If found, the timestamps on the
+ * directory, the task will fail. The task will also attempt to locate the EJB
+ * stubs and skeletons in this directory. If found, the timestamps on the
* stubs and skeletons will be checked to ensure they are up to date. Only if
* these files cannot be found or if they are out of date will ejbc be called
* to generate new stubs and skeletons.
@@ -123,42 +123,42 @@ import org.apache.tools.ant.BuildException;
*/
public class IPlanetEjbcTask extends Task {
- /* Attributes set by the Ant build file */
- private File ejbdescriptor;
- private File iasdescriptor;
- private File dest;
- private Path classpath;
- private boolean keepgenerated = false;
- private boolean debug = false;
- private File iashome;
+ /* Attributes set by the Ant build file */
+ private File ejbdescriptor;
+ private File iasdescriptor;
+ private File dest;
+ private Path classpath;
+ private boolean keepgenerated = false;
+ private boolean debug = false;
+ private File iashome;
/**
* Sets the location of the standard XML EJB descriptor. Typically, this
- * file is named "ejb-jar.xml".
- *
- * @param ejbdescriptor The name and location of the EJB descriptor.
+ * file is named "ejb-jar.xml".
+ *
+ * @param ejbdescriptor The name and location of the EJB descriptor.
*/
- public void setEjbdescriptor(File ejbdescriptor) {
- this.ejbdescriptor = ejbdescriptor;
- }
+ public void setEjbdescriptor(File ejbdescriptor) {
+ this.ejbdescriptor = ejbdescriptor;
+ }
/**
- * Sets the location of the iAS-specific XML EJB descriptor. Typically,
- * this file is named "ias-ejb-jar.xml".
- *
- * @param iasdescriptor The name and location of the iAS-specific EJB
- * descriptor.
+ * Sets the location of the iAS-specific XML EJB descriptor. Typically,
+ * this file is named "ias-ejb-jar.xml".
+ *
+ * @param iasdescriptor The name and location of the iAS-specific EJB
+ * descriptor.
*/
- public void setIasdescriptor (File iasdescriptor) {
- this.iasdescriptor = iasdescriptor;
- }
+ public void setIasdescriptor (File iasdescriptor) {
+ this.iasdescriptor = iasdescriptor;
+ }
/**
* Sets the destination directory where the EJB "source" classes must exist
- * and where the stubs and skeletons will be written. The destination
- * directory must exist before this task is executed.
- *
- * @param dest The directory where the compiled classes will be written.
+ * and where the stubs and skeletons will be written. The destination
+ * directory must exist before this task is executed.
+ *
+ * @param dest The directory where the compiled classes will be written.
*/
public void setDest(File dest) {
this.dest = dest;
@@ -166,8 +166,8 @@ public class IPlanetEjbcTask extends Task {
/**
* Sets the classpath to be used when compiling the EJB stubs and skeletons.
- *
- * @param classpath The classpath to be used.
+ *
+ * @param classpath The classpath to be used.
*/
public void setClasspath(Path classpath) {
if (this.classpath == null) {
@@ -188,107 +188,107 @@ public class IPlanetEjbcTask extends Task {
}
/**
- * Sets whether or not the Java source files which are generated by the
- * ejbc process should be retained or automatically deleted.
- *
- * @param keepgenerated A boolean indicating if the Java source files for
- * the stubs and skeletons should be retained.
+ * Sets whether or not the Java source files which are generated by the
+ * ejbc process should be retained or automatically deleted.
+ *
+ * @param keepgenerated A boolean indicating if the Java source files for
+ * the stubs and skeletons should be retained.
*/
- public void setKeepgenerated(boolean keepgenerated) {
- this.keepgenerated = keepgenerated;
- }
+ public void setKeepgenerated(boolean keepgenerated) {
+ this.keepgenerated = keepgenerated;
+ }
/**
* Sets whether or not debugging output will be generated when ejbc is
- * executed.
- *
- * @param debug A boolean indicating if debugging output should be generated
+ * executed.
+ *
+ * @param debug A boolean indicating if debugging output should be generated
*/
- public void setDebug(boolean debug) {
- this.debug = debug;
- }
-
+ public void setDebug(boolean debug) {
+ this.debug = debug;
+ }
+
/**
* Setter method used to store the "home" directory of the user's iAS
- * installation. The directory specified should typically be
- * [install-location]/iplanet/ias6/ias
.
- *
+ * installation. The directory specified should typically be
+ * [install-location]/iplanet/ias6/ias
.
+ *
* @param iashome The home directory for the user's iAS installation.
*/
- public void setIashome(File iashome) {
- this.iashome = iashome;
- }
+ public void setIashome(File iashome) {
+ this.iashome = iashome;
+ }
/**
* Does the work.
*/
public void execute() throws BuildException {
- checkConfiguration();
+ checkConfiguration();
+
+ executeEjbc(getParser());
+ }
- executeEjbc(getParser());
- }
-
/**
* Verifies that the user selections are valid.
- *
- * @throws BuildException If the user selections are invalid.
+ *
+ * @throws BuildException If the user selections are invalid.
*/
- private void checkConfiguration() throws BuildException {
+ private void checkConfiguration() throws BuildException {
- if (ejbdescriptor == null) {
- String msg = "The standard EJB descriptor must be specified using "
- + "the \"ejbdescriptor\" attribute.";
- throw new BuildException(msg, location);
- }
- if ((!ejbdescriptor.exists()) || (!ejbdescriptor.isFile())) {
- String msg = "The standard EJB descriptor (" + ejbdescriptor
- + ") was not found or isn't a file.";
- throw new BuildException(msg, location);
- }
+ if (ejbdescriptor == null) {
+ String msg = "The standard EJB descriptor must be specified using "
+ + "the \"ejbdescriptor\" attribute.";
+ throw new BuildException(msg, location);
+ }
+ if ((!ejbdescriptor.exists()) || (!ejbdescriptor.isFile())) {
+ String msg = "The standard EJB descriptor (" + ejbdescriptor
+ + ") was not found or isn't a file.";
+ throw new BuildException(msg, location);
+ }
- if (iasdescriptor == null) {
- String msg = "The iAS-speific XML descriptor must be specified using"
- + " the \"iasdescriptor\" attribute.";
- throw new BuildException(msg, location);
- }
- if ((!iasdescriptor.exists()) || (!iasdescriptor.isFile())) {
- String msg = "The iAS-specific XML descriptor (" + iasdescriptor
- + ") was not found or isn't a file.";
- throw new BuildException(msg, location);
- }
+ if (iasdescriptor == null) {
+ String msg = "The iAS-speific XML descriptor must be specified using"
+ + " the \"iasdescriptor\" attribute.";
+ throw new BuildException(msg, location);
+ }
+ if ((!iasdescriptor.exists()) || (!iasdescriptor.isFile())) {
+ String msg = "The iAS-specific XML descriptor (" + iasdescriptor
+ + ") was not found or isn't a file.";
+ throw new BuildException(msg, location);
+ }
- if (dest == null) {
- String msg = "The destination directory must be specified using "
- + "the \"dest\" attribute.";
- throw new BuildException(msg, location);
- }
- if ((!dest.exists()) || (!dest.isDirectory())) {
- String msg = "The destination directory (" + dest + ") was not "
- + "found or isn't a directory.";
- throw new BuildException(msg, location);
- }
+ if (dest == null) {
+ String msg = "The destination directory must be specified using "
+ + "the \"dest\" attribute.";
+ throw new BuildException(msg, location);
+ }
+ if ((!dest.exists()) || (!dest.isDirectory())) {
+ String msg = "The destination directory (" + dest + ") was not "
+ + "found or isn't a directory.";
+ throw new BuildException(msg, location);
+ }
- if ((iashome != null) && (!iashome.isDirectory())) {
- String msg = "If \"iashome\" is specified, it must be a valid "
- + "directory (it was set to " + iashome + ").";
- throw new BuildException(msg, getLocation());
- }
- }
+ if ((iashome != null) && (!iashome.isDirectory())) {
+ String msg = "If \"iashome\" is specified, it must be a valid "
+ + "directory (it was set to " + iashome + ").";
+ throw new BuildException(msg, getLocation());
+ }
+ }
/**
* Returns a SAXParser that may be used to process the XML descriptors.
- *
- * @return Parser which may be used to process the EJB descriptors.
- * @throws BuildException If the parser cannot be created or configured.
+ *
+ * @return Parser which may be used to process the EJB descriptors.
+ * @throws BuildException If the parser cannot be created or configured.
*/
- private SAXParser getParser() throws BuildException {
+ private SAXParser getParser() throws BuildException {
- SAXParser saxParser = null;
- try {
+ SAXParser saxParser = null;
+ try {
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
saxParserFactory.setValidating(true);
saxParser = saxParserFactory.newSAXParser();
- } catch (SAXException e) {
+ } catch (SAXException e) {
String msg = "Unable to create a SAXParser: " + e.getMessage();
throw new BuildException(msg, e, location);
}
@@ -297,57 +297,57 @@ public class IPlanetEjbcTask extends Task {
throw new BuildException(msg, e, location);
}
- return saxParser;
- }
+ return saxParser;
+ }
/**
* Executes the EJBc utility using the SAXParser provided.
- *
- * @param saxParser SAXParser that may be used to process the EJB
- * descriptors
- * @throws BuildException If there is an error reading or parsing the XML
- * descriptors
+ *
+ * @param saxParser SAXParser that may be used to process the EJB
+ * descriptors
+ * @throws BuildException If there is an error reading or parsing the XML
+ * descriptors
*/
- private void executeEjbc(SAXParser saxParser) throws BuildException {
- IPlanetEjbc ejbc = new IPlanetEjbc(ejbdescriptor,
- iasdescriptor,
- dest,
- getClasspath().toString(),
- saxParser);
- ejbc.setRetainSource(keepgenerated);
- ejbc.setDebugOutput(debug);
- if (iashome != null) {
- ejbc.setIasHomeDir(iashome);
- }
+ private void executeEjbc(SAXParser saxParser) throws BuildException {
+ IPlanetEjbc ejbc = new IPlanetEjbc(ejbdescriptor,
+ iasdescriptor,
+ dest,
+ getClasspath().toString(),
+ saxParser);
+ ejbc.setRetainSource(keepgenerated);
+ ejbc.setDebugOutput(debug);
+ if (iashome != null) {
+ ejbc.setIasHomeDir(iashome);
+ }
- try {
- ejbc.execute();
- } catch (IOException e) {
+ try {
+ ejbc.execute();
+ } catch (IOException e) {
String msg = "An IOException occurred while trying to read the XML "
- + "descriptor file: " + e.getMessage();
+ + "descriptor file: " + e.getMessage();
throw new BuildException(msg, e, location);
} catch (SAXException e) {
String msg = "A SAXException occurred while trying to read the XML "
- + "descriptor file: " + e.getMessage();
+ + "descriptor file: " + e.getMessage();
throw new BuildException(msg, e, location);
} catch (IPlanetEjbc.EjbcException e) {
String msg = "An exception occurred while trying to run the ejbc "
- + "utility: " + e.getMessage();
+ + "utility: " + e.getMessage();
throw new BuildException(msg, e, location);
}
- }
+ }
/**
* Returns the CLASSPATH to be used when calling EJBc. If no user CLASSPATH
- * is specified, the System classpath is returned instead.
- *
- * @return Path The classpath to be used for EJBc.
- */
- private Path getClasspath() {
- if (classpath == null) {
- classpath = Path.systemClasspath;
- }
+ * is specified, the System classpath is returned instead.
+ *
+ * @return Path The classpath to be used for EJBc.
+ */
+ private Path getClasspath() {
+ if (classpath == null) {
+ classpath = Path.systemClasspath;
+ }
- return classpath;
- }
+ return classpath;
+ }
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntTool.java
index 5c9ab7c8f..05e48e2e7 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntTool.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntTool.java
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * 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
@@ -17,15 +17,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
+ * 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
+ * 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"
@@ -73,20 +73,20 @@ import org.apache.tools.ant.BuildException;
public class VAJAntTool {
private final static String TOOL_DATA_KEY = "AntTool";
-
+
/**
* Loads the BuildInfo for the specified VAJ project from the
* tool data for this project.
* If there is no build info stored for that project, a new
* default BuildInfo is returned
- *
+ *
* @return BuildInfo buildInfo build info for the specified project
* @param projectName String project name
*/
public static VAJBuildInfo loadBuildData(String projectName) {
VAJBuildInfo result = null;
try {
- Project project =
+ Project project =
VAJLocalUtil.getWorkspace().loadedProjectNamed( projectName );
if ( project.testToolRepositoryData(TOOL_DATA_KEY) ) {
ToolData td = project.getToolRepositoryData(TOOL_DATA_KEY);
@@ -97,7 +97,7 @@ public class VAJAntTool {
}
result.setVAJProjectName( projectName );
} catch (Throwable t) {
- throw new BuildException("BuildInfo for Project "
+ throw new BuildException("BuildInfo for Project "
+ projectName + " could not be loaded" + t);
}
return result;
@@ -108,7 +108,7 @@ public class VAJAntTool {
* Starts the application.
*
* @param args an array of command-line arguments. VAJ puts the
- * VAJ project name into args[1] when starting the
+ * VAJ project name into args[1] when starting the
* tool from the project context menu
*/
public static void main(java.lang.String[] args) {
@@ -117,11 +117,11 @@ public class VAJAntTool {
if ( args.length >= 2 && args[1] instanceof String ) {
String projectName = (String)args[1];
info = loadBuildData( projectName );
- }
+ }
else {
info = new VAJBuildInfo();
}
-
+
VAJAntToolGUI mainFrame = new VAJAntToolGUI( info );
mainFrame.show();
} catch ( Throwable t ) {
@@ -141,10 +141,10 @@ public class VAJAntTool {
String data = info.asDataString();
try {
ToolData td = new ToolData( TOOL_DATA_KEY, data );
- VAJLocalUtil.getWorkspace().loadedProjectNamed(
+ VAJLocalUtil.getWorkspace().loadedProjectNamed(
info.getVAJProjectName() ).setToolRepositoryData( td );
} catch (Throwable t) {
- throw new BuildException("BuildInfo for Project "
+ throw new BuildException("BuildInfo for Project "
+ info.getVAJProjectName() + " could not be saved", t);
}
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntToolGUI.java b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntToolGUI.java
index 3260898a0..3537e58f0 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntToolGUI.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJAntToolGUI.java
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * 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
@@ -17,15 +17,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
+ * 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
+ * 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"
@@ -95,14 +95,14 @@ import org.apache.tools.ant.BuildEvent;
import org.apache.tools.ant.Project;
/**
- * This is a simple grafical user interface to provide the information needed
+ * This is a simple grafical user interface to provide the information needed
* by ANT and to start the build-process within IBM VisualAge for Java.
*
+ * Example:
+ *
* <vajexport destdir="C:/builddir/source">
* <include name="/MyVAProject/org/foo/subsystem1/**" />
* <exclude name="/MyVAProject/org/foo/subsystem1/test/**"/>
* </vajexport>
*
* exports all packages in the project MyVAProject which start with
- * 'org.foo.subsystem1' except of these starting with
+ * 'org.foo.subsystem1' except of these starting with
* 'org.foo.subsystem1.test'.
*
* There are flags to choose which items to export:
@@ -89,124 +89,124 @@ import org.apache.tools.ant.types.PatternSet;
*/
public class VAJExport extends VAJTask {
- //set set... method comments for description
- protected File destDir;
- protected boolean exportSources = true;
- protected boolean exportResources = true;
- protected boolean exportClasses = false;
- protected boolean exportDebugInfo = false;
- protected boolean useDefaultExcludes = true;
- protected boolean overwrite = true;
-
- protected PatternSet patternSet = new PatternSet();
-
- /**
- * add a name entry on the exclude list
- */
- public PatternSet.NameEntry createExclude() {
- return patternSet.createExclude();
- }
-
- /**
- * add a name entry on the include list
- */
- public PatternSet.NameEntry createInclude() {
- return patternSet.createInclude();
- }
-
- /**
- * do the export
- */
- public void execute() throws BuildException {
- // first off, make sure that we've got a destdir
- if (destDir == null) {
- throw new BuildException("destdir attribute must be set!");
- }
-
- // delegate the export to the VAJUtil object.
- getUtil().exportPackages(destDir,
- patternSet.getIncludePatterns(getProject()),
- patternSet.getExcludePatterns(getProject()),
- exportClasses, exportDebugInfo,
- exportResources, exportSources,
- useDefaultExcludes, overwrite);
- }
-
- /**
- * Sets whether default exclusions should be used or not.
- *
- * @param useDefaultExcludes "true"|"on"|"yes" when default exclusions
- * should be used, "false"|"off"|"no" when they
- * shouldn't be used.
- */
- public void setDefaultexcludes(boolean useDefaultExcludes) {
- this.useDefaultExcludes = useDefaultExcludes;
- }
-
- /**
- * Set the destination directory into which the selected
- * items should be exported
- */
- public void setDestdir(File destDir) {
- this.destDir = destDir;
- }
-
- /**
- * Sets the set of exclude patterns. Patterns may be separated by a comma
- * or a space. Currently only patterns denoting packages are
- * supported
- *
- * @param excludes the string containing the exclude patterns
- */
- public void setExcludes(String excludes) {
- patternSet.setExcludes(excludes);
- }
-
- /**
- * if exportClasses is set, class files are exported
- */
- public void setExportClasses(boolean doExport) {
- exportClasses = doExport;
- }
-
- /**
- * if exportDebugInfo is set, the exported class files contain
- * debug info
- */
- public void setExportDebugInfo(boolean doExport) {
- exportDebugInfo = doExport;
- }
-
- /**
- * if exportResources is set, resource file will be exported
- */
- public void setExportResources(boolean doExport) {
- exportResources = doExport;
- }
-
- /**
- * if exportSources is set, java files will be exported
- */
- public void setExportSources(boolean doExport) {
- exportSources = doExport;
- }
-
- /**
- * Sets the set of include patterns. Patterns may be separated by a comma
- * or a space.Currently only patterns denoting packages are
- * supported
- *
- * @param includes the string containing the include patterns
- */
- public void setIncludes(String includes) {
- patternSet.setIncludes(includes);
- }
-
- /**
- * if Overwrite is set, files will be overwritten during export
- */
- public void setOverwrite(boolean doOverwrite) {
- overwrite = doOverwrite;
- }
-
+ //set set... method comments for description
+ protected File destDir;
+ protected boolean exportSources = true;
+ protected boolean exportResources = true;
+ protected boolean exportClasses = false;
+ protected boolean exportDebugInfo = false;
+ protected boolean useDefaultExcludes = true;
+ protected boolean overwrite = true;
+
+ protected PatternSet patternSet = new PatternSet();
+
+ /**
+ * add a name entry on the exclude list
+ */
+ public PatternSet.NameEntry createExclude() {
+ return patternSet.createExclude();
+ }
+
+ /**
+ * add a name entry on the include list
+ */
+ public PatternSet.NameEntry createInclude() {
+ return patternSet.createInclude();
+ }
+
+ /**
+ * do the export
+ */
+ public void execute() throws BuildException {
+ // first off, make sure that we've got a destdir
+ if (destDir == null) {
+ throw new BuildException("destdir attribute must be set!");
+ }
+
+ // delegate the export to the VAJUtil object.
+ getUtil().exportPackages(destDir,
+ patternSet.getIncludePatterns(getProject()),
+ patternSet.getExcludePatterns(getProject()),
+ exportClasses, exportDebugInfo,
+ exportResources, exportSources,
+ useDefaultExcludes, overwrite);
+ }
+
+ /**
+ * Sets whether default exclusions should be used or not.
+ *
+ * @param useDefaultExcludes "true"|"on"|"yes" when default exclusions
+ * should be used, "false"|"off"|"no" when they
+ * shouldn't be used.
+ */
+ public void setDefaultexcludes(boolean useDefaultExcludes) {
+ this.useDefaultExcludes = useDefaultExcludes;
+ }
+
+ /**
+ * Set the destination directory into which the selected
+ * items should be exported
+ */
+ public void setDestdir(File destDir) {
+ this.destDir = destDir;
+ }
+
+ /**
+ * Sets the set of exclude patterns. Patterns may be separated by a comma
+ * or a space. Currently only patterns denoting packages are
+ * supported
+ *
+ * @param excludes the string containing the exclude patterns
+ */
+ public void setExcludes(String excludes) {
+ patternSet.setExcludes(excludes);
+ }
+
+ /**
+ * if exportClasses is set, class files are exported
+ */
+ public void setExportClasses(boolean doExport) {
+ exportClasses = doExport;
+ }
+
+ /**
+ * if exportDebugInfo is set, the exported class files contain
+ * debug info
+ */
+ public void setExportDebugInfo(boolean doExport) {
+ exportDebugInfo = doExport;
+ }
+
+ /**
+ * if exportResources is set, resource file will be exported
+ */
+ public void setExportResources(boolean doExport) {
+ exportResources = doExport;
+ }
+
+ /**
+ * if exportSources is set, java files will be exported
+ */
+ public void setExportSources(boolean doExport) {
+ exportSources = doExport;
+ }
+
+ /**
+ * Sets the set of include patterns. Patterns may be separated by a comma
+ * or a space.Currently only patterns denoting packages are
+ * supported
+ *
+ * @param includes the string containing the include patterns
+ */
+ public void setIncludes(String includes) {
+ patternSet.setIncludes(includes);
+ }
+
+ /**
+ * if Overwrite is set, files will be overwritten during export
+ */
+ public void setOverwrite(boolean doOverwrite) {
+ overwrite = doOverwrite;
+ }
+
}
\ No newline at end of file
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java
index 481bdaedf..fbf6da54b 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java
@@ -1,7 +1,7 @@
/*
* The Apache Software License, Version 1.1
*
- * Copyright (c) 1999 The Apache Software Foundation. All rights
+ * Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -9,7 +9,7 @@
* are met:
*
* 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
+ * 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
@@ -17,15 +17,15 @@
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
- * any, must include the following acknowlegement:
- * "This product includes software developed by the
+ * 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", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
- * from this software without prior written permission. For written
+ * 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"
@@ -64,11 +64,11 @@ import org.apache.tools.ant.types.FileSet;
import java.lang.reflect.Field;
/**
- * Import source, class files, and resources to the Visual Age for Java
+ * Import source, class files, and resources to the Visual Age for Java
* workspace using FileSets.
*
+ * Example:
+ *
* <vajimport project="MyVAProject">
* <fileset dir="src">
* <include name="org/foo/subsystem1/**" />
@@ -77,7 +77,7 @@ import java.lang.reflect.Field;
* </vajexport>
*
* import all source and resource files from the "src" directory
- * which start with 'org.foo.subsystem1', except of these starting with
+ * which start with 'org.foo.subsystem1', except of these starting with
* 'org.foo.subsystem1.test' into the project MyVAProject.
*
If MyVAProject isn't loaded into the Workspace, a new edition is @@ -117,116 +117,116 @@ import java.lang.reflect.Field; * @author: Glenn McAllister, inspired by a similar task written by Peter Kelley */ public class VAJImport extends VAJTask { - protected Vector filesets = new Vector(); - protected boolean importSources = true; - protected boolean importResources = true; - protected boolean importClasses = false; - protected String importProject = null; - protected boolean useDefaultExcludes = true; - - - /** - * The VisualAge for Java Project name to import into. - */ - public void setProject(String projectName) { - this.importProject = projectName; - } - - /** - * Adds a set of files (nested fileset attribute). - */ - public void addFileset(FileSet set) { - filesets.addElement(set); - } - - /** - * Import .class files. - */ - public void setImportClasses(boolean importClasses) { - this.importClasses = importClasses; - } - - /** - * Import resource files (anything that doesn't end in - * .class or .java) - */ - public void setImportResources(boolean importResources) { - this.importResources = importResources; - } - - /** - * Import .java files - */ - public void setImportSources(boolean importSources) { - this.importSources = importSources; - } - - /** - * Sets whether default exclusions should be used or not. - * - * @param useDefaultExcludes "true"|"on"|"yes" when default exclusions - * should be used, "false"|"off"|"no" when they - * shouldn't be used. - */ - public void setDefaultexcludes(boolean useDefaultExcludes) { - this.useDefaultExcludes = useDefaultExcludes; - } - - /** - * Do the import. - */ - public void execute() throws BuildException { - if (filesets.size() == 0) { - throw new BuildException("At least one fileset is required!"); - } - - if (importProject == null || "".equals(importProject)) { - throw new BuildException("The VisualAge for Java Project name is required!"); - } - - for (Enumeration e = filesets.elements(); e.hasMoreElements();) { - importFileset((FileSet) e.nextElement()); - } - } - - /** - * Import all files from the fileset into the Project in the - * Workspace. - */ - protected void importFileset(FileSet fileset) { - DirectoryScanner ds = fileset.getDirectoryScanner(this.project); - if (ds.getIncludedFiles().length == 0) { - return; - } - - String[] includes = null; - String[] excludes = null; - - // Hack to get includes and excludes. We could also use getIncludedFiles, - // but that would result in very long HTTP-requests. - // Therefore we want to send the patterns only to the remote tool server - // and let him figure out the files. - try { - Class directoryScanner = ds.getClass(); - - Field includesField = directoryScanner.getDeclaredField("includes"); - includesField.setAccessible(true); - includes = (String[]) includesField.get(ds); - - Field excludesField = directoryScanner.getDeclaredField("excludes"); - excludesField.setAccessible(true); - excludes = (String[]) excludesField.get(ds); - } catch (NoSuchFieldException nsfe) { - throw new BuildException( - "DirectoryScanner.includes or .excludes missing" + nsfe.getMessage()); - } catch (IllegalAccessException iae) { - throw new BuildException( - "Access to DirectoryScanner.includes or .excludes not allowed"); - } - - getUtil().importFiles( importProject, ds.getBasedir(), - includes, excludes, - importClasses, importResources, importSources, - useDefaultExcludes); - } + protected Vector filesets = new Vector(); + protected boolean importSources = true; + protected boolean importResources = true; + protected boolean importClasses = false; + protected String importProject = null; + protected boolean useDefaultExcludes = true; + + + /** + * The VisualAge for Java Project name to import into. + */ + public void setProject(String projectName) { + this.importProject = projectName; + } + + /** + * Adds a set of files (nested fileset attribute). + */ + public void addFileset(FileSet set) { + filesets.addElement(set); + } + + /** + * Import .class files. + */ + public void setImportClasses(boolean importClasses) { + this.importClasses = importClasses; + } + + /** + * Import resource files (anything that doesn't end in + * .class or .java) + */ + public void setImportResources(boolean importResources) { + this.importResources = importResources; + } + + /** + * Import .java files + */ + public void setImportSources(boolean importSources) { + this.importSources = importSources; + } + + /** + * Sets whether default exclusions should be used or not. + * + * @param useDefaultExcludes "true"|"on"|"yes" when default exclusions + * should be used, "false"|"off"|"no" when they + * shouldn't be used. + */ + public void setDefaultexcludes(boolean useDefaultExcludes) { + this.useDefaultExcludes = useDefaultExcludes; + } + + /** + * Do the import. + */ + public void execute() throws BuildException { + if (filesets.size() == 0) { + throw new BuildException("At least one fileset is required!"); + } + + if (importProject == null || "".equals(importProject)) { + throw new BuildException("The VisualAge for Java Project name is required!"); + } + + for (Enumeration e = filesets.elements(); e.hasMoreElements();) { + importFileset((FileSet) e.nextElement()); + } + } + + /** + * Import all files from the fileset into the Project in the + * Workspace. + */ + protected void importFileset(FileSet fileset) { + DirectoryScanner ds = fileset.getDirectoryScanner(this.project); + if (ds.getIncludedFiles().length == 0) { + return; + } + + String[] includes = null; + String[] excludes = null; + + // Hack to get includes and excludes. We could also use getIncludedFiles, + // but that would result in very long HTTP-requests. + // Therefore we want to send the patterns only to the remote tool server + // and let him figure out the files. + try { + Class directoryScanner = ds.getClass(); + + Field includesField = directoryScanner.getDeclaredField("includes"); + includesField.setAccessible(true); + includes = (String[]) includesField.get(ds); + + Field excludesField = directoryScanner.getDeclaredField("excludes"); + excludesField.setAccessible(true); + excludes = (String[]) excludesField.get(ds); + } catch (NoSuchFieldException nsfe) { + throw new BuildException( + "DirectoryScanner.includes or .excludes missing" + nsfe.getMessage()); + } catch (IllegalAccessException iae) { + throw new BuildException( + "Access to DirectoryScanner.includes or .excludes not allowed"); + } + + getUtil().importFiles( importProject, ds.getBasedir(), + includes, excludes, + importClasses, importResources, importSources, + useDefaultExcludes); + } } \ No newline at end of file diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImportServlet.java b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImportServlet.java index 2655ef352..5e6057237 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImportServlet.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImportServlet.java @@ -59,7 +59,7 @@ import java.io.File; /** * A Remote Access to Tools Servlet to import a Project - * from files into the Repository. The following + * from files into the Repository. The following * table describes the servlet parameters. * *