svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.h2spatial / org.gvsig.h2spatial.h2gis132 / org.gvsig.h2spatial.h2gis132.provider / src / main / java / org / gvsig / fmap / dal / store / h2 / H2SpatialLibrary.java @ 46414
History | View | Annotate | Download (3.8 KB)
1 | 45472 | 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.DataStore; |
||
27 | import org.gvsig.fmap.dal.impl.LargeMapImpl; |
||
28 | import org.gvsig.fmap.dal.impl.LargeSetImpl; |
||
29 | import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
||
30 | import org.gvsig.fmap.dal.store.db.DBHelper; |
||
31 | import org.gvsig.fmap.dal.store.jdbc2.JDBCLibrary; |
||
32 | import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCStoreProviderBase; |
||
33 | import org.gvsig.json.Json; |
||
34 | import org.gvsig.metadata.exceptions.MetadataException; |
||
35 | import org.gvsig.tools.library.AbstractLibrary; |
||
36 | import org.gvsig.tools.library.LibraryException; |
||
37 | |||
38 | public class H2SpatialLibrary extends AbstractLibrary { |
||
39 | |||
40 | public static final String NAME = DataStore.H2SPATIAL_PROVIDER_NAME; |
||
41 | |||
42 | @Override
|
||
43 | public void doRegistration() { |
||
44 | registerAsServiceOf(DALLibrary.class); |
||
45 | require(JDBCLibrary.class); |
||
46 | } |
||
47 | |||
48 | @Override
|
||
49 | protected void doInitialize() throws LibraryException { |
||
50 | } |
||
51 | |||
52 | @Override
|
||
53 | protected void doPostInitialize() throws LibraryException { |
||
54 | LibraryException ex = null;
|
||
55 | |||
56 | DataManagerProviderServices dataman = |
||
57 | (DataManagerProviderServices) DALLocator.getDataManager(); |
||
58 | |||
59 | try {
|
||
60 | Class.forName(H2SpatialHelper.H2SPATIAL_JDBC_DRIVER);
|
||
61 | } catch(Throwable th) { |
||
62 | H2SpatialHelper.LOGGER.warn("Can't load H2Spatial JDBC Driver.",th);
|
||
63 | } |
||
64 | |||
65 | DBHelper.registerParametersDefinition( |
||
66 | NAME + "StoreParameters",
|
||
67 | H2SpatialStoreParameters.class, |
||
68 | dataman.getResourceAsStream(this, NAME + "Parameters.xml") |
||
69 | ); |
||
70 | DBHelper.registerParametersDefinition( |
||
71 | NAME + "NewStoreParameters",
|
||
72 | H2SpatialNewStoreParameters.class, |
||
73 | dataman.getResourceAsStream(this, NAME + "Parameters.xml") |
||
74 | ); |
||
75 | DBHelper.registerParametersDefinition( |
||
76 | NAME + "ServerExplorerParameters",
|
||
77 | H2SpatialExplorerParameters.class, |
||
78 | dataman.getResourceAsStream(this, NAME + "Parameters.xml") |
||
79 | ); |
||
80 | try {
|
||
81 | DBHelper.registerMetadataDefinition( |
||
82 | NAME, |
||
83 | JDBCStoreProviderBase.class, |
||
84 | dataman.getResourceAsStream(this, NAME + "Metadata.xml") |
||
85 | ); |
||
86 | } catch (MetadataException e) {
|
||
87 | ex = new LibraryException(this.getClass(), e); |
||
88 | } |
||
89 | |||
90 | if (!dataman.getStoreProviderRegister().exits(NAME)) {
|
||
91 | dataman.registerStoreProviderFactory(new H2SpatialStoreProviderFactory());
|
||
92 | } |
||
93 | |||
94 | if (!dataman.getServerExplorerRegister().exits(NAME)) {
|
||
95 | dataman.registerServerExplorerFactory(new H2SpatialExplorerFactory());
|
||
96 | } |
||
97 | LargeMapImpl.selfRegister(); |
||
98 | LargeSetImpl.selfRegister(); |
||
99 | Json.registerSerializer(H2SpatialExplorerParameters.class); |
||
100 | if (ex != null) { |
||
101 | throw ex;
|
||
102 | } |
||
103 | } |
||
104 | |||
105 | } |