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


001:        /**
002:         * Sequoia: Database clustering technology.
003:         * Copyright (C) 2005 Emic Networks.
004:         * Contact: sequoia@continuent.org
005:         * 
006:         * Licensed under the Apache License, Version 2.0 (the "License");
007:         * you may not use this file except in compliance with the License.
008:         * You may obtain a copy of the License at
009:         * 
010:         * http://www.apache.org/licenses/LICENSE-2.0
011:         * 
012:         * Unless required by applicable law or agreed to in writing, software
013:         * distributed under the License is distributed on an "AS IS" BASIS,
014:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:         * See the License for the specific language governing permissions and
016:         * limitations under the License. 
017:         *
018:         * Initial developer(s): Jeff Mesnil.
019:         * Contributor(s): ______________________.
020:         */package org.continuent.sequoia.controller.backend.management;
021:
022:        import java.util.ArrayList;
023:        import java.util.HashMap;
024:        import java.util.HashSet;
025:        import java.util.Iterator;
026:        import java.util.List;
027:        import java.util.Set;
028:
029:        import javax.management.NotCompliantMBeanException;
030:
031:        import org.continuent.sequoia.common.i18n.Translate;
032:        import org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean;
033:        import org.continuent.sequoia.common.locks.TransactionLogicalLock;
034:        import org.continuent.sequoia.common.sql.schema.DatabaseColumn;
035:        import org.continuent.sequoia.common.sql.schema.DatabaseTable;
036:        import org.continuent.sequoia.controller.jmx.AbstractStandardMBean;
037:
038:        /**
039:         * This class defines a DatabaseBackend MBean.
040:         * 
041:         * @author <a href="mailto:emmanuel.cecchet@emicnetworks.com">Emmanuel Cecchet</a>
042:         * @version 1.0
043:         */
044:        public class DatabaseBackend extends AbstractStandardMBean implements 
045:                DatabaseBackendMBean {
046:            private org.continuent.sequoia.controller.backend.DatabaseBackend managedBackend;
047:
048:            /**
049:             * Creates a new Managed <code>DatabaseBackend</code> object
050:             * 
051:             * @param managedBackend the backend that is managed
052:             * @throws NotCompliantMBeanException if this MBean is not JMX compliant
053:             */
054:            public DatabaseBackend(
055:                    org.continuent.sequoia.controller.backend.DatabaseBackend managedBackend)
056:                    throws NotCompliantMBeanException {
057:                super (DatabaseBackendMBean.class);
058:                this .managedBackend = managedBackend;
059:            }
060:
061:            /**
062:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#isInitialized()
063:             */
064:            public boolean isInitialized() throws Exception {
065:                return managedBackend.isInitialized();
066:            }
067:
068:            /**
069:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#isReadEnabled()
070:             */
071:            public boolean isReadEnabled() {
072:                return managedBackend.isReadEnabled();
073:            }
074:
075:            /**
076:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#isWriteEnabled()
077:             */
078:            public boolean isWriteEnabled() {
079:                return managedBackend.isWriteEnabled();
080:            }
081:
082:            /**
083:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#isDisabled()
084:             */
085:            public boolean isDisabled() {
086:                return managedBackend.isDisabled();
087:            }
088:
089:            /**
090:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#enableRead()
091:             */
092:            public void enableRead() {
093:                managedBackend.enableRead();
094:            }
095:
096:            /**
097:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#enableWrite()
098:             */
099:            public void enableWrite() {
100:                managedBackend.enableWrite();
101:            }
102:
103:            /**
104:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#disableRead()
105:             */
106:            public void disableRead() {
107:                managedBackend.disableRead();
108:            }
109:
110:            /**
111:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#disableWrite()
112:             */
113:            public void disableWrite() {
114:                managedBackend.disableWrite();
115:            }
116:
117:            /**
118:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#disable()
119:             */
120:            public void disable() {
121:                managedBackend.disable();
122:            }
123:
124:            /**
125:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#getConnectionTestStatement()
126:             */
127:            public String getConnectionTestStatement() {
128:                return managedBackend.getConnectionTestStatement();
129:            }
130:
131:            /**
132:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#getDriverClassName()
133:             */
134:            public String getDriverClassName() {
135:                return managedBackend.getDriverClassName();
136:            }
137:
138:            /**
139:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#getName()
140:             */
141:            public String getName() {
142:                return managedBackend.getName();
143:            }
144:
145:            /**
146:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#getState()
147:             */
148:            public String getState() {
149:                return managedBackend.getState();
150:            }
151:
152:            /**
153:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#getStateValue()
154:             */
155:            public int getStateValue() {
156:                return managedBackend.getStateValue();
157:            }
158:
159:            /**
160:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#getPendingRequestsDescription(int,
161:             *      boolean, boolean)
162:             */
163:            public List getPendingRequestsDescription(int count,
164:                    boolean fromFirst, boolean clone) {
165:                return managedBackend.getPendingRequestsDescription(count,
166:                        fromFirst, clone);
167:            }
168:
169:            /**
170:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#getActiveTransactions()
171:             */
172:            public List getActiveTransactions() {
173:                return managedBackend.getActiveTransactions();
174:            }
175:
176:            /**
177:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#getURL()
178:             */
179:            public String getURL() {
180:                return managedBackend.getURL();
181:            }
182:
183:            /**
184:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#getTablesNames()
185:             */
186:            public String[] getTablesNames() {
187:                Set uniqueValues = new HashSet(managedBackend.getTables());
188:                Object[] tables = uniqueValues.toArray();
189:                String[] res = new String[tables.length];
190:                for (int i = 0; i < tables.length; i++) {
191:                    DatabaseTable table = (DatabaseTable) tables[i];
192:                    String fqtn = table.getSchema() + "." + table.getName(); //$NON-NLS-1$
193:                    res[i] = fqtn;
194:                }
195:                return res;
196:            }
197:
198:            /**
199:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#getColumnsNames(String)
200:             */
201:            public String[] getColumnsNames(String tableName) {
202:                DatabaseTable theTable = getTable(tableName);
203:
204:                if (theTable == null)
205:                    return null;
206:                // throw new VirtualDatabaseException("no such table");
207:
208:                ArrayList l = theTable.getColumns();
209:
210:                String[] ret = new String[l.size()];
211:
212:                for (int i = 0; i < ret.length; i++) {
213:                    DatabaseColumn column = (DatabaseColumn) l.get(i);
214:                    ret[i] = column.getName();
215:                }
216:                return ret;
217:            }
218:
219:            /**
220:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#getLockInfo(String)
221:             */
222:            public String getLockInfo(String tableName) {
223:                DatabaseTable theTable = getTable(tableName);
224:                if (theTable == null)
225:                    return null;
226:                TransactionLogicalLock tll = theTable.getLock();
227:                if (tll.isLocked()) {
228:                    return Translate.get("backend.locker", tll.getLocker()); //$NON-NLS-1$
229:                    // FIXME: print waiting list ?
230:                } else {
231:                    return Translate.get("backend.no.lock"); //$NON-NLS-1$
232:                }
233:            }
234:
235:            /**
236:             * Retrieves a table from its fully qualified name.
237:             * 
238:             * @param tableName table name under the for <code><schema>.<table></code>
239:             * @return the corresponding table in the current backend
240:             */
241:            private DatabaseTable getTable(String tableName) {
242:                Set uniqueValues = new HashSet(managedBackend.getTables());
243:                Object[] tables = uniqueValues.toArray();
244:
245:                DatabaseTable theTable = null;
246:                for (int i = 0; i < tables.length; i++) {
247:                    DatabaseTable table = (DatabaseTable) tables[i];
248:                    String fqtn = table.getSchema() + "." + table.getName(); //$NON-NLS-1$
249:                    if (fqtn.equals(tableName)) {
250:                        theTable = table;
251:                        break;
252:                    }
253:                }
254:                return theTable;
255:            }
256:
257:            /**
258:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#getStoredProceduresNames()
259:             */
260:            public String[] getStoredProceduresNames() {
261:                HashMap hm = managedBackend.getDatabaseSchema().getProcedures();
262:                Set keys = hm.keySet();
263:                String[] res = new String[keys.size()];
264:                int i = 0;
265:                for (Iterator iter = keys.iterator(); iter.hasNext(); i++) {
266:                    res[i] = (String) iter.next();
267:                }
268:                return res;
269:            }
270:
271:            /**
272:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#isSchemaStatic()
273:             */
274:            public boolean isSchemaStatic() {
275:                return managedBackend.isSchemaStatic();
276:            }
277:
278:            /**
279:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#getDriverPath()
280:             */
281:            public String getDriverPath() {
282:                return managedBackend.getDriverPath();
283:            }
284:
285:            /**
286:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#getLastKnownCheckpoint()
287:             */
288:            public String getLastKnownCheckpoint() {
289:                return managedBackend.getLastKnownCheckpoint();
290:            }
291:
292:            /**
293:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#isJDBCConnected()
294:             */
295:            public boolean isJDBCConnected() {
296:                return managedBackend.isJDBCConnected();
297:            }
298:
299:            /**
300:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#getSchemaXml(boolean)
301:             */
302:            public String getSchemaXml(boolean expandSchema) {
303:                return managedBackend.getSchemaXml(expandSchema);
304:            }
305:
306:            /**
307:             * @see org.continuent.sequoia.common.jmx.mbeans.DatabaseBackendMBean#getXml()
308:             */
309:            public String getXml() {
310:                return managedBackend.getXml();
311:            }
312:
313:            /**
314:             * @see org.continuent.sequoia.controller.jmx.AbstractStandardMBean#getAssociatedString()
315:             */
316:            public String getAssociatedString() {
317:                return "backend"; //$NON-NLS-1$
318:            }
319:
320:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.