Source Code Cross Referenced for DataStoreConfig.java in  » GIS » GeoServer » org » vfny » geoserver » config » 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 » GeoServer » org.vfny.geoserver.config 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org.  All rights reserved.
002:         * This code is licensed under the GPL 2.0 license, availible at the root
003:         * application directory.
004:         */
005:        package org.vfny.geoserver.config;
006:
007:        import org.geotools.data.DataStore;
008:        import org.geotools.data.DataStoreFactorySpi;
009:        import org.vfny.geoserver.global.dto.DataStoreInfoDTO;
010:        import org.vfny.geoserver.util.DataStoreUtils;
011:        import java.io.IOException;
012:        import java.util.HashMap;
013:        import java.util.Map;
014:        import javax.servlet.ServletContext;
015:
016:        /**
017:         * DataStoreInfo purpose.
018:         *
019:         * <p>
020:         * Used to describe a datastore, typically one specified in the catalog.xml
021:         * config file.
022:         * </p>
023:         *
024:         * <p></p>
025:         *
026:         * @author dzwiers, Refractions Research, Inc.
027:         * @version $Id: DataStoreConfig.java 6326 2007-03-15 18:36:40Z jdeolive $
028:         */
029:        public class DataStoreConfig {
030:            /** unique datasore identifier */
031:            private String id;
032:
033:            /** unique namespace to refer to this datastore */
034:            private String nameSpaceId;
035:
036:            /** wether this data store is enabled */
037:            private boolean enabled = true;
038:
039:            /** a short description about this data store */
040:            private String title;
041:
042:            /** a short description about this data store */
043:            private String _abstract;
044:
045:            /** connection parameters to create the DataStoreInfo */
046:            private Map connectionParams;
047:
048:            /** Config ONLY! DataStoreFactory used to test params */
049:            private DataStoreFactorySpi factory;
050:
051:            /**
052:             * Create a new DataStoreConfig from a dataStoreId and factoryDescription
053:             *
054:             * <p>
055:             * Creates a DataStoreInfo to represent an instance with default data.
056:             * </p>
057:             *
058:             * @param dataStoreId Description of DataStore (see DataStoreUtils)
059:             * @param factoryDescription DOCUMENT ME!
060:             *
061:             * @see defaultSettings()
062:             */
063:            public DataStoreConfig(String dataStoreId, String factoryDescription) {
064:                this (dataStoreId, DataStoreUtils
065:                        .aquireFactory(factoryDescription));
066:            }
067:
068:            /** Creates a new DataStoreConfig for the provided factory. */
069:            public DataStoreConfig(String dataStoreId,
070:                    DataStoreFactorySpi factory) {
071:                this .factory = factory;
072:                id = dataStoreId;
073:                nameSpaceId = "";
074:                enabled = true;
075:                title = "";
076:                _abstract = "";
077:                connectionParams = DataStoreUtils.defaultParams(factory);
078:            }
079:
080:            /**
081:             * DataStoreInfo constructor.
082:             *
083:             * <p>
084:             * Creates a copy of the DataStoreInfoDTO provided. All the datastructures
085:             * are cloned.
086:             * </p>
087:             *
088:             * @param dto The datastore to copy.
089:             */
090:            public DataStoreConfig(DataStoreInfoDTO dto) {
091:                reset(dto);
092:            }
093:
094:            /**
095:             * Called to update Config class based on DTO information
096:             *
097:             * @param dto DOCUMENT ME!
098:             *
099:             * @throws NullPointerException DOCUMENT ME!
100:             */
101:            public void reset(DataStoreInfoDTO dto) {
102:                if (dto == null) {
103:                    throw new NullPointerException(
104:                            "Non null DataStoreInfoDTO required");
105:                }
106:
107:                factory = DataStoreUtils.aquireFactory(dto
108:                        .getConnectionParams());
109:
110:                id = dto.getId();
111:                nameSpaceId = dto.getNameSpaceId();
112:                enabled = dto.isEnabled();
113:                _abstract = dto.getAbstract();
114:                connectionParams = new HashMap(dto.getConnectionParams());
115:            }
116:
117:            /**
118:             * Implement loadDTO.
119:             *
120:             * <p>
121:             * Populates the data fields with the DataStoreInfoDTO provided.
122:             * </p>
123:             *
124:             * @param ds the DataStoreInfoDTO to use.
125:             *
126:             * @throws NullPointerException DOCUMENT ME!
127:             *
128:             * @see org.vfny.geoserver.config.DataStructure#loadDTO(java.lang.Object)
129:             */
130:            public void update(DataStoreInfoDTO ds) {
131:                if (ds == null) {
132:                    throw new NullPointerException(
133:                            "DataStoreInfo Data Transfer Object required");
134:                }
135:
136:                id = ds.getId();
137:                nameSpaceId = ds.getNameSpaceId();
138:                enabled = ds.isEnabled();
139:                _abstract = ds.getAbstract();
140:
141:                try {
142:                    connectionParams = new HashMap(ds.getConnectionParams()); //clone?
143:                } catch (Exception e) {
144:                    connectionParams = new HashMap();
145:                }
146:            }
147:
148:            /**
149:             * Implement toDTO.
150:             *
151:             * <p>
152:             * Create a DataStoreInfoDTO from the current config object.
153:             * </p>
154:             *
155:             * @return The data represented as a DataStoreInfoDTO
156:             *
157:             * @see org.vfny.geoserver.config.DataStructure#toDTO()
158:             */
159:            public DataStoreInfoDTO toDTO() {
160:                DataStoreInfoDTO ds = new DataStoreInfoDTO();
161:                ds.setId(id);
162:                ds.setNameSpaceId(nameSpaceId);
163:                ds.setEnabled(enabled);
164:                ds.setAbstract(_abstract);
165:
166:                try {
167:                    ds.setConnectionParams(new HashMap(connectionParams));
168:                } catch (Exception e) {
169:                    // default already created  	
170:                }
171:
172:                return ds;
173:            }
174:
175:            /**
176:             * getAbstract purpose.
177:             *
178:             * <p>
179:             * Description ...
180:             * </p>
181:             *
182:             * @return
183:             */
184:            public String getAbstract() {
185:                return _abstract;
186:            }
187:
188:            /**
189:             * getConnectionParams purpose.
190:             *
191:             * <p>
192:             * Description ...
193:             * </p>
194:             *
195:             * @return
196:             */
197:            public Map getConnectionParams() {
198:                return connectionParams;
199:            }
200:
201:            /**
202:             * isEnabled purpose.
203:             *
204:             * <p>
205:             * Description ...
206:             * </p>
207:             *
208:             * @return
209:             */
210:            public boolean isEnabled() {
211:                return enabled;
212:            }
213:
214:            /**
215:             * This is the DataStore ID
216:             *
217:             * <p>
218:             *
219:             * </p>
220:             *
221:             * @return
222:             */
223:            public String getId() {
224:                return id;
225:            }
226:
227:            /**
228:             * getNameSpace purpose.
229:             *
230:             * <p>
231:             * Description ...
232:             * </p>
233:             *
234:             * @return
235:             */
236:            public String getNameSpaceId() {
237:                return nameSpaceId;
238:            }
239:
240:            /**
241:             * getTitle purpose.
242:             *
243:             * <p>
244:             * Description ...
245:             * </p>
246:             *
247:             * @return
248:             */
249:            public String getTitle() {
250:                return title;
251:            }
252:
253:            /**
254:             * setAbstract purpose.
255:             *
256:             * <p>
257:             * Description ...
258:             * </p>
259:             *
260:             * @param string
261:             */
262:            public void setAbstract(String string) {
263:                if (string != null) {
264:                    _abstract = string;
265:                }
266:            }
267:
268:            /**
269:             * setConnectionParams purpose.
270:             *
271:             * <p>
272:             * Description ...
273:             * </p>
274:             *
275:             * @param map
276:             */
277:            public void setConnectionParams(Map map) {
278:                connectionParams = map;
279:            }
280:
281:            /**
282:             * setEnabled purpose.
283:             *
284:             * <p>
285:             * Description ...
286:             * </p>
287:             *
288:             * @param b
289:             */
290:            public void setEnabled(boolean b) {
291:                enabled = b;
292:            }
293:
294:            /**
295:             * setNameSpace purpose.
296:             *
297:             * <p>
298:             * Description ...
299:             * </p>
300:             *
301:             * @param support
302:             */
303:            public void setNameSpaceId(String support) {
304:                if (support != null) {
305:                    nameSpaceId = support;
306:                }
307:            }
308:
309:            /**
310:             * setTitle purpose.
311:             *
312:             * <p>
313:             * Description ...
314:             * </p>
315:             *
316:             * @param string
317:             */
318:            public void setTitle(String string) {
319:                if (string != null) {
320:                    title = string;
321:                }
322:            }
323:
324:            // Access to Dyanmic Content
325:
326:            /**
327:             * It would be nice if we did not throw this away - but life is too short
328:             *
329:             * @return Real DataStore generated by this DataStoreConfig
330:             *
331:             * @throws IOException If DataStore could not be aquired
332:             */
333:            public DataStore findDataStore(ServletContext sc)
334:                    throws IOException {
335:                return DataStoreUtils.acquireDataStore(connectionParams, sc);
336:            }
337:
338:            /**
339:             * Get DataStoreFactorySpi used for this DataStoreConfig.
340:             *
341:             * @return DataStoreFactorySpi that this DataStoreConfig matches
342:             */
343:            public DataStoreFactorySpi getFactory() {
344:                return factory;
345:            }
346:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.