Source Code Cross Referenced for VirtualDatabaseAdmin.java in  » Database-JDBC-Connection-Pool » sequoia-2.10.9 » org » continuent » sequoia » console » text » module » 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 » Database JDBC Connection Pool » sequoia 2.10.9 » org.continuent.sequoia.console.text.module 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Sequoia: Database clustering technology.
003:         * Copyright (C) 2002-2004 French National Institute For Research In Computer
004:         * Science And Control (INRIA).
005:         * Copyright (C) 2005 AmicoSoft, Inc. dba Emic Networks
006:         * Contact: sequoia@continuent.org
007:         * 
008:         * Licensed under the Apache License, Version 2.0 (the "License");
009:         * you may not use this file except in compliance with the License.
010:         * You may obtain a copy of the License at
011:         * 
012:         * http://www.apache.org/licenses/LICENSE-2.0
013:         * 
014:         * Unless required by applicable law or agreed to in writing, software
015:         * distributed under the License is distributed on an "AS IS" BASIS,
016:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:         * See the License for the specific language governing permissions and
018:         * limitations under the License. 
019:         *
020:         * Initial developer(s): Emmanuel Cecchet.
021:         * Contributor(s): Mathieu Peltier, Nicolas Modrzyk
022:         */package org.continuent.sequoia.console.text.module;
023:
024:        import java.util.HashSet;
025:        import java.util.Set;
026:
027:        import org.continuent.sequoia.common.i18n.ConsoleTranslate;
028:        import org.continuent.sequoia.common.jmx.mbeans.ControllerMBean;
029:        import org.continuent.sequoia.common.jmx.mbeans.VirtualDatabaseMBean;
030:        import org.continuent.sequoia.console.text.Console;
031:        import org.continuent.sequoia.console.text.ConsoleException;
032:
033:        /**
034:         * This is the Sequoia controller console virtual database administration
035:         * module.
036:         * 
037:         * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
038:         * @author <a href="mailto:Mathieu.Peltier@inrialpes.fr">Mathieu Peltier </a>
039:         * @author <a href="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
040:         * @version 1.0
041:         */
042:        public class VirtualDatabaseAdmin extends AbstractConsoleModule {
043:            private String virtualDbName, login, password;
044:
045:            /**
046:             * Returns the login value.
047:             * 
048:             * @return Returns the login.
049:             */
050:            public String getLogin() {
051:                return login;
052:            }
053:
054:            /**
055:             * Returns the password value.
056:             * 
057:             * @return Returns the password.
058:             */
059:            public String getPassword() {
060:                return password;
061:            }
062:
063:            /**
064:             * Returns the virtualDbName value.
065:             * 
066:             * @return Returns the virtualDbName.
067:             */
068:            public String getVirtualDbName() {
069:                return virtualDbName;
070:            }
071:
072:            /**
073:             * @see org.continuent.sequoia.console.text.module.AbstractConsoleModule#login(java.lang.String[])
074:             */
075:            public void login(String[] params) throws ConsoleException {
076:                // In case a login has failed before
077:                quit = false;
078:                String vdbName = params[0];
079:                console.getConsoleReader().addCompletor(this .getCompletor());
080:                console.getConsoleReader().removeCompletor(
081:                        console.getControllerModule().getCompletor());
082:
083:                if (vdbName == null || vdbName.trim().equals("")) {
084:                    vdbName = console.readLine(ConsoleTranslate
085:                            .get("admin.login.dbname"));
086:                    if (vdbName == null)
087:                        return;
088:                }
089:
090:                login = console.readLine(ConsoleTranslate
091:                        .get("admin.login.user"));
092:                if (login == null)
093:                    return;
094:
095:                password = console.readPassword(ConsoleTranslate
096:                        .get("admin.login.password"));
097:                if (password == null)
098:                    return;
099:
100:                try {
101:                    ControllerMBean mbean = console.getJmxClient()
102:                            .getControllerProxy();
103:                    if (!mbean.getVirtualDatabaseNames().contains(vdbName)) {
104:                        throw new ConsoleException(ConsoleTranslate.get(
105:                                "module.database.invalid", vdbName));
106:                    }
107:                    VirtualDatabaseMBean vdb = console.getJmxClient()
108:                            .getVirtualDatabaseProxy(vdbName, login, password);
109:                    if (!vdb.checkAdminAuthentication(login, password)) {
110:                        throw new ConsoleException(ConsoleTranslate.get(
111:                                "module.database.login.fail", login));
112:                    }
113:                } catch (ConsoleException e) {
114:                    quit();
115:                    throw e;
116:                } catch (Exception e) {
117:                    quit();
118:                    throw new ConsoleException(e);
119:                }
120:
121:                virtualDbName = vdbName;
122:                // Reload commands because target has changed
123:                loadCommands();
124:                console.printInfo(ConsoleTranslate.get("admin.login.ready",
125:                        virtualDbName));
126:            }
127:
128:            /**
129:             * @see org.continuent.sequoia.console.text.module.AbstractConsoleModule#getDescriptionString()
130:             */
131:            public String getDescriptionString() {
132:                return "VirtualDatabase Administration";
133:            }
134:
135:            /**
136:             * @see org.continuent.sequoia.console.text.module.AbstractConsoleModule#getPromptString()
137:             */
138:            public String getPromptString() {
139:                return virtualDbName + "(" + login + ")";
140:            }
141:
142:            /**
143:             * Create a <code>Set</code> of expert commands. This <code>Set</code> of
144:             * commands can be added/removed dynamically to the list of admin commands
145:             * with the methods {@link #addExpertCommands()} and
146:             * {@link #removeExpertCommands()}
147:             * 
148:             * @return the set of expert commands
149:             */
150:            private Set expertCommandsSet() {
151:                Set expertCmds = new HashSet();
152:                String expertCommandsList = loadCommandsFromProperties("admin.expert");
153:                String[] expertCommands = parseCommands(expertCommandsList);
154:                addCommands(expertCommands, expertCmds);
155:                return expertCmds;
156:            }
157:
158:            /**
159:             * Create a <code>Set</code> of debug commands. This <code>Set</code> of
160:             * commands can be added/removed dynamically to the list of admin commands
161:             * with the methods {@link #addDebugCommands()} and
162:             * {@link #removeDebugCommands()}
163:             * 
164:             * @return the set of expert commands
165:             */
166:            private Set debugCommandsSet() {
167:                Set debugCmds = new HashSet();
168:                String debugCommandsList = loadCommandsFromProperties("admin.debug");
169:                String[] debugCommands = parseCommands(debugCommandsList);
170:                addCommands(debugCommands, debugCmds);
171:                return debugCmds;
172:            }
173:
174:            /**
175:             * Add the expert commands to the list of admin commands.
176:             */
177:            public void addExpertCommands() {
178:                commands.addAll(expertCommandsSet());
179:                // reload the completor or the newly added
180:                // commands won't be taken into account
181:                reloadCompletor();
182:            }
183:
184:            /**
185:             * Revmoe the expert commands from the list of admin commands.
186:             */
187:            public void removeExpertCommands() {
188:                commands.removeAll(expertCommandsSet());
189:                // reload the completor or the removed
190:                // commands will still be taken into account
191:                reloadCompletor();
192:            }
193:
194:            /**
195:             * Add the debug commands to the list of admin commands.
196:             */
197:            public void addDebugCommands() {
198:                commands.addAll(debugCommandsSet());
199:                // reload the completor or the newly added
200:                // commands won't be taken into account
201:                reloadCompletor();
202:            }
203:
204:            /**
205:             * Revmoe the debug commands from the list of admin commands.
206:             */
207:            public void removeDebugCommands() {
208:                commands.removeAll(debugCommandsSet());
209:                // reload the completor or the removed
210:                // commands will still be taken into account
211:                reloadCompletor();
212:            }
213:
214:            /**
215:             * Creates a new <code>VirtualDatabaseAdmin</code> instance.
216:             * 
217:             * @param console console console
218:             */
219:            public VirtualDatabaseAdmin(Console console) {
220:                super (console);
221:            }
222:
223:            /**
224:             * @see org.continuent.sequoia.console.text.module.AbstractConsoleModule#getModuleID()
225:             */
226:            protected String getModuleID() {
227:                return "admin"; //$NON-NLS-1$
228:            }
229:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.