Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_daldb / src / org / gvsig / fmap / dal / store / postgresql / PostgreSQLLibrary.java @ 28424

History | View | Annotate | Download (3.38 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.postgresql;
29

    
30
import org.gvsig.fmap.dal.DALLocator;
31
import org.gvsig.fmap.dal.resource.spi.ResourceManagerProviderServices;
32
import org.gvsig.fmap.dal.spi.DataManagerProviderServices;
33
import org.gvsig.tools.locator.BaseLibrary;
34
import org.gvsig.tools.locator.ReferenceNotRegisteredException;
35

    
36

    
37
public class PostgreSQLLibrary extends BaseLibrary {
38

    
39

    
40
        static String DEFAULT_JDCB_DRIVER_NAME = "org.postgresql.Driver";
41

    
42
//        static PostgreSQLResourceParameters getResourceParameters(
43
//                        PostgreSQLServerexplorerParameters serverExplorerParameters) {
44
//
45
//        }
46

    
47

    
48

    
49
        public static String getJdbcUrl(String host, Integer port, String db) {
50
                String url;
51
                String sport = "";
52
                if (port != null) {
53
                        sport = ":" + port;
54
                }
55
                url = "jdbc:postgresql://" + host + sport + "/" + db;
56

    
57
                return url;
58
        }
59

    
60

    
61
        public void initialize() throws ReferenceNotRegisteredException {
62
                super.initialize();
63

    
64
        }
65

    
66
        public void postInitialize() throws ReferenceNotRegisteredException {
67
                super.postInitialize();
68

    
69
            ResourceManagerProviderServices resman = (ResourceManagerProviderServices) DALLocator
70
                                .getResourceManager();
71

    
72
            PostgreSQLResourceParameters.registerDynClass();
73

    
74
            if (!resman.getResourceProviders().contains(PostgreSQLResource.NAME)) {
75
                        resman.register(PostgreSQLResource.NAME,
76
                                        PostgreSQLResource.DESCRIPTION, PostgreSQLResource.class,
77
                                        PostgreSQLResourceParameters.class);
78
                }
79

    
80

    
81
            PostgreSQLStoreParameters.registerDynClass();
82
            PostgreSQLNewStoreParameters.registerDynClass();
83
                PostgreSQLStoreProvider.registerDynClass();
84

    
85
        DataManagerProviderServices dataman = (DataManagerProviderServices) DALLocator
86
                                .getDataManager();
87

    
88
        /*
89
         * Read only provider
90
         *
91
                if (!dataman.getStoreProviders().contains(PostgreSQLStoreProvider.NAME)) {
92
                        dataman.registerStoreProvider(PostgreSQLStoreProvider.NAME,
93
                                        PostgreSQLStoreProvider.class,
94
                                        PostgreSQLStoreParameters.class);
95
                }
96
                */
97

    
98
                if (!dataman.getStoreProviders().contains(PostgreSQLStoreProvider.NAME)) {
99
                        dataman.registerStoreProvider(PostgreSQLStoreProvider.NAME,
100
                                        // PostgreSQLStoreProvider.class,
101
                                        PostgreSQLStoreProviderWriter.class,
102
                                        PostgreSQLStoreParameters.class);
103
                }
104

    
105
                if (!dataman.getExplorerProviders().contains(
106
                                PostgreSQLStoreProvider.NAME)) {
107
                        dataman.registerExplorerProvider(PostgreSQLServerExplorer.NAME,
108
                                        PostgreSQLServerExplorer.class,
109
                                        PostgreSQLServerExplorerParameters.class);
110
                }
111

    
112

    
113

    
114
        }
115

    
116
}