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.jdbc / src / main / java / org / gvsig / fmap / dal / store / jdbc2 / JDBCLibrary.java @ 45444
History | View | Annotate | Download (4.32 KB)
1 | 43020 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | *
|
||
4 | 45065 | jjdelcerro | * Copyright (C) 2007-2020 gvSIG Association.
|
5 | 43020 | jjdelcerro | *
|
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 | *
|
||
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 | *
|
||
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.
|
||
19 | *
|
||
20 | * For any additional information, do not hesitate to contact us at info AT
|
||
21 | * gvsig.com, or visit our website www.gvsig.com.
|
||
22 | */
|
||
23 | package org.gvsig.fmap.dal.store.jdbc2; |
||
24 | |||
25 | import org.gvsig.fmap.dal.DALLibrary; |
||
26 | import org.gvsig.fmap.dal.DALLocator; |
||
27 | import org.gvsig.fmap.dal.resource.db.DBResourceLibrary; |
||
28 | import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
||
29 | import org.gvsig.fmap.dal.store.db.DBHelper; |
||
30 | import org.gvsig.fmap.dal.store.db.DBStoreLibrary; |
||
31 | import org.gvsig.fmap.dal.store.jdbc.JDBCNewStoreParameters; |
||
32 | import org.gvsig.fmap.dal.store.jdbc.JDBCResourceParameters; |
||
33 | import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
||
34 | import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
||
35 | import org.gvsig.metadata.exceptions.MetadataException; |
||
36 | import org.gvsig.tools.library.AbstractLibrary; |
||
37 | import org.gvsig.tools.library.LibraryException; |
||
38 | |||
39 | /**
|
||
40 | * Initialize JDBC Provider Library
|
||
41 | *
|
||
42 | */
|
||
43 | public class JDBCLibrary extends AbstractLibrary { |
||
44 | |||
45 | public static final String NAME = "JDBC2"; |
||
46 | |||
47 | @Override
|
||
48 | public void doRegistration() { |
||
49 | registerAsServiceOf(DALLibrary.class); |
||
50 | require(DBStoreLibrary.class); |
||
51 | require(DBResourceLibrary.class); |
||
52 | } |
||
53 | |||
54 | @Override
|
||
55 | protected void doInitialize() throws LibraryException { |
||
56 | } |
||
57 | |||
58 | @Override
|
||
59 | protected void doPostInitialize() throws LibraryException { |
||
60 | |||
61 | LibraryException ex = null;
|
||
62 | |||
63 | DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator |
||
64 | .getDataManager(); |
||
65 | |||
66 | DBHelper.registerParametersDefinition( |
||
67 | NAME + "StoreParameters",
|
||
68 | JDBCStoreParameters.class, |
||
69 | dataman.getResourceAsStream(this, NAME + "Parameters.xml") |
||
70 | ); |
||
71 | DBHelper.registerParametersDefinition( |
||
72 | NAME + "NewStoreParameters",
|
||
73 | JDBCNewStoreParameters.class, |
||
74 | dataman.getResourceAsStream(this, NAME + "Parameters.xml") |
||
75 | ); |
||
76 | DBHelper.registerParametersDefinition( |
||
77 | NAME + "ServerExplorerParameters",
|
||
78 | JDBCServerExplorerParameters.class, |
||
79 | dataman.getResourceAsStream(this, NAME + "Parameters.xml") |
||
80 | ); |
||
81 | DBHelper.registerParametersDefinition( |
||
82 | NAME + "ResourceParameters",
|
||
83 | JDBCResourceParameters.class, |
||
84 | dataman.getResourceAsStream(this, NAME + "Parameters.xml") |
||
85 | ); |
||
86 | |||
87 | try {
|
||
88 | DBHelper.registerMetadataDefinition( |
||
89 | NAME, |
||
90 | JDBCStoreProvider.class, |
||
91 | dataman.getResourceAsStream(this, NAME + "Metadata.xml") |
||
92 | ); |
||
93 | } catch (MetadataException e) {
|
||
94 | ex = new LibraryException(this.getClass(), e); |
||
95 | } |
||
96 | |||
97 | // ResourceManagerProviderServices resman = (ResourceManagerProviderServices) DALLocator
|
||
98 | // .getResourceManager();
|
||
99 | //
|
||
100 | // if (!resman.getResourceProviders().contains(NAME)) {
|
||
101 | // resman.register(
|
||
102 | // JDBCResource.NAME,
|
||
103 | // JDBCResource.DESCRIPTION,
|
||
104 | // JDBCResource.class,
|
||
105 | // JDBCResourceParameters.class
|
||
106 | // );
|
||
107 | // }
|
||
108 | |||
109 | // if (!dataman.getStoreProviderRegister().exits(NAME)) {
|
||
110 | // dataman.registerStoreProviderFactory(new JDBCStoreProviderFactory());
|
||
111 | // }
|
||
112 | //
|
||
113 | // if (!dataman.getServerExplorerRegister().exits(NAME)) {
|
||
114 | // dataman.registerServerExplorerFactory(new JDBCServerExplorerFactory());
|
||
115 | // }
|
||
116 | |||
117 | if (ex != null) { |
||
118 | throw ex;
|
||
119 | } |
||
120 | } |
||
121 | } |