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 / jdbc / JDBCLibrary.java @ 43020
History | View | Annotate | Download (3.95 KB)
1 | 40559 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40559 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
6 | 43020 | jjdelcerro | * 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 | 40435 | jjdelcerro | *
|
11 | 43020 | jjdelcerro | * 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 | 40435 | jjdelcerro | *
|
16 | 43020 | jjdelcerro | * 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 | 40435 | jjdelcerro | *
|
20 | 43020 | jjdelcerro | * For any additional information, do not hesitate to contact us at info AT
|
21 | * gvsig.com, or visit our website www.gvsig.com.
|
||
22 | 40435 | jjdelcerro | */
|
23 | package org.gvsig.fmap.dal.store.jdbc; |
||
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.resource.spi.ResourceManagerProviderServices; |
||
29 | import org.gvsig.fmap.dal.spi.DataManagerProviderServices; |
||
30 | import org.gvsig.fmap.dal.store.db.DBHelper; |
||
31 | import org.gvsig.fmap.dal.store.db.DBStoreLibrary; |
||
32 | import org.gvsig.metadata.exceptions.MetadataException; |
||
33 | import org.gvsig.tools.library.AbstractLibrary; |
||
34 | import org.gvsig.tools.library.LibraryException; |
||
35 | |||
36 | /**
|
||
37 | * Initialize JDBC Provider Library
|
||
38 | *
|
||
39 | */
|
||
40 | public class JDBCLibrary extends AbstractLibrary { |
||
41 | |||
42 | 43020 | jjdelcerro | public static final String NAME = "JDBC"; |
43 | |||
44 | 40435 | jjdelcerro | @Override
|
45 | public void doRegistration() { |
||
46 | registerAsServiceOf(DALLibrary.class); |
||
47 | require(DBStoreLibrary.class); |
||
48 | require(DBResourceLibrary.class); |
||
49 | } |
||
50 | |||
51 | 43020 | jjdelcerro | @Override
|
52 | protected void doInitialize() throws LibraryException { |
||
53 | } |
||
54 | 40435 | jjdelcerro | |
55 | 43020 | jjdelcerro | @Override
|
56 | protected void doPostInitialize() throws LibraryException { |
||
57 | LibraryException ex = null;
|
||
58 | 40435 | jjdelcerro | |
59 | 43020 | jjdelcerro | 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 | } |
||
117 | 40435 | jjdelcerro | } |