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.mdb / src / main / java / org / gvsig / fmap / dal / store / mdb / MDBLibrary.java @ 44916

History | View | Annotate | Download (3.5 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
package org.gvsig.fmap.dal.store.mdb;
23

    
24
import org.gvsig.fmap.dal.DALLibrary;
25
import org.gvsig.fmap.dal.DALLocator;
26
import org.gvsig.fmap.dal.DataStore;
27
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
28
import org.gvsig.fmap.dal.store.db.DBHelper;
29
import org.gvsig.fmap.dal.store.jdbc2.JDBCLibrary;
30
import org.gvsig.fmap.dal.store.jdbc2.spi.JDBCStoreProviderBase;
31
import org.gvsig.metadata.exceptions.MetadataException;
32
import org.gvsig.tools.library.AbstractLibrary;
33
import org.gvsig.tools.library.LibraryException;
34

    
35
public class MDBLibrary extends AbstractLibrary {
36

    
37
    public static final String NAME = DataStore.MDB_PROVIDER_NAME;
38

    
39
    @Override
40
    public void doRegistration() {
41
        registerAsServiceOf(DALLibrary.class);
42
        require(JDBCLibrary.class);
43
    }
44

    
45
    @Override
46
    protected void doInitialize() throws LibraryException {
47
    }
48

    
49
    @Override
50
    protected void doPostInitialize() throws LibraryException {
51
        LibraryException ex = null;
52

    
53
        DataManagerProviderServices dataman = 
54
                (DataManagerProviderServices) DALLocator.getDataManager();
55

    
56
        try {
57
            Class.forName(MDBHelper.MDBSPATIAL_JDBC_DRIVER);
58
        } catch(Throwable th) {
59
            MDBHelper.LOGGER.warn("Can't load MDBSpatial JDBC Driver.",th);
60
        }
61
        
62
        DBHelper.registerParametersDefinition(
63
                NAME + "StoreParameters",
64
                MDBStoreParameters.class,
65
                dataman.getResourceAsStream(this, NAME + "Parameters.xml")
66
        );
67
        DBHelper.registerParametersDefinition(
68
                NAME + "NewStoreParameters",
69
                MDBNewStoreParameters.class,
70
                dataman.getResourceAsStream(this, NAME + "Parameters.xml")
71
        );
72
        DBHelper.registerParametersDefinition(
73
                NAME + "ServerExplorerParameters",
74
                MDBExplorerParameters.class,
75
                dataman.getResourceAsStream(this, NAME + "Parameters.xml")
76
        );
77
        try {
78
            DBHelper.registerMetadataDefinition(
79
                NAME,
80
                JDBCStoreProviderBase.class,
81
                dataman.getResourceAsStream(this, NAME + "Metadata.xml")
82
            );
83
        } catch (MetadataException e) {
84
            ex = new LibraryException(this.getClass(), e);
85
        }
86

    
87
        if (!dataman.getStoreProviderRegister().exits(NAME)) {
88
            dataman.registerStoreProviderFactory(new MDBStoreProviderFactory());
89
        }
90

    
91
        if (!dataman.getServerExplorerRegister().exits(NAME)) {
92
            dataman.registerServerExplorerFactory(new MDBExplorerFactory());
93
        }
94
        if (ex != null) {
95
            throw ex;
96
        }
97
    }
98

    
99
}