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

History | View | Annotate | Download (3.71 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 2
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

    
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 IVER T.I. S.A.   {{Task}}
26
*/
27

    
28
package org.gvsig.fmap.dal.store.jdbc;
29

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

    
41
/**
42
 * Initialize JDBC Provider Library
43
 * 
44
 * @author jmvivo
45
 *
46
 */
47
public class JDBCLibrary extends AbstractLibrary {
48

    
49
    @Override
50
    public void doRegistration() {
51
        registerAsServiceOf(DALLibrary.class);
52
        require(DBStoreLibrary.class);
53
        require(DBResourceLibrary.class);
54
    }
55

    
56
        @Override
57
        protected void doInitialize() throws LibraryException {
58
        }
59

    
60
        @Override
61
        protected void doPostInitialize() throws LibraryException {
62
                LibraryException ex=null;
63
                
64
                DBHelper.registerParametersDefinition(
65
                                 JDBCStoreParameters.PARAMETERS_DEFINITION_NAME,
66
                                 JDBCStoreParameters.class,
67
                                 "JDBCParameters.xml"
68
                );
69
                DBHelper.registerParametersDefinition(
70
                                JDBCNewStoreParameters.PARAMETERS_DEFINITION_NAME,
71
                                JDBCNewStoreParameters.class,
72
                                "JDBCParameters.xml"
73
                );
74
                DBHelper.registerParametersDefinition(
75
                                JDBCServerExplorerParameters.PARAMETERS_DEFINITION_NAME, 
76
                                JDBCServerExplorerParameters.class, 
77
                                "JDBCParameters.xml"
78
                );
79
                DBHelper.registerParametersDefinition(
80
                                JDBCResourceParameters.PARAMETERS_DEFINITION_NAME, 
81
                                JDBCResourceParameters.class, 
82
                                "JDBCParameters.xml"
83
                );
84
                
85
                try {
86
                        DBHelper.registerMetadataDefinition(
87
                                        JDBCStoreProvider.METADATA_DEFINITION_NAME, 
88
                                        JDBCStoreProvider.class, 
89
                                        "JDBCMetadata.xml"
90
                        );
91
                } catch (MetadataException e) {
92
                        ex = new LibraryException(this.getClass(),e);
93
                }
94
                
95
                
96
            ResourceManagerProviderServices resman = (ResourceManagerProviderServices) DALLocator
97
                .getResourceManager();
98

    
99
                if (!resman.getResourceProviders().contains(JDBCResource.NAME)) {
100
                        resman.register(JDBCResource.NAME, JDBCResource.DESCRIPTION,
101
                                        JDBCResource.class, JDBCResourceParameters.class);
102
                }
103
                
104
                DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator
105
                                .getDataManager();
106
                
107
                
108
                if (!dataman.getStoreProviders().contains(JDBCStoreProvider.NAME)) {
109
                        dataman.registerStoreProvider(JDBCStoreProvider.NAME,
110
                                        JDBCStoreProviderWriter.class, JDBCStoreParameters.class);
111
                }
112
                
113
                if (!dataman.getExplorerProviders().contains(JDBCStoreProvider.NAME)) {
114
                        dataman.registerExplorerProvider(JDBCServerExplorer.NAME,
115
                                        JDBCServerExplorer.class,
116
                                        JDBCServerExplorerParameters.class);
117
                }
118
                
119
                if( ex!=null ) {
120
                        throw ex;
121
                }
122
        }
123
}