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


001:        /**
002:         * Sequoia: Database clustering technology.
003:         * Copyright (C) 2005 Continuent, Inc.
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): Edward Archibald
019:         * Contributor(s): Emmanuel Cecchet
020:         */package org.continuent.sequoia.common.sql.schema;
021:
022:        import java.util.SortedSet;
023:        import java.util.TreeSet;
024:
025:        /**
026:         * This class defines the semantic associated to a stored procedure. This
027:         * includes the references this stored procedure has to database tables or other
028:         * stored procedures and semantic properties such as if the stored procedure can
029:         * be executed out of order or not.
030:         * 
031:         * @author <a href="mailto:ed.archibald@continuent.com">Edward Archibald</a>
032:         * @author <a href="mailto:emmanuel.cecchet@continuent.com">Emmanuel Cecchet
033:         *         </a>
034:         * @version 1.0
035:         */
036:        public class DatabaseProcedureSemantic {
037:            /**
038:             * Sorted list of table names that are referenced by this procedure.
039:             */
040:            private SortedSet writeTables = null;
041:
042:            /**
043:             * If this procedure references other procedures, we will set them here.
044:             */
045:            private SortedSet proceduresReferenced = null;
046:
047:            /**
048:             * The following attributes are meant to communicate some information about
049:             * how the procedure is used, semantically, by the calling application. Note
050:             * that the default values are meant to communicate the most restrictive
051:             * semantic case which would require the stored procedure to be executed in
052:             * isolation.
053:             */
054:
055:            /** procedure has one or more SELECT statements */
056:            private boolean hasSelect = true;
057:
058:            /** procedure has one or more INSERT statements */
059:            private boolean hasInsert = true;
060:
061:            /** procedure has one or more UPDATE statements */
062:            private boolean hasUpdate = true;
063:
064:            /** procedure has one or more DELETE statements */
065:            private boolean hasDelete = true;
066:
067:            /** procedure has one or more DDL statements */
068:            private boolean hasDDLWrite = true;
069:
070:            /** procedure has one or more internally managed transactions */
071:            private boolean hasTransaction = true;
072:
073:            /**
074:             * procedure executes read operations that may be causally dependent on the
075:             * completion of a preceeding write statement executed by the same application
076:             * client but on a different connection
077:             */
078:            private boolean isCausallyDependent = true;
079:
080:            /**
081:             * procedure execution is commutative with other procedures and SQL
082:             * statements, which affect the same tables, and which are also commutative
083:             */
084:            private boolean isCommutative = false;
085:
086:            /**
087:             * This semantic information is the default semantic information for stored
088:             * procedures. It is used when no specific
089:             */
090:            private boolean useDefaultSemantic = false;
091:
092:            /**
093:             * Creates a new <code>DatabaseProcedureSemantic</code> object
094:             * 
095:             * @param hasSelect true if this procedure has one or more SELECT statements
096:             * @param hasInsert true if this procedure has one or more INSERT statements
097:             * @param hasUpdate true if this procedure has one or more UPDATE statements
098:             * @param hasDelete true if this procedure has one or more DELETE statements
099:             * @param hasDDLWrite true if this procedure has one or more DDL statements
100:             * @param hasTransaction true if this procedure has one or more internally
101:             *          managed transactions
102:             * @param isCausallyDependent true if this procedure executes read operations
103:             *          that may be causally dependent on the completion of a preceeding
104:             *          write statement executed by the same application client but on a
105:             *          different connection
106:             * @param isCommutative true if this procedure execution is commutative with
107:             *          other procedures and SQL statements, which affect the same tables,
108:             *          and which are also commutative
109:             */
110:            public DatabaseProcedureSemantic(boolean hasSelect,
111:                    boolean hasInsert, boolean hasUpdate, boolean hasDelete,
112:                    boolean hasDDLWrite, boolean hasTransaction,
113:                    boolean isCausallyDependent, boolean isCommutative) {
114:                this .hasSelect = hasSelect;
115:                this .hasInsert = hasInsert;
116:                this .hasUpdate = hasUpdate;
117:                this .hasDelete = hasDelete;
118:                this .hasDDLWrite = hasDDLWrite;
119:                this .hasTransaction = hasTransaction;
120:                this .isCausallyDependent = isCausallyDependent;
121:                this .isCommutative = isCommutative;
122:            }
123:
124:            /**
125:             * Add the name of a table that is written by this stored procedure.
126:             * 
127:             * @param tableName the name of updated table
128:             */
129:            public void addWriteTable(String tableName) {
130:                if (writeTables == null)
131:                    writeTables = new TreeSet();
132:
133:                writeTables.add(tableName);
134:            }
135:
136:            /**
137:             * Add a reference to a stored procedure called by this stored procedure.
138:             * 
139:             * @param procKey the unique key of the referenced stored procedure as
140:             *          returned by DatabaseProcedure.getKey()
141:             */
142:            public void addProcedureRef(String procKey) {
143:                if (proceduresReferenced == null)
144:                    proceduresReferenced = new TreeSet();
145:
146:                proceduresReferenced.add(procKey);
147:            }
148:
149:            /**
150:             * Returns the name of the stored procedures referenced by this stored
151:             * procedure.
152:             * 
153:             * @return Returns the procedures referenced.
154:             */
155:            public SortedSet getProceduresReferenced() {
156:                return proceduresReferenced;
157:            }
158:
159:            /**
160:             * Returns the names of the tables that are written by this stored procedure.
161:             * 
162:             * @return Returns the name of updated tables.
163:             */
164:            public SortedSet getWriteTables() {
165:                return writeTables;
166:            }
167:
168:            /**
169:             * Returns true if this procedure has one or more DDL statements.
170:             * 
171:             * @return true if the stored procedure executes DDL statements.
172:             */
173:            public boolean hasDDLWrite() {
174:                return hasDDLWrite;
175:            }
176:
177:            /**
178:             * Returns true if this procedure has one or more DELETE statements.
179:             * 
180:             * @return true if the stored procedure executes DELETE statements.
181:             */
182:            public boolean hasDelete() {
183:                return hasDelete;
184:            }
185:
186:            /**
187:             * Returns true if this procedure has one or more INSERT statements.
188:             * 
189:             * @return true if the stored procedure executes INSERT statements.
190:             */
191:            public boolean hasInsert() {
192:                return hasInsert;
193:            }
194:
195:            /**
196:             * Returns true if this procedure has one or more SELECT statements.
197:             * 
198:             * @return true if the stored procedure executes SELECT statements.
199:             */
200:            public boolean hasSelect() {
201:                return hasSelect;
202:            }
203:
204:            /**
205:             * Returns true true if this procedure has one or more internally managed
206:             * transactions
207:             * 
208:             * @return true if the stored procedure executes transactions.
209:             */
210:            public boolean hasTransaction() {
211:                return hasTransaction;
212:            }
213:
214:            /**
215:             * Returns true if this procedure has one or more UPDATE statements.
216:             * 
217:             * @return true if the stored procedure executes UPDATE statements.
218:             */
219:            public boolean hasUpdate() {
220:                return hasUpdate;
221:            }
222:
223:            /**
224:             * Returns true if the procedure execution is commutative with other
225:             * procedures and SQL statements, which affect the same tables, and which are
226:             * also commutative
227:             * 
228:             * @return Returns true if the stored procedure execution is commutative.
229:             */
230:            public boolean isCommutative() {
231:                return isCommutative;
232:            }
233:
234:            /**
235:             * Returns true if the procedure executes read operations that may be causally
236:             * dependent on the completion of a preceeding write statement executed by the
237:             * same application client but on a different connection
238:             * 
239:             * @return true if the stored procedure is causally dependent with preceeding
240:             *         write statements
241:             */
242:            public boolean isCausallyDependent() {
243:                return isCausallyDependent;
244:            }
245:
246:            /**
247:             * Returns true if this stored procedure has only select statements.
248:             * 
249:             * @return true if stored procedure is read-only.
250:             */
251:            public boolean isReadOnly() {
252:                return (hasSelect && !(hasInsert || hasUpdate || hasDelete || hasDDLWrite));
253:            }
254:
255:            /**
256:             * Returns if default stored procedure semantic is used or not.
257:             * 
258:             * @return true if default stored procedure semantic must be used
259:             */
260:            public boolean isUseDefaultSemantic() {
261:                return useDefaultSemantic;
262:            }
263:
264:            /**
265:             * Set the default stored procedure semantic usage.
266:             * 
267:             * @param isDefault true if default semantic must be usde
268:             */
269:            public void setUseDefaultSemantic(boolean isDefault) {
270:                this .useDefaultSemantic = isDefault;
271:            }
272:
273:            /**
274:             * Returns true if stored procedure executes a statement that updates the
275:             * database (insert, update, delete or DDL).
276:             * 
277:             * @return true if the stored procedure executes write statements
278:             */
279:            public boolean isWrite() {
280:                return hasInsert || hasUpdate || hasDelete || hasDDLWrite;
281:            }
282:
283:            /**
284:             * @see java.lang.Object#toString()
285:             */
286:            public String toString() {
287:                return "isReadOnly:" + isReadOnly() + " - isWrite:" + isWrite()
288:                        + " - hasDDLWrite:" + hasDDLWrite()
289:                        + " - isCommutative:" + isCommutative
290:                        + " - hasTransaction:" + hasTransaction
291:                        + " - write tables:" + writeTables
292:                        + " - procedures referenced:" + proceduresReferenced;
293:            }
294:
295:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.