svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.oracle / src / org / gvsig / fmap / dal / store / oracle / OracleResourceParameters.java @ 30231
History | View | Annotate | Download (3.95 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 Prodevelop S.L. main development
|
26 |
*/
|
27 |
|
28 |
package org.gvsig.fmap.dal.store.oracle; |
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 OracleResourceParameters extends JDBCResourceParameters implements |
38 |
OracleConnectionParameters { |
39 |
|
40 |
private static DynClass DYNCLASS = null; |
41 |
|
42 |
public static final String DYNCLASS_NAME = "OracleResourceParameters"; |
43 |
|
44 |
public OracleResourceParameters() {
|
45 |
super();
|
46 |
} |
47 |
|
48 |
public OracleResourceParameters(String url, String host, Integer port, |
49 |
String dbName, String user, String password, |
50 |
String jdbcDriverClassName, Boolean ssl, String oraDriverType) { |
51 |
|
52 |
super(url, host, port, dbName, user, password, jdbcDriverClassName);
|
53 |
|
54 |
if (ssl != null) { |
55 |
this.setUseSSL(ssl.booleanValue());
|
56 |
} |
57 |
if (oraDriverType.compareToIgnoreCase("THIN") == 0 |
58 |
&& oraDriverType.compareToIgnoreCase("OCI") == 0) { |
59 |
this.setOraDriverType(oraDriverType);
|
60 |
} else {
|
61 |
this.setOraDriverType("THIN"); |
62 |
} |
63 |
} |
64 |
|
65 |
/**
|
66 |
* register dynamic class
|
67 |
*/
|
68 |
protected static void registerDynClass() { |
69 |
DynObjectManager dynman = ToolsLocator.getDynObjectManager(); |
70 |
DynClass dynClass = dynman.get(DYNCLASS_NAME); |
71 |
DynField field; |
72 |
if (dynClass == null) { |
73 |
dynClass = dynman.add(DYNCLASS_NAME); |
74 |
|
75 |
dynClass.extend(JDBCResourceParameters.DYNCLASS_NAME); |
76 |
|
77 |
field = dynClass.addDynField(DYNFIELDNAME_USESSL); |
78 |
field.setTheTypeOfAvailableValues(DynField.SINGLE); |
79 |
field.setDescription("use SSL connetion");
|
80 |
field.setType(DataTypes.BOOLEAN); |
81 |
field.setDefaultDynValue(Boolean.FALSE);
|
82 |
|
83 |
field = dynClass.addDynField(DYNFIELDNAME_JDBC_DRIVER_CLASS_NAME); |
84 |
field.setTheTypeOfAvailableValues(DynField.SINGLE); |
85 |
field.setDescription("JDBC Driver class");
|
86 |
field.setMandatory(true);
|
87 |
field.setType(DataTypes.STRING); |
88 |
field.setDefaultDynValue(OracleLibrary.DEFAULT_JDCB_DRIVER_NAME); |
89 |
|
90 |
field = dynClass.addDynField(DYNFIELDNAME_ORADRIVERTYPE); |
91 |
field.setTheTypeOfAvailableValues(DynField.SINGLE); |
92 |
field.setDescription("Oracle driver type");
|
93 |
field.setType(DataTypes.STRING); |
94 |
field.setDefaultDynValue("THIN");
|
95 |
|
96 |
} |
97 |
DYNCLASS = dynClass; |
98 |
} |
99 |
|
100 |
public String getUrl() { |
101 |
return OracleLibrary.getJdbcUrl(getOraDriverType(), getHost(),
|
102 |
getPort(), getDBName()); |
103 |
} |
104 |
|
105 |
public String getTypeName() { |
106 |
return OracleResource.NAME;
|
107 |
} |
108 |
|
109 |
public Boolean getUseSSL() { |
110 |
return (Boolean) this.getDynValue(DYNFIELDNAME_USESSL); |
111 |
} |
112 |
|
113 |
public String getOraDriverType() { |
114 |
return (String) this.getDynValue(DYNFIELDNAME_ORADRIVERTYPE); |
115 |
} |
116 |
|
117 |
public void setUseSSL(Boolean useSSL) { |
118 |
this.setDynValue(DYNFIELDNAME_USESSL, useSSL);
|
119 |
} |
120 |
|
121 |
public void setUseSSL(boolean useSSL) { |
122 |
this.setDynValue(DYNFIELDNAME_USESSL, new Boolean(useSSL)); |
123 |
} |
124 |
|
125 |
public void setOraDriverType(String oraDriverType) { |
126 |
this.setDynValue(DYNFIELDNAME_ORADRIVERTYPE, oraDriverType);
|
127 |
} |
128 |
|
129 |
protected String getDynClassName() { |
130 |
return DYNCLASS_NAME;
|
131 |
} |
132 |
|
133 |
} |