[jboss-svn-commits] JBL Code SVN: r23024 - in labs/jbossesb/workspace/maeste/product/services/soap: src/main/java/org/jboss/soa/esb/actions/soap/wise and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Sep 23 17:21:20 EDT 2008
Author: maeste
Date: 2008-09-23 17:21:20 -0400 (Tue, 23 Sep 2008)
New Revision: 23024
Modified:
labs/jbossesb/workspace/maeste/product/services/soap/lib/ext/Wise-core.jar
labs/jbossesb/workspace/maeste/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java
Log:
fixed concurrency issues introduced in JBESB-2037
Modified: labs/jbossesb/workspace/maeste/product/services/soap/lib/ext/Wise-core.jar
===================================================================
(Binary files differ)
Modified: labs/jbossesb/workspace/maeste/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java
===================================================================
--- labs/jbossesb/workspace/maeste/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java 2008-09-23 21:17:48 UTC (rev 23023)
+++ labs/jbossesb/workspace/maeste/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java 2008-09-23 21:21:20 UTC (rev 23024)
@@ -149,157 +149,223 @@
*
* @author <a href="mailto:stefano.maestri at javalinux.it">stefano.maestri at javalinux.it</a>
*/
-public class SOAPClient extends AbstractActionPipelineProcessor {
+public class SOAPClient extends AbstractActionPipelineProcessor
+{
- private final Logger logger = Logger.getLogger(SOAPClient.class);
- private final String wsdl;
- private final String soapAction;
- private final String endPointName;
- private final String smooksRequestMapperURL;
- private final String smooksResponseMapperURL;
- private String serviceName;
- private final String username;
- private final String password;
- // private WSDynamicClient client;
- private final List<String> smooksHandler = new ArrayList<String>();
- private final List<String> customHandlers = new ArrayList<String>();
- private final MessagePayloadProxy payloadProxy;
- private boolean loggingEnabled = false;
- private String smooksRequestReport = null;
- private String smooksResponseReport = null;
+ private final Logger logger = Logger.getLogger(SOAPClient.class);
+ private final String wsdl;
+ private final String soapAction;
+ private final String endPointName;
+ private final String smooksRequestMapperURL;
+ private final String smooksResponseMapperURL;
+ private String serviceName;
+ private final String username;
+ private final String password;
+ // private WSDynamicClient client;
+ private final List<String> smooksHandler = new ArrayList<String>();
+ private final List<String> customHandlers = new ArrayList<String>();
+ private final MessagePayloadProxy payloadProxy;
+ private boolean loggingEnabled = false;
+ private String smooksRequestReport = null;
+ private String smooksResponseReport = null;
- private InvocationResult result = null;
+ private WSMethod method = null;
+ private WSEndpoint endpoint;
- private WSMethod method = null;
+ public SOAPClient(ConfigTree config) throws ConfigurationException
+ {
+ wsdl = config.getRequiredAttribute("wsdl");
+ soapAction = config.getRequiredAttribute("SOAPAction");
+ endPointName = config.getRequiredAttribute("EndPointName");
+ smooksRequestMapperURL = config.getAttribute("SmooksRequestMapper");
+ smooksResponseMapperURL = config.getAttribute("SmooksResponseMapper");
+ serviceName = config.getAttribute("serviceName");
+ serviceName = serviceName != null ? serviceName : wsdl.substring(wsdl.lastIndexOf("/"), wsdl.lastIndexOf("?"));
+ username = config.getAttribute("username");
+ password = config.getAttribute("password");
+ smooksRequestReport = config.getAttribute("smooksRequestReport");
+ smooksResponseReport = config.getAttribute("smooksResponseReport");
+ logger.info(config.getAttribute("LoggingMessages"));
+ loggingEnabled = Boolean.parseBoolean(config.getAttribute("LoggingMessages"));
+ logger.info("loggingEnabled:" + loggingEnabled);
+ ConfigTree[] handlersConfig;
+ if (config.getAttribute("smooks-handler-config") != null)
+ {
+ smooksHandler.add(config.getAttribute("smooks-handler-config"));
+ }
+ if (config.getAttribute("custom-handlers") != null)
+ {
+ for (String className : config.getAttribute("custom-handlers").split(";"))
+ {
+ customHandlers.add(className);
+ }
- private WiseMapper responseMapper = null;
- private WiseMapper requestMapper = null;
- private WSEndpoint endpoint;
+ }
+ handlersConfig = config.getChildren("custom-handlers");
- public SOAPClient( ConfigTree config ) throws ConfigurationException {
- wsdl = config.getRequiredAttribute("wsdl");
- soapAction = config.getRequiredAttribute("SOAPAction");
- endPointName = config.getRequiredAttribute("EndPointName");
- smooksRequestMapperURL = config.getAttribute("SmooksRequestMapper");
- smooksResponseMapperURL = config.getAttribute("SmooksResponseMapper");
- serviceName = config.getAttribute("serviceName");
- serviceName = serviceName != null ? serviceName : wsdl.substring(wsdl.lastIndexOf("/"), wsdl.lastIndexOf("?"));
- username = config.getAttribute("username");
- password = config.getAttribute("password");
- smooksRequestReport = config.getAttribute("smooksRequestReport");
- smooksResponseReport = config.getAttribute("smooksResponseReport");
- logger.info(config.getAttribute("LoggingMessages"));
- loggingEnabled = Boolean.parseBoolean(config.getAttribute("LoggingMessages"));
- logger.info("loggingEnabled:" + loggingEnabled);
- ConfigTree[] handlersConfig;
- if (config.getAttribute("smooks-handler-config") != null) {
- smooksHandler.add(config.getAttribute("smooks-handler-config"));
- }
- if (config.getAttribute("custom-handlers") != null) {
- for (String className : config.getAttribute("custom-handlers").split(";")) {
- customHandlers.add(className);
- }
+ payloadProxy = new MessagePayloadProxy(config);
- }
- handlersConfig = config.getChildren("custom-handlers");
+ }
- payloadProxy = new MessagePayloadProxy(config);
+ @Override
+ public void initialise() throws ActionLifecycleException
+ {
+ super.initialise();
+ try
+ {
+ WSDynamicClientFactory.getInstace().clearCache();
+ SmooksCache.getInstance().clear();
+ Object params;
+ WSDynamicClient client = null;
+ // get client from cache
+ try
+ {
+ client = WSDynamicClientFactory.getInstace().getClient(wsdl, serviceName, username, password);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ throw new ActionProcessingException("Error durinfg wise client creation", e);
+ }
- }
+ Map<String, WSEndpoint> endpointsMap = client.processEndpoints();
+ if (endPointName != null)
+ {
+ this.setEndpoint(endpointsMap.get(endPointName));
+ }
+ else
+ {
+ this.setEndpoint(endpointsMap.values().iterator().next());
+ }
- @Override
- public void initialise() throws ActionLifecycleException {
- super.initialise();
- try {
- WSDynamicClientFactory.getInstace().clearCache();
- SmooksCache.getInstance().clear();
- Object params;
- WSDynamicClient client = null;
- // get client from cache
- try {
- client = WSDynamicClientFactory.getInstace().getClient(wsdl, serviceName, username, password);
- } catch (Exception e) {
- e.printStackTrace();
- throw new ActionProcessingException("Error durinfg wise client creation", e);
+ for (String config : customHandlers)
+ {
+ logger.info("adding custom handler:" + config);
+ try
+ {
+ Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(config);
+ this.getEndpoint().addHandler((Handler)clazz.newInstance());
}
-
- Map<String, WSEndpoint> endpointsMap = client.processEndpoints();
- if (endPointName != null) {
- endpoint = endpointsMap.get(endPointName);
- } else {
- endpoint = endpointsMap.values().iterator().next();
+ catch (Exception e)
+ {
+ logger.info("Failed during custom handler addition:" + e.getLocalizedMessage());
}
+ }
- for (String config : customHandlers) {
- logger.info("adding custom handler:" + config);
- try {
- Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(config);
- endpoint.addHandler((Handler)clazz.newInstance());
- } catch (Exception e) {
- logger.info("Failed during custom handler addition:" + e.getLocalizedMessage());
- }
- }
+ if (loggingEnabled)
+ {
+ logger.info("adding logging handler");
+ this.getEndpoint().addHandler(new LoggingHandler());
+ }
- if (loggingEnabled) {
- logger.info("adding logging handler");
- endpoint.addHandler(new LoggingHandler());
- }
+ Map<String, WSMethod> wsmethodsMap = this.getEndpoint().getWSMethods();
+ this.setMethod(wsmethodsMap.get(this.soapAction));
- Map<String, WSMethod> wsmethodsMap = endpoint.getWSMethods();
+ }
+ catch (Exception e)
+ {
+ throw new ActionLifecycleException("Error durinfg wise client cache cleaning", e);
+ }
- if (this.smooksRequestMapperURL != null) {
- requestMapper = new SmooksMapper(this.smooksRequestMapperURL, this.smooksRequestReport);
- }
- method = wsmethodsMap.get(this.soapAction);
+ }
- if (this.smooksResponseMapperURL != null) {
- responseMapper = new SmooksMapper(this.smooksResponseMapperURL, this.smooksResponseReport);
- }
+ @Override
+ public void destroy() throws ActionLifecycleException
+ {
+ // nop
+ }
- } catch (Exception e) {
- throw new ActionLifecycleException("Error durinfg wise client cache cleaning", e);
- }
+ public Message process(final Message message) throws ActionProcessingException
+ {
+ Object params;
+ WiseMapper responseMapper = null;
+ WiseMapper requestMapper = null;
- }
+ if (this.smooksRequestMapperURL != null)
+ {
+ requestMapper = new SmooksMapper(this.smooksRequestMapperURL, this.smooksRequestReport);
+ }
- @Override
- public void destroy() throws ActionLifecycleException {
- // nop
- }
+ if (this.smooksResponseMapperURL != null)
+ {
+ responseMapper = new SmooksMapper(this.smooksResponseMapperURL, this.smooksResponseReport);
+ }
- public Message process( final Message message ) throws ActionProcessingException {
- Object params;
+ try
+ {
+ params = payloadProxy.getPayload(message);
+ }
+ catch (MessageDeliverException e)
+ {
+ throw new ActionProcessingException("Could not locate SOAP message parameters from payload", e);
+ }
- try {
- params = payloadProxy.getPayload(message);
- } catch (MessageDeliverException e) {
- throw new ActionProcessingException("Could not locate SOAP message parameters from payload", e);
- }
+ for (String config : smooksHandler)
+ {
+ logger.info("adding smooks handler:" + config);
+ if (params instanceof Map)
+ {
+ this.getEndpoint().addHandler(new SmooksHandler(config, (Map)params));
+ }
+ else
+ {
+ this.getEndpoint().addHandler(new SmooksHandler(config, null));
+ }
+ }
- for (String config : smooksHandler) {
- logger.info("adding smooks handler:" + config);
- if (params instanceof Map) {
- endpoint.addHandler(new SmooksHandler(config, (Map)params));
- } else {
- endpoint.addHandler(new SmooksHandler(config, null));
- }
- }
+ InvocationResult result = null;
+ try
+ {
+ result = this.getMethod().invoke(params, requestMapper);
+ }
+ catch (WiseException e)
+ {
+ throw new ActionProcessingException("Could not call method" + this.soapAction, e);
+ }
- try {
- result = method.invoke(params, requestMapper);
- } catch (WiseException e) {
- throw new ActionProcessingException("Could not call method" + this.soapAction, e);
- }
+ try
+ {
+ Map map = result.getMappedResult(responseMapper, (Map)params);
+ payloadProxy.setPayload(message, map);
+ }
+ catch (Exception e)
+ {
+ throw new ActionProcessingException("Could not set payload to SOAP message", e);
+ }
- try {
- Map map = result.getMappedResult(responseMapper, (Map)params);
- logger.info("map = " + map);
- payloadProxy.setPayload(message, map);
- } catch (Exception e) {
- throw new ActionProcessingException("Could not set payload to SOAP message", e);
- }
+ return message;
+ }
- return message;
- }
+ /**
+ * @return the method
+ */
+ public synchronized WSMethod getMethod()
+ {
+ return method;
+ }
+ /**
+ * @param method the method to set
+ */
+ public synchronized void setMethod(WSMethod method)
+ {
+ this.method = method;
+ }
+
+ /**
+ * @return the endpoint
+ */
+ public synchronized WSEndpoint getEndpoint()
+ {
+ return endpoint;
+ }
+
+ /**
+ * @param endpoint the endpoint to set
+ */
+ public synchronized void setEndpoint(WSEndpoint endpoint)
+ {
+ this.endpoint = endpoint;
+ }
+
}
More information about the jboss-svn-commits
mailing list