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

History | View | Annotate | Download (4.58 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 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.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.fmap.dal.store.jdbc.JDBCNewStoreParameters;
33
import org.gvsig.fmap.dal.store.jdbc.JDBCResource;
34
import org.gvsig.fmap.dal.store.jdbc.JDBCResourceParameters;
35
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters;
36
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters;
37
import org.gvsig.fmap.dal.store.jdbc2.impl.JDBCServerExplorerFactory;
38
import org.gvsig.fmap.dal.store.jdbc2.impl.JDBCStoreProviderFactory;
39
import org.gvsig.metadata.exceptions.MetadataException;
40
import org.gvsig.tools.library.AbstractLibrary;
41
import org.gvsig.tools.library.LibraryException;
42

    
43
/**
44
 * Initialize JDBC Provider Library
45
 *
46
 */
47
public class JDBCLibrary extends AbstractLibrary {
48

    
49
    public static final String NAME = "JDBC2";
50

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

    
58
    @Override
59
    protected void doInitialize() throws LibraryException {
60
    }
61

    
62
    @Override
63
    protected void doPostInitialize() throws LibraryException {
64
        
65
        LibraryException ex = null;
66

    
67
        DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator
68
                .getDataManager();
69

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

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

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

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

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