Author: dblevins
Date: Thu Jul 12 18:48:53 2007
New Revision: 555835

URL: http://svn.apache.org/viewvc?view=rev&rev=555835
Log:
A command line deploy tool that connects to the server and deploys over the 
DeployerEjb
Several improvements to deployment exception handling, tracking of created jndi 
names for ejbs, and reporting the validation results.

Added:
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ValidationFailedException.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ValidationResults.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Connect.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/resources/org/apache/openejb/config/
      - copied from r554753, 
openejb/trunk/openejb3/container/openejb-core/src/main/resources/org/apache/openejb/alt/config/
    
openejb/trunk/openejb3/container/openejb-core/src/main/resources/org/apache/openejb/config/Messages.properties
Removed:
    
openejb/trunk/openejb3/container/openejb-core/src/main/resources/org/apache/openejb/alt/config/
Modified:
    
openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/openejb
    openejb/trunk/openejb3/assembly/openejb-standalone/try.sh
    openejb/trunk/openejb3/container/openejb-core/pom.xml
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanInfo.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cli/MainImpl.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/Deploy.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbSet.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbValidator.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ValidateEjbModule.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/VmDeploymentManager.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Messages.java
    
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/OpenEjbVersion.java
    
openejb/trunk/openejb3/server/openejb-server/src/main/java/org/apache/openejb/server/Start.java

Modified: 
openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/openejb
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/openejb?view=diff&rev=555835&r1=555834&r2=555835
==============================================================================
--- 
openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/openejb 
(original)
+++ 
openejb/trunk/openejb3/assembly/openejb-standalone/src/main/resources/openejb 
Thu Jul 12 18:48:53 2007
@@ -72,134 +72,12 @@
   OPENEJB_HOME=`cygpath --path --windows "$OPENEJB_HOME"`
 fi
 
-echo OPENEJB_HOME = $OPENEJB_HOME
+#echo OPENEJB_HOME = $OPENEJB_HOME
 
 OPTIONS="-Dopenejb.home=$OPENEJB_HOME"
 
 OPENEJB_CORE_JAR="$OPENEJB_HOME/lib/openejb-core-${pom.version}.jar"
 OPENEJB_JAVAAGENT_JAR="$OPENEJB_HOME/lib/openejb-javaagent-${pom.version}.jar"
 
-#============================================================
-_command_help()
-{
-    case $2 in
-        "validate")
-            java -javaagent:$OPENEJB_JAVAAGENT_JAR -jar $OPENEJB_CORE_JAR 
validate --help
-        ;;
-        "deploy")
-            java -javaagent:$OPENEJB_JAVAAGENT_JAR -jar $OPENEJB_CORE_JAR 
deploy --help
-        ;;
-        "start")
-            java -javaagent:$OPENEJB_JAVAAGENT_JAR -jar $OPENEJB_CORE_JAR 
start --help
-        ;;
-        "stop")
-            java -javaagent:$OPENEJB_JAVAAGENT_JAR -jar $OPENEJB_CORE_JAR stop 
--help
-        ;;
-        "test")
-            java -javaagent:$OPENEJB_JAVAAGENT_JAR -jar $OPENEJB_CORE_JAR test 
--help
-        ;;
-        *)
-            java -javaagent:$OPENEJB_JAVAAGENT_JAR -jar $OPENEJB_CORE_JAR
-        ;;
-    esac
-}
-#============================================================
-_command_deploy()
-{
-   shift
-   java -javaagent:$OPENEJB_JAVAAGENT_JAR -jar $OPENEJB_CORE_JAR deploy $@
-}
-#============================================================
-_command_validate()
-{
-   shift
-   java -javaagent:$OPENEJB_JAVAAGENT_JAR -jar $OPENEJB_CORE_JAR validate $@
-}
-#============================================================
-_command_start()
-{
-   java -javaagent:$OPENEJB_JAVAAGENT_JAR -jar $OPENEJB_CORE_JAR start $@
-}
-#============================================================
-_command_stop()
-{
-   java -javaagent:$OPENEJB_JAVAAGENT_JAR -jar $OPENEJB_CORE_JAR stop $@
-}
-#============================================================
-_test_intravm()
-{
-   java -javaagent:$OPENEJB_JAVAAGENT_JAR -jar $OPENEJB_CORE_JAR test local
-}
-#============================================================
-_test_server()
-{
-   java -javaagent:$OPENEJB_JAVAAGENT_JAR -jar $OPENEJB_CORE_JAR test remote
-}
-#============================================================
-_command_test()
-{
-case $2 in
-    "local")
-        _test_intravm
-    ;;
-    "remote")
-        _test_server
-    ;;
-    "--help")
-        _test_help
-    ;;
-    *)
-        _test_noargs
-    ;;
-esac
-}
-#============================================================
-_test_help()
-{
-   java -javaagent:$OPENEJB_JAVAAGENT_JAR -jar $OPENEJB_CORE_JAR test --help
-}
-#============================================================
-_test_noargs()
-{
-   _test_intravm
-   _test_server
-}
-#============================================================
-case $1 in
-    "build")
-        _command_build $@
-    ;;
-    "test")
-        _command_test $@
-    ;;
-    "validate")
-        _command_validate $@
-    ;;
-    "deploy")
-        _command_deploy $@
-    ;;
-    "start")
-        _command_start $@
-    ;;
-    "stop")
-        _command_stop $@
-    ;;
-    "corba")
-        _start_corba $@
-    ;;
-    "create_stubs")
-        _create_stubs $@
-    ;;
-    "help")
-        _command_help $@
-    ;;
-    "-help")
-        _command_help $@
-    ;;
-    "--help")
-        _command_help $@
-    ;;
-    *)  _command_help $@
-    ;;
-esac
 
+java -javaagent:$OPENEJB_JAVAAGENT_JAR -jar $OPENEJB_CORE_JAR "$@"

Modified: openejb/trunk/openejb3/assembly/openejb-standalone/try.sh
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/assembly/openejb-standalone/try.sh?view=diff&rev=555835&r1=555834&r2=555835
==============================================================================
--- openejb/trunk/openejb3/assembly/openejb-standalone/try.sh (original)
+++ openejb/trunk/openejb3/assembly/openejb-standalone/try.sh Thu Jul 12 
18:48:53 2007
@@ -21,8 +21,12 @@
 
 cd target/
 
-tar xzvf openejb-3.0.0-SNAPSHOT-bin.tar.gz
+#tar xzvf openejb-3.0.0-SNAPSHOT-bin.tar.gz
 cd openejb-3.0.0-SNAPSHOT
-cp $JAR apps/
-./bin/openejb start
+#cp $JAR apps/
+#./bin/openejb start &
+#sleep 14
+./bin/openejb deploy -h
+#$JAR
+
 

Modified: openejb/trunk/openejb3/container/openejb-core/pom.xml
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/pom.xml?view=diff&rev=555835&r1=555834&r2=555835
==============================================================================
--- openejb/trunk/openejb3/container/openejb-core/pom.xml (original)
+++ openejb/trunk/openejb3/container/openejb-core/pom.xml Thu Jul 12 18:48:53 
2007
@@ -65,6 +65,7 @@
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
+        <version>2.2</version>
         <configuration>
           <forkMode>pertest</forkMode>
           <!-- DEBUG: Uncomment this line and comment out the next -->
@@ -78,7 +79,7 @@
             </property>
             <property>
               <name>log4j.configuration</name>
-              
<value>file:///${basedir}/target/classes/default.logging.conf</value>
+              <value>${basedir}/target/classes/default.logging.conf</value>
             </property>
           </systemProperties>
           <!--
@@ -182,6 +183,11 @@
       <artifactId>openejb-itests-client</artifactId>
       <version>${version}</version>
       <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>commons-cli</groupId>
+      <artifactId>commons-cli</artifactId>
+      <version>1.1</version>
     </dependency>
     <!-- ActiveMQ -->
     <dependency>

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java?view=diff&rev=555835&r1=555834&r2=555835
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/Assembler.java
 Thu Jul 12 18:48:53 2007
@@ -366,17 +366,13 @@
         }
 
         if (used.size() > 0) {
-            String message = "Application cannot be deployed as it contains 
deployment-ids which are already deployed: app: " + appInfo.jarPath;
+            String message = "Application cannot be deployed as it contains 
deployment-ids which are in use: app: " + appInfo.jarPath;
             logger.error(message);
-            OpenEJBException openEJBException = new 
DuplicateDeploymentIdException(message);
-            Exception e = openEJBException;
             for (String id : used) {
                 logger.debug("DeploymentId already used: " + id);
-                DuplicateDeploymentIdException e2 = new 
DuplicateDeploymentIdException(id);
-                e.initCause(e2);
-                e = e2;
+                message += "\n    "+id;
             }
-            throw openEJBException;
+            throw new DuplicateDeploymentIdException(message);
         }
 
         try {
@@ -411,13 +407,14 @@
                     jaccPermissionsBuilder.install(policyContext);
                 }
 
+
                 // process transaction attributes
                 for (DeploymentInfo deploymentInfo : deployments.values()) {
                     applyTransactionAttributes((CoreDeploymentInfo) 
deploymentInfo, ejbJar.methodTransactions);
                     containerSystem.addDeployment(deploymentInfo);
-                    jndiBuilder.bind(deploymentInfo);
-
                 }
+
+                jndiBuilder.build(ejbJar, deployments);
 
                 // setup timers - must be after transaction attibutes are set
                 for (DeploymentInfo deploymentInfo : deployments.values()) {

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanInfo.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanInfo.java?view=diff&rev=555835&r1=555834&r2=555835
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanInfo.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/EnterpriseBeanInfo.java
 Thu Jul 12 18:48:53 2007
@@ -61,4 +61,6 @@
 
     public String containerId;
     public String serviceEndpoint;
+
+    public List<String> jndiNames = new ArrayList<String>();
 }

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java?view=diff&rev=555835&r1=555834&r2=555835
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/assembler/classic/JndiBuilder.java
 Thu Jul 12 18:48:53 2007
@@ -65,6 +65,13 @@
         }
     }
 
+    public void build(EjbJarInfo ejbJar, HashMap<String, DeploymentInfo> 
deployments) {
+        for (EnterpriseBeanInfo beanInfo : ejbJar.enterpriseBeans) {
+            DeploymentInfo deploymentInfo = 
deployments.get(beanInfo.ejbDeploymentId);
+            bind(deploymentInfo, beanInfo);
+        }
+    }
+
     public static interface JndiNameStrategy {
 
         public static enum Interface {
@@ -178,7 +185,7 @@
         return strategy;
     }
 
-    public void bind(DeploymentInfo deploymentInfo) {
+    public void bind(DeploymentInfo deploymentInfo, EnterpriseBeanInfo 
beanInfo) {
         JndiNameStrategy strategy = getStrategy();
         CoreDeploymentInfo deployment = (CoreDeploymentInfo) deploymentInfo;
 
@@ -192,10 +199,10 @@
 
                 String name = "openejb/ejb/" + strategy.getName(deployment, 
deploymentInfo.getRemoteInterface(), JndiNameStrategy.Interface.REMOTE_HOME);
                 ObjectReference ref = new 
ObjectReference(deployment.getEJBHome());
-                bind(name, ref, bindings);
+                bind(name, ref, bindings, beanInfo);
 
                 name = "openejb/Deployment/" + deployment.getDeploymentID() + 
"/" + deployment.getRemoteInterface().getName();
-                bind(name, ref, bindings);
+                bind(name, ref, bindings, beanInfo);
             }
         } catch (NamingException e) {
             throw new RuntimeException("Unable to bind home interface for 
deployment " + id, e);
@@ -207,10 +214,10 @@
 
                 String name = "openejb/ejb/" + strategy.getName(deployment, 
deploymentInfo.getLocalInterface(), JndiNameStrategy.Interface.LOCAL_HOME);
                 ObjectReference ref = new 
ObjectReference(deployment.getEJBLocalHome());
-                bind(name, ref, bindings);
+                bind(name, ref, bindings, beanInfo);
 
                 name = "openejb/Deployment/" + deployment.getDeploymentID() + 
"/" + deployment.getLocalInterface().getName();
-                bind(name, ref, bindings);
+                bind(name, ref, bindings, beanInfo);
             }
         } catch (NamingException e) {
             throw new RuntimeException("Unable to bind local interface for 
deployment " + id, e);
@@ -222,18 +229,18 @@
 
                 String name = "openejb/ejb/" + strategy.getName(deployment, 
businessLocalInterface, JndiNameStrategy.Interface.BUSINESS_LOCAL);
                 DeploymentInfo.BusinessLocalHome businessLocalHome = 
deployment.getBusinessLocalHome();
-                bind(name, new BusinessLocalReference(businessLocalHome), 
bindings);
+                bind(name, new BusinessLocalReference(businessLocalHome), 
bindings, beanInfo);
 
                 for (Class interfce : deployment.getBusinessLocalInterfaces()) 
{
                     DeploymentInfo.BusinessLocalHome home = 
deployment.getBusinessLocalHome(asList(interfce));
                     BusinessLocalReference ref = new 
BusinessLocalReference(home);
 
                     name = "openejb/Deployment/" + 
deployment.getDeploymentID() + "/" + interfce.getName();
-                    bind(name, ref, bindings);
+                    bind(name, ref, bindings, beanInfo);
 
                     try {
                         name = "openejb/ejb/" + strategy.getName(deployment, 
interfce, JndiNameStrategy.Interface.BUSINESS_LOCAL);
-                        bind(name, ref, bindings);
+                        bind(name, ref, bindings, beanInfo);
                     } catch (NamingException dontCareJustYet) {
                     }
                 }
@@ -250,18 +257,18 @@
                 BusinessRemoteReference ref = new 
BusinessRemoteReference(businessRemoteHome);
 
                 String name = "openejb/ejb/" + strategy.getName(deployment, 
businessRemoteInterface, JndiNameStrategy.Interface.BUSINESS_REMOTE);
-                bind(name, ref, bindings);
+                bind(name, ref, bindings, beanInfo);
 
                 for (Class interfce : 
deployment.getBusinessRemoteInterfaces()) {
                     DeploymentInfo.BusinessRemoteHome home = 
deployment.getBusinessRemoteHome(asList(interfce));
                     ref = new BusinessRemoteReference(home);
 
                     name = "openejb/Deployment/" + 
deployment.getDeploymentID() + "/" + interfce.getName();
-                    bind(name, ref, bindings);
+                    bind(name, ref, bindings, beanInfo);
 
                     try {
                         name = "openejb/ejb/" + strategy.getName(deployment, 
interfce, JndiNameStrategy.Interface.BUSINESS_REMOTE);
-                        bind(name, ref, bindings);
+                        bind(name, ref, bindings, beanInfo);
                     } catch (NamingException dontCareJustYet) {
                     }
                 }
@@ -278,7 +285,7 @@
                 String jndiName = "java:openejb/Resource/" + destinationId;
                 Reference reference = new IntraVmJndiReference(jndiName);
 
-                bind(name, reference, bindings);
+                bind(name, reference, bindings, beanInfo);
             }
         } catch (NamingException e) {
             throw new RuntimeException("Unable to bind mdb destination in 
jndi.", e);
@@ -286,12 +293,15 @@
     }
 
 
-    private void bind(String name, Reference ref, Bindings bindings) throws 
NamingException {
+    private void bind(String name, Reference ref, Bindings bindings, 
EnterpriseBeanInfo beanInfo) throws NamingException {
         context.bind(name, ref);
         bindings.add(name);
         if (name.startsWith("openejb/ejb/")) {
             name = name.replaceFirst("openejb/ejb/", "");
             logger.info("Jndi(name=" + name+")");
+            if (!beanInfo.jndiNames.contains(name)){
+                beanInfo.jndiNames.add(name);
+            }
         }
     }
 

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cli/MainImpl.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cli/MainImpl.java?view=diff&rev=555835&r1=555834&r2=555835
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cli/MainImpl.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/cli/MainImpl.java
 Thu Jul 12 18:48:53 2007
@@ -51,6 +51,21 @@
     public void main(String[] args) {
         ArrayList<String> argsList = new ArrayList<String>();
 
+        // We have to pre-screen for openejb.base as it has a direct affect
+        // on where we look for the conf/system.properties file which we
+        // need to read in and apply before we apply the command line -D
+        // properties.  Once SystemInstance.init() is called in the next
+        // section of code, the openejb.base value is cemented and cannot
+        // be changed.
+        for (String arg : args) {
+            if (arg.indexOf("-Dopenejb.base") != -1) {
+                String prop = arg.substring(arg.indexOf("-D") + 2, 
arg.indexOf("="));
+                String val = arg.substring(arg.indexOf("=") + 1);
+
+                System.setProperty(prop, val);
+            }
+        }
+
         // get SystemInstance (the only static class in the system)
         // so we'll set up all the props in it
         SystemInstance systemInstance = null;
@@ -62,6 +77,7 @@
             return;
         }
 
+        // Read in and apply the conf/system.properties
         try {
             File conf = systemInstance.getBase().getDirectory("conf");
             File file = new File(conf, "system.properties");
@@ -76,15 +92,16 @@
             System.out.println("Processing conf/system.properties failed: 
"+e.getMessage());
         }
 
+        // Now read in and apply the properties specified on the command line
         for (int i = 0; i < args.length; i++) {
             String arg = args[i];
-            if (arg.indexOf("-D") == -1) {
-                argsList.add(arg);
-            } else {
+            if (arg.indexOf("-D") != -1) {
                 String prop = arg.substring(arg.indexOf("-D") + 2, 
arg.indexOf("="));
                 String val = arg.substring(arg.indexOf("=") + 1);
 
                 System.setProperty(prop, val);
+            } else {
+                argsList.add(arg);
             }
         }
 

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/Deploy.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/Deploy.java?view=diff&rev=555835&r1=555834&r2=555835
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/Deploy.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/Deploy.java
 Thu Jul 12 18:48:53 2007
@@ -16,18 +16,261 @@
  */
 package org.apache.openejb.config;
 
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.HelpFormatter;
+import org.apache.commons.cli.Option;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.PosixParser;
+import org.apache.openejb.OpenEJBException;
+import org.apache.openejb.loader.SystemInstance;
+import org.apache.openejb.assembler.Deployer;
+import org.apache.openejb.assembler.classic.AppInfo;
+import org.apache.openejb.assembler.classic.EjbJarInfo;
+import org.apache.openejb.assembler.classic.EnterpriseBeanInfo;
+import org.apache.openejb.assembler.classic.InterceptorInfo;
+import org.apache.openejb.assembler.classic.ClientInfo;
+import org.apache.openejb.assembler.classic.PersistenceUnitInfo;
+import org.apache.openejb.util.Messages;
+import org.apache.openejb.util.OpenEjbVersion;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.io.File;
+import java.io.OutputStream;
+import java.io.InputStream;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.Closeable;
+import java.util.Properties;
+
 /**
  * Deploy EJB beans
  */
 public class Deploy {
+
+    private static Messages messages = new Messages(Deploy.class);
+
+    private static final String defaultServerUrl = "ejbd://localhost:4201";
+    private static final int BUF_SIZE = 8192;
+
+
     public static void main(String[] args) {
-        // TODO: Use the deploy bean here instead
-        // This class could simply be a nice command line version
-        // of the client for that tool
-        System.out.println("Place application in the apps/ directory are 
restart the server");
-        System.out.println("");
-        System.out.println("Hot deploy is supported in the codebase, but not 
yet hooked up.");
-        System.out.println("This tool will be a command-line version of hot 
deploy allowing");
-        System.out.println("you to specify options and see success/failure on 
the deploy.");
+
+        CommandLineParser parser = new PosixParser();
+
+        // create the Options
+        Options options = new Options();
+        options.addOption(option("v", "version", "cmd.deploy.opt.version"));
+        options.addOption(option("h", "help", "cmd.deploy.opt.help"));
+        options.addOption(option("o", "offline", "cmd.deploy.opt.offline"));
+        options.addOption(option("s", "server-url", "url", 
"cmd.deploy.opt.server"));
+        options.addOption(option("d", "debug", "cmd.deploy.opt.debug"));
+        options.addOption(option("q", "quiet", "cmd.deploy.opt.quiet"));
+        options.addOption(option(null, "dir", "cmd.deploy.opt.dir"));
+
+        CommandLine line = null;
+        try {
+            // parse the command line arguments
+            line = parser.parse(options, args);
+        } catch (ParseException exp) {
+            help(options);
+            System.exit(-1);
+        }
+
+        if (line.hasOption("help")) {
+            help(options);
+            System.exit(0);
+        } else if (line.hasOption("version")) {
+            OpenEjbVersion.get().print(System.out);
+            System.exit(0);
+        }
+
+        if (line.getArgList().size() == 0) {
+            System.out.println("Must specify an archive to deploy.");
+            help(options);
+        }
+
+
+        boolean offline = line.hasOption("offline");
+
+        File apps = null;
+        try {
+            String dir = line.getOptionValue("dir", "apps");
+            apps = SystemInstance.get().getBase().getDirectory(dir);
+        } catch (IOException e) {
+
+        }
+
+        if (!apps.exists()) {
+            System.out.println("Directory does not exist: " + 
apps.getAbsolutePath());
+        }
+
+        Properties p = new Properties();
+        p.put(Context.INITIAL_CONTEXT_FACTORY, 
"org.apache.openejb.client.RemoteInitialContextFactory");
+
+        String serverUrl = defaultServerUrl;
+        if (line.hasOption(serverUrl)) {
+            serverUrl = line.getOptionValue("serverUrl");
+        }
+        p.put(Context.PROVIDER_URL, serverUrl);
+
+        Deployer deployer = null;
+        try {
+            InitialContext ctx = new InitialContext(p);
+            deployer = (Deployer) ctx.lookup("openejb/DeployerBusinessRemote");
+        } catch (javax.naming.ServiceUnavailableException e) {
+            System.out.println(e.getCause().getMessage());
+            System.out.println(messages.format("cmd.deploy.serverOffline"));
+            System.exit(1);
+        } catch (javax.naming.NamingException e) {
+            System.out.println("DeployerEjb does not exist in server '" + 
serverUrl + "', check the server logs to ensure it exists and has not been 
removed.");
+            System.exit(2);
+        }
+
+        int exitCode = 0;
+        for (Object obj : line.getArgList()) {
+            String path = (String) obj;
+
+            try {
+                File file = new File(path);
+
+                checkSource(file);
+
+                File destFile = new File(apps, file.getName());
+
+                checkDest(destFile, file);
+
+                copyFile(file, destFile);
+
+                if (offline) {
+                    System.out.println(messages.format("cmd.deploy.offline", 
path, apps.getAbsolutePath()));
+                    continue;
+                }
+
+                AppInfo appInfo = deployer.deploy(file.getAbsolutePath());
+
+                System.out.println(messages.format("cmd.deploy.successful", 
path, appInfo.jarPath));
+
+                if (line.hasOption("quiet")) {
+                    continue;
+                }
+
+                System.out.println("App(id=" + appInfo.jarPath + ")");
+
+                for (EjbJarInfo info : appInfo.ejbJars) {
+                    System.out.println("    EjbJar(id=" + info.moduleId + ", 
path=" + info.jarPath + ")");
+                    for (EnterpriseBeanInfo beanInfo : info.enterpriseBeans) {
+                        System.out.println("        Ejb(ejb-name=" + 
beanInfo.ejbName + ", id=" + beanInfo.ejbDeploymentId + ")");
+                        for (String name : beanInfo.jndiNames) {
+                            System.out.println("            Jndi(name=" + name 
+ ")");
+                        }
+                        System.out.println("");
+                    }
+                    for (InterceptorInfo interceptorInfo : info.interceptors) {
+                        System.out.println("        Interceptor(class=" + 
interceptorInfo.clazz + ")");
+                    }
+                    System.out.println("");
+                }
+                for (ClientInfo clientInfo : appInfo.clients) {
+                    System.out.println("    Client(main-class=" + 
clientInfo.mainClass + ", id=" + clientInfo.moduleId + ", path=" + 
clientInfo.codebase + ")");
+                    System.out.println("");
+                }
+                for (PersistenceUnitInfo persistenceUnitInfo : 
appInfo.persistenceUnits) {
+                    System.out.println("    PersistenceUnit(name=" + 
persistenceUnitInfo.name + ", provider=" + persistenceUnitInfo.provider+ ")");
+                    System.out.println("");
+                }
+            } catch (DeploymentTerminatedException e) {
+                System.out.println(e.getMessage());
+                exitCode += 100;
+            } catch (ValidationFailedException e) {
+                
System.out.println(messages.format("cmd.deploy.validationFailed", path));
+                int level = 2;
+                if (line.hasOption("debug")){
+                    level = 3;
+                }
+                EjbValidator ejbValidator = new EjbValidator(level, false, 
true, false);
+                ejbValidator.printResults(e);
+                exitCode += 100;
+            } catch (OpenEJBException e) {
+                System.out.println(messages.format("cmd.deploy.failed", path));
+                e.printStackTrace(System.out);
+                exitCode += 100;
+            }
+        }
+
+        System.exit(exitCode);
+    }
+
+    private static void checkSource(File file) throws 
DeploymentTerminatedException {
+        if (!file.exists()) {
+            throw new 
DeploymentTerminatedException(messages.format("cmd.deploy.fileNotFound", 
file.getAbsolutePath()));
+        }
+    }
+
+    private static void checkDest(File destFile, File file) throws 
DeploymentTerminatedException {
+        if (destFile.exists()){
+            throw new 
DeploymentTerminatedException(messages.format("cmd.deploy.destExists", 
file.getAbsolutePath(), destFile.getAbsolutePath()));
+        }
+    }
+
+    private static void copyFile(File file, File destFile) throws 
DeploymentTerminatedException {
+        InputStream in = null;
+        OutputStream out = null;
+        try {
+            in = new FileInputStream(file);
+            out = new FileOutputStream(destFile);
+
+            byte[] buffer = new byte[BUF_SIZE];
+            int count = 0;
+            do {
+                out.write(buffer, 0, count);
+                count = in.read(buffer, 0, buffer.length);
+            } while (count != -1);
+        } catch (Exception e) {
+            throw new 
DeploymentTerminatedException(messages.format("cmd.deploy.cantCopy", 
file.getAbsolutePath(), destFile.getAbsolutePath()));
+        } finally {
+            close(in);
+            close(out);
+        }
+    }
+
+    private static void close(Closeable in) {
+        if (in != null) {
+            try {
+                in.close();
+            } catch (IOException e) {
+            }
+        }
+    }
+
+    private static void help(Options options) {
+        HelpFormatter formatter = new HelpFormatter();
+        formatter.printHelp("deploy [options] <file> [<file>...]", "\nConnects 
to the server and deploys the application.  Note that full remote deployment is 
not yet supported, deployment can only be done on the same machine as the 
server.  Track OPENEJB-609 for development of full remote deployment 
feature.\n\nOptions:", options, "\n");
+    }
+
+    private static Option option(String shortOpt, String longOpt, String 
description) {
+        return 
OptionBuilder.withLongOpt(longOpt).withDescription(i18n(description)).create(shortOpt);
+    }
+
+    private static Option option(String shortOpt, String longOpt, String 
argName, String description) {
+        return 
OptionBuilder.withLongOpt(longOpt).withArgName(argName).hasArg().withDescription(i18n(description)).create(shortOpt);
+    }
+
+    private static String i18n(String key) {
+        return messages.format(key);
+    }
+
+    public static class DeploymentTerminatedException extends Exception {
+        public DeploymentTerminatedException(String message) {
+            super(message);
+        }
+
+        public DeploymentTerminatedException(String message, Throwable cause) {
+            super(message, cause);
+        }
     }
 }

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbSet.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbSet.java?view=diff&rev=555835&r1=555834&r2=555835
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbSet.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbSet.java
 Thu Jul 12 18:48:53 2007
@@ -20,7 +20,7 @@
 
 import org.apache.openejb.jee.EjbJar;
 
-public class EjbSet {
+public class EjbSet implements ValidationResults {
 
     private final Vector failures = new Vector();
     private final Vector warnings = new Vector();

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbValidator.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbValidator.java?view=diff&rev=555835&r1=555834&r2=555835
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbValidator.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/EjbValidator.java
 Thu Jul 12 18:48:53 2007
@@ -24,11 +24,6 @@
 import java.util.Vector;
 
 import org.apache.openejb.OpenEJBException;
-import org.apache.openejb.jee.EjbRef;
-import org.apache.openejb.jee.EnvEntry;
-import org.apache.openejb.jee.SecurityRoleRef;
-import org.apache.openejb.jee.ResourceRef;
-import org.apache.openejb.jee.EjbLocalRef;
 import org.apache.openejb.loader.SystemInstance;
 import org.apache.openejb.config.rules.CheckClasses;
 import org.apache.openejb.config.rules.CheckMethods;
@@ -42,7 +37,6 @@
     protected static final Messages _messages = new 
Messages("org.apache.openejb.config.rules");
 
     int LEVEL = 2;
-    boolean PRINT_DETAILS = false;
     boolean PRINT_XML = false;
     boolean PRINT_WARNINGS = true;
     boolean PRINT_COUNT = false;
@@ -55,12 +49,19 @@
     public EjbValidator() throws OpenEJBException {
     }
 
-    public void addEjbSet(EjbSet set) {
+    public EjbValidator(int LEVEL, boolean PRINT_XML, boolean PRINT_WARNINGS, 
boolean PRINT_COUNT) {
+        this.LEVEL = LEVEL;
+        this.PRINT_XML = PRINT_XML;
+        this.PRINT_WARNINGS = PRINT_WARNINGS;
+        this.PRINT_COUNT = PRINT_COUNT;
+    }
+
+    public void addValidationResults(ValidationResults set) {
         sets.add(set);
     }
 
-    public EjbSet[] getEjbSets() {
-        EjbSet[] ejbSets = new EjbSet[sets.size()];
+    public ValidationResults[] getValidationResultsSets() {
+        ValidationResults[] ejbSets = new ValidationResults[sets.size()];
         sets.copyInto(ejbSets);
         return ejbSets;
     }
@@ -92,7 +93,7 @@
         return rules;
     }
 
-    public void printResults(EjbSet set) {
+    public void printResults(ValidationResults set) {
         if (!set.hasErrors() && !set.hasFailures() && (!PRINT_WARNINGS || 
!set.hasWarnings())) {
             return;
         }
@@ -136,7 +137,7 @@
 
     }
 
-    public void printResultsXML(EjbSet set) {
+    public void printResultsXML(ValidationResults set) {
         if (!set.hasErrors() && !set.hasFailures() && (!PRINT_WARNINGS || 
!set.hasWarnings())) {
             return;
         }
@@ -177,7 +178,7 @@
         }
     }
 
-    public void displayResults(EjbSet[] sets) {
+    public void displayResults(ValidationResults[] sets) {
         if (PRINT_XML) {
             System.out.println("<results>");
             for (int i = 0; i < sets.length; i++) {
@@ -305,7 +306,7 @@
                             }
                             final EjbModule ejbModule = new 
EjbModule(classLoader, ejbJarUtils.getJarLocation(), ejbJarUtils.getEjbJar(), 
ejbJarUtils.getOpenejbJar());
                             EjbSet set = v.validateJar(ejbModule);
-                            v.addEjbSet(set);
+                            v.addValidationResults(set);
                         } catch (Exception e) {
                             e.printStackTrace();
                         }
@@ -313,7 +314,7 @@
                 }
             }
 
-            EjbSet[] sets = v.getEjbSets();
+            ValidationResults[] sets = v.getValidationResultsSets();
             v.displayResults(sets);
 
             for (int i = 0; i < sets.length; i++) {

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ValidateEjbModule.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ValidateEjbModule.java?view=diff&rev=555835&r1=555834&r2=555835
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ValidateEjbModule.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ValidateEjbModule.java
 Thu Jul 12 18:48:53 2007
@@ -45,7 +45,7 @@
     public EjbModule deploy(EjbModule ejbModule) throws OpenEJBException {
 
         EjbValidator validator = new EjbValidator();
-        EjbSet set = validator.validateJar(ejbModule);
+        ValidationResults set = validator.validateJar(ejbModule);
         if (set.hasErrors() || set.hasFailures()) {
             Logger logger = Logger.getInstance("OpenEJB.startup.validation", 
"org.apache.openejb.config.rules");
 
@@ -54,17 +54,16 @@
                 ValidationError e = errors[j];
                 String ejbName = e.getComponentName();
                 logger.error(e.getPrefix() + " ... " + ejbName + ":\t" + 
e.getMessage(2));
-                System.out.println(e.getPrefix() + " ... " + 
e.getComponentName() + ":\t" + e.getMessage(2));
             }
             ValidationFailure[] failures = set.getFailures();
             for (int j = 0; j < failures.length; j++) {
                 ValidationFailure e = failures[j];
                 logger.error(e.getPrefix() + " ... " + e.getComponentName() + 
":\t" + e.getMessage(2));
-                System.out.println(e.getPrefix() + " ... " + 
e.getComponentName() + ":\t" + e.getMessage(2));
             }
 
-            throw new OpenEJBException("Jar failed validation.  Use the 
validation tool for more details");
+            throw new ValidationFailedException("Jar failed validation.", set);
         }
         return ejbModule;
     }
+
 }

Added: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ValidationFailedException.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ValidationFailedException.java?view=auto&rev=555835
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ValidationFailedException.java
 (added)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ValidationFailedException.java
 Thu Jul 12 18:48:53 2007
@@ -0,0 +1,65 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.config;
+
+import org.apache.openejb.OpenEJBException;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class ValidationFailedException extends OpenEJBException implements 
ValidationResults {
+    private final ValidationError[] errors;
+    private final ValidationFailure[] failures;
+    private final ValidationWarning[] warnings;
+    private final String jarPath;
+
+    public ValidationFailedException(String message, ValidationResults set) {
+        super(message);
+        jarPath = set.getJarPath();
+        errors = set.getErrors();
+        failures = set.getFailures();
+        warnings = set.getWarnings();
+    }
+
+    public String getJarPath() {
+        return jarPath;
+    }
+
+    public ValidationError[] getErrors() {
+        return errors;
+    }
+
+    public ValidationFailure[] getFailures() {
+        return failures;
+    }
+
+    public ValidationWarning[] getWarnings() {
+        return warnings;
+    }
+
+    public boolean hasWarnings() {
+        return warnings.length > 0;
+    }
+
+    public boolean hasFailures() {
+        return failures.length > 0;
+    }
+
+    public boolean hasErrors() {
+        return errors.length > 0;
+    }
+}

Added: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ValidationResults.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ValidationResults.java?view=auto&rev=555835
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ValidationResults.java
 (added)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/ValidationResults.java
 Thu Jul 12 18:48:53 2007
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.config;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public interface ValidationResults {
+    ValidationFailure[] getFailures();
+
+    ValidationWarning[] getWarnings();
+
+    ValidationError[] getErrors();
+
+    boolean hasWarnings();
+
+    boolean hasFailures();
+
+    boolean hasErrors();
+
+    String getJarPath();
+}

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/VmDeploymentManager.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/VmDeploymentManager.java?view=diff&rev=555835&r1=555834&r2=555835
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/VmDeploymentManager.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/config/VmDeploymentManager.java
 Thu Jul 12 18:48:53 2007
@@ -77,7 +77,7 @@
     private boolean deployerLocal;
 
     public VmDeploymentManager() {
-        String openejbHome = System.getProperty("openejb.home", 
"target/openejb-3.0-incubating-SNAPSHOT");
+        String openejbHome = System.getProperty("openejb.home", 
"target/openejb-3.0.0-SNAPSHOT");
         File openejbHomeDir = new File(openejbHome);
         if (!openejbHomeDir.exists()) {
             throw new IllegalArgumentException("OpenEJB home dir does not 
exist: " + openejbHomeDir);

Added: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Connect.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Connect.java?view=auto&rev=555835
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Connect.java
 (added)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Connect.java
 Thu Jul 12 18:48:53 2007
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.util;
+
+import javax.naming.InitialContext;
+import javax.naming.Context;
+import java.net.Socket;
+import java.io.OutputStream;
+import java.util.Properties;
+
+/**
+ * @version $Rev$ $Date$
+ */
+public class Connect {
+
+    public static boolean connect(int tries, String host, int port) {
+
+        try {
+
+            Socket socket = new Socket(host, port);
+
+            OutputStream out = socket.getOutputStream();
+
+        } catch (Exception e) {
+
+            if (tries < 2) {
+
+                return false;
+
+            } else {
+
+                try {
+
+                    Thread.sleep(2000);
+
+                } catch (Exception e2) {
+
+                    e.printStackTrace();
+
+                }
+
+                return connect(--tries, host, port);
+
+            }
+
+        }
+
+        return true;
+    }
+
+    
+}

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Messages.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Messages.java?view=diff&rev=555835&r1=555834&r2=555835
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Messages.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/Messages.java
 Thu Jul 12 18:48:53 2007
@@ -34,6 +34,15 @@
     private Locale _locale;
     private String _resourceName;
 
+    public Messages(Class clazz) {
+        this(packageName(clazz));
+    }
+
+    private static String packageName(Class clazz) {
+        String name = clazz.getName();
+        return name.substring(0, name.lastIndexOf("."));
+    }
+
     public Messages(String resourceName) {
         synchronized (Messages.class) {
             _locale = _globalLocale;

Modified: 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/OpenEjbVersion.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/OpenEjbVersion.java?view=diff&rev=555835&r1=555834&r2=555835
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/OpenEjbVersion.java
 (original)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/java/org/apache/openejb/util/OpenEjbVersion.java
 Thu Jul 12 18:48:53 2007
@@ -18,8 +18,8 @@
 
 import org.apache.xbean.finder.ResourceFinder;
 
-import java.net.URL;
 import java.util.Properties;
+import java.io.PrintStream;
 
 /**
  * @version $Rev$ $Date$
@@ -73,5 +73,10 @@
 
     public String getVersion() {
         return version;
+    }
+
+    public void print(PrintStream out) {
+        out.println("Apache OpenEJB " + getVersion() + "    build: " + 
getDate() + "-" + getTime());
+        out.println(getUrl());
     }
 }

Added: 
openejb/trunk/openejb3/container/openejb-core/src/main/resources/org/apache/openejb/config/Messages.properties
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/container/openejb-core/src/main/resources/org/apache/openejb/config/Messages.properties?view=auto&rev=555835
==============================================================================
--- 
openejb/trunk/openejb3/container/openejb-core/src/main/resources/org/apache/openejb/config/Messages.properties
 (added)
+++ 
openejb/trunk/openejb3/container/openejb-core/src/main/resources/org/apache/openejb/config/Messages.properties
 Thu Jul 12 18:48:53 2007
@@ -0,0 +1,44 @@
+# options.addOption(option("v", "version", "cmd.deploy.opt.version"));
+cmd.deploy.opt.version = Prints the OpenEJB version and exits.
+
+# options.addOption(option("h", "help", "cmd.deploy.opt.help"));
+cmd.deploy.opt.help = Lists these options and exit.
+
+# options.addOption(option("o", "offline", "cmd.deploy.opt.offline"));
+cmd.deploy.opt.offline = Deploys the app to an offline server by copying the 
archive into the server's apps/ directory.  The app will be deployed when the 
server is started.  The default is online.
+
+# options.addOption(option("s", "server-url", "url", "cmd.deploy.opt.server"));
+cmd.deploy.opt.server = Sets the url of the OpenEJB server to which the app 
will be deployed.  The value should be the same as the JNDI Provider URL used 
to lookup EJBs.  The default is 'ejbd://localhost:4201'.
+
+# options.addOption(option("d", "debug", "cmd.deploy.opt.debug"));
+cmd.deploy.opt.debug = Increases the level of detail on validation errors and 
deployment summary.
+
+# options.addOption(option("q", "quiet", "cmd.deploy.opt.quiet"));
+cmd.deploy.opt.quiet = Decreases the level of detail on validation and skips 
the deployment summary.
+
+# options.addOption(option(null, "dir", "cmd.deploy.opt.dir"));
+cmd.deploy.opt.dir = Sets the destination directory where the app will be 
deployed.  The default is {openejb.base}/apps/ directory.  Note when changing 
this setting make sure the directory is listed in the openejb.xml via a 
<Deployments dir=""/> tag or the app will not be picked up again on restart.
+
+# System.out.println(messages.format("cmd.deploy.serverOffline"));
+cmd.deploy.serverOffline =  The server is offline or not contactable at the 
configured address.  Either start the server or try deployment again in 
--offline mode.
+
+# System.out.println(messages.format("cmd.deploy.offline", path, 
destFile.getAbsolutePath()));
+cmd.deploy.offline =  The application '{0}' has been copied to the directory 
'{1}' and will be loaded when the server starts.
+
+# System.out.println(messages.format("cmd.deploy.successful", path, 
appInfo.jarPath));
+cmd.deploy.successful =  Application deployed successfully at '{0}'
+
+# System.out.println(messages.format("cmd.deploy.validationFailed", path));
+cmd.deploy.validationFailed = Application did not pass validation: {0}
+
+# System.out.println(messages.format("cmd.deploy.failed", path));
+cmd.deploy.failed = Application failed to deploy '{0}'.  Check server logs for 
more details.
+
+# throw new 
DeploymentTerminatedException(messages.format("cmd.deploy.fileNotFound", 
file.getAbsolutePath()));
+cmd.deploy.fileNotFound = Archive does not exist: {0}
+
+# throw new 
DeploymentTerminatedException(messages.format("cmd.deploy.destExists", 
file.getAbsolutePath(), destFile.getAbsolutePath()));
+cmd.deploy.destExists = Application already deployed at '{1}'
+
+# throw new 
DeploymentTerminatedException(messages.format("cmd.deploy.cantCopy", 
file.getAbsolutePath(), destFile.getAbsolutePath()));
+cmd.deploy.cantCopy = Unable to copy application to '{1}'.  Check that the 
directory is writable and that there is enough disk space.
\ No newline at end of file

Modified: 
openejb/trunk/openejb3/server/openejb-server/src/main/java/org/apache/openejb/server/Start.java
URL: 
http://svn.apache.org/viewvc/openejb/trunk/openejb3/server/openejb-server/src/main/java/org/apache/openejb/server/Start.java?view=diff&rev=555835&r1=555834&r2=555835
==============================================================================
--- 
openejb/trunk/openejb3/server/openejb-server/src/main/java/org/apache/openejb/server/Start.java
 (original)
+++ 
openejb/trunk/openejb3/server/openejb-server/src/main/java/org/apache/openejb/server/Start.java
 Thu Jul 12 18:48:53 2007
@@ -16,6 +16,8 @@
  */
 package org.apache.openejb.server;
 
+import org.apache.openejb.util.Connect;
+
 import java.io.File;
 
 import java.io.InputStream;
@@ -24,8 +26,6 @@
 
 import java.lang.reflect.Method;
 
-import java.net.Socket;
-
 import java.util.ArrayList;
 
 import java.util.Iterator;
@@ -50,7 +50,7 @@
 
             forkServerProcess();
 
-            return connect(10);
+            return Connect.connect(10, "localhost", 4201);
 
         } else {
 
@@ -168,45 +168,9 @@
 
     }
 
-    private boolean connect() {
-
-        return connect(1);
-
-    }
-
-    private boolean connect(int tries) {
-
-        try {
-
-            Socket socket = new Socket("localhost", 4201);
-
-            OutputStream out = socket.getOutputStream();
-
-        } catch (Exception e) {
-
-            if (tries < 2) {
-
-                return false;
-
-            } else {
-
-                try {
-
-                    Thread.sleep(2000);
-
-                } catch (Exception e2) {
-
-                    e.printStackTrace();
-
-                }
-
-                return connect(--tries);
-
-            }
-
-        }
+    public static boolean connect() {
 
-        return true;
+        return Connect.connect(1, "localhost", 4201);
 
     }
 


Reply via email to