Source Code Cross Referenced for GTCurrentConnectionsDataSource.java in  » Database-DBMS » mckoi » com » mckoi » database » 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 DBMS » mckoi » com.mckoi.database 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * com.mckoi.database.GTCurrentConnectionsDataSource  23 Mar 2002
003:         *
004:         * Mckoi SQL Database ( http://www.mckoi.com/database )
005:         * Copyright (C) 2000, 2001, 2002  Diehl and Associates, Inc.
006:         *
007:         * This program is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU General Public License
009:         * Version 2 as published by the Free Software Foundation.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License Version 2 for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * Version 2 along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
019:         *
020:         * Change Log:
021:         * 
022:         * 
023:         */package com.mckoi.database;
024:
025:        import java.util.ArrayList;
026:        import java.util.Date;
027:
028:        /**
029:         * An implementation of MutableTableDataSource that presents the current
030:         * list of connections on the database.
031:         * <p>
032:         * NOTE: This is not designed to be a long kept object.  It must not last
033:         *   beyond the lifetime of a transaction.
034:         *
035:         * @author Tobias Downer
036:         */
037:
038:        final class GTCurrentConnectionsDataSource extends GTDataSource {
039:
040:            /**
041:             * The DatabaseConnection object that this is table is modelling the
042:             * information within.
043:             */
044:            private DatabaseConnection database;
045:
046:            /**
047:             * The list of info keys/values in this object.
048:             */
049:            private ArrayList key_value_pairs;
050:
051:            /**
052:             * Constructor.
053:             */
054:            public GTCurrentConnectionsDataSource(DatabaseConnection connection) {
055:                super (connection.getSystem());
056:                this .database = connection;
057:                this .key_value_pairs = new ArrayList();
058:            }
059:
060:            /**
061:             * Initialize the data source.
062:             */
063:            public GTCurrentConnectionsDataSource init() {
064:
065:                UserManager user_manager = database.getDatabase()
066:                        .getUserManager();
067:                // Synchronize over the user manager while we inspect the information,
068:                synchronized (user_manager) {
069:                    for (int i = 0; i < user_manager.userCount(); ++i) {
070:                        User user = user_manager.userAt(i);
071:                        key_value_pairs.add(user.getUserName());
072:                        key_value_pairs.add(user.getConnectionString());
073:                        key_value_pairs
074:                                .add(new Date(user.getLastCommandTime()));
075:                        key_value_pairs.add(new Date(user.getTimeConnected()));
076:                    }
077:                }
078:
079:                return this ;
080:            }
081:
082:            // ---------- Implemented from GTDataSource ----------
083:
084:            public DataTableDef getDataTableDef() {
085:                return DEF_DATA_TABLE_DEF;
086:            }
087:
088:            public int getRowCount() {
089:                return key_value_pairs.size() / 4;
090:            }
091:
092:            public TObject getCellContents(final int column, final int row) {
093:                switch (column) {
094:                case 0: // username
095:                    return columnValue(column, (String) key_value_pairs
096:                            .get(row * 4));
097:                case 1: // host_string
098:                    return columnValue(column, (String) key_value_pairs
099:                            .get((row * 4) + 1));
100:                case 2: // last_command
101:                    return columnValue(column, (Date) key_value_pairs
102:                            .get((row * 4) + 2));
103:                case 3: // time_connected
104:                    return columnValue(column, (Date) key_value_pairs
105:                            .get((row * 4) + 3));
106:                default:
107:                    throw new Error("Column out of bounds.");
108:                }
109:            }
110:
111:            // ---------- Overwritten from GTDataSource ----------
112:
113:            public void dispose() {
114:                super .dispose();
115:                key_value_pairs = null;
116:                database = null;
117:            }
118:
119:            // ---------- Static ----------
120:
121:            /**
122:             * The data table def that describes this table of data source.
123:             */
124:            static final DataTableDef DEF_DATA_TABLE_DEF;
125:
126:            static {
127:
128:                DataTableDef def = new DataTableDef();
129:                def.setTableName(new TableName(Database.SYSTEM_SCHEMA,
130:                        "sUSRCurrentConnections"));
131:
132:                // Add column definitions
133:                def.addColumn(stringColumn("username"));
134:                def.addColumn(stringColumn("host_string"));
135:                def.addColumn(dateColumn("last_command"));
136:                def.addColumn(dateColumn("time_connected"));
137:
138:                // Set to immutable
139:                def.setImmutable();
140:
141:                DEF_DATA_TABLE_DEF = def;
142:
143:            }
144:
145:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.