antelder 2003/03/18 09:53:02
Modified: java/test/jms Jms.wsdl
java/src/org/apache/wsif/util/jms WSIFJMSProperties.java
java/src/org/apache/wsif/providers/jms
WSIFOperation_Jms.java JMSFormatter.java
Added: java/test/jms ServerSidePropertiesTest.java
Log:
Add API for setting of JMS Message properties
Revision Changes Path
1.11 +57 -0 xml-axis-wsif/java/test/jms/Jms.wsdl
Index: Jms.wsdl
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/test/jms/Jms.wsdl,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- Jms.wsdl 7 Mar 2003 13:23:45 -0000 1.10
+++ Jms.wsdl 18 Mar 2003 17:53:01 -0000 1.11
@@ -433,6 +433,56 @@
</operation>
</binding>
+ <binding name="SSOutProperties" type="tns:AddressBook">
+ <jms:binding type="ObjectMessage"/>
+ <format:typeMapping encoding="Java" style="Java">
+ <format:typeMap typeName="typens:address"
formatType="com.ibm.www.namespace.wsif.samples.ab.types.Address" />
+ <format:typeMap typeName="xsd:string" formatType="java.lang.String" />
+ </format:typeMapping>
+ <operation name="addEntry">
+ <input name="AddEntryRequest">
+ <jms:property name="JMSDeliveryMode" part="requestDeliveryMode" />
+ </input>
+ <output name="AddEntryResponse">
+ </output>
+ </operation>
+ <operation name="addEntry">
+ <input name="AddEntryJmsPropRequest">
+ <jms:property name="JMSPriority" part="requestPriority" />
+ <jms:property name="JMSReplyTo" part="requestReplyTo" />
+ <jms:property name="JMSDeliveryMode" part="requestDeliveryMode" />
+ <jms:property name="JMSTimeToLive" part="requestTimeToLive" />
+ </input>
+ <output name="AddEntryJmsPropResponse">
+ </output>
+ </operation>
+ <operation name="addEntry">
+ <input name="AddEntryUserPropRequest">
+ <jms:property name="JMSDeliveryMode" part="requestDeliveryMode" />
+ <jms:property name="MyBooleanProperty" part="requestUPBoolean" />
+ <jms:property name="MyByteProperty" part="requestUPByte" />
+ <jms:property name="MyShortProperty" part="requestUPShort" />
+ <jms:property name="MyIntProperty" part="requestUPInt" />
+ <jms:property name="MyLongProperty" part="requestUPLong" />
+ <jms:property name="MyFloatProperty" part="requestUPFloat" />
+ <jms:property name="MyDoubleProperty" part="requestUPDouble" />
+ <jms:property name="MyStringProperty" part="requestUPString" />
+ <jms:property name="MyObjectProperty" part="requestUPObject" />
+ </input>
+ <output name="AddEntryUserPropResponse">
+ </output>
+ </operation>
+ <operation name="getAddressFromName">
+ <input name="GetAddressFromNameRequest">
+ <jms:property name="JMSDeliveryMode" part="requestDeliveryMode" />
+ </input>
+ <output name="GetAddressFromNameResponse">
+ <jms:property name="userOutProperty1" part="userOutPropPart1" />
+ <jms:property name="userOutProperty2" part="userOutPropPart2" />
+ </output>
+ </operation>
+ </binding>
+
<!-- service decln -->
<service name="AddressBookService">
<port name="default" binding="tns:SOAPJmsBinding">
@@ -914,6 +964,13 @@
</jms:address>
</port>
<port name="NJtimeout" binding="tns:NativeJmsBinding">
+ <jms:address jmsProviderDestinationName="SYSTEM.DEAD.LETTER.QUEUE"
+ destinationStyle="queue"
+ jndiConnectionFactoryName="WSIFSampleQCF"
+
initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory"
+ jndiProviderURL="file:///JNDI-Directory"/>
+ </port>
+ <port name="SSOutProperties" binding="tns:SSOutProperties">
<jms:address jmsProviderDestinationName="SYSTEM.DEAD.LETTER.QUEUE"
destinationStyle="queue"
jndiConnectionFactoryName="WSIFSampleQCF"
1.1 xml-axis-wsif/java/test/jms/ServerSidePropertiesTest.java
Index: ServerSidePropertiesTest.java
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "WSIF" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 2001, 2002, International
* Business Machines, Inc., http://www.apache.org. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package jms;
import java.util.Map;
import javax.jms.Message;
import javax.wsdl.Definition;
import javax.wsdl.Port;
import javax.wsdl.Service;
import javax.xml.namespace.QName;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import org.apache.wsif.WSIFMessage;
import org.apache.wsif.WSIFRequest;
import org.apache.wsif.WSIFResponse;
import org.apache.wsif.WSIFService;
import org.apache.wsif.WSIFServiceFactory;
import org.apache.wsif.base.WSIFDefaultMessage;
import org.apache.wsif.providers.jms.JMSFormatter;
import org.apache.wsif.providers.jms.WSIFOperation_Jms;
import org.apache.wsif.providers.jms.WSIFPort_Jms;
import org.apache.wsif.util.jms.WSIFJMSDestination;
import org.apache.wsif.wsdl.extensions.jms.JMSConstants;
import util.TestUtilities;
/**
* Junit test for setting JMS Message properties on the server side
*
* @author Ant Elder <[EMAIL PROTECTED]>
*/
public class ServerSidePropertiesTest extends TestCase {
String wsdlLocation =
TestUtilities.getWsdlPath("java\\test\\jms") + "jms2.wsdl";
public ServerSidePropertiesTest(String name) {
super(name);
}
public static void main(String[] args) {
junit.textui.TestRunner.run(suite());
}
public static Test suite() {
return new TestSuite(ServerSidePropertiesTest.class);
}
public void setUp() {
TestUtilities.setUpExtensionsAndProviders();
}
public void testDynamicAxis() {
try {
WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
WSIFService service =
factory.getService(
wsdlLocation,
null,
null,
"http://wsifservice.addressbook/",
"AddressBook");
WSIFPort_Jms wsifPort =
(WSIFPort_Jms) service.getPort("SSOutProperties");
Definition def = wsifPort.getDefinition();
Map services = def.getServices();
QName qn = (QName) services.keySet().iterator().next();
Service s = (Service) services.get(qn);
Port port = s.getPort("SSOutProperties");
JMSFormatter formatter = new JMSFormatter(def, port);
WSIFRequest wr = new WSIFRequest(null);
wr.setOperationName("getAddressFromName");
wr.setInputName("GetAddressFromNameRequest");
wr.setOutputName("GetAddressFromNameResponse");
WSIFJMSDestination dest = wsifPort.getJmsDestination();
Message jmsMsg =
dest.createMessage(JMSConstants.MESSAGE_TYPE_OBJECTMESSAGE);
formatter.formatRequest(wr, jmsMsg);
String value1 = "petra";
String value2 = "ant";
WSIFMessage wsifMsg = new WSIFDefaultMessage();
wsifMsg.setObjectPart("userOutPropPart1", value1);
wsifMsg.setObjectPart("userOutPropPart2", value2);
WSIFOperation_Jms.setJMSMessageOutputHeaderProperties(
jmsMsg,
wsifMsg,
formatter);
String x = jmsMsg.getStringProperty("userOutProperty1");
assertTrue("property not correctly set!!", value1.equals(x));
x = jmsMsg.getStringProperty("userOutProperty2");
assertTrue("property not correctly set!!", value2.equals(x));
} catch (Exception e) {
e.printStackTrace();
assertTrue("got Exception: " + e.getLocalizedMessage(), false);
}
}
}
1.10 +10 -4
xml-axis-wsif/java/src/org/apache/wsif/util/jms/WSIFJMSProperties.java
Index: WSIFJMSProperties.java
===================================================================
RCS file:
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/util/jms/WSIFJMSProperties.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- WSIFJMSProperties.java 7 Dec 2002 12:33:58 -0000 1.9
+++ WSIFJMSProperties.java 18 Mar 2003 17:53:01 -0000 1.10
@@ -137,7 +137,7 @@
public boolean set(MessageProducer producer, Message message)
throws WSIFException {
Trc.entry(this, producer, message);
- if (direction != IN)
+ if (producer != null && direction != IN)
throw new WSIFException("Only input properties can be set on a
MessageProducer");
if (isEmpty()) {
@@ -158,14 +158,18 @@
} else if (prop.equals(DELIVERYMODE)) {
message.setJMSDeliveryMode(
((Integer) value).intValue());
- producer.setDeliveryMode(((Integer) value).intValue());
+ if (producer != null) {
+ producer.setDeliveryMode(((Integer)
value).intValue());
+ }
} else if (prop.equals(DESTINATION)) {
message.setJMSDestination((Destination) value);
} else if (prop.equals(EXPIRATION)) {
message.setJMSExpiration(((Long) value).longValue());
} else if (prop.equals(PRIORITY)) {
message.setJMSPriority(((Integer) value).intValue());
- producer.setPriority(((Integer) value).intValue());
+ if (producer != null) {
+ producer.setPriority(((Integer) value).intValue());
+ }
} else if (prop.equals(REDELIVERED)) {
message.setJMSRedelivered(
((Boolean) value).booleanValue());
@@ -174,7 +178,9 @@
} else if (prop.equals(TIMESTAMP)) {
message.setJMSTimestamp(((Long) value).longValue());
} else if (prop.equals(TIMETOLIVE)) {
- producer.setTimeToLive(((Long) value).longValue());
+ if (producer != null) {
+ producer.setTimeToLive(((Long) value).longValue());
+ }
} else if(prop.equals(TYPE)) {
message.setJMSType((String)value);
}
1.40 +94 -1
xml-axis-wsif/java/src/org/apache/wsif/providers/jms/WSIFOperation_Jms.java
Index: WSIFOperation_Jms.java
===================================================================
RCS file:
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/jms/WSIFOperation_Jms.java,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- WSIFOperation_Jms.java 13 Jan 2003 20:40:21 -0000 1.39
+++ WSIFOperation_Jms.java 18 Mar 2003 17:53:01 -0000 1.40
@@ -95,6 +95,7 @@
import org.apache.wsif.util.WSIFUtils;
import org.apache.wsif.util.jms.WSIFJMSCorrelationId;
import org.apache.wsif.util.jms.WSIFJMSDestination;
+import org.apache.wsif.util.jms.WSIFJMSProperties;
import org.apache.wsif.wsdl.extensions.jms.JMSAddress;
import org.apache.wsif.wsdl.extensions.jms.JMSBinding;
import org.apache.wsif.wsdl.extensions.jms.JMSConstants;
@@ -1011,7 +1012,99 @@
Trc.exit(fieldJmsPort);
return fieldJmsPort;
}
-
+
+ /**
+ * Sets JMS properties on a JMS message
+ * @param targetMsg the JMS message where properties will be set
+ * @param srcMsg WSIF message containing the JMS property values
+ * @param formatter JMSFormatter holding WSDL definitions defining
+ * which JMS properties should be set
+ */
+ public static void setJMSMessageOutputHeaderProperties(
+ javax.jms.Message targetMsg,
+ WSIFMessage srcMsg,
+ JMSFormatter formatter)
+ throws WSIFException {
+
+ Trc.entry(null, targetMsg, srcMsg, formatter);
+
+ if (targetMsg == null) {
+ throw new IllegalArgumentException("targetMsg is null");
+ }
+ if (srcMsg == null) {
+ throw new IllegalArgumentException("srcMsg is null");
+ }
+ if (formatter == null) {
+ throw new IllegalArgumentException("formatter is null");
+ }
+
+ WSIFJMSProperties jmsProps = new WSIFJMSProperties(WSIFJMSProperties.OUT);
+
+ Map properties = getJMSOutputProperties(formatter);
+ for (Iterator i = properties.keySet().iterator(); i.hasNext(); ) {
+ String wsifMsgPart = (String) i.next();
+ String jmsProperty = (String) properties.get(wsifMsgPart);
+ Object value = null;
+ try {
+ value = srcMsg.getObjectPart(wsifMsgPart);
+ jmsProps.put(jmsProperty, value);
+ } catch (WSIFException e) {
+ Trc.ignoredException(e);
+ }
+ }
+
+ jmsProps.set(null, targetMsg);
+
+ Trc.exit();
+ }
+
+ /**
+ * Gets the output jms:property's defined in a WSDL JMS binding
+ */
+ protected static Map getJMSOutputProperties(JMSFormatter f) throws
WSIFException {
+ Map jmsProperties = new HashMap();
+
+ BindingOperation bop = getFormatterOperation(f);
+ BindingOutput bout = bop.getBindingOutput();
+ if (bout != null) {
+ List extEls = bout.getExtensibilityElements();
+ for (Iterator i = extEls.iterator(); i.hasNext(); ) {
+ ExtensibilityElement ele = (ExtensibilityElement) i.next();
+ if (ele instanceof JMSProperty) {
+ jmsProperties.put(
+ ((JMSProperty) ele).getPart(),
+ ((JMSProperty) ele).getName());
+ }
+ }
+ }
+
+ return jmsProperties;
+ }
+
+ /**
+ * Gets the WSDL binding operation associated with a JMSFormatter
+ */
+ protected static BindingOperation getFormatterOperation(JMSFormatter f) throws
WSIFException {
+
+ Port port = f.getPort();
+ if (port == null) {
+ throw new WSIFException("formatter contains a null Port");
+ }
+
+ BindingOperation bop =
+ WSIFUtils.getBindingOperation(
+ port.getBinding(),
+ f.getOperationName(),
+ f.getInputName(),
+ f.getOutputName());
+
+ if (bop == null) {
+ throw new WSIFException("cannot find binding operation for formatter");
+ }
+
+ return bop;
+ }
+
public String deep() {
String buff = "";
try {
1.13 +19 -3
xml-axis-wsif/java/src/org/apache/wsif/providers/jms/JMSFormatter.java
Index: JMSFormatter.java
===================================================================
RCS file:
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/jms/JMSFormatter.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- JMSFormatter.java 7 Dec 2002 12:33:55 -0000 1.12
+++ JMSFormatter.java 18 Mar 2003 17:53:01 -0000 1.13
@@ -631,7 +631,7 @@
return list;
}
- private String getOperationName() {
+ public String getOperationName() {
return reqOpName;
}
@@ -639,7 +639,7 @@
reqOpName = s;
}
- private String getInputName() {
+ public String getInputName() {
return reqInputName;
}
@@ -647,7 +647,7 @@
reqInputName = s;
}
- private String getOutputName() {
+ public String getOutputName() {
return reqOutputName;
}
@@ -659,6 +659,22 @@
Trc.entry(this);
Trc.exit(lastBindingFault);
return lastBindingFault;
+ }
+
+ /**
+ * Returns the WSDL Definition.
+ * @return javax.wsdl.Definition
+ */
+ public javax.wsdl.Definition getDefinition() {
+ return fieldDefinition;
+ }
+
+ /**
+ * Returns the WSDL Port.
+ * @return javax.wsdl.Port
+ */
+ public javax.wsdl.Port getPort() {
+ return fieldPort;
}
}