root / branches / v2_0_0_prep / libraries / libFMap_daldb / src / org / gvsig / fmap / dal / store / jdbc / JDBCResourceParameters.java @ 30754
History | View | Annotate | Download (4.03 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.jdbc; |
29 |
|
30 |
import org.gvsig.fmap.dal.DataTypes; |
31 |
import org.gvsig.fmap.dal.resource.db.DBResourceParameters; |
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 JDBCResourceParameters extends DBResourceParameters |
38 |
implements JDBCConnectionParameters {
|
39 |
|
40 |
public static final String DYNCLASS_NAME = "JDBCResourceParameters"; |
41 |
|
42 |
private static DynClass DYNCLASS = null; |
43 |
|
44 |
|
45 |
public JDBCResourceParameters(String url, String host, Integer port, |
46 |
String dbName,
|
47 |
String user, String password, String jdbcDriverClassName) { |
48 |
super();
|
49 |
|
50 |
this.setUrl(url);
|
51 |
this.setHost(host);
|
52 |
this.setPort(port);
|
53 |
this.setDBName(dbName);
|
54 |
this.setUser(user);
|
55 |
this.setPassword(password);
|
56 |
this.setJDBCDriverClassName(jdbcDriverClassName);
|
57 |
} |
58 |
|
59 |
|
60 |
public JDBCResourceParameters() {
|
61 |
super();
|
62 |
} |
63 |
|
64 |
public String getTypeName() { |
65 |
return JDBCResource.NAME;
|
66 |
} |
67 |
|
68 |
protected String getDynClassName() { |
69 |
return DYNCLASS_NAME;
|
70 |
} |
71 |
|
72 |
static void registerDynClass() { |
73 |
DynObjectManager dynman = ToolsLocator.getDynObjectManager(); |
74 |
DynClass dynClass = dynman.get(DYNCLASS_NAME); |
75 |
DynField field; |
76 |
if (dynClass == null) { |
77 |
dynClass = dynman.add(DYNCLASS_NAME); |
78 |
|
79 |
dynClass.extend(DBResourceParameters.DYNCLASS_NAME); |
80 |
|
81 |
field = dynClass.addDynField(DYNFIELDNAME_JDBC_DRIVER_CLASS_NAME); |
82 |
field.setTheTypeOfAvailableValues(DynField.SINGLE); |
83 |
field.setDescription("JDBC Driver class");
|
84 |
field.setMandatory(true);
|
85 |
field.setType(DataTypes.STRING); |
86 |
|
87 |
field = dynClass.addDynField(DYNFIELDNAME_URL); |
88 |
field.setTheTypeOfAvailableValues(DynField.SINGLE); |
89 |
field.setDescription("JDBC connection url");
|
90 |
field.setMandatory(true);
|
91 |
field.setType(DataTypes.STRING); |
92 |
|
93 |
|
94 |
field = dynClass.addDynField(DYNFIELDNAME_CATALOG); |
95 |
field.setTheTypeOfAvailableValues(DynField.SINGLE); |
96 |
field.setDescription("DB Catalog");
|
97 |
field.setType(DataTypes.STRING); |
98 |
|
99 |
field = dynClass.addDynField(DYNFIELDNAME_SCHEMA); |
100 |
field.setTheTypeOfAvailableValues(DynField.SINGLE); |
101 |
field.setDescription("DB Schema");
|
102 |
field.setType(DataTypes.STRING); |
103 |
|
104 |
// Register the DynClass in the PersistenceManager
|
105 |
ToolsLocator.getPersistenceManager().registerClass( |
106 |
JDBCResourceParameters.class, dynClass); |
107 |
} |
108 |
DYNCLASS = dynClass; |
109 |
|
110 |
} |
111 |
|
112 |
|
113 |
public void setJDBCDriverClassName(String className) { |
114 |
this.setDynValue(DYNFIELDNAME_JDBC_DRIVER_CLASS_NAME, className);
|
115 |
} |
116 |
|
117 |
public String getJDBCDriverClassName() { |
118 |
return (String) this.getDynValue(DYNFIELDNAME_JDBC_DRIVER_CLASS_NAME); |
119 |
} |
120 |
|
121 |
public String getCatalog() { |
122 |
return (String) this.getDynValue(DYNFIELDNAME_CATALOG); |
123 |
} |
124 |
|
125 |
public void setCatalog(String catalog) { |
126 |
this.setDynValue(DYNFIELDNAME_CATALOG, catalog);
|
127 |
} |
128 |
|
129 |
public String getSchema() { |
130 |
return (String) this.getDynValue(DYNFIELDNAME_SCHEMA); |
131 |
} |
132 |
|
133 |
public void setSchema(String schema) { |
134 |
this.setDynValue(DYNFIELDNAME_SCHEMA, schema);
|
135 |
} |
136 |
|
137 |
|
138 |
public String getUrl() { |
139 |
return (String) this.getDynValue(DYNFIELDNAME_URL); |
140 |
} |
141 |
|
142 |
public void setUrl(String url) { |
143 |
this.setDynValue(DYNFIELDNAME_URL, url);
|
144 |
} |
145 |
|
146 |
|
147 |
} |