@@ -47,7 +47,7 @@ public class ArangoConfigure {
4747 private static final int DEFAULT_PORT = 8529 ;
4848
4949 /** default */
50- private static final int DEFAULT_MAX_PER_CONNECTION = 20 ; // 2;
50+ private static final int DEFAULT_MAX_PER_CONNECTION = 20 ;
5151 /** default maximum conections */
5252 private static final int DEFAULT_MAX_CONNECTION = 20 ;
5353
@@ -146,125 +146,9 @@ public void loadProperties(String propertyPath) {
146146 try {
147147 in = getClass ().getResourceAsStream (propertyPath );
148148 if (in != null ) {
149-
150149 logger .debug ("load property: file={}" , propertyPath );
151150
152- Properties prop = new Properties ();
153- prop .load (in );
154-
155- //
156- String port = prop .getProperty ("port" );
157- if (port != null ) {
158- arangoHosts .get (0 ).setPort (Integer .parseInt (port ));
159- }
160-
161- String host = prop .getProperty ("host" );
162- if (host != null ) {
163- arangoHosts .get (0 ).setHost (host );
164- }
165-
166- String arangoHost = prop .getProperty ("arangoHost" );
167- if (arangoHost != null ) {
168- ArangoHost ah = parseArangoHost (arangoHost );
169- if (ah != null ) {
170- arangoHosts .get (0 ).setHost (ah .getHost ());
171- arangoHosts .get (0 ).setPort (ah .getPort ());
172- }
173- }
174-
175- String fallbackArangoHost = prop .getProperty ("fallbackArangoHost" );
176- if (fallbackArangoHost != null ) {
177- ArangoHost ah = parseArangoHost (fallbackArangoHost );
178- if (ah != null ) {
179- addFallbackArangoHost (ah );
180- }
181- }
182-
183- String timeout = prop .getProperty ("timeout" );
184- if (timeout != null ) {
185- setTimeout (Integer .parseInt (timeout ));
186- }
187-
188- String connectionTimeout = prop .getProperty ("connectionTimeout" );
189- if (connectionTimeout != null ) {
190- setConnectionTimeout (Integer .parseInt (connectionTimeout ));
191- }
192-
193- String proxyHost = prop .getProperty ("proxy.host" );
194- if (proxyHost != null ) {
195- setProxyHost (proxyHost );
196- }
197-
198- String proxyPort = prop .getProperty ("proxy.port" );
199- if (proxyPort != null ) {
200- setProxyPort (Integer .parseInt (proxyPort ));
201- }
202-
203- String maxPerConnection = prop .getProperty ("maxPerConnection" );
204- if (maxPerConnection != null ) {
205- setMaxPerConnection (Integer .parseInt (maxPerConnection ));
206- }
207-
208- String maxTotalConnection = prop .getProperty ("maxTotalConnection" );
209- if (maxTotalConnection != null ) {
210- setMaxTotalConnection (Integer .parseInt (maxTotalConnection ));
211- }
212-
213- String retryCount = prop .getProperty ("retryCount" );
214- if (retryCount != null ) {
215- setRetryCount (Integer .parseInt (retryCount ));
216- }
217-
218- String connnectRetryCount = prop .getProperty ("connnectRetryCount" );
219- if (connnectRetryCount != null ) {
220- setConnectRetryCount (Integer .parseInt (connnectRetryCount ));
221- }
222-
223- String connectRetryWait = prop .getProperty ("connectRetryWait" );
224- if (connectRetryWait != null ) {
225- setConnectRetryWait (Integer .parseInt (connectRetryWait ));
226- }
227-
228- String user = prop .getProperty ("user" );
229- if (user != null ) {
230- setUser (user );
231- }
232-
233- String password = prop .getProperty ("password" );
234- if (password != null ) {
235- setPassword (password );
236- }
237-
238- String defaultDatabase = prop .getProperty ("defaultDatabase" );
239- if (defaultDatabase != null ) {
240- setDefaultDatabase (defaultDatabase );
241- }
242-
243- String enableCURLLogger = prop .getProperty ("enableCURLLogger" );
244- if (enableCURLLogger != null ) {
245- setEnableCURLLogger (Boolean .parseBoolean (enableCURLLogger ));
246- }
247-
248- String staleConnectionCheck = prop .getProperty ("staleConnectionCheck" );
249- if (staleConnectionCheck != null ) {
250- setStaleConnectionCheck (Boolean .parseBoolean (staleConnectionCheck ));
251- }
252-
253- String batchSize = prop .getProperty ("batchSize" );
254- if (batchSize != null ) {
255- setBatchSize (Integer .parseInt (batchSize ));
256- }
257-
258- String useSsl = prop .getProperty ("useSsl" );
259- if (useSsl != null ) {
260- setUseSsl (Boolean .parseBoolean (useSsl ));
261- }
262-
263- String sslTrustStore = prop .getProperty ("sslTrustStore" );
264- if (sslTrustStore != null ) {
265- setSslTrustStore (sslTrustStore );
266- }
267-
151+ loadProperties (in );
268152 }
269153 } catch (IOException e ) {
270154 logger .warn ("load property error" , e );
@@ -275,6 +159,125 @@ public void loadProperties(String propertyPath) {
275159 }
276160 }
277161
162+ private void loadProperties (InputStream in ) throws IOException {
163+
164+ Properties prop = new Properties ();
165+ prop .load (in );
166+
167+ //
168+ String port = prop .getProperty ("port" );
169+ if (port != null ) {
170+ arangoHosts .get (0 ).setPort (Integer .parseInt (port ));
171+ }
172+
173+ String host = prop .getProperty ("host" );
174+ if (host != null ) {
175+ arangoHosts .get (0 ).setHost (host );
176+ }
177+
178+ String arangoHost = prop .getProperty ("arangoHost" );
179+ if (arangoHost != null ) {
180+ ArangoHost ah = parseArangoHost (arangoHost );
181+ if (ah != null ) {
182+ arangoHosts .get (0 ).setHost (ah .getHost ());
183+ arangoHosts .get (0 ).setPort (ah .getPort ());
184+ }
185+ }
186+
187+ String fallbackArangoHost = prop .getProperty ("fallbackArangoHost" );
188+ if (fallbackArangoHost != null ) {
189+ ArangoHost ah = parseArangoHost (fallbackArangoHost );
190+ if (ah != null ) {
191+ addFallbackArangoHost (ah );
192+ }
193+ }
194+
195+ String timeoutProperty = prop .getProperty ("timeout" );
196+ if (timeoutProperty != null ) {
197+ setTimeout (Integer .parseInt (timeoutProperty ));
198+ }
199+
200+ String connectionTimeoutProperty = prop .getProperty ("connectionTimeout" );
201+ if (connectionTimeoutProperty != null ) {
202+ setConnectionTimeout (Integer .parseInt (connectionTimeoutProperty ));
203+ }
204+
205+ String proxyHostProperty = prop .getProperty ("proxy.host" );
206+ if (proxyHostProperty != null ) {
207+ setProxyHost (proxyHostProperty );
208+ }
209+
210+ String proxyPortProperty = prop .getProperty ("proxy.port" );
211+ if (proxyPortProperty != null ) {
212+ setProxyPort (Integer .parseInt (proxyPortProperty ));
213+ }
214+
215+ String maxPerConnectionProperty = prop .getProperty ("maxPerConnection" );
216+ if (maxPerConnectionProperty != null ) {
217+ setMaxPerConnection (Integer .parseInt (maxPerConnectionProperty ));
218+ }
219+
220+ String maxTotalConnectionProperty = prop .getProperty ("maxTotalConnection" );
221+ if (maxTotalConnectionProperty != null ) {
222+ setMaxTotalConnection (Integer .parseInt (maxTotalConnectionProperty ));
223+ }
224+
225+ String retryCountProperty = prop .getProperty ("retryCount" );
226+ if (retryCountProperty != null ) {
227+ setRetryCount (Integer .parseInt (retryCountProperty ));
228+ }
229+
230+ String connnectRetryCount = prop .getProperty ("connnectRetryCount" );
231+ if (connnectRetryCount != null ) {
232+ setConnectRetryCount (Integer .parseInt (connnectRetryCount ));
233+ }
234+
235+ String connectRetryWaitProperty = prop .getProperty ("connectRetryWait" );
236+ if (connectRetryWaitProperty != null ) {
237+ setConnectRetryWait (Integer .parseInt (connectRetryWaitProperty ));
238+ }
239+
240+ String userProperty = prop .getProperty ("user" );
241+ if (userProperty != null ) {
242+ setUser (userProperty );
243+ }
244+
245+ String passwordProperty = prop .getProperty ("password" );
246+ if (passwordProperty != null ) {
247+ setPassword (passwordProperty );
248+ }
249+
250+ String defaultDatabaseProperty = prop .getProperty ("defaultDatabase" );
251+ if (defaultDatabaseProperty != null ) {
252+ setDefaultDatabase (defaultDatabaseProperty );
253+ }
254+
255+ String enableCURLLoggerProperty = prop .getProperty ("enableCURLLogger" );
256+ if (enableCURLLoggerProperty != null ) {
257+ setEnableCURLLogger (Boolean .parseBoolean (enableCURLLoggerProperty ));
258+ }
259+
260+ String staleConnectionCheckProperty = prop .getProperty ("staleConnectionCheck" );
261+ if (staleConnectionCheckProperty != null ) {
262+ setStaleConnectionCheck (Boolean .parseBoolean (staleConnectionCheckProperty ));
263+ }
264+
265+ String batchSizeProperty = prop .getProperty ("batchSize" );
266+ if (batchSizeProperty != null ) {
267+ setBatchSize (Integer .parseInt (batchSizeProperty ));
268+ }
269+
270+ String useSslProperty = prop .getProperty ("useSsl" );
271+ if (useSslProperty != null ) {
272+ setUseSsl (Boolean .parseBoolean (useSslProperty ));
273+ }
274+
275+ String sslTrustStoreProperty = prop .getProperty ("sslTrustStore" );
276+ if (sslTrustStoreProperty != null ) {
277+ setSslTrustStore (sslTrustStoreProperty );
278+ }
279+ }
280+
278281 private ArangoHost parseArangoHost (String str ) {
279282 if (str == null ) {
280283 return null ;
0 commit comments