Source Code Cross Referenced for TextConsole.java in  » J2EE » openejb3 » org » apache » openejb » server » telnet » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » J2EE » openejb3 » org.apache.openejb.server.telnet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */package org.apache.openejb.server.telnet;
017:
018:        import java.io.DataInputStream;
019:
020:        import java.io.IOException;
021:
022:        import java.io.InputStream;
023:
024:        import java.io.PrintStream;
025:
026:        import java.util.Properties;
027:
028:        import org.apache.openejb.util.LogCategory;
029:        import org.apache.openejb.util.Logger;
030:
031:        public class TextConsole {
032:
033:            Logger logger = Logger.getInstance(LogCategory.OPENEJB_ADMIN,
034:                    "org.apache.openejb.server.util.resources");
035:
036:            Properties props;
037:
038:            public TextConsole() {
039:
040:            }
041:
042:            public void init(Properties props) throws Exception {
043:
044:                this .props = props;
045:
046:            }
047:
048:            boolean stop = false;
049:
050:            DataInputStream in = null;
051:
052:            PrintStream out = null;
053:
054:            public static final char ESC = (char) 27;
055:
056:            public static final String TTY_Reset = ESC + "[0m";
057:
058:            public static final String TTY_Bright = ESC + "[1m";
059:
060:            public static final String TTY_Dim = ESC + "[2m";
061:
062:            public static final String TTY_Underscore = ESC + "[4m";
063:
064:            public static final String TTY_Blink = ESC + "[5m";
065:
066:            public static final String TTY_Reverse = ESC + "[7m";
067:
068:            public static final String TTY_Hidden = ESC + "[8m";
069:
070:            /* Foreground Colors */
071:
072:            public static final String TTY_FG_Black = ESC + "[30m";
073:
074:            public static final String TTY_FG_Red = ESC + "[31m";
075:
076:            public static final String TTY_FG_Green = ESC + "[32m";
077:
078:            public static final String TTY_FG_Yellow = ESC + "[33m";
079:
080:            public static final String TTY_FG_Blue = ESC + "[34m";
081:
082:            public static final String TTY_FG_Magenta = ESC + "[35m";
083:
084:            public static final String TTY_FG_Cyan = ESC + "[36m";
085:
086:            public static final String TTY_FG_White = ESC + "[37m";
087:
088:            /* Background Colors */
089:
090:            public static final String TTY_BG_Black = ESC + "[40m";
091:
092:            public static final String TTY_BG_Red = ESC + "[41m";
093:
094:            public static final String TTY_BG_Green = ESC + "[42m";
095:
096:            public static final String TTY_BG_Yellow = ESC + "[43m";
097:
098:            public static final String TTY_BG_Blue = ESC + "[44m";
099:
100:            public static final String TTY_BG_Magenta = ESC + "[45m";
101:
102:            public static final String TTY_BG_Cyan = ESC + "[46m";
103:
104:            public static final String TTY_BG_White = ESC + "[47m";
105:
106:            static String PROMPT = TTY_Reset + TTY_Bright + "[openejb]$ "
107:                    + TTY_Reset;
108:
109:            protected void exec(InputStream input, PrintStream out) {
110:
111:                DataInputStream in = new DataInputStream(input);
112:
113:                while (!stop) {
114:
115:                    prompt(in, out);
116:
117:                }
118:
119:            }
120:
121:            protected void prompt(DataInputStream in, PrintStream out) {
122:
123:                try {
124:
125:                    out.print(PROMPT);
126:
127:                    out.flush();
128:
129:                    String commandline = in.readLine();
130:
131:                    logger.debug("command: " + commandline);
132:
133:                    commandline = commandline.trim();
134:
135:                    if (commandline.length() < 1)
136:                        return;
137:
138:                    String command = commandline;
139:
140:                    Command.Arguments args = null;
141:
142:                    int spacePosition = commandline.indexOf(' ');
143:
144:                    int tabPosition = commandline.indexOf('\t');
145:
146:                    if (spacePosition != -1 || tabPosition != -1) {
147:
148:                        int cutPosition = (spacePosition > tabPosition ? spacePosition
149:                                : tabPosition);
150:
151:                        command = commandline.substring(0, cutPosition);
152:
153:                        args = new Command.Arguments(commandline
154:                                .substring(cutPosition + 1));
155:
156:                    }
157:
158:                    Command cmd = Command.getCommand(command);
159:
160:                    if (cmd == null) {
161:
162:                        out.print(command);
163:
164:                        out.println(": command not found");
165:
166:                    } else {
167:
168:                        cmd.exec(args, in, out);
169:
170:                    }
171:
172:                } catch (UnsupportedOperationException e) {
173:
174:                    this .stop = true;
175:
176:                } catch (Throwable e) {
177:
178:                    e.printStackTrace(new PrintStream(out));
179:
180:                    this .stop = true;
181:
182:                }
183:
184:            }
185:
186:            protected void badCommand(DataInputStream in, PrintStream out)
187:                    throws IOException
188:
189:            {
190:
191:            }
192:
193:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.