01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */package org.apache.openejb.server.telnet;
17:
18: import java.io.DataInputStream;
19: import java.io.IOException;
20: import java.io.PrintStream;
21:
22: //import org.codehaus.groovy.runtime.InvokerHelper;
23: //import groovy.lang.GroovyShell;
24:
25: public class GroovySh extends Command {
26:
27: public static void register() {
28:
29: }
30:
31: public void exec(Arguments args, DataInputStream in, PrintStream out)
32: throws IOException {
33: /* GroovyShell shell = new GroovyShell();
34: BufferedReader reader = new BufferedReader(new InputStreamReader(in));
35:
36: String version = InvokerHelper.getVersion();
37:
38: out.println("Lets get Groovy!");
39: out.println("================");
40: out.println("Version: " + version + " JVM: " + System.getProperty("java.vm.version"));
41: out.println("Hit carriage return twice to execute a command");
42: out.println("The command 'quit' will terminate the shell");
43:
44: int counter = 1;
45: while (true) {
46: StringBuffer buffer = new StringBuffer();
47: while (true) {
48: out.print("groovy> ");
49: String line = reader.readLine();
50: if (line != null) {
51: buffer.append(line);
52: buffer.append('\n');
53: }
54: if (line == null || line.trim().length() == 0) {
55: break;
56: }
57: }
58: String command = buffer.toString().trim();
59: if (command == null || command.equals("quit")) {
60: break;
61: }
62: try {
63: Object answer = shell.evaluate(command, "CommandLine" + counter++ +".groovy");
64: out.println(InvokerHelper.inspect(answer));
65: }
66: catch (Exception e) {
67: out.println("Caught: " + e);
68: e.printStackTrace();
69: }
70: }
71: */}
72: }
|