Source Code Cross Referenced for WrappedPostgisDataStore.java in  » GIS » GeoTools-2.4.1 » org » geotools » data » postgis » 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 » GIS » GeoTools 2.4.1 » org.geotools.data.postgis 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2002-2006, GeoTools Project Managment Committee (PMC)
005:         * 
006:         *    This library is free software; you can redistribute it and/or
007:         *    modify it under the terms of the GNU Lesser General Public
008:         *    License as published by the Free Software Foundation;
009:         *    version 2.1 of the License.
010:         *
011:         *    This library 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 GNU
014:         *    Lesser General Public License for more details.
015:         */
016:        package org.geotools.data.postgis;
017:
018:        import java.io.IOException;
019:        import java.sql.Connection;
020:        import java.sql.SQLException;
021:
022:        import javax.sql.DataSource;
023:
024:        import org.geotools.data.DataSourceException;
025:        import org.geotools.data.Query;
026:        import org.geotools.data.Transaction;
027:        import org.geotools.data.jdbc.ConnectionPool;
028:        import org.geotools.data.jdbc.FeatureTypeHandler;
029:        import org.geotools.data.jdbc.JDBCDataStoreConfig;
030:        import org.geotools.data.jdbc.fidmapper.FIDMapperFactory;
031:        import org.geotools.data.postgis.fidmapper.PostgisFIDMapperFactory;
032:        import org.geotools.data.postgis.fidmapper.VersionedFIDMapperFactory;
033:
034:        /**
035:         * A postgis datastore subclass that provides extra accessors so that the versioned datastore can
036:         * work.<br>
037:         * This class is needed because this way all the JDBC datastore infrastructure can work without the
038:         * need to break its assumptions.<br>
039:         * For example, getSchema() usually returns a feature type that mimics the table structure, but for
040:         * versioned data we have to return one that does not have the versioning columns.
041:         * 
042:         * @author aaime
043:         * @since 2.4
044:         * 
045:         */
046:        class WrappedPostgisDataStore extends PostgisDataStore {
047:
048:            public WrappedPostgisDataStore(DataSource dataSource,
049:                    JDBCDataStoreConfig config, int optimizeMode)
050:                    throws IOException {
051:                super (dataSource, config, optimizeMode);
052:
053:            }
054:
055:            public WrappedPostgisDataStore(DataSource dataSource,
056:                    String schema, String namespace, int optimizeMode)
057:                    throws IOException {
058:                super (dataSource, schema, namespace, optimizeMode);
059:
060:            }
061:
062:            public WrappedPostgisDataStore(DataSource dataSource,
063:                    String schema, String namespace) throws IOException {
064:                super (dataSource, schema, namespace);
065:
066:            }
067:
068:            public WrappedPostgisDataStore(DataSource dataSource,
069:                    String namespace) throws IOException {
070:                super (dataSource, namespace);
071:
072:            }
073:
074:            public WrappedPostgisDataStore(DataSource dataSource)
075:                    throws IOException {
076:                super (dataSource);
077:
078:            }
079:
080:            /**
081:             * Overridden to store a versioned jdbc transaction state instead
082:             */
083:            public Connection getConnection(Transaction transaction)
084:                    throws IOException {
085:                if (transaction != Transaction.AUTO_COMMIT) {
086:                    // we will need to save a JDBC connection is
087:                    // transaction.putState( connectionPool, JDBCState )
088:                    // throw new UnsupportedOperationException("Transactions not
089:                    // supported yet");
090:
091:                    VersionedJdbcTransactionState state;
092:
093:                    state = getVersionedJdbcTransactionState(transaction);
094:                    return state.getConnection();
095:                }
096:
097:                try {
098:                    return createConnection();
099:                } catch (SQLException sqle) {
100:                    throw new DataSourceException("Connection failed:" + sqle,
101:                            sqle);
102:                }
103:            }
104:
105:            /**
106:             * Returns the versioned jdbc transaction state, eventually
107:             * 
108:             * @param transaction
109:             * @return
110:             * @throws IOException
111:             * @throws DataSourceException
112:             */
113:            protected VersionedJdbcTransactionState getVersionedJdbcTransactionState(
114:                    Transaction transaction) throws IOException,
115:                    DataSourceException {
116:                synchronized (transaction) {
117:                    VersionedJdbcTransactionState state;
118:                    state = (VersionedJdbcTransactionState) transaction
119:                            .getState(this );
120:
121:                    if (state == null) {
122:                        try {
123:                            Connection conn = createConnection();
124:                            conn.setAutoCommit(requireAutoCommit());
125:                            if (getTransactionIsolation() != Connection.TRANSACTION_NONE) {
126:                                // for us, NONE means use the default, which is
127:                                // usually READ_COMMITTED
128:                                conn
129:                                        .setTransactionIsolation(getTransactionIsolation());
130:                            }
131:                            state = new VersionedJdbcTransactionState(conn,
132:                                    this );
133:                            transaction.putState(this , state);
134:                        } catch (SQLException eep) {
135:                            throw new DataSourceException("Connection failed:"
136:                                    + eep, eep);
137:                        }
138:                    }
139:                    return state;
140:                }
141:            }
142:
143:            protected FIDMapperFactory buildFIDMapperFactory(
144:                    JDBCDataStoreConfig config) {
145:                return new VersionedFIDMapperFactory(
146:                        new PostgisFIDMapperFactory(config));
147:            }
148:
149:            public String[] propertyNames(Query query) throws IOException {
150:                return super .propertyNames(query);
151:            }
152:
153:            public JDBCDataStoreConfig getConfig() {
154:                return config;
155:            }
156:
157:            public FeatureTypeHandler getTypeHandler() {
158:                return typeHandler;
159:            }
160:
161:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.