Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_daldb / src / org / gvsig / fmap / dal / store / mysql / MySQLResourceParameters.java @ 30754

History | View | Annotate | Download (3.34 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
* 2009 IVER T.I   {{Task}}
26
*/
27

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

    
30
import org.gvsig.fmap.dal.DataTypes;
31
import org.gvsig.fmap.dal.store.jdbc.JDBCResourceParameters;
32
import org.gvsig.tools.ToolsLocator;
33
import org.gvsig.tools.dynobject.DynClass;
34
import org.gvsig.tools.dynobject.DynField;
35
import org.gvsig.tools.dynobject.DynObjectManager;
36

    
37
public class MySQLResourceParameters extends JDBCResourceParameters
38
                implements MySQLConnectionParameters {
39

    
40
        private static DynClass DYNCLASS = null;
41

    
42
        public static final String DYNCLASS_NAME = "MySQLResourceParameters";
43

    
44
        public MySQLResourceParameters() {
45
                super();
46
        }
47

    
48
    public MySQLResourceParameters(String url, String host, Integer port,
49
                        String dbName, String user, String password,
50
                        String jdbcDriverClassName, Boolean ssl) {
51
                super(url, host, port, dbName, user, password, jdbcDriverClassName);
52
                if (ssl != null) {
53
                        this.setUseSSL(ssl.booleanValue());
54
                }
55
        }
56

    
57
        protected static void registerDynClass() {
58
                DynObjectManager dynman = ToolsLocator.getDynObjectManager();
59
                DynClass dynClass = dynman.get(DYNCLASS_NAME);
60
                DynField field;
61
                if (dynClass == null) {
62
                        dynClass = dynman.add(DYNCLASS_NAME);
63

    
64
                        dynClass.extend(JDBCResourceParameters.DYNCLASS_NAME);
65

    
66
                        field = dynClass.addDynField(DYNFIELDNAME_USESSL);
67
                        field.setTheTypeOfAvailableValues(DynField.SINGLE);
68
                        field.setDescription("use SSL connetion");
69
                        field.setType(DataTypes.BOOLEAN);
70
                        field.setDefaultDynValue(Boolean.FALSE);
71

    
72
                        field = dynClass.addDynField(DYNFIELDNAME_JDBC_DRIVER_CLASS_NAME);
73
                        field.setTheTypeOfAvailableValues(DynField.SINGLE);
74
                        field.setDescription("JDBC Driver class");
75
                        field.setMandatory(true);
76
                        field.setType(DataTypes.STRING);
77
                        field.setDefaultDynValue(MySQLLibrary.DEFAULT_JDCB_DRIVER_NAME);
78

    
79
                        // Register the DynClass in the PersistenceManager
80
                        ToolsLocator.getPersistenceManager().registerClass(
81
                                        MySQLResourceParameters.class, dynClass);
82
                }
83
                DYNCLASS = dynClass;
84
        }
85

    
86

    
87
        public String getUrl() {
88
                return MySQLLibrary.getJdbcUrl(getHost(),
89
                                getPort(),
90
                                getDBName());
91
        }
92

    
93
        public String getTypeName() {
94
                return MySQLResource.NAME;
95
        }
96

    
97
        public Boolean getUseSSL() {
98
                return (Boolean) this.getDynValue(DYNFIELDNAME_USESSL);
99
        }
100

    
101
        public void setUseSSL(Boolean useSSL) {
102
                this.setDynValue(DYNFIELDNAME_USESSL, useSSL);
103
        }
104

    
105
        public void setUseSSL(boolean useSSL) {
106
                this.setDynValue(DYNFIELDNAME_USESSL, new Boolean(useSSL));
107
        }
108

    
109
        protected String getDynClassName() {
110
                return DYNCLASS_NAME;
111
        }
112
}