Author: richard.opalka(a)jboss.com
Date: 2007-08-29 09:13:13 -0400 (Wed, 29 Aug 2007)
New Revision: 4502
Modified:
stack/native/branches/ropalka/trunk/src/main/java/org/jboss/ws/core/client/RemotingConnectionImpl.java
Log:
refactoring + adding RM stuff
Modified:
stack/native/branches/ropalka/trunk/src/main/java/org/jboss/ws/core/client/RemotingConnectionImpl.java
===================================================================
---
stack/native/branches/ropalka/trunk/src/main/java/org/jboss/ws/core/client/RemotingConnectionImpl.java 2007-08-24
17:53:06 UTC (rev 4501)
+++
stack/native/branches/ropalka/trunk/src/main/java/org/jboss/ws/core/client/RemotingConnectionImpl.java 2007-08-29
13:13:13 UTC (rev 4502)
@@ -54,6 +54,10 @@
import org.jboss.ws.core.soap.MessageContextAssociation;
import org.jboss.ws.metadata.config.EndpointProperty;
+import org.jboss.ws.extensions.wsrm.RMHelper;
+import org.jboss.ws.extensions.wsrm.RMChannel;
+import org.jboss.ws.extensions.wsrm.RMMetadata;
+
/**
* SOAPConnection implementation.
* <p/>
@@ -85,14 +89,6 @@
private static Map<String, String> configMap = new HashMap<String,
String>();
static
{
- // Remoting constants since 2.0.0.GA
- //configMap.put(StubExt.PROPERTY_KEY_STORE,
SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH);
- //configMap.put(StubExt.PROPERTY_KEY_STORE_PASSWORD,
SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD);
- //configMap.put(StubExt.PROPERTY_KEY_STORE_TYPE,
SSLSocketBuilder.REMOTING_KEY_STORE_TYPE);
- //configMap.put(StubExt.PROPERTY_TRUST_STORE,
SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH);
- //configMap.put(StubExt.PROPERTY_TRUST_STORE_PASSWORD,
SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD);
- //configMap.put(StubExt.PROPERTY_TRUST_STORE_TYPE,
SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE);
-
configMap.put(StubExt.PROPERTY_KEY_STORE,
"org.jboss.remoting.keyStore");
configMap.put(StubExt.PROPERTY_KEY_STORE_PASSWORD,
"org.jboss.remoting.keyStorePassword");
configMap.put(StubExt.PROPERTY_KEY_STORE_TYPE,
"org.jboss.remoting.keyStoreType");
@@ -102,7 +98,9 @@
}
private boolean closed;
-
+
+ private static final RMChannel RM_CHANNEL = RMChannel.getInstance();
+
public RemotingConnectionImpl()
{
// HTTPClientInvoker conect sends gratuitous POST
@@ -162,37 +160,83 @@
// setup remoting client
Map<String, Object> metadata = createRemotingMetaData(reqMessage,
callProps);
- Client client = createRemotingClient(endpoint, targetAddress, oneway);
-
+ Marshaller marshaller = getMarshaller();
+ UnMarshaller unmarshaller = getUnmarshaller();
+ InvokerLocator locator = null;
try
{
- if (log.isDebugEnabled())
- log.debug("Remoting metadata: " + metadata);
+ // Get the invoker from Remoting for a given endpoint address
+ log.debug("Get locator for: " + endpoint);
+
+ /**
+ * [JBWS-1704] The Use Of Remoting Causes An Additional 'datatype'
Parameter To Be Sent On All Requests
+ *
+ * An HTTPClientInvoker may disconnect from the server and recreated by the
remoting layer.
+ * In that case the new invoker does not inherit the marshaller/unmarshaller
from the disconnected invoker.
+ * We therefore explicitly specify the invoker locator datatype and register the
SOAP marshaller/unmarshaller
+ * with the MarshalFactory.
+ *
+ * This applies to remoting-1.4.5 and less
+ */
+ String version = getRemotingVersion();
+ if (version.startsWith("1.4"))
+ {
+ targetAddress = addURLParameter(targetAddress, InvokerLocator.DATATYPE,
"JBossWSMessage");
+ MarshalFactory.addMarshaller("JBossWSMessage", marshaller,
unmarshaller);
+ }
- // debug the outgoing message
- MessageTrace.traceMessage("Outgoing Request Message", reqMessage);
+ locator = new InvokerLocator(targetAddress);
+ }
+ catch (MalformedURLException e)
+ {
+ throw new IllegalArgumentException("Malformed endpoint address", e);
+ }
- MessageAbstraction resMessage = null;
-
- if (oneway == true)
+ try
+ {
+ if (RMHelper.isRMMessage(reqMessage))
{
- client.invokeOneway(reqMessage, metadata, false);
+ RMMetadata rmMetadata = new RMMetadata(targetAddress, oneway, marshaller,
unmarshaller, callProps, metadata, clientConfig);
+ return RM_CHANNEL.send(reqMessage, rmMetadata);
}
- else
+ else
{
- resMessage = (MessageAbstraction)client.invoke(reqMessage, metadata);
- }
+ Client client = new Client(locator, "jbossws", clientConfig);
+ client.connect();
- // Disconnect the remoting client
- client.disconnect();
+ client.setMarshaller(marshaller);
- callProps.clear();
- callProps.putAll(metadata);
+ if (oneway == false)
+ client.setUnMarshaller(unmarshaller);
+
+ if (log.isDebugEnabled())
+ log.debug("Remoting metadata: " + metadata);
- // trace the incomming response message
- MessageTrace.traceMessage("Incoming Response Message", resMessage);
+ // debug the outgoing message
+ MessageTrace.traceMessage("Outgoing Request Message", reqMessage);
- return resMessage;
+ MessageAbstraction resMessage = null;
+
+ if (oneway == true)
+ {
+ client.invokeOneway(reqMessage, metadata, false);
+ }
+ else
+ {
+ resMessage = (MessageAbstraction)client.invoke(reqMessage, metadata);
+ }
+
+ // Disconnect the remoting client
+ client.disconnect();
+
+ callProps.clear();
+ callProps.putAll(metadata);
+
+ // trace the incomming response message
+ MessageTrace.traceMessage("Incoming Response Message",
resMessage);
+
+ return resMessage;
+ }
}
catch (Throwable th)
{
@@ -206,7 +250,7 @@
throw io;
}
}
-
+
private String addURLParameter(String url, String key, String value)
{
int qmIndex = url.indexOf("?");
@@ -214,54 +258,6 @@
return url;
}
- private Client createRemotingClient(Object endpoint, String targetAddress, boolean
oneway)
- {
- Client client;
- try
- {
- // Get the invoker from Remoting for a given endpoint address
- log.debug("Get locator for: " + endpoint);
-
- Marshaller marshaller = getMarshaller();
- UnMarshaller unmarshaller = getUnmarshaller();
-
- /**
- * [JBWS-1704] The Use Of Remoting Causes An Additional 'datatype'
Parameter To Be Sent On All Requests
- *
- * An HTTPClientInvoker may disconnect from the server and recreated by the
remoting layer.
- * In that case the new invoker does not inherit the marshaller/unmarshaller
from the disconnected invoker.
- * We therefore explicitly specify the invoker locator datatype and register the
SOAP marshaller/unmarshaller
- * with the MarshalFactory.
- *
- * This applies to remoting-1.4.5 and less
- */
- String version = getRemotingVersion();
- if (version.startsWith("1.4"))
- {
- targetAddress = addURLParameter(targetAddress, InvokerLocator.DATATYPE,
"JBossWSMessage");
- MarshalFactory.addMarshaller("JBossWSMessage", marshaller,
unmarshaller);
- }
-
- InvokerLocator locator = new InvokerLocator(targetAddress);
- client = new Client(locator, "jbossws", clientConfig);
- client.connect();
-
- client.setMarshaller(marshaller);
-
- if (oneway == false)
- client.setUnMarshaller(unmarshaller);
- }
- catch (MalformedURLException e)
- {
- throw new IllegalArgumentException("Malformed endpoint address", e);
- }
- catch (Exception e)
- {
- throw new IllegalStateException("Could not setup remoting client",
e);
- }
- return client;
- }
-
private String getRemotingVersion()
{
String version = null;