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 / H2Library.java @ 41719
History | View | Annotate | Download (4.04 KB)
1 |
/* 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 3
|
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.resource.spi.ResourceManagerProviderServices; |
27 |
import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
28 |
import org.gvsig.fmap.dal.store.db.DBHelper; |
29 |
import org.gvsig.fmap.dal.store.jdbc.JDBCLibrary; |
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 H2Library extends AbstractLibrary { |
35 |
|
36 |
static String DEFAULT_H2_DRIVER_NAME = "org.h2.Driver"; |
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 |
//new JDBCLibrary().postInitialize();
|
53 |
|
54 |
DBHelper.registerParametersDefinition( |
55 |
H2StoreParameters.PARAMETERS_DEFINITION_NAME, |
56 |
H2StoreParameters.class, |
57 |
"H2SQLParameters.xml"
|
58 |
); |
59 |
DBHelper.registerParametersDefinition( |
60 |
H2NewStoreParameters.PARAMETERS_DEFINITION_NAME, |
61 |
H2NewStoreParameters.class, |
62 |
"H2SQLParameters.xml"
|
63 |
); |
64 |
DBHelper.registerParametersDefinition( |
65 |
H2ServerExplorerParameters.PARAMETERS_DEFINITION_NAME, |
66 |
H2ServerExplorerParameters.class, |
67 |
"H2SQLParameters.xml"
|
68 |
); |
69 |
DBHelper.registerParametersDefinition( |
70 |
H2ResourceParameters.PARAMETERS_DEFINITION_NAME, |
71 |
H2ResourceParameters.class, |
72 |
"H2SQLParameters.xml"
|
73 |
); |
74 |
try {
|
75 |
DBHelper.registerMetadataDefinition( |
76 |
H2StoreProvider.METADATA_DEFINITION_NAME, |
77 |
H2StoreProvider.class, |
78 |
"H2SQLMetadata.xml"
|
79 |
); |
80 |
} catch (MetadataException e) {
|
81 |
ex = new LibraryException(this.getClass(), e); |
82 |
} |
83 |
|
84 |
ResourceManagerProviderServices resman = (ResourceManagerProviderServices) DALLocator |
85 |
.getResourceManager(); |
86 |
|
87 |
if ( !resman.getResourceProviders().contains(H2Resource.NAME) ) {
|
88 |
resman.register(H2Resource.NAME, |
89 |
H2Resource.DESCRIPTION, H2Resource.class, |
90 |
H2ResourceParameters.class); |
91 |
} |
92 |
|
93 |
DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator |
94 |
.getDataManager(); |
95 |
|
96 |
if ( !dataman.getStoreProviders().contains(H2StoreProvider.NAME) ) {
|
97 |
dataman.registerStoreProvider(H2StoreProvider.NAME, |
98 |
H2StoreProvider.class, |
99 |
H2StoreParameters.class); |
100 |
} |
101 |
|
102 |
if ( !dataman.getExplorerProviders().contains(
|
103 |
H2StoreProvider.NAME) ) { |
104 |
dataman.registerExplorerProvider(H2ServerExplorer.NAME, |
105 |
H2ServerExplorer.class, |
106 |
H2ServerExplorerParameters.class); |
107 |
} |
108 |
if ( ex != null ) { |
109 |
throw ex;
|
110 |
} |
111 |
} |
112 |
|
113 |
} |