Source Code Cross Referenced for SchedulerDatabaseSchema.java in  » Database-JDBC-Connection-Pool » sequoia-2.10.9 » org » continuent » sequoia » controller » scheduler » schema » 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.scheduler.schema 
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:         * Contact: sequoia@continuent.org
006:         * 
007:         * Licensed under the Apache License, Version 2.0 (the "License");
008:         * you may not use this file except in compliance with the License.
009:         * You may obtain a copy of the License at
010:         * 
011:         * http://www.apache.org/licenses/LICENSE-2.0
012:         * 
013:         * Unless required by applicable law or agreed to in writing, software
014:         * distributed under the License is distributed on an "AS IS" BASIS,
015:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016:         * See the License for the specific language governing permissions and
017:         * limitations under the License. 
018:         *
019:         * Initial developer(s): Emmanuel Cecchet.
020:         * Contributor(s): _________________________.
021:         */package org.continuent.sequoia.controller.scheduler.schema;
022:
023:        import java.util.ArrayList;
024:        import java.util.Collection;
025:        import java.util.Iterator;
026:
027:        import org.continuent.sequoia.common.sql.schema.DatabaseSchema;
028:        import org.continuent.sequoia.common.sql.schema.DatabaseTable;
029:
030:        /**
031:         * A <code>SchedulerDatabaseSchema</code> describes all the tables and columns
032:         * of a database and its associated cache entries.
033:         * 
034:         * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
035:         * @version 1.0
036:         */
037:        public class SchedulerDatabaseSchema {
038:            /** <code>ArrayList</code> of <code>SchedulerDatabaseTable</code>. */
039:            private ArrayList tables;
040:
041:            private TransactionExclusiveLock lock = new TransactionExclusiveLock();
042:
043:            /**
044:             * Creates a new <code>SchedulerDatabaseSchema</code> instance by cloning an
045:             * existing <code>DatabaseSchema</code>.
046:             * 
047:             * @param schema the database schema to clone
048:             */
049:            public SchedulerDatabaseSchema(DatabaseSchema schema) {
050:                if (schema == null) {
051:                    tables = new ArrayList();
052:                    return;
053:                }
054:
055:                // Clone the tables
056:                Collection origTables = schema.getTables().values();
057:                int size = origTables.size();
058:                tables = new ArrayList(size);
059:                for (Iterator iter = origTables.iterator(); iter.hasNext();)
060:                    tables.add(new SchedulerDatabaseTable((DatabaseTable) iter
061:                            .next()));
062:            }
063:
064:            /**
065:             * Adds a <code>SchedulerDatabaseTable</code> describing a table of the
066:             * database.
067:             * 
068:             * @param table the table to add
069:             */
070:            public void addTable(SchedulerDatabaseTable table) {
071:                tables.add(table);
072:            }
073:
074:            /**
075:             * Removes a <code>SchedulerDatabaseTable</code> describing a table of the
076:             * database.
077:             * 
078:             * @param table the table to remove
079:             */
080:            public void removeTable(SchedulerDatabaseTable table) {
081:                tables.remove(table);
082:            }
083:
084:            /**
085:             * Merge the given schema with the current one. All missing tables are added
086:             * if no conflict is detected. An exception is thrown if the given schema
087:             * definition conflicts with the current one.
088:             * 
089:             * @param databaseSchema the schema to merge
090:             */
091:            public void mergeSchema(SchedulerDatabaseSchema databaseSchema) {
092:                if (databaseSchema == null)
093:                    return;
094:
095:                ArrayList otherTables = databaseSchema.getTables();
096:                if (otherTables == null)
097:                    return;
098:
099:                int size = otherTables.size();
100:                for (int i = 0; i < size; i++) {
101:                    SchedulerDatabaseTable t = (SchedulerDatabaseTable) otherTables
102:                            .get(i);
103:                    SchedulerDatabaseTable original = getTable(t.getName());
104:                    if (original == null)
105:                        addTable(t);
106:                }
107:            }
108:
109:            /**
110:             * Returns an <code>ArrayList</code> of <code>SchedulerDatabaseTable</code>
111:             * objects describing the database.
112:             * 
113:             * @return an <code>ArrayList</code> of <code>SchedulerDatabaseTable</code>
114:             */
115:            public ArrayList getTables() {
116:                return tables;
117:            }
118:
119:            /**
120:             * Returns the <code>SchedulerDatabaseTable</code> object matching the given
121:             * table name or <code>null</code> if not found. Matching is case
122:             * insensitive.
123:             * 
124:             * @param tableName the table name to look for
125:             * @return a <code>SchedulerDatabaseTable</code> value or null
126:             */
127:            public SchedulerDatabaseTable getTable(String tableName) {
128:                SchedulerDatabaseTable t;
129:                int size = tables.size();
130:                for (int i = 0; i < size; i++) {
131:                    t = (SchedulerDatabaseTable) tables.get(i);
132:                    if (tableName.equalsIgnoreCase(t.getName()))
133:                        return t;
134:                }
135:                return null;
136:            }
137:
138:            /**
139:             * Returns <code>true</code> if the given <code>TableName</code> is found
140:             * in this schema.
141:             * 
142:             * @param tableName the name of the table you are looking for
143:             * @return <code>true</code> if the table has been found
144:             */
145:            public boolean hasTable(String tableName) {
146:                int size = tables.size();
147:                for (int i = 0; i < size; i++) {
148:                    SchedulerDatabaseTable t = (SchedulerDatabaseTable) tables
149:                            .get(i);
150:                    if (tableName.equals(t.getName()))
151:                        return true;
152:                }
153:                return false;
154:            }
155:
156:            /**
157:             * Returns the lock for this table.
158:             * 
159:             * @return a <code>TransactionExclusiveLock</code> instance
160:             * @see TransactionExclusiveLock
161:             */
162:            public TransactionExclusiveLock getLock() {
163:                return lock;
164:            }
165:
166:            /**
167:             * Two <code>SchedulerDatabaseSchema</code> are equals if they have the same
168:             * tables.
169:             * 
170:             * @param other the object to compare with
171:             * @return true if the objects are the same
172:             */
173:            public boolean equals(Object other) {
174:                if (!(other instanceof  SchedulerDatabaseSchema))
175:                    return false;
176:
177:                if (tables == null)
178:                    return ((SchedulerDatabaseSchema) other).getTables() == null;
179:                else
180:                    return tables.equals(((SchedulerDatabaseSchema) other)
181:                            .getTables());
182:            }
183:
184:            /**
185:             * Returns information about the database schema.
186:             * 
187:             * @param longFormat <code>true</code> for a <code>long</code> format,
188:             *          <code>false</code> for a short summary
189:             * @return a <code>String</code> value
190:             */
191:            public String getInformation(boolean longFormat) {
192:                StringBuffer result = new StringBuffer();
193:                SchedulerDatabaseTable t;
194:                int size = tables.size();
195:                for (int i = 0; i < size; i++) {
196:                    t = (SchedulerDatabaseTable) tables.get(i);
197:                    result.append(t.getInformation(longFormat));
198:                    result.append(System.getProperty("line.separator"));
199:                }
200:                return result.toString();
201:            }
202:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.