Statistics
| Revision:

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 @ 40596

History | View | Annotate | Download (3.69 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
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
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24

    
25
package org.gvsig.fmap.dal.store.jdbc;
26

    
27
import org.gvsig.fmap.dal.DALLibrary;
28
import org.gvsig.fmap.dal.DALLocator;
29
import org.gvsig.fmap.dal.resource.db.DBResourceLibrary;
30
import org.gvsig.fmap.dal.resource.spi.ResourceManagerProviderServices;
31
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
32
import org.gvsig.fmap.dal.store.db.DBHelper;
33
import org.gvsig.fmap.dal.store.db.DBStoreLibrary;
34
import org.gvsig.metadata.exceptions.MetadataException;
35
import org.gvsig.tools.library.AbstractLibrary;
36
import org.gvsig.tools.library.LibraryException;
37

    
38
/**
39
 * Initialize JDBC Provider Library
40
 * 
41
 * @author jmvivo
42
 *
43
 */
44
public class JDBCLibrary extends AbstractLibrary {
45

    
46
    @Override
47
    public void doRegistration() {
48
        registerAsServiceOf(DALLibrary.class);
49
        require(DBStoreLibrary.class);
50
        require(DBResourceLibrary.class);
51
    }
52

    
53
        @Override
54
        protected void doInitialize() throws LibraryException {
55
        }
56

    
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();
95

    
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
        }
120
}