geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject cvs commit: incubator-geronimo/modules/twiddle/src/java/org/apache/geronimo/twiddle/cli Main.java
Date Mon, 25 Aug 2003 15:49:13 GMT
jdillon     2003/08/25 08:49:13

  Modified:    modules/twiddle/src/java/org/apache/geronimo/twiddle
                        Twiddle.java
               modules/twiddle/src/java/org/apache/geronimo/twiddle/cli
                        Main.java
  Log:
   o Tighter integration with Classworlds
  
  Revision  Changes    Path
  1.8       +21 -3     incubator-geronimo/modules/twiddle/src/java/org/apache/geronimo/twiddle/Twiddle.java
  
  Index: Twiddle.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/twiddle/src/java/org/apache/geronimo/twiddle/Twiddle.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Twiddle.java	24 Aug 2003 11:20:17 -0000	1.7
  +++ Twiddle.java	25 Aug 2003 15:49:13 -0000	1.8
  @@ -61,6 +61,8 @@
   import java.io.StringWriter;
   import java.io.PrintWriter;
   
  +import com.werken.classworlds.ClassWorld;
  +
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   
  @@ -92,6 +94,9 @@
       /** The input/output context. */
       protected IOContext io;
       
  +    /** The class world to isolate classes. */
  +    protected ClassWorld world;
  +    
       /** The command container. */
       protected CommandContainer container;
       
  @@ -101,13 +106,17 @@
       /**
        * Construct a <code>Twiddle</code> command processor.
        */
  -    public Twiddle(final IOContext io)
  +    public Twiddle(final IOContext io, final ClassWorld world)
       {
           if (io == null) {
               throw new NullArgumentException("io");
           }
  +        if (world == null) {
  +            throw new NullArgumentException("world");
  +        }
           
           this.io = io;
  +        this.world = world;
           this.container = new CommandContainer();
           this.executor = new CommandExecutor(container);
       }
  @@ -116,9 +125,18 @@
        * Construct a <code>Twiddle</code> command processor using system
        * defaults for the input/output context.
        */
  +    public Twiddle(final ClassWorld world)
  +    {
  +        this(new IOContext(System.in, System.out, System.err), world);
  +    }
  +    
  +    /**
  +     * Construct a <code>Twiddle</code> command processor using system
  +     * defaults for the input/output context and a default class world.
  +     */
       public Twiddle()
       {
  -        this(new IOContext(System.in, System.out, System.err));
  +        this(new ClassWorld());
       }
       
       /**
  
  
  
  1.9       +42 -11    incubator-geronimo/modules/twiddle/src/java/org/apache/geronimo/twiddle/cli/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/twiddle/src/java/org/apache/geronimo/twiddle/cli/Main.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Main.java	24 Aug 2003 22:45:40 -0000	1.8
  +++ Main.java	25 Aug 2003 15:49:13 -0000	1.9
  @@ -63,6 +63,8 @@
   import java.net.URL;
   import java.net.URLDecoder;
   
  +import com.werken.classworlds.ClassWorld;
  +
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   import org.apache.commons.logging.impl.LogFactoryImpl;
  @@ -75,11 +77,11 @@
   import org.apache.commons.cli.OptionBuilder;
   import org.apache.commons.cli.ParseException;
   
  -import org.apache.geronimo.twiddle.Twiddle;
  +import org.apache.geronimo.common.NullArgumentException;
   
  +import org.apache.geronimo.twiddle.Twiddle;
   import org.apache.geronimo.twiddle.config.Configuration;
   import org.apache.geronimo.twiddle.config.ConfigurationReader;
  -
   import org.apache.geronimo.twiddle.util.HelpFormatter;
   
   /**
  @@ -91,20 +93,29 @@
   {
       static {
           // Add our default Commons Logger that support the trace level
  -        if(System.getProperty(LogFactoryImpl.LOG_PROPERTY) == null) {
  +        if (System.getProperty(LogFactoryImpl.LOG_PROPERTY) == null) {
               System.setProperty(LogFactoryImpl.LOG_PROPERTY, "org.apache.geronimo.core.log.CachingLog4jLog");
           }
       }
       
       private static final Log log = LogFactory.getLog(Main.class);
       
  -    /** Platform dependent line separator. */
  -    private static final String LINE_SEPARATOR = System.getProperty("line.separator");
  -    
       private String filename = "etc/twiddle.conf";
  +    private ClassWorld world;
  +    
  +    public Main(final ClassWorld world)
  +    {
  +        if (world == null) {
  +            throw new NullArgumentException("world");
  +        }
  +        
  +        this.world = world;
  +    }
       
  -    public String[] processCommandLine(final String[] args) throws Exception
  +    private String[] processCommandLine(final String[] args) throws Exception
       {
  +        assert args != null;
  +        
           // create the Options
           Options options = new Options();
           options.addOption(OptionBuilder.withLongOpt("help")
  @@ -171,6 +182,10 @@
       
       public void boot(String[] args) throws Exception
       {
  +        if (args == null) {
  +            throw new NullArgumentException("args");
  +        }
  +        
           // Process command-line options
           args = processCommandLine(args);
           
  @@ -194,7 +209,7 @@
           ConfigurationReader reader = new ConfigurationReader();
           Configuration config = reader.read(configURL);
           
  -        Twiddle twiddle = new Twiddle();
  +        Twiddle twiddle = new Twiddle(world);
           twiddle.configure(config);
           
           if (args.length != 0) {
  @@ -210,9 +225,25 @@
           }
       }
       
  +    public static void main(final String[] args, final ClassWorld world)
  +    {
  +        // args & world are checked for null by Main
  +        
  +        try {
  +            Main main = new Main(world);
  +            main.boot(args);
  +        }
  +        catch (Exception e) {
  +            e.printStackTrace();
  +            System.exit(-1);
  +        }
  +    }
  +    
       public static void main(final String[] args) throws Exception
       {
  -        Main main = new Main();
  -        main.boot(args);
  +        // args are checked for null by Main
  +        
  +        ClassWorld world = new ClassWorld();
  +        main(args, world);
       }
   }
  
  
  

Mime
View raw message