Skip to content

Commit df507c8

Browse files
committed
Add setConnectTimeout and setReadTimeout #54
1 parent 9186ac0 commit df507c8

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed

src/main/java/es/upv/i3m/grycap/im/InfrastructureManager.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,26 @@ private ImClient getImClient() {
9999
return imClient;
100100
}
101101

102+
/**
103+
* Set the client connection timeout.
104+
*
105+
* @param connectTimeout
106+
* : int with the client connection timeout
107+
*/
108+
public void setConnectTimeout(final int connectTimeout) {
109+
imClient.setConnectTimeout(connectTimeout);
110+
}
111+
112+
/**
113+
* Set the client read timeout.
114+
*
115+
* @param readTimeout
116+
* : int with the client read timeout
117+
*/
118+
public void setReadTimeout(final int readTimeout) {
119+
imClient.setReadTimeout(readTimeout);
120+
}
121+
102122
/**
103123
* Create and configure an infrastructure with the requirements specified in
104124
* the document of the body contents.<br>

src/main/java/es/upv/i3m/grycap/im/rest/client/ImClient.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -87,26 +87,22 @@ public ImClient(final String targetUrl, final String authorizationHeader)
8787
}
8888

8989
/**
90-
* Creates a new client using the 'imServiceUrl' as endpoint.<br>
91-
* Loads the authorization credentials from the 'authorizationHeader'
92-
* parameter. It also enables to set the read and connection timeouts.
90+
* Set the client connection timeout.
9391
*
94-
* @param targetUrl
95-
* : url of the IM rest service
96-
* @param authorizationHeader
97-
* : string with the authorization content
9892
* @param connectTimeout
9993
* : int with the client connection timeout
94+
*/
95+
public void setConnectTimeout(final int connectTimeout) {
96+
this.client.property("jersey.config.client.connectTimeout", connectTimeout);
97+
}
98+
99+
/**
100+
* Set the client read timeout.
101+
*
100102
* @param readTimeout
101103
* : int with the client read timeout
102104
*/
103-
public ImClient(final String targetUrl, final String authorizationHeader,
104-
final int connectTimeout, final int readTimeout)
105-
throws ImClientException {
106-
this.targetUrl = targetUrl;
107-
this.authorizationHeader = authorizationHeader;
108-
this.client = createRestClient();
109-
this.client.property("jersey.config.client.connectTimeout", connectTimeout);
105+
public void setReadTimeout(final int readTimeout) {
110106
this.client.property("jersey.config.client.readTimeout", readTimeout);
111107
}
112108

0 commit comments

Comments
 (0)