jlaskowski 2005/06/24 08:04:40
Modified: modules/core/src/java/org/openejb/alt/config Deploy.java
Log:
Fixes for:
o #OPENEJB-32: (Slightly) better command line options handling
o #OPENEJB-31:log4j:WARN No appenders could be found for logger (OpenEJB)
Revision Changes Path
1.5 +26 -4
openejb1/modules/core/src/java/org/openejb/alt/config/Deploy.java
Index: Deploy.java
===================================================================
RCS file:
/home/projects/openejb/scm/openejb1/modules/core/src/java/org/openejb/alt/config/Deploy.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Deploy.java 16 Jun 2005 22:29:50 -0000 1.4
+++ Deploy.java 24 Jun 2005 12:04:40 -0000 1.5
@@ -66,6 +66,7 @@
import org.openejb.util.JarUtils;
import org.openejb.util.Messages;
import org.openejb.util.SafeToolkit;
+import org.openejb.util.Logger;
/**
* This class represents a command line tool for deploying beans.
@@ -226,6 +227,9 @@
public void init(String openejbConfigFile) throws OpenEJBException {
try {
+ // Initialize loggers
+ Logger.initialize( System.getProperties() );
+
if (System.getProperty("openejb.nobanner") == null) {
printVersion();
System.out.println("");
@@ -749,6 +753,9 @@
/* Static methods */
/*------------------------------------------------------*/
+ private static final String ERROR_NO_EJBJARFILES_SPECIFIED = "No EJB
JARFILES specified";
+ private static final String INCORRECT_OPTION = "Incorrect option: ";
+
public static void main(String args[]) {
try {
org.openejb.util.ClasspathUtils.addJarsToPath("lib");
@@ -760,10 +767,12 @@
Deploy d = new Deploy();
if (args.length == 0) {
+ error(ERROR_NO_EJBJARFILES_SPECIFIED);
printHelp();
return;
}
+ boolean noBeansToDeploySpecified = true;
for (int i = 0; i < args.length; i++) {
//AUTODEPLOY
if (args[i].equals("-a")) {
@@ -791,14 +800,18 @@
if (args.length > i + 1) {
System.setProperty("openejb.home", args[++i]);
}
- } else if (args[i].equals("-help")) {
- printHelp();
} else if (args[i].equals("-examples")) {
printExamples();
} else if (args[i].equals("-version")) {
printVersion();
+ } else if (args[i].equals("-help")) {
+ printHelp();
+ } else if (args[i].startsWith("-")) {
+ error(INCORRECT_OPTION + args[i]);
+ printHelp();
} else {
// We must have reached the jar list
+ noBeansToDeploySpecified = false;
d.init(null);
for (; i < args.length; i++) {
try {
@@ -811,7 +824,11 @@
}
}
}
-
+ if (noBeansToDeploySpecified) {
+ error(ERROR_NO_EJBJARFILES_SPECIFIED);
+ printHelp();
+ return;
+ }
} catch (Exception e) {
System.out.println(e.getMessage());
//e.printStackTrace();
@@ -893,6 +910,11 @@
}
} catch (java.io.IOException e) {
}
+ }
+
+ // Print error message to stderr
+ private static void error(String msg) {
+ System.err.println("\nERROR: " + msg + "\n");
}
/*------------------------------------------------------*/