svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.db / org.gvsig.fmap.dal.db.h2 / src / main / java / org / gvsig / fmap / dal / store / h2 / H2SpatialLibrary.java @ 44198
History | View | Annotate | Download (3.49 KB)
1 | 43377 | jjdelcerro | /* gvSIG. Geographic Information System of the Valencian Government
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2007-2008 Infrastructures and Transports Department
|
||
4 | * of the Valencian Government (CIT)
|
||
5 | *
|
||
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | * as published by the Free Software Foundation; either version 2
|
||
9 | * of the License, or (at your option) any later version.
|
||
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
19 | * MA 02110-1301, USA.
|
||
20 | *
|
||
21 | */
|
||
22 | package org.gvsig.fmap.dal.store.h2; |
||
23 | |||
24 | import org.gvsig.fmap.dal.DALLibrary; |
||
25 | import org.gvsig.fmap.dal.DALLocator; |
||
26 | import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
||
27 | import org.gvsig.fmap.dal.store.db.DBHelper; |
||
28 | import org.gvsig.fmap.dal.store.jdbc2.JDBCLibrary; |
||
29 | import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCStoreProviderBase; |
||
30 | import org.gvsig.metadata.exceptions.MetadataException; |
||
31 | import org.gvsig.tools.library.AbstractLibrary; |
||
32 | import org.gvsig.tools.library.LibraryException; |
||
33 | |||
34 | public class H2SpatialLibrary extends AbstractLibrary { |
||
35 | |||
36 | public static final String NAME = "H2Spatial"; |
||
37 | |||
38 | @Override
|
||
39 | public void doRegistration() { |
||
40 | registerAsServiceOf(DALLibrary.class); |
||
41 | require(JDBCLibrary.class); |
||
42 | } |
||
43 | |||
44 | @Override
|
||
45 | protected void doInitialize() throws LibraryException { |
||
46 | } |
||
47 | |||
48 | @Override
|
||
49 | protected void doPostInitialize() throws LibraryException { |
||
50 | LibraryException ex = null;
|
||
51 | |||
52 | DataManagerProviderServices dataman = |
||
53 | (DataManagerProviderServices) DALLocator.getDataManager(); |
||
54 | |||
55 | try {
|
||
56 | 44198 | jjdelcerro | Class.forName(H2SpatialHelper.H2SPATIAL_JDBC_DRIVER);
|
57 | 43377 | jjdelcerro | } catch(Throwable th) { |
58 | 44198 | jjdelcerro | H2SpatialHelper.LOGGER.warn("Can't load H2Spatial JDBC Driver.",th);
|
59 | 43377 | jjdelcerro | } |
60 | |||
61 | DBHelper.registerParametersDefinition( |
||
62 | NAME + "StoreParameters",
|
||
63 | H2SpatialStoreParameters.class, |
||
64 | dataman.getResourceAsStream(this, NAME + "Parameters.xml") |
||
65 | ); |
||
66 | DBHelper.registerParametersDefinition( |
||
67 | NAME + "NewStoreParameters",
|
||
68 | H2SpatialNewStoreParameters.class, |
||
69 | dataman.getResourceAsStream(this, NAME + "Parameters.xml") |
||
70 | ); |
||
71 | DBHelper.registerParametersDefinition( |
||
72 | NAME + "ServerExplorerParameters",
|
||
73 | H2SpatialExplorerParameters.class, |
||
74 | dataman.getResourceAsStream(this, NAME + "Parameters.xml") |
||
75 | ); |
||
76 | try {
|
||
77 | DBHelper.registerMetadataDefinition( |
||
78 | NAME, |
||
79 | JDBCStoreProviderBase.class, |
||
80 | dataman.getResourceAsStream(this, NAME + "Metadata.xml") |
||
81 | ); |
||
82 | } catch (MetadataException e) {
|
||
83 | ex = new LibraryException(this.getClass(), e); |
||
84 | } |
||
85 | |||
86 | if (!dataman.getStoreProviderRegister().exits(NAME)) {
|
||
87 | dataman.registerStoreProviderFactory(new H2SpatialStoreProviderFactory());
|
||
88 | } |
||
89 | |||
90 | if (!dataman.getServerExplorerRegister().exits(NAME)) {
|
||
91 | dataman.registerServerExplorerFactory(new H2SpatialExplorerFactory());
|
||
92 | } |
||
93 | if (ex != null) { |
||
94 | throw ex;
|
||
95 | } |
||
96 | } |
||
97 | |||
98 | } |