Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changed ServiceClient implementation, now getting from bpms-common. S…

…o, that it can use MultiThreadedHttpConnection.
  • Loading branch information...
commit 126dddc08748b962a4e19bac18eecf7f09335872 1 parent 2dfc7d9
@jayantvaish jayantvaish authored
View
4 Buildfile
@@ -38,8 +38,8 @@ define "security" do
desc "Security Web-Service Client"
define "ws-client" do
- compile.with projects("api", "ws-common"),JASYPT,AXIOM, AXIS2, SLF4J, STAX_API,APACHE_COMMONS[:httpclient], SPRING[:core]
- test.with APACHE_COMMONS[:httpclient], APACHE_COMMONS[:codec], CASTOR, LOG4J, SUNMAIL, XERCES, WS_COMMONS_SCHEMA, WSDL4J, WOODSTOX, CAS_CLIENT, INSTINCT
+ compile.with projects("api", "ws-common"),JASYPT,AXIOM, AXIS2, SLF4J, STAX_API,APACHE_COMMONS[:httpclient], SPRING[:core], BPMS_COMMON
+ test.with APACHE_COMMONS[:httpclient], APACHE_COMMONS[:codec], CASTOR, LOG4J, SUNMAIL, XERCES, WS_COMMONS_SCHEMA, WSDL4J, WOODSTOX, CAS_CLIENT, INSTINCT, BPMS_COMMON
# Remember to set JAVA_OPTIONS before starting Jetty
# export JAVA_OPTIONS=-Dorg.intalio.tempo.configDirectory=/home/boisvert/svn/tempo/security-ws2/src/test/resources
View
1  dependencies.rb
@@ -122,3 +122,4 @@
]
OPENSSO_CLIENT_SDK = "com.sun:openssoclientsdk:jar:3.0"
+BPMS_COMMON="com.intalio.bpms.common:bpms-common:jar:1.0.0.0"
View
90 ws-client/src/main/java/org/intalio/tempo/security/ws/TokenClient.java
@@ -33,6 +33,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.intalio.bpms.common.AxisUtil;
+
/**
* Client web services API for the Token Service.
*/
@@ -110,44 +112,37 @@ public boolean isWorkflowAdmin(String token) throws AuthenticationException, Rem
return Boolean.valueOf(response.getRequiredString(TokenConstants.IS_WORKFLOW_ADMIN));
}
- protected OMParser invoke(String action, OMElement request)
- throws AxisFault {
- ServiceClient serviceClient = getServiceClient();
- Options options = serviceClient.getOptions();
- EndpointReference targetEPR = new EndpointReference(_endpoint);
- options.setTo(targetEPR);
- options.setAction(action);
-
- // Disabling chunking as lighthttpd doesnt support it
-
- if (isChunking())
- options.setProperty(
- org.apache.axis2.transport.http.HTTPConstants.CHUNKED,
- Boolean.FALSE);
- else
- options.setProperty(
- org.apache.axis2.transport.http.HTTPConstants.CHUNKED,
- Boolean.FALSE);
-
-
- OMElement response = null;
- try {
- response = serviceClient.sendReceive(request);
- response.build();
- } catch (AxisFault e) {
- // Sometimes we get nasty errors and we need to understand what
- // caused these errors, having service client options
- // being printed will help
- _logger.error("Service was called with this option "
- + serviceClient.getServiceContext());
- throw e;
- } finally {
-
- serviceClient.cleanupTransport();
- }
- _logger.debug("Invoked service for authentication");
- return new OMParser(response);
- }
+ protected OMParser invoke(String action, OMElement request) throws AxisFault {
+ ServiceClient serviceClient = null;
+ OMElement response = null;
+ AxisUtil util = new AxisUtil();
+ try {
+ serviceClient = util.getServiceClient();
+ serviceClient.getOptions().setTo(new EndpointReference(_endpoint));
+ serviceClient.getOptions().setAction(action);
+ // Disabling chunking as lighthttpd doesnt support it
+ if (isChunking())
+ serviceClient.getOptions()
+ .setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
+ else
+ serviceClient.getOptions()
+ .setProperty(org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE);
+ response = serviceClient.sendReceive(request);
+ response.build();
+ } catch (AxisFault e) {
+ _logger.error("Service was called with this option " + serviceClient.getServiceContext());
+ throw e;
+ } finally {
+ if (serviceClient != null)
+ try {
+ util.closeClient(serviceClient);
+ } catch (Exception e) {
+ _logger.error("Error while cleanup");
+ }
+ }
+ _logger.debug("Invoked service for authentication");
+ return new OMParser(response);
+ }
private static OMElement element(QName name) {
@@ -180,25 +175,6 @@ public String getTokenFromOpenSSOToken(String tokenId)
return response.getRequiredString(TokenConstants.TOKEN);
}
-
- protected ServiceClient getServiceClient() throws AxisFault {
- HttpClient httpClient = new HttpClient(
- MultiThreadedHttpConnectionManagerFactory.getInstance());
- Options options = new Options();
- options.setTimeOutInMilliSeconds(120 * 1000);
- ServiceClient serviceClient = new ServiceClient();
- serviceClient.setOptions(options);
- serviceClient.getOptions().setProperty(HTTPConstants.REUSE_HTTP_CLIENT,
- org.apache.axis2.Constants.VALUE_TRUE);
- serviceClient.getOptions().setProperty(
- HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
- // Disabling chunking as lighthttpd doesnt support it
- serviceClient.getOptions().setProperty(
- org.apache.axis2.transport.http.HTTPConstants.CHUNKED,
- Boolean.FALSE);
- return serviceClient;
- }
-
public String getHttpChunking() {
return httpChunking;
}

0 comments on commit 126dddc

Please sign in to comment.
Something went wrong with that request. Please try again.