1 46 47 package groovy.j2ee; 48 49 import groovy.lang.GroovyObject; 50 import groovy.lang.GroovyShell; 51 52 import java.util.Properties ; 53 54 import javax.naming.Context ; 55 import javax.naming.InitialContext ; 56 57 import org.codehaus.groovy.runtime.InvokerHelper; 58 59 65 public class J2eeConsole { 66 67 public static void main(String [] args) { 68 if (args.length <= 0) { 69 System.out.println("Usage: home [configuaration] [localcopy]"); 70 return; 71 } 72 73 String home = args[0]; 74 75 Properties p = new Properties (); 76 System.setProperty("openejb.home", home); 77 p.put(Context.INITIAL_CONTEXT_FACTORY, "org.openejb.client.LocalInitialContextFactory"); 78 p.put("openejb.loader", "embed"); 79 p.put("openejb.home", home); 80 81 if (args.length > 1) { 82 String conf = args[1]; 83 System.setProperty("openejb.configuration", conf); 84 p.put("openejb.configuration", conf); 85 } 86 if (args.length > 2) { 87 String copy = args[2]; 88 System.setProperty("openejb.localcopy", copy); 89 p.put("openejb.localcopy", copy); 90 } 91 try { 92 InitialContext ctx = new InitialContext (p); 93 94 GroovyShell shell = new GroovyShell(); 95 shell.setVariable("context", ctx); 96 98 GroovyObject console = (GroovyObject) InvokerHelper.invokeConstructor("groovy.ui.Console", null); 100 console.setProperty("shell", shell); 101 console.invokeMethod("run", null); 102 104 } 105 catch (Exception e) { 106 System.out.println("Caught: " + e); 107 } 108 } 109 } 110 | Popular Tags |