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


001:        /*
002:         *    GeoLBS - OpenSource Location Based Servces toolkit
003:         *    (C) 2004, Julian J. Ray, All Rights Reserved
004:         *
005:         *    This library is free software; you can redistribute it and/or
006:         *    modify it under the terms of the GNU Lesser General Public
007:         *    License as published by the Free Software Foundation;
008:         *    version 2.1 of the License.
009:         *
010:         *    This library is distributed in the hope that it will be useful,
011:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
012:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
013:         *    Lesser General Public License for more details.
014:         *
015:         */
016:
017:        package org.geotools.data.geomedia;
018:
019:        import java.io.IOException;
020:        import java.sql.SQLException;
021:        import java.util.Map;
022:        import java.util.Collections;
023:        import java.util.logging.Logger;
024:
025:        import org.geotools.data.DataSourceException;
026:        import org.geotools.data.DataStore;
027:        import org.geotools.data.DataStoreFactorySpi;
028:        import org.geotools.data.jdbc.ConnectionPool;
029:
030:        /**
031:         * Creates a GeoMediaDataStoreFactoru based on the correct params.
032:         * 
033:         * <p>
034:         * This factory should be registered in the META-INF/ folder, under services/ in the DataStoreFactorySpi file.
035:         * </p>
036:         *
037:         * @author Jody Garnett, Refractions Research
038:         * @author Sean Geoghegan, Defence Science and Technology Organisation
039:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/geomedia/src/main/java/org/geotools/data/geomedia/GeoMediaDataStoreFactory.java $
040:         */
041:        public class GeoMediaDataStoreFactory implements  DataStoreFactorySpi {
042:            /** A logger for logging */
043:            private static final Logger LOGGER = org.geotools.util.logging.Logging
044:                    .getLogger("org.geotools.data.geomedia");
045:
046:            /** DOCUMENT ME! */
047:            private GeoMediaConnectionParam[] mConnectionParams = null;
048:
049:            /**
050:             * Creates a new instance of GeoMediaDataStoreFactory
051:             */
052:            public GeoMediaDataStoreFactory() {
053:            }
054:
055:            /**
056:             * DOCUMENT ME!
057:             *
058:             * @param params DOCUMENT ME!
059:             */
060:            public void setConnectionParams(GeoMediaConnectionParam[] params) {
061:                mConnectionParams = params;
062:            }
063:
064:            /**
065:             * DOCUMENT ME!
066:             *
067:             * @return DOCUMENT ME!
068:             */
069:            public GeoMediaConnectionParam[] getConnectionParams() {
070:                return mConnectionParams;
071:            }
072:
073:            /**
074:             * Determines whether DataStore created by this factory can process the parameters.
075:             * 
076:             * <p>
077:             * Required Parameters are:
078:             * </p>
079:             * 
080:             * <ul>
081:             * <li>
082:             * <code>dbtype</code> - must equal "oracle"
083:             * </li>
084:             * <li>
085:             * <code>host</code>
086:             * </li>
087:             * <li>
088:             * <code>port</code>
089:             * </li>
090:             * <li>
091:             * <code>user</code>
092:             * </li>
093:             * <li>
094:             * <code>passwd</code>
095:             * </li>
096:             * <li>
097:             * <code>instance</code>
098:             * </li>
099:             * </ul>
100:             * 
101:             * <p>
102:             * There are no defaults since each parameter must be explicitly defined by the user, or another
103:             * DataSourceFactorySpi should be used. This behaviour is defined in the DataStoreFactorySpi contract.
104:             * </p>
105:             *
106:             * @param params The parameter to check.
107:             *
108:             * @return True if all the required parameters are supplied.
109:             */
110:            public boolean canProcess(Map params) {
111:                if (mConnectionParams == null) {
112:                    return false;
113:                }
114:                return params.containsKey("dbtype")
115:                        && params.get("dbtype").equals("geomedia")
116:                        && params.containsKey("dbkey")
117:                        && params.containsKey("dbdriver")
118:                        && params.containsKey("user")
119:                        && params.containsKey("passwd");
120:
121:                //&& params.containsKey("parameters");
122:            }
123:
124:            /**
125:             * Construct a postgis data store using the params.
126:             *
127:             * @param params The full set of information needed to construct a live data source.  Should have  dbtype equal to
128:             *        geomedia, as well as host, user, passwd, database, dbkey.
129:             *
130:             * @return The created DataSource, this may be null if the required resource was not found or if insufficent
131:             *         parameters were given. Note that canProcess() should have returned false if the problem is to do with
132:             *         insufficent parameters.
133:             *
134:             * @throws IOException DOCUMENT ME!
135:             * @throws DataSourceException Thrown if there were any problems creating or connecting the datasource.
136:             */
137:            public DataStore createDataStore(Map params) throws IOException {
138:                /* There are no defaults here. Calling canProcess verifies that
139:                 * all these variables exist.
140:                 */
141:                String databaseDriver = (String) DBDRIVER.lookUp(params);
142:                String databasePoolKey = (String) DBKEY.lookUp(params);
143:
144:                String user = (String) USER.lookUp(params);
145:                String passwd = (String) PASSWD.lookUp(params);
146:
147:                try {
148:                    GeoMediaConnectionFactory factory = new GeoMediaConnectionFactory(
149:                            databaseDriver, databasePoolKey, mConnectionParams);
150:
151:                    factory.setLogin(user, passwd);
152:
153:                    ConnectionPool pool = factory.getConnectionPool();
154:                    GeoMediaDataStore dataStore = new GeoMediaDataStore(pool);
155:
156:                    return dataStore;
157:                } catch (SQLException ex) {
158:                    throw new DataSourceException(ex.getMessage());
159:                }
160:            }
161:
162:            /**
163:             * Oracle cannot create a new database.
164:             *
165:             * @param params
166:             *
167:             *
168:             * @throws IOException DOCUMENT ME!
169:             * @throws UnsupportedOperationException Cannot create new database
170:             */
171:            public DataStore createNewDataStore(Map params) throws IOException {
172:                throw new UnsupportedOperationException(
173:                        "GeoTools cannot create a new GeoMedia Database");
174:            }
175:
176:            public String getDisplayName() {
177:                return "GeoMedia";
178:            }
179:
180:            /**
181:             * Describe the nature of the datastore constructed by this factory.
182:             *
183:             * @return A human readable description that is suitable for inclusion in a list of available datasources.
184:             */
185:            public String getDescription() {
186:                return "GeoMedia Spatial Database";
187:            }
188:
189:            //    // TODO: have a clue
190:            //	public DataSourceMetadataEnity createMetadata( Map params ) throws IOException {
191:            //	    String databaseDriver = (String) DBDRIVER.lookUp( params );
192:            //        String databasePoolKey = (String) DBKEY.lookUp( params );
193:            //        
194:            //        String user = (String) USER.lookUp( params );        
195:            //        
196:            //	    return new DataSourceMetadataEnity( databasePoolKey, "GeoMedia "+user, "GeoMedia connection to "+databasePoolKey+" as "+user );
197:            //	}
198:            /**
199:             * Test to see if this datastore is available, if it has all the
200:             * appropriate libraries to construct a datastore.  This datastore just
201:             * returns true for now.  This method is used for gui apps, so as to
202:             * not advertise data store capabilities they don't actually have.
203:             *
204:             * @return <tt>true</tt> if and only if this factory is available to create
205:             *         DataStores.
206:             *
207:             * @task REVISIT: I'm just adding this method to compile, maintainer should
208:             *       revisit to check for any libraries that may be necessary for
209:             *       datastore creations. ch.
210:             */
211:            public boolean isAvailable() {
212:                return true;
213:            }
214:
215:            static final Param DBTYPE = new Param("dbtype", String.class,
216:                    "This must be 'geomedia'.", true);
217:            static final Param DBDRIVER = new Param("dbdriver", String.class,
218:                    "Class name of a Type4 Javax DataSource database driver.",
219:                    true);
220:            static final Param USER = new Param("user", String.class,
221:                    "The user name to log in with.", true);
222:            static final Param PASSWD = new Param("passwd", String.class,
223:                    "The password.", true);
224:            static final Param DBKEY = new Param("databasePoolKey",
225:                    String.class, "the port number on the host, usually 1433",
226:                    true, "1433");
227:            static final Param[] PARAM_INFO = new Param[] { DBTYPE, DBDRIVER,
228:                    USER, PASSWD };
229:
230:            /**
231:             * Describe parameters.
232:             *
233:             *
234:             * @see org.geolbs.data.DataStoreFactorySpi#getParametersInfo()
235:             */
236:            public Param[] getParametersInfo() {
237:                return PARAM_INFO;
238:            }
239:
240:            /**
241:             * Returns the implementation hints. The default implementation returns en empty map.
242:             */
243:            public Map getImplementationHints() {
244:                return Collections.EMPTY_MAP;
245:            }
246:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.