1 package ca.uhn.fhir.rest.client;
2
3 /*
4 * #%L
5 * HAPI FHIR - Core Library
6 * %%
7 * Copyright (C) 2014 University Health Network
8 * %%
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * #L%
21 */
22
23 import org.apache.http.client.HttpClient;
24
25 import ca.uhn.fhir.context.ConfigurationException;
26 import ca.uhn.fhir.rest.client.api.IRestfulClient;
27
28 public interface IRestfulClientFactory {
29
30 /**
31 * Instantiates a new client instance
32 *
33 * @param theClientType
34 * The client type, which is an interface type to be instantiated
35 * @param theServerBase
36 * The URL of the base for the restful FHIR server to connect to
37 * @return A newly created client
38 * @throws ConfigurationException
39 * If the interface type is not an interface
40 */
41 <T extends IRestfulClient> T newClient(Class<T> theClientType, String theServerBase);
42
43
44 /**
45 * Sets the Apache HTTP client instance to be used by any new restful clients created by
46 * this factory. If set to <code>null</code>, a new HTTP client with
47 * default settings will be created.
48 *
49 * @param theHttpClient An HTTP client instance to use, or <code>null</code>
50 */
51 void setHttpClient(HttpClient theHttpClient);
52
53 /**
54 * Returns the Apache HTTP client instance. This method will not return null.
55 *
56 * @see #setHttpClient(HttpClient)
57 */
58 HttpClient getHttpClient();
59
60 /**
61 * Instantiates a new generic client instance
62 *
63 * @param theServerBase
64 * The URL of the base for the restful FHIR server to connect to
65 * @return A newly created client
66 */
67 IGenericClient newGenericClient(String theServerBase);
68
69
70 void setSocketTimeout(int theSocketTimeout);
71
72
73 void setConnectTimeout(int theConnectTimeout);
74
75
76 void setConnectionRequestTimeout(int theConnectionRequestTimeout);
77
78 /**
79 * Sets the HTTP proxy to use for outgoing connections
80 *
81 * @param theHost The host (or null to disable proxying, as is the default)
82 * @param thePort The port (or null to disable proxying, as is the default)
83 */
84 void setProxy(String theHost, Integer thePort);
85
86 }