Return-Path: Delivered-To: apmail-ws-axis-dev-archive@www.apache.org Received: (qmail 67340 invoked from network); 13 Jun 2006 12:50:18 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 13 Jun 2006 12:50:18 -0000 Received: (qmail 59242 invoked by uid 500); 13 Jun 2006 12:50:14 -0000 Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 59208 invoked by uid 500); 13 Jun 2006 12:50:14 -0000 Mailing-List: contact axis-dev-help@ws.apache.org; run by ezmlm Precedence: bulk Reply-To: axis-dev@ws.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list axis-dev@ws.apache.org Received: (qmail 59197 invoked by uid 99); 13 Jun 2006 12:50:14 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Jun 2006 05:50:14 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [209.68.5.17] (HELO relay03.pair.com) (209.68.5.17) by apache.org (qpsmtpd/0.29) with SMTP; Tue, 13 Jun 2006 05:50:12 -0700 Received: (qmail 11062 invoked from network); 13 Jun 2006 12:49:50 -0000 Received: from unknown (HELO ?127.0.0.1?) (unknown) by unknown with SMTP; 13 Jun 2006 12:49:50 -0000 X-pair-Authenticated: 222.165.173.63 Message-ID: <448EB46A.7020605@opensource.lk> Date: Tue, 13 Jun 2006 18:19:46 +0530 From: Deepal Jayasinghe User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: axis-dev@ws.apache.org Subject: Re: [Axis2] Patch for Axis2 JMS classes References: <448EB3D3.6020506@wso2.com> In-Reply-To: <448EB3D3.6020506@wso2.com> X-Enigmail-Version: 0.93.0.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N done Asankha C. Perera wrote: > Can someone please apply this patch to Axis2 > > This includes a fix to support JMS Text messages in addition to Binary > messages (else, on the server side a class cast exception was thrown) > and to make the JMS sender uses the TRANSPORT_URL property if set, and > use the To address only if its not specified. This would be required > for Synapse. > > thanks > asankha > > >------------------------------------------------------------------------ > >Index: modules/core/src/org/apache/axis2/transport/jms/JMSSender.java >=================================================================== >--- modules/core/src/org/apache/axis2/transport/jms/JMSSender.java (revision 413826) >+++ modules/core/src/org/apache/axis2/transport/jms/JMSSender.java (working copy) >@@ -22,10 +22,12 @@ > import org.apache.axiom.soap.SOAPEnvelope; > import org.apache.axis2.AxisFault; > import org.apache.axis2.Constants; >+import org.apache.axis2.addressing.AddressingConstants; > import org.apache.axis2.client.Options; > import org.apache.axis2.context.ConfigurationContext; > import org.apache.axis2.context.MessageContext; > import org.apache.axis2.context.OperationContext; >+import org.apache.axis2.context.MessageContextConstants; > import org.apache.axis2.description.Parameter; > import org.apache.axis2.description.TransportOutDescription; > import org.apache.axis2.handlers.AbstractHandler; >@@ -199,7 +201,16 @@ > } > } > >- String endpointAddress = msgContext.getTo() != null ? msgContext.getTo().getAddress() : null; >+ String endpointAddress = (String) msgContext >+ .getProperty(MessageContextConstants.TRANSPORT_URL); >+ if (endpointAddress == null && >+ msgContext.getTo() != null && >+ !AddressingConstants.Submission.WSA_ANONYMOUS_URL >+ .equals(msgContext.getTo().getAddress()) && >+ !AddressingConstants.Final.WSA_ANONYMOUS_URL >+ .equals(msgContext.getTo().getAddress())) { >+ endpointAddress = msgContext.getTo().getAddress(); >+ } > boolean waitForResponse = false; > > if (dest == null) { >Index: modules/core/src/org/apache/axis2/transport/jms/SimpleJMSListener.java >=================================================================== >--- modules/core/src/org/apache/axis2/transport/jms/SimpleJMSListener.java (revision 413826) >+++ modules/core/src/org/apache/axis2/transport/jms/SimpleJMSListener.java (working copy) >@@ -184,8 +184,8 @@ > public void onMessage(javax.jms.Message message) { > try { > // pass off the message to a worker as a BytesMessage >- SimpleJMSWorker worker = new SimpleJMSWorker(configurationContext, this, >- (BytesMessage) message); >+ SimpleJMSWorker worker = new SimpleJMSWorker >+ (configurationContext, this, message); > > // do we allow multi-threaded workers? > if (doThreads) { >Index: modules/core/src/org/apache/axis2/transport/jms/SimpleJMSWorker.java >=================================================================== >--- modules/core/src/org/apache/axis2/transport/jms/SimpleJMSWorker.java (revision 413826) >+++ modules/core/src/org/apache/axis2/transport/jms/SimpleJMSWorker.java (working copy) >@@ -41,6 +41,8 @@ > import org.apache.commons.logging.LogFactory; > > import javax.jms.BytesMessage; >+import javax.jms.Message; >+import javax.jms.TextMessage; > import javax.xml.namespace.QName; > import javax.xml.parsers.FactoryConfigurationError; > import javax.xml.stream.XMLInputFactory; >@@ -59,10 +61,10 @@ > private static final Log log = LogFactory.getLog(SimpleJMSWorker.class); > private ConfigurationContext configurationContext; > SimpleJMSListener listener; >- BytesMessage message; >+ Message message; > > public SimpleJMSWorker(ConfigurationContext configurationContext, SimpleJMSListener listener, >- BytesMessage message) { >+ Message message) { > this.listener = listener; > this.message = message; > this.configurationContext = configurationContext; >@@ -179,20 +181,38 @@ > * This is where the incoming message is processed. > */ > public void run() { >- InputStream in ; >+ InputStream in = null; > > try { >- > // get the incoming msg content into a byte array >- byte[] buffer = new byte[8 * 1024]; >- ByteArrayOutputStream out = new ByteArrayOutputStream(); >+ if (message instanceof BytesMessage) { >+ byte[] buffer = new byte[8 * 1024]; >+ ByteArrayOutputStream out = new ByteArrayOutputStream(); > >- for (int bytesRead = message.readBytes(buffer); bytesRead != -1; >- bytesRead = message.readBytes(buffer)) { >- out.write(buffer, 0, bytesRead); >+ BytesMessage byteMsg = (BytesMessage) message; >+ for (int bytesRead = byteMsg.readBytes(buffer); bytesRead != -1; >+ bytesRead = byteMsg.readBytes(buffer)) { >+ out.write(buffer, 0, bytesRead); >+ } >+ in = new ByteArrayInputStream(out.toByteArray()); >+ >+ } else if (message instanceof TextMessage) { >+ TextMessage txtMsg = (TextMessage) message; >+ String contentType = message.getStringProperty("contentType"); >+ if (contentType != null) { >+ String charSetEnc = >+ TransportUtils.getCharSetEncoding(contentType); >+ in = new ByteArrayInputStream(txtMsg.getText().getBytes(charSetEnc)); >+ } else { >+ in = new ByteArrayInputStream(txtMsg.getText().getBytes()); >+ } >+ >+ } else { >+ log.error("Unsupported JMS Message type : " + message); >+ log.error(Messages.getMessage("exception00")); > } > >- in = new ByteArrayInputStream(out.toByteArray()); >+ > } catch (Exception e) { > log.error(Messages.getMessage("exception00"), e); > e.printStackTrace(); > > > > >------------------------------------------------------------------------ > >--------------------------------------------------------------------- >To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org >For additional commands, e-mail: axis-dev-help@ws.apache.org > -- Thanks, Deepal ................................................................ ~Future is Open~ --------------------------------------------------------------------- To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org For additional commands, e-mail: axis-dev-help@ws.apache.org