[jboss-cvs] JBossAS SVN: r77450 - trunk/ejb3/src/main/org/jboss/ejb3/client.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Aug 25 14:26:15 EDT 2008


Author: scott.stark at jboss.org
Date: 2008-08-25 14:26:15 -0400 (Mon, 25 Aug 2008)
New Revision: 77450

Modified:
   trunk/ejb3/src/main/org/jboss/ejb3/client/ClientLauncher.java
Log:
JBAS-5888, add launcher specific arguments:
-remotingDelgatesToTCL : true if remoting should first delegate to the the tcl based class loader
-extraClassPath : comma separated list of vfsurls for additional classpath


Modified: trunk/ejb3/src/main/org/jboss/ejb3/client/ClientLauncher.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/client/ClientLauncher.java	2008-08-25 17:48:07 UTC (rev 77449)
+++ trunk/ejb3/src/main/org/jboss/ejb3/client/ClientLauncher.java	2008-08-25 18:26:15 UTC (rev 77450)
@@ -87,6 +87,10 @@
    private static BasicXMLDeployer deployer;
    /** The mainClass used by the ClientContainer */
    private static Class<?> theMainClass;
+   /** Should the remoting class loader delegate to the tcl */
+   private static boolean remotingDelgatesToTCL = true;
+   /** Additional classpath elements to client container classpath */
+   private static List<String> extraClassPath = new ArrayList<String>();
 
    
    public static Class<?> getTheMainClass()
@@ -172,7 +176,7 @@
       throws Throwable
    {
       // Init the kernel and deployers
-      init();
+      args = init(args);
 
       // Pass in the jndi env properties so InitialContext() works
       if(jndiEnv != null)
@@ -184,7 +188,8 @@
          }
       }
       // Have the remoting class loader delegate to the tcl
-      System.setProperty(Remoting.CLASSLOADING_PARENT_FIRST_DELEGATION_PROP, "false");
+      if(remotingDelgatesToTCL)
+         System.setProperty(Remoting.CLASSLOADING_PARENT_FIRST_DELEGATION_PROP, "false");
 
       // Setup the 
       ArrayList<BeanMetaDataFactory> beanFactories = new ArrayList<BeanMetaDataFactory>();
@@ -217,6 +222,12 @@
             log.debug(path);
             roots.add(path);
          }
+         for(String path : extraClassPath)
+         {
+            log.debug(path);
+            roots.add(path);
+         }
+         log.debug("End classpath");
          factory.setRoots(roots);
          beanFactories.add(factory);
          // ClientContainer(xml, mainClass, applicationClientName, jndiEnv);
@@ -318,8 +329,21 @@
       }
    }
 
-   private static void init() throws Throwable
+   /**
+    * Initialize the mc kernel and deployer as well as extract any client
+    * launcher specific args from the input arguments.
+    * 
+    * @param args - the input args to both the launcher and the client main. The
+    * launcher specific arguments are:
+    *   -remotingDelgatesToTCL : true if remoting should first delegate to the the tcl based class loader
+    *   -extraClassPath : comma separated list of vfsurls for additional classpath
+    * @return the remaining arguments to pass to the client main.
+    * @throws Throwable
+    */
+   private static String[] init(String[] args) throws Throwable
    {
+      // Extract any launcher args from the input
+      String[] newArgs = parseArgs(args);
       // Bootstrap the kernel
       AbstractBootstrap bootstrap = new BasicBootstrap();
       bootstrap.run();
@@ -328,7 +352,44 @@
       // Create the deployer
       deployer = createDeployer();
 
+      return newArgs;
    }
+   /**
+    * Extract the launcher specific arguments from the arguments array.
+    * @see #init(String[])
+    * @param args - the input args to both the launcher and the client main.
+    * @return the remaining arguments to pass to the client main.
+    */
+   private static String[] parseArgs(String[] args)
+   {
+      ArrayList<String> tmp = new ArrayList<String>();
+      for(int n = 0; n < args.length; n ++)
+      {
+         String arg = args[n];
+         if(arg.equalsIgnoreCase("-remotingDelgatesToTCL"))
+         {
+            remotingDelgatesToTCL = Boolean.parseBoolean(args[++ n]);
+         }
+         else if(arg.equalsIgnoreCase("-extraClassPath"))
+         {
+            // Split classpath elements based on ','
+            String cparg = args[++ n];
+            String[] cp = cparg.split(",");
+            for(String path : cp)
+            {
+               extraClassPath.add(path);
+            }
+            log.debug("Set extraClassPath to: "+extraClassPath);
+         }
+         else
+         {
+            tmp.add(arg);
+         }
+      }
+      String[] newArgs = new String[tmp.size()];
+      tmp.toArray(newArgs);
+      return newArgs;
+   }
 
    private static BasicXMLDeployer createDeployer()
    {




More information about the jboss-cvs-commits mailing list