1
+ /*
2
+ * Copyright (c) 2010-2014 Sonatype, Inc. All rights reserved.
3
+ *
4
+ * This program is licensed to you under the Apache License Version 2.0,
5
+ * and you may not use this file except in compliance with the Apache License Version 2.0.
6
+ * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
7
+ *
8
+ * Unless required by applicable law or agreed to in writing,
9
+ * software distributed under the Apache License Version 2.0 is distributed on an
10
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
+ * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
12
+ */
1
13
package org .asynchttpclient ;
2
14
3
15
import org .asynchttpclient .util .AsyncImplHelper ;
@@ -38,25 +50,22 @@ public static AsyncHttpClient getAsyncHttpClient() {
38
50
return (AsyncHttpClient ) asyncHttpClientImplClass .newInstance ();
39
51
} catch (InstantiationException e ) {
40
52
throw new AsyncHttpClientImplException ("Unable to create the class specified by system property : "
41
- + AsyncImplHelper .ASYNC_HTTP_CLIENT_IMPL_SYSTEM_PROPERTY ,e );
53
+ + AsyncImplHelper .ASYNC_HTTP_CLIENT_IMPL_SYSTEM_PROPERTY , e );
42
54
} catch (IllegalAccessException e ) {
43
55
throw new AsyncHttpClientImplException ("Unable to find the class specified by system property : "
44
- + AsyncImplHelper .ASYNC_HTTP_CLIENT_IMPL_SYSTEM_PROPERTY ,e );
56
+ + AsyncImplHelper .ASYNC_HTTP_CLIENT_IMPL_SYSTEM_PROPERTY , e );
45
57
}
46
58
return new DefaultAsyncHttpClient ();
47
59
}
48
60
49
61
public static AsyncHttpClient getAsyncHttpClient (AsyncHttpProvider provider ) {
50
62
if (attemptInstantiation ()) {
51
63
try {
52
- Constructor <AsyncHttpClient > constructor = asyncHttpClientImplClass
53
- .getConstructor (AsyncHttpProvider .class );
64
+ Constructor <AsyncHttpClient > constructor = asyncHttpClientImplClass .getConstructor (AsyncHttpProvider .class );
54
65
return constructor .newInstance (provider );
55
- }catch (Exception e ) {
56
- throw new AsyncHttpClientImplException (
57
- "Unable to find the instantiate the class specified by system property : "
58
- + AsyncImplHelper .ASYNC_HTTP_CLIENT_IMPL_SYSTEM_PROPERTY
59
- + "(AsyncHttpProvider) due to : " + e .getMessage (), e );
66
+ } catch (Exception e ) {
67
+ throw new AsyncHttpClientImplException ("Unable to find the instantiate the class specified by system property : "
68
+ + AsyncImplHelper .ASYNC_HTTP_CLIENT_IMPL_SYSTEM_PROPERTY + "(AsyncHttpProvider) due to : " + e .getMessage (), e );
60
69
}
61
70
}
62
71
return new DefaultAsyncHttpClient (provider );
@@ -65,14 +74,11 @@ public static AsyncHttpClient getAsyncHttpClient(AsyncHttpProvider provider) {
65
74
public static AsyncHttpClient getAsyncHttpClient (AsyncHttpClientConfig config ) {
66
75
if (attemptInstantiation ()) {
67
76
try {
68
- Constructor <AsyncHttpClient > constructor = asyncHttpClientImplClass
69
- .getConstructor (AsyncHttpClientConfig .class );
77
+ Constructor <AsyncHttpClient > constructor = asyncHttpClientImplClass .getConstructor (AsyncHttpClientConfig .class );
70
78
return constructor .newInstance (config );
71
79
} catch (Exception e ) {
72
- throw new AsyncHttpClientImplException (
73
- "Unable to find the instantiate the class specified by system property : "
74
- + AsyncImplHelper .ASYNC_HTTP_CLIENT_IMPL_SYSTEM_PROPERTY
75
- + "(AsyncHttpProvider) due to : " + e .getMessage (), e );
80
+ throw new AsyncHttpClientImplException ("Unable to find the instantiate the class specified by system property : "
81
+ + AsyncImplHelper .ASYNC_HTTP_CLIENT_IMPL_SYSTEM_PROPERTY + "(AsyncHttpProvider) due to : " + e .getMessage (), e );
76
82
}
77
83
}
78
84
return new DefaultAsyncHttpClient (config );
@@ -81,14 +87,12 @@ public static AsyncHttpClient getAsyncHttpClient(AsyncHttpClientConfig config) {
81
87
public static AsyncHttpClient getAsyncHttpClient (AsyncHttpProvider provider , AsyncHttpClientConfig config ) {
82
88
if (attemptInstantiation ()) {
83
89
try {
84
- Constructor <AsyncHttpClient > constructor = asyncHttpClientImplClass .getConstructor (
85
- AsyncHttpProvider . class , AsyncHttpClientConfig .class );
90
+ Constructor <AsyncHttpClient > constructor = asyncHttpClientImplClass .getConstructor (AsyncHttpProvider . class ,
91
+ AsyncHttpClientConfig .class );
86
92
return constructor .newInstance (provider , config );
87
93
} catch (Exception e ) {
88
- throw new AsyncHttpClientImplException (
89
- "Unable to find the instantiate the class specified by system property : "
90
- + AsyncImplHelper .ASYNC_HTTP_CLIENT_IMPL_SYSTEM_PROPERTY
91
- + "(AsyncHttpProvider) due to : " + e .getMessage (), e );
94
+ throw new AsyncHttpClientImplException ("Unable to find the instantiate the class specified by system property : "
95
+ + AsyncImplHelper .ASYNC_HTTP_CLIENT_IMPL_SYSTEM_PROPERTY + "(AsyncHttpProvider) due to : " + e .getMessage (), e );
92
96
}
93
97
}
94
98
return new DefaultAsyncHttpClient (provider , config );
@@ -101,10 +105,8 @@ public static AsyncHttpClient getAsyncHttpClient(String providerClass, AsyncHttp
101
105
AsyncHttpClientConfig .class );
102
106
return constructor .newInstance (providerClass , config );
103
107
} catch (Exception e ) {
104
- throw new AsyncHttpClientImplException (
105
- "Unable to find the instantiate the class specified by system property : "
106
- + AsyncImplHelper .ASYNC_HTTP_CLIENT_IMPL_SYSTEM_PROPERTY
107
- + "(AsyncHttpProvider) due to : " + e .getMessage (), e );
108
+ throw new AsyncHttpClientImplException ("Unable to find the instantiate the class specified by system property : "
109
+ + AsyncImplHelper .ASYNC_HTTP_CLIENT_IMPL_SYSTEM_PROPERTY + "(AsyncHttpProvider) due to : " + e .getMessage (), e );
108
110
}
109
111
}
110
112
return new DefaultAsyncHttpClient (providerClass , config );
@@ -115,8 +117,7 @@ private static boolean attemptInstantiation() {
115
117
lock .lock ();
116
118
try {
117
119
if (!instantiated ) {
118
- asyncHttpClientImplClass = AsyncImplHelper
119
- .getAsyncImplClass (AsyncImplHelper .ASYNC_HTTP_CLIENT_IMPL_SYSTEM_PROPERTY );
120
+ asyncHttpClientImplClass = AsyncImplHelper .getAsyncImplClass (AsyncImplHelper .ASYNC_HTTP_CLIENT_IMPL_SYSTEM_PROPERTY );
120
121
instantiated = true ;
121
122
}
122
123
} finally {
0 commit comments