11
11
package io .vertx .oracleclient ;
12
12
13
13
import io .vertx .codegen .annotations .DataObject ;
14
- import io .vertx .core .json .JsonArray ;
15
14
import io .vertx .core .json .JsonObject ;
15
+ import io .vertx .core .net .SocketAddress ;
16
16
import io .vertx .core .tracing .TracingPolicy ;
17
+ import io .vertx .oracleclient .impl .OracleConnectionUriParser ;
17
18
import io .vertx .sqlclient .SqlConnectOptions ;
18
19
20
+ import java .util .Map ;
21
+ import java .util .function .Predicate ;
22
+
19
23
@ DataObject (generateConverter = true )
20
24
public class OracleConnectOptions extends SqlConnectOptions {
21
25
22
26
// Support TNS_ADMIN (tnsnames.ora, ojdbc.properties).
23
27
private String tnsAdmin ;
24
28
25
- private int connectTimeout ;
26
- private int idleTimeout ;
27
-
28
-
29
- private TracingPolicy tracingPolicy ;
30
-
31
- public OracleConnectOptions (JsonObject toJson ) {
32
- super (toJson );
33
- // TODO Copy
34
- }
35
-
36
29
public OracleConnectOptions () {
30
+ }
37
31
32
+ public OracleConnectOptions (OracleConnectOptions other ) {
33
+ super (other );
34
+ this .tnsAdmin = other .tnsAdmin ;
38
35
}
39
36
40
37
public OracleConnectOptions (SqlConnectOptions options ) {
41
38
super (options );
42
- // TODO Copy
43
39
}
44
40
45
- // TODO...
46
-
47
- /**
48
- * @return the tracing policy
49
- */
50
- public TracingPolicy getTracingPolicy () {
51
- return tracingPolicy ;
41
+ public OracleConnectOptions (JsonObject json ) {
42
+ super (json );
43
+ OracleConnectOptionsConverter .fromJson (json , this );
52
44
}
53
45
54
46
/**
55
- * Set the tracing policy for the client behavior when Vert.x has tracing enabled .
47
+ * Provide a {@link OracleConnectOptions} configured from a connection URI .
56
48
*
57
- * @param tracingPolicy the tracing policy
58
- * @return a reference to this, so the API can be used fluently
49
+ * @param connectionUri the connection URI to configure from
50
+ * @return a {@link OracleConnectOptions} parsed from the connection URI
51
+ * @throws IllegalArgumentException when the {@code connectionUri} is in an invalid format
59
52
*/
60
- public OracleConnectOptions setTracingPolicy ( TracingPolicy tracingPolicy ) {
61
- this . tracingPolicy = tracingPolicy ;
62
- return this ;
53
+ public static OracleConnectOptions fromUri ( String connectionUri ) throws IllegalArgumentException {
54
+ JsonObject parsedConfiguration = OracleConnectionUriParser . parse ( connectionUri ) ;
55
+ return new OracleConnectOptions ( parsedConfiguration ) ;
63
56
}
64
57
65
- // Oracle specifics
58
+ // Oracle-specific options
66
59
67
60
public String getTnsAdmin () {
68
61
return tnsAdmin ;
@@ -73,51 +66,127 @@ public OracleConnectOptions setTnsAdmin(String tnsAdmin) {
73
66
return this ;
74
67
}
75
68
69
+ // Non-specific options
70
+
76
71
@ Override
77
- public OracleConnectOptions setPort (int port ) {
78
- super .setPort (port );
79
- return this ;
72
+ public String getHost () {
73
+ return super .getHost ();
80
74
}
81
75
82
76
@ Override
83
77
public OracleConnectOptions setHost (String host ) {
84
- super .setHost (host );
85
- return this ;
78
+ return (OracleConnectOptions ) super .setHost (host );
86
79
}
87
80
88
81
@ Override
89
- public OracleConnectOptions setDatabase (String db ) {
90
- super .setDatabase (db );
91
- return this ;
82
+ public int getPort () {
83
+ return super .getPort ();
84
+ }
85
+
86
+ @ Override
87
+ public OracleConnectOptions setPort (int port ) {
88
+ return (OracleConnectOptions ) super .setPort (port );
89
+ }
90
+
91
+ @ Override
92
+ public String getUser () {
93
+ return super .getUser ();
92
94
}
93
95
94
96
@ Override
95
97
public OracleConnectOptions setUser (String user ) {
96
- super .setUser (user );
97
- return this ;
98
+ return (OracleConnectOptions ) super .setUser (user );
98
99
}
99
100
100
101
@ Override
101
- public OracleConnectOptions setPassword (String pwd ) {
102
- super .setPassword (pwd );
103
- return this ;
102
+ public String getPassword () {
103
+ return super .getPassword ();
104
+ }
105
+
106
+ @ Override
107
+ public OracleConnectOptions setPassword (String password ) {
108
+ return (OracleConnectOptions ) super .setPassword (password );
104
109
}
105
110
106
- public int getConnectTimeout () {
107
- return connectTimeout ;
111
+ @ Override
112
+ public String getDatabase () {
113
+ return super .getDatabase ();
108
114
}
109
115
110
- public OracleConnectOptions setConnectTimeout ( int connectTimeout ) {
111
- this . connectTimeout = connectTimeout ;
112
- return this ;
116
+ @ Override
117
+ public OracleConnectOptions setDatabase ( String database ) {
118
+ return ( OracleConnectOptions ) super . setDatabase ( database ) ;
113
119
}
114
120
115
- public int getIdleTimeout () {
116
- return idleTimeout ;
121
+ @ Override
122
+ public boolean getCachePreparedStatements () {
123
+ return super .getCachePreparedStatements ();
117
124
}
118
125
119
- public OracleConnectOptions setIdleTimeout (int idleTimeout ) {
120
- this .idleTimeout = idleTimeout ;
121
- return this ;
126
+ @ Override
127
+ public OracleConnectOptions setCachePreparedStatements (boolean cachePreparedStatements ) {
128
+ return (OracleConnectOptions ) super .setCachePreparedStatements (cachePreparedStatements );
129
+ }
130
+
131
+ @ Override
132
+ public int getPreparedStatementCacheMaxSize () {
133
+ return super .getPreparedStatementCacheMaxSize ();
134
+ }
135
+
136
+ @ Override
137
+ public OracleConnectOptions setPreparedStatementCacheMaxSize (int preparedStatementCacheMaxSize ) {
138
+ return (OracleConnectOptions ) super .setPreparedStatementCacheMaxSize (preparedStatementCacheMaxSize );
139
+ }
140
+
141
+ @ Override
142
+ public Predicate <String > getPreparedStatementCacheSqlFilter () {
143
+ return super .getPreparedStatementCacheSqlFilter ();
144
+ }
145
+
146
+ @ Override
147
+ public OracleConnectOptions setPreparedStatementCacheSqlFilter (Predicate <String > predicate ) {
148
+ return (OracleConnectOptions ) super .setPreparedStatementCacheSqlFilter (predicate );
149
+ }
150
+
151
+ @ Override
152
+ public OracleConnectOptions setPreparedStatementCacheSqlLimit (int preparedStatementCacheSqlLimit ) {
153
+ return (OracleConnectOptions ) super .setPreparedStatementCacheSqlLimit (preparedStatementCacheSqlLimit );
154
+ }
155
+
156
+ @ Override
157
+ public Map <String , String > getProperties () {
158
+ return super .getProperties ();
159
+ }
160
+
161
+ @ Override
162
+ public OracleConnectOptions setProperties (Map <String , String > properties ) {
163
+ return (OracleConnectOptions ) super .setProperties (properties );
164
+ }
165
+
166
+ @ Override
167
+ public OracleConnectOptions addProperty (String key , String value ) {
168
+ return (OracleConnectOptions ) super .addProperty (key , value );
169
+ }
170
+
171
+ @ Override
172
+ public SocketAddress getSocketAddress () {
173
+ return super .getSocketAddress ();
174
+ }
175
+
176
+ @ Override
177
+ public TracingPolicy getTracingPolicy () {
178
+ return super .getTracingPolicy ();
179
+ }
180
+
181
+ @ Override
182
+ public OracleConnectOptions setTracingPolicy (TracingPolicy tracingPolicy ) {
183
+ return (OracleConnectOptions ) super .setTracingPolicy (tracingPolicy );
184
+ }
185
+
186
+ @ Override
187
+ public JsonObject toJson () {
188
+ JsonObject json = super .toJson ();
189
+ OracleConnectOptionsConverter .toJson (this , json );
190
+ return json ;
122
191
}
123
192
}
0 commit comments