Revision 43020 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.dal/org.gvsig.fmap.dal.db/org.gvsig.fmap.dal.db.jdbc/src/main/java/org/gvsig/fmap/dal/store/jdbc/JDBCLibrary.java
JDBCLibrary.java | ||
---|---|---|
3 | 3 |
* |
4 | 4 |
* Copyright (C) 2007-2013 gvSIG Association. |
5 | 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.
|
|
6 |
* This program is free software; you can redistribute it and/or modify it under
|
|
7 |
* the terms of the GNU General Public License as published by the Free Software
|
|
8 |
* Foundation; either version 3 of the License, or (at your option) any later
|
|
9 |
* version. |
|
10 | 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.
|
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
13 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
14 |
* details. |
|
15 | 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. |
|
16 |
* You should have received a copy of the GNU General Public License along with |
|
17 |
* this program; if not, write to the Free Software Foundation, Inc., 51 |
|
18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
20 | 19 |
* |
21 |
* For any additional information, do not hesitate to contact us |
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
|
20 |
* For any additional information, do not hesitate to contact us at info AT
|
|
21 |
* gvsig.com, or visit our website www.gvsig.com. |
|
23 | 22 |
*/ |
24 |
|
|
25 | 23 |
package org.gvsig.fmap.dal.store.jdbc; |
26 | 24 |
|
27 | 25 |
import org.gvsig.fmap.dal.DALLibrary; |
... | ... | |
37 | 35 |
|
38 | 36 |
/** |
39 | 37 |
* Initialize JDBC Provider Library |
40 |
* |
|
41 |
* @author jmvivo |
|
42 | 38 |
* |
43 | 39 |
*/ |
44 | 40 |
public class JDBCLibrary extends AbstractLibrary { |
45 | 41 |
|
42 |
public static final String NAME = "JDBC"; |
|
43 |
|
|
46 | 44 |
@Override |
47 | 45 |
public void doRegistration() { |
48 | 46 |
registerAsServiceOf(DALLibrary.class); |
... | ... | |
50 | 48 |
require(DBResourceLibrary.class); |
51 | 49 |
} |
52 | 50 |
|
53 |
@Override
|
|
54 |
protected void doInitialize() throws LibraryException {
|
|
55 |
}
|
|
51 |
@Override
|
|
52 |
protected void doInitialize() throws LibraryException {
|
|
53 |
}
|
|
56 | 54 |
|
57 |
@Override |
|
58 |
protected void doPostInitialize() throws LibraryException { |
|
59 |
LibraryException ex=null; |
|
60 |
|
|
61 |
DBHelper.registerParametersDefinition( |
|
62 |
JDBCStoreParameters.PARAMETERS_DEFINITION_NAME, |
|
63 |
JDBCStoreParameters.class, |
|
64 |
"JDBCParameters.xml" |
|
65 |
); |
|
66 |
DBHelper.registerParametersDefinition( |
|
67 |
JDBCNewStoreParameters.PARAMETERS_DEFINITION_NAME, |
|
68 |
JDBCNewStoreParameters.class, |
|
69 |
"JDBCParameters.xml" |
|
70 |
); |
|
71 |
DBHelper.registerParametersDefinition( |
|
72 |
JDBCServerExplorerParameters.PARAMETERS_DEFINITION_NAME, |
|
73 |
JDBCServerExplorerParameters.class, |
|
74 |
"JDBCParameters.xml" |
|
75 |
); |
|
76 |
DBHelper.registerParametersDefinition( |
|
77 |
JDBCResourceParameters.PARAMETERS_DEFINITION_NAME, |
|
78 |
JDBCResourceParameters.class, |
|
79 |
"JDBCParameters.xml" |
|
80 |
); |
|
81 |
|
|
82 |
try { |
|
83 |
DBHelper.registerMetadataDefinition( |
|
84 |
JDBCStoreProvider.METADATA_DEFINITION_NAME, |
|
85 |
JDBCStoreProvider.class, |
|
86 |
"JDBCMetadata.xml" |
|
87 |
); |
|
88 |
} catch (MetadataException e) { |
|
89 |
ex = new LibraryException(this.getClass(),e); |
|
90 |
} |
|
91 |
|
|
92 |
|
|
93 |
ResourceManagerProviderServices resman = (ResourceManagerProviderServices) DALLocator |
|
94 |
.getResourceManager(); |
|
55 |
@Override |
|
56 |
protected void doPostInitialize() throws LibraryException { |
|
57 |
LibraryException ex = null; |
|
95 | 58 |
|
96 |
if (!resman.getResourceProviders().contains(JDBCResource.NAME)) { |
|
97 |
resman.register(JDBCResource.NAME, JDBCResource.DESCRIPTION, |
|
98 |
JDBCResource.class, JDBCResourceParameters.class); |
|
99 |
} |
|
100 |
|
|
101 |
DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator |
|
102 |
.getDataManager(); |
|
103 |
|
|
104 |
|
|
105 |
if (!dataman.getStoreProviders().contains(JDBCStoreProvider.NAME)) { |
|
106 |
dataman.registerStoreProvider(JDBCStoreProvider.NAME, |
|
107 |
JDBCStoreProviderWriter.class, JDBCStoreParameters.class); |
|
108 |
} |
|
109 |
|
|
110 |
if (!dataman.getExplorerProviders().contains(JDBCStoreProvider.NAME)) { |
|
111 |
dataman.registerExplorerProvider(JDBCServerExplorer.NAME, |
|
112 |
JDBCServerExplorer.class, |
|
113 |
JDBCServerExplorerParameters.class); |
|
114 |
} |
|
115 |
|
|
116 |
if( ex!=null ) { |
|
117 |
throw ex; |
|
118 |
} |
|
119 |
} |
|
59 |
DBHelper.registerParametersDefinition( |
|
60 |
NAME + "StoreParameters", |
|
61 |
JDBCStoreParameters.class, |
|
62 |
NAME + "Parameters.xml" |
|
63 |
); |
|
64 |
DBHelper.registerParametersDefinition( |
|
65 |
NAME + "NewStoreParameters", |
|
66 |
JDBCNewStoreParameters.class, |
|
67 |
NAME + "Parameters.xml" |
|
68 |
); |
|
69 |
DBHelper.registerParametersDefinition( |
|
70 |
NAME + "ServerExplorerParameters", |
|
71 |
JDBCServerExplorerParameters.class, |
|
72 |
NAME + "Parameters.xml" |
|
73 |
); |
|
74 |
DBHelper.registerParametersDefinition( |
|
75 |
NAME + "ResourceParameters", |
|
76 |
JDBCResourceParameters.class, |
|
77 |
NAME + "Parameters.xml" |
|
78 |
); |
|
79 |
|
|
80 |
try { |
|
81 |
DBHelper.registerMetadataDefinition( |
|
82 |
NAME, |
|
83 |
JDBCStoreProvider.class, |
|
84 |
NAME + "Metadata.xml" |
|
85 |
); |
|
86 |
} catch (MetadataException e) { |
|
87 |
ex = new LibraryException(this.getClass(), e); |
|
88 |
} |
|
89 |
|
|
90 |
ResourceManagerProviderServices resman = (ResourceManagerProviderServices) DALLocator |
|
91 |
.getResourceManager(); |
|
92 |
|
|
93 |
if (!resman.getResourceProviders().contains(NAME)) { |
|
94 |
resman.register( |
|
95 |
JDBCResource.NAME, |
|
96 |
JDBCResource.DESCRIPTION, |
|
97 |
JDBCResource.class, |
|
98 |
JDBCResourceParameters.class |
|
99 |
); |
|
100 |
} |
|
101 |
|
|
102 |
DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator |
|
103 |
.getDataManager(); |
|
104 |
|
|
105 |
if (!dataman.getStoreProviders().contains(NAME)) { |
|
106 |
dataman.registerStoreProviderFactory(new JDBCStoreProviderFactory()); |
|
107 |
} |
|
108 |
|
|
109 |
if (!dataman.getServerExplorerRegister().exits(JDBCStoreProvider.NAME)) { |
|
110 |
dataman.registerServerExplorerFactory(new JDBCServerExplorerFactory()); |
|
111 |
} |
|
112 |
|
|
113 |
if (ex != null) { |
|
114 |
throw ex; |
|
115 |
} |
|
116 |
} |
|
120 | 117 |
} |
Also available in: Unified diff