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 / jdbc2 / JDBCLibrary.java @ 45606

History | View | Annotate | Download (4.45 KB)

1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2020 gvSIG Association.
5
 *
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.fmap.dal.store.jdbc2.impl.expressionevaluator.JDBCSymbolTableFactory;
36
import org.gvsig.metadata.exceptions.MetadataException;
37
import org.gvsig.tools.library.AbstractLibrary;
38
import org.gvsig.tools.library.LibraryException;
39

    
40
/**
41
 * Initialize JDBC Provider Library
42
 *
43
 */
44
public class JDBCLibrary extends AbstractLibrary {
45

    
46
    public static final String NAME = "JDBC2";
47

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

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

    
59
    @Override
60
    protected void doPostInitialize() throws LibraryException {
61
        
62
        LibraryException ex = null;
63

    
64
        DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator
65
                .getDataManager();
66

    
67
        DBHelper.registerParametersDefinition(
68
                NAME + "StoreParameters",
69
                JDBCStoreParameters.class,
70
                dataman.getResourceAsStream(this, NAME + "Parameters.xml")
71
        );
72
        DBHelper.registerParametersDefinition(
73
                NAME + "NewStoreParameters",
74
                JDBCNewStoreParameters.class,
75
                dataman.getResourceAsStream(this, NAME + "Parameters.xml")
76
        );
77
        DBHelper.registerParametersDefinition(
78
                NAME + "ServerExplorerParameters",
79
                JDBCServerExplorerParameters.class,
80
                dataman.getResourceAsStream(this, NAME + "Parameters.xml")
81
        );
82
        DBHelper.registerParametersDefinition(
83
                NAME + "ResourceParameters",
84
                JDBCResourceParameters.class,
85
                dataman.getResourceAsStream(this, NAME + "Parameters.xml")
86
        );
87

    
88
        try {
89
            DBHelper.registerMetadataDefinition(
90
                    NAME,
91
                    JDBCStoreProvider.class,
92
                    dataman.getResourceAsStream(this, NAME + "Metadata.xml")
93
            );
94
        } catch (MetadataException e) {
95
            ex = new LibraryException(this.getClass(), e);
96
        }
97

    
98
//        ResourceManagerProviderServices resman = (ResourceManagerProviderServices) DALLocator
99
//                .getResourceManager();
100
//
101
//        if (!resman.getResourceProviders().contains(NAME)) {
102
//            resman.register(
103
//                    JDBCResource.NAME, 
104
//                    JDBCResource.DESCRIPTION,
105
//                    JDBCResource.class,
106
//                    JDBCResourceParameters.class
107
//            );
108
//        }
109

    
110
//        if (!dataman.getStoreProviderRegister().exits(NAME)) {
111
//            dataman.registerStoreProviderFactory(new JDBCStoreProviderFactory());
112
//        }
113
//
114
//        if (!dataman.getServerExplorerRegister().exits(NAME)) {
115
//            dataman.registerServerExplorerFactory(new JDBCServerExplorerFactory());
116
//        }
117

    
118
        JDBCSymbolTableFactory.selfRegister();
119

    
120
        if (ex != null) {
121
            throw ex;
122
        }
123
    }
124
}