You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by fa...@apache.org on 2014/09/06 13:23:14 UTC
svn commit: r1622849 [3/9] - in
/qpid/proton/branches/fadams-javascript-binding: ./ contrib/
contrib/proton-hawtdispatch/ contrib/proton-hawtdispatch/src/
contrib/proton-hawtdispatch/src/main/
contrib/proton-hawtdispatch/src/main/java/ contrib/proton-h...
Added: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/pom.xml
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/pom.xml?rev=1622849&view=auto
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/pom.xml (added)
+++ qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/pom.xml Sat Sep 6 11:23:10 2014
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>proton-project</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ <relativePath>../..</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>proton-jms</artifactId>
+ <name>proton-jms</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.qpid</groupId>
+ <artifactId>proton-j</artifactId>
+ <version>${project.parent.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-jms_1.1_spec</artifactId>
+ <version>1.1.1</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ </build>
+ <scm>
+ <url>http://svn.apache.org/viewvc/qpid/proton/</url>
+ </scm>
+
+</project>
Propchange: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/pom.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AMQPNativeInboundTransformer.java
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AMQPNativeInboundTransformer.java?rev=1622849&view=auto
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AMQPNativeInboundTransformer.java (added)
+++ qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AMQPNativeInboundTransformer.java Sat Sep 6 11:23:10 2014
@@ -0,0 +1,40 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.qpid.proton.jms;
+
+import javax.jms.Message;
+
+/**
+* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+*/
+public class AMQPNativeInboundTransformer extends AMQPRawInboundTransformer {
+
+
+ public AMQPNativeInboundTransformer(JMSVendor vendor) {
+ super(vendor);
+ }
+
+ @Override
+ public Message transform(EncodedMessage amqpMessage) throws Exception {
+ org.apache.qpid.proton.message.Message amqp = amqpMessage.decode();
+
+ Message rc = super.transform(amqpMessage);
+
+ populateMessage(rc, amqp);
+ return rc;
+ }
+}
Propchange: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AMQPNativeInboundTransformer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AMQPNativeInboundTransformer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AMQPNativeOutboundTransformer.java
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AMQPNativeOutboundTransformer.java?rev=1622849&view=auto
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AMQPNativeOutboundTransformer.java (added)
+++ qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AMQPNativeOutboundTransformer.java Sat Sep 6 11:23:10 2014
@@ -0,0 +1,103 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.qpid.proton.jms;
+
+import org.apache.qpid.proton.codec.CompositeWritableBuffer;
+import org.apache.qpid.proton.codec.DroppingWritableBuffer;
+import org.apache.qpid.proton.codec.WritableBuffer;
+import org.apache.qpid.proton.amqp.UnsignedInteger;
+
+import javax.jms.BytesMessage;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageFormatException;
+import java.nio.ByteBuffer;
+
+import org.apache.qpid.proton.message.ProtonJMessage;
+/**
+* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+*/
+public class AMQPNativeOutboundTransformer extends OutboundTransformer {
+
+ public AMQPNativeOutboundTransformer(JMSVendor vendor) {
+ super(vendor);
+ }
+
+ @Override
+ public EncodedMessage transform(Message msg) throws Exception {
+ if( msg == null )
+ return null;
+ if( !(msg instanceof BytesMessage) )
+ return null;
+ try {
+ if( !msg.getBooleanProperty(prefixVendor + "NATIVE") ) {
+ return null;
+ }
+ } catch (MessageFormatException e) {
+ return null;
+ }
+ return transform(this, (BytesMessage) msg);
+ }
+
+ static EncodedMessage transform(OutboundTransformer options, BytesMessage msg) throws JMSException {
+ long messageFormat;
+ try {
+ messageFormat = msg.getLongProperty(options.prefixVendor + "MESSAGE_FORMAT");
+ } catch (MessageFormatException e) {
+ return null;
+ }
+ byte data[] = new byte[(int) msg.getBodyLength()];
+ int dataSize = data.length;
+ msg.readBytes(data);
+ msg.reset();
+
+ try {
+ int count = msg.getIntProperty("JMSXDeliveryCount");
+ if( count > 1 ) {
+
+ // decode...
+ ProtonJMessage amqp = (ProtonJMessage) org.apache.qpid.proton.message.Message.Factory.create();
+ int offset = 0;
+ int len = data.length;
+ while( len > 0 ) {
+ final int decoded = amqp.decode(data, offset, len);
+ assert decoded > 0: "Make progress decoding the message";
+ offset += decoded;
+ len -= decoded;
+ }
+
+ // Update the DeliveryCount header...
+ amqp.getHeader().setDeliveryCount(new UnsignedInteger(count));
+
+ // Re-encode...
+ ByteBuffer buffer = ByteBuffer.wrap(new byte[1024*4]);
+ final DroppingWritableBuffer overflow = new DroppingWritableBuffer();
+ int c = amqp.encode(new CompositeWritableBuffer(new WritableBuffer.ByteBufferWrapper(buffer), overflow));
+ if( overflow.position() > 0 ) {
+ buffer = ByteBuffer.wrap(new byte[1024*4+overflow.position()]);
+ c = amqp.encode(new WritableBuffer.ByteBufferWrapper(buffer));
+ }
+ data = buffer.array();
+ dataSize = c;
+ }
+ } catch (JMSException e) {
+ }
+
+ return new EncodedMessage(messageFormat, data, 0, dataSize);
+ }
+
+}
Propchange: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AMQPNativeOutboundTransformer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AMQPNativeOutboundTransformer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AMQPRawInboundTransformer.java
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AMQPRawInboundTransformer.java?rev=1622849&view=auto
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AMQPRawInboundTransformer.java (added)
+++ qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AMQPRawInboundTransformer.java Sat Sep 6 11:23:10 2014
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.qpid.proton.jms;
+
+import javax.jms.BytesMessage;
+import javax.jms.Message;
+
+public class AMQPRawInboundTransformer extends InboundTransformer {
+
+ public AMQPRawInboundTransformer(JMSVendor vendor) {
+ super(vendor);
+ }
+
+ @Override
+ public Message transform(EncodedMessage amqpMessage) throws Exception {
+ BytesMessage rc = vendor.createBytesMessage();
+ rc.writeBytes(amqpMessage.getArray(), amqpMessage.getArrayOffset(), amqpMessage.getLength());
+
+ rc.setJMSDeliveryMode(defaultDeliveryMode);
+ rc.setJMSPriority(defaultPriority);
+
+ final long now = System.currentTimeMillis();
+ rc.setJMSTimestamp(now);
+ if( defaultTtl > 0 ) {
+ rc.setJMSExpiration(now + defaultTtl);
+ }
+
+ rc.setLongProperty(prefixVendor + "MESSAGE_FORMAT", amqpMessage.getMessageFormat());
+ rc.setBooleanProperty(prefixVendor + "NATIVE", true);
+
+ return rc;
+ }
+}
Propchange: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AMQPRawInboundTransformer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AMQPRawInboundTransformer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AutoOutboundTransformer.java
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AutoOutboundTransformer.java?rev=1622849&view=auto
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AutoOutboundTransformer.java (added)
+++ qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AutoOutboundTransformer.java Sat Sep 6 11:23:10 2014
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.qpid.proton.jms;
+
+import javax.jms.BytesMessage;
+import javax.jms.Message;
+
+/**
+* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+*/
+public class AutoOutboundTransformer extends JMSMappingOutboundTransformer {
+
+ public AutoOutboundTransformer(JMSVendor vendor) {
+ super(vendor);
+ }
+
+ @Override
+ public EncodedMessage transform(Message msg) throws Exception {
+ if( msg == null )
+ return null;
+ if( msg.getBooleanProperty(prefixVendor + "NATIVE") ) {
+ if( msg instanceof BytesMessage ) {
+ return AMQPNativeOutboundTransformer.transform(this, (BytesMessage)msg);
+ } else {
+ return null;
+ }
+ } else {
+ return JMSMappingOutboundTransformer.transform(this, msg);
+ }
+ }
+
+}
Propchange: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AutoOutboundTransformer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/AutoOutboundTransformer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/EncodedMessage.java
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/EncodedMessage.java?rev=1622849&view=auto
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/EncodedMessage.java (added)
+++ qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/EncodedMessage.java Sat Sep 6 11:23:10 2014
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.qpid.proton.jms;
+
+import org.apache.qpid.proton.message.Message;
+import org.apache.qpid.proton.amqp.Binary;
+
+/**
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+public class EncodedMessage
+{
+
+ private final Binary data;
+ final long messageFormat;
+
+ public EncodedMessage(long messageFormat, byte[] data, int offset, int length) {
+ this.data = new Binary(data, offset, length);
+ this.messageFormat = messageFormat;
+ }
+
+ public long getMessageFormat() {
+ return messageFormat;
+ }
+
+ public Message decode() throws Exception {
+ Message amqp = Message.Factory.create();
+
+ int offset = getArrayOffset();
+ int len = getLength();
+ while( len > 0 ) {
+ final int decoded = amqp.decode(getArray(), offset, len);
+ assert decoded > 0: "Make progress decoding the message";
+ offset += decoded;
+ len -= decoded;
+ }
+
+ return amqp;
+ }
+
+ public int getLength()
+ {
+ return data.getLength();
+ }
+
+ public int getArrayOffset()
+ {
+ return data.getArrayOffset();
+ }
+
+ public byte[] getArray()
+ {
+ return data.getArray();
+ }
+
+ @Override
+ public String toString()
+ {
+ return data.toString();
+ }
+}
Propchange: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/EncodedMessage.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/EncodedMessage.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/InboundTransformer.java
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/InboundTransformer.java?rev=1622849&view=auto
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/InboundTransformer.java (added)
+++ qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/InboundTransformer.java Sat Sep 6 11:23:10 2014
@@ -0,0 +1,314 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.qpid.proton.jms;
+
+import org.apache.qpid.proton.amqp.*;
+import org.apache.qpid.proton.amqp.messaging.ApplicationProperties;
+import org.apache.qpid.proton.amqp.messaging.DeliveryAnnotations;
+import org.apache.qpid.proton.amqp.messaging.Footer;
+import org.apache.qpid.proton.amqp.messaging.Header;
+import org.apache.qpid.proton.amqp.messaging.MessageAnnotations;
+import org.apache.qpid.proton.amqp.messaging.Properties;
+
+import javax.jms.*;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.Queue;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+/**
+* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+*/
+public abstract class InboundTransformer {
+
+ JMSVendor vendor;
+
+ public static final String TRANSFORMER_NATIVE = "native";
+ public static final String TRANSFORMER_RAW = "raw";
+ public static final String TRANSFORMER_JMS = "jms";
+
+ String prefixVendor = "JMS_AMQP_";
+ String prefixDeliveryAnnotations = "DA_";
+ String prefixMessageAnnotations= "MA_";
+ String prefixFooter = "FT_";
+
+ int defaultDeliveryMode = javax.jms.Message.DEFAULT_DELIVERY_MODE;
+ int defaultPriority = javax.jms.Message.DEFAULT_PRIORITY;
+ long defaultTtl = javax.jms.Message.DEFAULT_TIME_TO_LIVE;
+
+ public InboundTransformer(JMSVendor vendor) {
+ this.vendor = vendor;
+ }
+
+ abstract public Message transform(EncodedMessage amqpMessage) throws Exception;
+
+ public int getDefaultDeliveryMode() {
+ return defaultDeliveryMode;
+ }
+
+ public void setDefaultDeliveryMode(int defaultDeliveryMode) {
+ this.defaultDeliveryMode = defaultDeliveryMode;
+ }
+
+ public int getDefaultPriority() {
+ return defaultPriority;
+ }
+
+ public void setDefaultPriority(int defaultPriority) {
+ this.defaultPriority = defaultPriority;
+ }
+
+ public long getDefaultTtl() {
+ return defaultTtl;
+ }
+
+ public void setDefaultTtl(long defaultTtl) {
+ this.defaultTtl = defaultTtl;
+ }
+
+ public String getPrefixVendor() {
+ return prefixVendor;
+ }
+
+ public void setPrefixVendor(String prefixVendor) {
+ this.prefixVendor = prefixVendor;
+ }
+
+ public JMSVendor getVendor() {
+ return vendor;
+ }
+
+ public void setVendor(JMSVendor vendor) {
+ this.vendor = vendor;
+ }
+
+ protected void populateMessage(Message jms, org.apache.qpid.proton.message.Message amqp) throws Exception {
+ Header header = amqp.getHeader();
+ if( header==null ) {
+ header = new Header();
+ }
+
+ if( header.getDurable()!=null ) {
+ jms.setJMSDeliveryMode(header.getDurable().booleanValue() ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
+ } else {
+ jms.setJMSDeliveryMode(defaultDeliveryMode);
+ }
+ if( header.getPriority()!=null ) {
+ jms.setJMSPriority(header.getPriority().intValue());
+ } else {
+ jms.setJMSPriority(defaultPriority);
+ }
+ if( header.getFirstAcquirer() !=null ) {
+ jms.setBooleanProperty(prefixVendor + "FirstAcquirer", header.getFirstAcquirer());
+ }
+ if( header.getDeliveryCount()!=null ) {
+ vendor.setJMSXDeliveryCount(jms, header.getDeliveryCount().longValue());
+ }
+
+ final DeliveryAnnotations da = amqp.getDeliveryAnnotations();
+ if( da!=null ) {
+ for (Map.Entry<?,?> entry : da.getValue().entrySet()) {
+ String key = entry.getKey().toString();
+ setProperty(jms, prefixVendor + prefixDeliveryAnnotations + key, entry.getValue());
+ }
+ }
+
+ Class<? extends Destination> toAttributes = Destination.class;
+ Class<? extends Destination> replyToAttributes = Destination.class;
+
+ final MessageAnnotations ma = amqp.getMessageAnnotations();
+ if( ma!=null ) {
+ for (Map.Entry<?,?> entry : ma.getValue().entrySet()) {
+ String key = entry.getKey().toString();
+ if( "x-opt-jms-type".equals(key.toString()) && entry.getValue() != null ) {
+ jms.setJMSType(entry.getValue().toString());
+ } else if( "x-opt-to-type".equals(key.toString()) ) {
+ toAttributes = toClassFromAttributes(entry.getValue().toString());
+ } else if( "x-opt-reply-type".equals(key.toString()) ) {
+ replyToAttributes = toClassFromAttributes(entry.getValue().toString());
+ } else {
+ setProperty(jms, prefixVendor + prefixMessageAnnotations + key, entry.getValue());
+ }
+ }
+ }
+
+ final ApplicationProperties ap = amqp.getApplicationProperties();
+ if( ap !=null ) {
+ for (Map.Entry entry : (Set<Map.Entry>)ap.getValue().entrySet()) {
+ String key = entry.getKey().toString();
+ if( "JMSXGroupID".equals(key) ) {
+ vendor.setJMSXGroupID(jms, entry.getValue().toString());
+ } else if( "JMSXGroupSequence".equals(key) ) {
+ vendor.setJMSXGroupSequence(jms, ((Number)entry.getValue()).intValue());
+ } else if( "JMSXUserID".equals(key) ) {
+ vendor.setJMSXUserID(jms, entry.getValue().toString());
+ } else {
+ setProperty(jms, key, entry.getValue());
+ }
+ }
+ }
+
+ final Properties properties = amqp.getProperties();
+ if( properties!=null ) {
+ if( properties.getMessageId()!=null ) {
+ jms.setJMSMessageID(properties.getMessageId().toString());
+ }
+ Binary userId = properties.getUserId();
+ if( userId!=null ) {
+ vendor.setJMSXUserID(jms, new String(userId.getArray(), userId.getArrayOffset(), userId.getLength(), "UTF-8"));
+ }
+ if( properties.getTo()!=null ) {
+ jms.setJMSDestination(vendor.createDestination(properties.getTo(), toAttributes));
+ }
+ if( properties.getSubject()!=null ) {
+ jms.setStringProperty(prefixVendor + "Subject", properties.getSubject());
+ }
+ if( properties.getReplyTo() !=null ) {
+ jms.setJMSReplyTo(vendor.createDestination(properties.getReplyTo(), replyToAttributes));
+ }
+ if( properties.getCorrelationId() !=null ) {
+ jms.setJMSCorrelationID(properties.getCorrelationId().toString());
+ }
+ if( properties.getContentType() !=null ) {
+ jms.setStringProperty(prefixVendor + "ContentType", properties.getContentType().toString());
+ }
+ if( properties.getContentEncoding() !=null ) {
+ jms.setStringProperty(prefixVendor + "ContentEncoding", properties.getContentEncoding().toString());
+ }
+ if( properties.getCreationTime()!=null ) {
+ jms.setJMSTimestamp(properties.getCreationTime().getTime());
+ }
+ if( properties.getGroupId()!=null ) {
+ vendor.setJMSXGroupID(jms, properties.getGroupId());
+ }
+ if( properties.getGroupSequence()!=null ) {
+ vendor.setJMSXGroupSequence(jms, properties.getGroupSequence().intValue());
+ }
+ if( properties.getReplyToGroupId()!=null ) {
+ jms.setStringProperty(prefixVendor + "ReplyToGroupID", properties.getReplyToGroupId());
+ }
+ if( properties.getAbsoluteExpiryTime()!=null ) {
+ jms.setJMSExpiration(properties.getAbsoluteExpiryTime().getTime());
+ }
+ }
+
+ // If the jms expiration has not yet been set...
+ if( jms.getJMSExpiration()==0 ) {
+ // Then lets try to set it based on the message ttl.
+ long ttl = defaultTtl;
+ if( header.getTtl()!=null ) {
+ ttl = header.getTtl().longValue();
+ }
+ if( ttl == 0 ) {
+ jms.setJMSExpiration(0);
+ } else {
+ jms.setJMSExpiration(System.currentTimeMillis()+ttl);
+ }
+ }
+
+ final Footer fp = amqp.getFooter();
+ if( fp !=null ) {
+ for (Map.Entry entry : (Set<Map.Entry>)fp.getValue().entrySet()) {
+ String key = entry.getKey().toString();
+ setProperty(jms, prefixVendor + prefixFooter + key, entry.getValue());
+ }
+ }
+ }
+
+ private static final Set<String> QUEUE_ATTRIBUTES = createSet("queue");
+ private static final Set<String> TOPIC_ATTRIBUTES = createSet("topic");
+ private static final Set<String> TEMP_QUEUE_ATTRIBUTES = createSet("queue", "temporary");
+ private static final Set<String> TEMP_TOPIC_ATTRIBUTES = createSet("topic", "temporary");
+
+ private static Set<String> createSet(String ... args) {
+ HashSet<String> s = new HashSet<String>();
+ for (String arg : args)
+ {
+ s.add(arg);
+ }
+ return Collections.unmodifiableSet(s);
+ }
+
+ Class<? extends Destination> toClassFromAttributes(String value)
+ {
+ if( value ==null ) {
+ return null;
+ }
+ HashSet<String> attributes = new HashSet<String>();
+ for( String x: value.split("\\s*,\\s*") ) {
+ attributes.add(x);
+ }
+
+ if( QUEUE_ATTRIBUTES.equals(attributes) ) {
+ return Queue.class;
+ }
+ if( TOPIC_ATTRIBUTES.equals(attributes) ) {
+ return Topic.class;
+ }
+ if( TEMP_QUEUE_ATTRIBUTES.equals(attributes) ) {
+ return TemporaryQueue.class;
+ }
+ if( TEMP_TOPIC_ATTRIBUTES.equals(attributes) ) {
+ return TemporaryTopic.class;
+ }
+ return Destination.class;
+ }
+
+
+ private void setProperty(Message msg, String key, Object value) throws JMSException {
+ if( value instanceof UnsignedLong) {
+ long v = ((UnsignedLong) value).longValue();
+ msg.setLongProperty(key, v);
+ } else if( value instanceof UnsignedInteger) {
+ long v = ((UnsignedInteger) value).longValue();
+ if( Integer.MIN_VALUE <= v && v <= Integer.MAX_VALUE ) {
+ msg.setIntProperty(key, (int) v);
+ } else {
+ msg.setLongProperty(key, v);
+ }
+ } else if( value instanceof UnsignedShort) {
+ int v = ((UnsignedShort) value).intValue();
+ if( Short.MIN_VALUE <= v && v <= Short.MAX_VALUE ) {
+ msg.setShortProperty(key, (short) v);
+ } else {
+ msg.setIntProperty(key, v);
+ }
+ } else if( value instanceof UnsignedByte) {
+ short v = ((UnsignedByte) value).shortValue();
+ if( Byte.MIN_VALUE <= v && v <= Byte.MAX_VALUE ) {
+ msg.setByteProperty(key, (byte) v);
+ } else {
+ msg.setShortProperty(key, v);
+ }
+ } else if( value instanceof Symbol) {
+ msg.setStringProperty(key, value.toString());
+ } else if( value instanceof Decimal128 ) {
+ msg.setDoubleProperty(key, ((Decimal128)value).doubleValue());
+ } else if( value instanceof Decimal64 ) {
+ msg.setDoubleProperty(key, ((Decimal64)value).doubleValue());
+ } else if( value instanceof Decimal32 ) {
+ msg.setFloatProperty(key, ((Decimal32)value).floatValue());
+ } else if( value instanceof Binary ) {
+ msg.setStringProperty(key, value.toString());
+ } else {
+ msg.setObjectProperty(key, value);
+ }
+ }
+}
Propchange: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/InboundTransformer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/InboundTransformer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSMappingInboundTransformer.java
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSMappingInboundTransformer.java?rev=1622849&view=auto
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSMappingInboundTransformer.java (added)
+++ qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSMappingInboundTransformer.java Sat Sep 6 11:23:10 2014
@@ -0,0 +1,102 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.qpid.proton.jms;
+
+import org.apache.qpid.proton.amqp.Binary;
+import org.apache.qpid.proton.amqp.messaging.Section;
+import org.apache.qpid.proton.amqp.messaging.*;
+
+import javax.jms.*;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+*/
+public class JMSMappingInboundTransformer extends InboundTransformer {
+
+ public JMSMappingInboundTransformer(JMSVendor vendor) {
+ super(vendor);
+ }
+
+ @Override
+ public Message transform(EncodedMessage amqpMessage) throws Exception {
+ org.apache.qpid.proton.message.Message amqp = amqpMessage.decode();
+
+ Message rc;
+ final Section body = amqp.getBody();
+ if( body == null ) {
+ rc = vendor.createMessage();
+ } else if( body instanceof Data ) {
+ Binary d = ((Data) body).getValue();
+ BytesMessage m = vendor.createBytesMessage();
+ m.writeBytes(d.getArray(), d.getArrayOffset(), d.getLength());
+ rc = m;
+ } else if (body instanceof AmqpSequence ) {
+ AmqpSequence sequence = (AmqpSequence) body;
+ StreamMessage m = vendor.createStreamMessage();
+ for( Object item : sequence.getValue()) {
+ m.writeObject(item);
+ }
+ rc = m;
+ } else if (body instanceof AmqpValue) {
+ Object value = ((AmqpValue) body).getValue();
+ if( value == null ) {
+ rc = vendor.createObjectMessage();
+ } if( value instanceof String ) {
+ TextMessage m = vendor.createTextMessage();
+ m.setText((String) value);
+ rc = m;
+ } else if( value instanceof Binary ) {
+ Binary d = (Binary) value;
+ BytesMessage m = vendor.createBytesMessage();
+ m.writeBytes(d.getArray(), d.getArrayOffset(), d.getLength());
+ rc = m;
+ } else if( value instanceof List) {
+ StreamMessage m = vendor.createStreamMessage();
+ for( Object item : (List) value) {
+ m.writeObject(item);
+ }
+ rc = m;
+ } else if( value instanceof Map) {
+ MapMessage m = vendor.createMapMessage();
+ final Set<Map.Entry<String, Object>> set = ((Map) value).entrySet();
+ for (Map.Entry<String, Object> entry : set) {
+ m.setObject(entry.getKey(), entry.getValue());
+ }
+ rc = m;
+ } else {
+ ObjectMessage m = vendor.createObjectMessage();
+ m.setObject((Serializable) value);
+ rc = m;
+ }
+ } else {
+ throw new RuntimeException("Unexpected body type: "+body.getClass());
+ }
+ rc.setJMSDeliveryMode(defaultDeliveryMode);
+ rc.setJMSPriority(defaultPriority);
+ rc.setJMSExpiration(defaultTtl);
+
+ populateMessage(rc, amqp);
+
+ rc.setLongProperty(prefixVendor + "MESSAGE_FORMAT", amqpMessage.getMessageFormat());
+ rc.setBooleanProperty(prefixVendor + "NATIVE", false);
+ return rc;
+ }
+}
Propchange: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSMappingInboundTransformer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSMappingInboundTransformer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSMappingOutboundTransformer.java
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSMappingOutboundTransformer.java?rev=1622849&view=auto
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSMappingOutboundTransformer.java (added)
+++ qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSMappingOutboundTransformer.java Sat Sep 6 11:23:10 2014
@@ -0,0 +1,246 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.qpid.proton.jms;
+
+import org.apache.qpid.proton.amqp.messaging.Section;
+import org.apache.qpid.proton.codec.CompositeWritableBuffer;
+import org.apache.qpid.proton.codec.WritableBuffer;
+import org.apache.qpid.proton.codec.DroppingWritableBuffer;
+import org.apache.qpid.proton.message.ProtonJMessage;
+import org.apache.qpid.proton.amqp.Binary;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.UnsignedByte;
+import org.apache.qpid.proton.amqp.UnsignedInteger;
+import org.apache.qpid.proton.amqp.messaging.*;
+
+import javax.jms.*;
+import java.io.UnsupportedEncodingException;
+import java.nio.ByteBuffer;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.HashMap;
+
+/**
+* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+*/
+public class JMSMappingOutboundTransformer extends OutboundTransformer {
+
+ String prefixDeliveryAnnotations = "DA_";
+ String prefixMessageAnnotations= "MA_";
+ String prefixFooter = "FT_";
+
+ public JMSMappingOutboundTransformer(JMSVendor vendor) {
+ super(vendor);
+ }
+
+ @Override
+ public EncodedMessage transform(Message msg) throws Exception {
+ if( msg == null )
+ return null;
+ try {
+ if( msg.getBooleanProperty(prefixVendor + "NATIVE") ) {
+ return null;
+ }
+ } catch (MessageFormatException e) {
+ return null;
+ }
+ return transform(this, msg);
+ }
+
+ static EncodedMessage transform(JMSMappingOutboundTransformer options, Message msg) throws JMSException, UnsupportedEncodingException {
+ final JMSVendor vendor = options.vendor;
+
+ final String messageFormatKey = options.prefixVendor + "MESSAGE_FORMAT";
+ final String nativeKey = options.prefixVendor + "NATIVE";
+ final String firstAcquirerKey = options.prefixVendor + "FirstAcquirer";
+ final String prefixDeliveryAnnotationsKey = options.prefixVendor + options.prefixDeliveryAnnotations;
+ final String prefixMessageAnnotationsKey = options.prefixVendor + options.prefixMessageAnnotations;
+ final String subjectKey = options.prefixVendor +"Subject";
+ final String contentTypeKey = options.prefixVendor +"ContentType";
+ final String contentEncodingKey = options.prefixVendor +"ContentEncoding";
+ final String replyToGroupIDKey = options.prefixVendor +"ReplyToGroupID";
+ final String prefixFooterKey = options.prefixVendor + options.prefixFooter;
+
+ long messageFormat;
+ try {
+ messageFormat = msg.getLongProperty(messageFormatKey);
+ } catch (MessageFormatException e) {
+ return null;
+ }
+
+ Header header = new Header();
+ Properties props=new Properties();
+ HashMap<Symbol, Object> daMap = null;
+ HashMap<Symbol, Object> maMap = null;
+ HashMap apMap = null;
+ Section body=null;
+ HashMap footerMap = null;
+ if( msg instanceof BytesMessage ) {
+ BytesMessage m = (BytesMessage)msg;
+ byte data[] = new byte[(int) m.getBodyLength()];
+ m.readBytes(data);
+ m.reset(); //Need to reset after readBytes or future readBytes calls (ex: redeliveries) will fail and return -1
+ body = new Data(new Binary(data));
+ } if( msg instanceof TextMessage ) {
+ body = new AmqpValue(((TextMessage) msg).getText());
+ } if( msg instanceof MapMessage ) {
+ final HashMap map = new HashMap();
+ final MapMessage m = (MapMessage) msg;
+ final Enumeration names = m.getMapNames();
+ while (names.hasMoreElements()) {
+ String key = (String) names.nextElement();
+ map.put(key, m.getObject(key));
+ }
+ body = new AmqpValue(map);
+ } if( msg instanceof StreamMessage ) {
+ ArrayList list = new ArrayList();
+ final StreamMessage m = (StreamMessage) msg;
+ try {
+ while(true) {
+ list.add(m.readObject());
+ }
+ } catch(MessageEOFException e){}
+ body = new AmqpSequence(list);
+ } if( msg instanceof ObjectMessage ) {
+ body = new AmqpValue(((ObjectMessage) msg).getObject());
+ }
+
+ header.setDurable(msg.getJMSDeliveryMode() == DeliveryMode.PERSISTENT ? true : false);
+ header.setPriority(new UnsignedByte((byte) msg.getJMSPriority()));
+ if( msg.getJMSType()!=null ) {
+ if( maMap==null ) maMap = new HashMap<Symbol, Object>();
+ maMap.put(Symbol.valueOf("x-opt-jms-type"), msg.getJMSType());
+ }
+ if( msg.getJMSMessageID()!=null ) {
+ props.setMessageId(msg.getJMSMessageID());
+ }
+ if( msg.getJMSDestination()!=null ) {
+ props.setTo(vendor.toAddress(msg.getJMSDestination()));
+ if( maMap==null ) maMap = new HashMap();
+ maMap.put(Symbol.valueOf("x-opt-to-type"), destinationAttributes(msg.getJMSDestination()));
+ }
+ if( msg.getJMSReplyTo()!=null ) {
+ props.setReplyTo(vendor.toAddress(msg.getJMSReplyTo()));
+ if( maMap==null ) maMap = new HashMap();
+ maMap.put(Symbol.valueOf("x-opt-reply-type"), destinationAttributes(msg.getJMSReplyTo()));
+ }
+ if( msg.getJMSCorrelationID()!=null ) {
+ props.setCorrelationId(msg.getJMSCorrelationID());
+ }
+ if( msg.getJMSExpiration() != 0 ) {
+ long ttl = msg.getJMSExpiration() - System.currentTimeMillis();
+ if (ttl < 0) {
+ ttl = 1;
+ }
+ header.setTtl(new UnsignedInteger((int)ttl));
+
+ props.setAbsoluteExpiryTime(new Date(msg.getJMSExpiration()));
+ }
+ if( msg.getJMSTimestamp()!= 0 ) {
+ props.setCreationTime(new Date(msg.getJMSTimestamp()));
+ }
+
+ final Enumeration keys = msg.getPropertyNames();
+ while (keys.hasMoreElements()) {
+ String key = (String) keys.nextElement();
+ if( key.equals(messageFormatKey) || key.equals(nativeKey)) {
+ // skip..
+ } else if( key.equals(firstAcquirerKey) ) {
+ header.setFirstAcquirer(msg.getBooleanProperty(key));
+ } else if( key.startsWith("JMSXDeliveryCount") ) {
+ header.setDeliveryCount(new UnsignedInteger(msg.getIntProperty(key)));
+ } else if( key.startsWith("JMSXUserID") ) {
+ String value = msg.getStringProperty(key);
+ props.setUserId(new Binary(value.getBytes("UTF-8")));
+ } else if( key.startsWith("JMSXGroupID") ) {
+ String value = msg.getStringProperty(key);
+ props.setGroupId(value);
+ if( apMap==null ) apMap = new HashMap();
+ apMap.put(key, value);
+ } else if( key.startsWith("JMSXGroupSeq") ) {
+ UnsignedInteger value = new UnsignedInteger(msg.getIntProperty(key));
+ props.setGroupSequence(value);
+ if( apMap==null ) apMap = new HashMap();
+ apMap.put(key, value);
+ } else if( key.startsWith(prefixDeliveryAnnotationsKey) ) {
+ if( daMap == null ) daMap = new HashMap<Symbol, Object>();
+ String name = key.substring(prefixDeliveryAnnotationsKey.length());
+ daMap.put(Symbol.valueOf(name), msg.getObjectProperty(key));
+ } else if( key.startsWith(prefixMessageAnnotationsKey) ) {
+ if( maMap==null ) maMap = new HashMap<Symbol, Object>();
+ String name = key.substring(prefixMessageAnnotationsKey.length());
+ maMap.put(Symbol.valueOf(name), msg.getObjectProperty(key));
+ } else if( key.equals(subjectKey) ) {
+ props.setSubject(msg.getStringProperty(key));
+ } else if( key.equals(contentTypeKey) ) {
+ props.setContentType(Symbol.getSymbol(msg.getStringProperty(key)));
+ } else if( key.equals(contentEncodingKey) ) {
+ props.setContentEncoding(Symbol.getSymbol(msg.getStringProperty(key)));
+ } else if( key.equals(replyToGroupIDKey) ) {
+ props.setReplyToGroupId(msg.getStringProperty(key));
+ } else if( key.startsWith(prefixFooterKey) ) {
+ if( footerMap==null ) footerMap = new HashMap();
+ String name = key.substring(prefixFooterKey.length());
+ footerMap.put(name, msg.getObjectProperty(key));
+ } else {
+ if( apMap==null ) apMap = new HashMap();
+ apMap.put(key, msg.getObjectProperty(key));
+ }
+ }
+
+
+ MessageAnnotations ma=null;
+ if( maMap!=null ) ma = new MessageAnnotations(maMap);
+ DeliveryAnnotations da=null;
+ if( daMap!=null ) da = new DeliveryAnnotations(daMap);
+ ApplicationProperties ap=null;
+ if( apMap!=null ) ap = new ApplicationProperties(apMap);
+ Footer footer=null;
+ if( footerMap!=null ) footer = new Footer(footerMap);
+
+ ProtonJMessage amqp = (ProtonJMessage) org.apache.qpid.proton.message.Message.Factory.create(header, da, ma, props, ap, body, footer);
+
+ ByteBuffer buffer = ByteBuffer.wrap(new byte[1024*4]);
+ final DroppingWritableBuffer overflow = new DroppingWritableBuffer();
+ int c = amqp.encode(new CompositeWritableBuffer(new WritableBuffer.ByteBufferWrapper(buffer), overflow));
+ if( overflow.position() > 0 ) {
+ buffer = ByteBuffer.wrap(new byte[1024*4+overflow.position()]);
+ c = amqp.encode(new WritableBuffer.ByteBufferWrapper(buffer));
+ }
+
+ return new EncodedMessage(messageFormat, buffer.array(), 0, c);
+ }
+
+ private static String destinationAttributes(Destination destination) {
+ if( destination instanceof Queue ) {
+ if( destination instanceof TemporaryQueue ) {
+ return "temporary,queue";
+ } else {
+ return "queue";
+ }
+ }
+ if( destination instanceof Topic ) {
+ if( destination instanceof TemporaryTopic ) {
+ return "temporary,topic";
+ } else {
+ return "topic";
+ }
+ }
+ return "";
+ }
+}
Propchange: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSMappingOutboundTransformer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSMappingOutboundTransformer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSVendor.java
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSVendor.java?rev=1622849&view=auto
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSVendor.java (added)
+++ qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSVendor.java Sat Sep 6 11:23:10 2014
@@ -0,0 +1,45 @@
+package org.apache.qpid.proton.jms;
+
+import javax.jms.*;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+abstract public class JMSVendor {
+
+ public abstract BytesMessage createBytesMessage();
+
+ public abstract StreamMessage createStreamMessage();
+
+ public abstract Message createMessage();
+
+ public abstract TextMessage createTextMessage();
+
+ public abstract ObjectMessage createObjectMessage();
+
+ public abstract MapMessage createMapMessage();
+
+ public abstract void setJMSXUserID(Message msg, String value);
+
+ @Deprecated
+ public Destination createDestination(String name) {
+ return null;
+ }
+
+ @SuppressWarnings("deprecation")
+ public <T extends Destination> T createDestination(String name, Class<T> kind) {
+ return kind.cast(createDestination(name));
+ }
+
+ public abstract void setJMSXGroupID(Message msg, String groupId);
+
+ public abstract void setJMSXGroupSequence(Message msg, int i);
+
+ public abstract void setJMSXDeliveryCount(Message rc, long l);
+
+ public abstract String toAddress(Destination msgDestination);
+
+}
Propchange: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSVendor.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/JMSVendor.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/OutboundTransformer.java
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/OutboundTransformer.java?rev=1622849&view=auto
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/OutboundTransformer.java (added)
+++ qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/OutboundTransformer.java Sat Sep 6 11:23:10 2014
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.qpid.proton.jms;
+
+import org.apache.qpid.proton.engine.Delivery;
+
+import javax.jms.Message;
+
+/**
+* @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+*/
+public abstract class OutboundTransformer {
+
+ JMSVendor vendor;
+ String prefixVendor = "JMS_AMQP_";
+
+ public OutboundTransformer(JMSVendor vendor) {
+ this.vendor = vendor;
+ }
+
+ public abstract EncodedMessage transform(Message jms) throws Exception;
+
+ public String getPrefixVendor() {
+ return prefixVendor;
+ }
+
+ public void setPrefixVendor(String prefixVendor) {
+ this.prefixVendor = prefixVendor;
+ }
+
+ public JMSVendor getVendor() {
+ return vendor;
+ }
+
+ public void setVendor(JMSVendor vendor) {
+ this.vendor = vendor;
+ }
+}
Propchange: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/OutboundTransformer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: qpid/proton/branches/fadams-javascript-binding/contrib/proton-jms/src/main/java/org/apache/qpid/proton/jms/OutboundTransformer.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: qpid/proton/branches/fadams-javascript-binding/examples/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/examples/CMakeLists.txt?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/examples/CMakeLists.txt (original)
+++ qpid/proton/branches/fadams-javascript-binding/examples/CMakeLists.txt Sat Sep 6 11:23:10 2014
@@ -19,4 +19,5 @@
set (Proton_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
add_subdirectory(messenger/c)
Modified: qpid/proton/branches/fadams-javascript-binding/examples/messenger/java/recv
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/examples/messenger/java/recv?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/examples/messenger/java/recv (original)
+++ qpid/proton/branches/fadams-javascript-binding/examples/messenger/java/recv Sat Sep 6 11:23:10 2014
@@ -6,7 +6,7 @@
HERE=$(cd $(dirname $0); pwd)
TOP=$(cd $(dirname $0); cd ../../..; pwd)
-LIBS=$HERE/target/classes:$TOP/proton-j/proton-api/target/classes:$TOP/proton-j/proton/target/classes
+LIBS=$HERE/target/classes:$TOP/proton-j/target/classes
JFLAGS="-Djava.util.logging.config.file=$HERE/recv.trace.props -cp $LIBS"
java -cp $LIBS org.apache.qpid.proton.example.Recv "$@"
Modified: qpid/proton/branches/fadams-javascript-binding/examples/messenger/java/send
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/examples/messenger/java/send?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/examples/messenger/java/send (original)
+++ qpid/proton/branches/fadams-javascript-binding/examples/messenger/java/send Sat Sep 6 11:23:10 2014
@@ -4,7 +4,7 @@
HERE=$(cd $(dirname $0); pwd)
TOP=$(cd $(dirname $0); cd ../../..; pwd)
-LIBS=$HERE/target/classes:$TOP/proton-j/proton-api/target/classes:$TOP/proton-j/proton/target/classes
+LIBS=$HERE/target/classes:$TOP/proton-j/target/classes
JFLAGS="-Djava.util.logging.config.file=$HERE/send.trace.props -cp $LIBS"
java -cp $LIBS org.apache.qpid.proton.example.Send "$@"
Modified: qpid/proton/branches/fadams-javascript-binding/examples/messenger/java/src/main/java/org/apache/qpid/proton/example/Send.java
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/examples/messenger/java/src/main/java/org/apache/qpid/proton/example/Send.java?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/examples/messenger/java/src/main/java/org/apache/qpid/proton/example/Send.java (original)
+++ qpid/proton/branches/fadams-javascript-binding/examples/messenger/java/src/main/java/org/apache/qpid/proton/example/Send.java Sat Sep 6 11:23:10 2014
@@ -40,9 +40,9 @@ import java.util.logging.Logger;
public class Send {
private static Logger tracer = Logger.getLogger("proton.example");
- private String address = "amqp://0.0.0.0/test";
+ private String address = "amqp://0.0.0.0";
private String subject;
- private String[] bodies;
+ private String[] bodies = new String[]{"Hello World!"};
private static void usage() {
System.err.println("Usage: send [-a ADDRESS] [-s SUBJECT] MSG+");
@@ -67,7 +67,11 @@ public class Send {
break;
}
}
- bodies = Arrays.copyOfRange(args, i, args.length);
+
+ if(i != args.length)
+ {
+ bodies = Arrays.copyOfRange(args, i, args.length);
+ }
}
private void run() {
Modified: qpid/proton/branches/fadams-javascript-binding/examples/messenger/javascript/send.html
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/examples/messenger/javascript/send.html?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/examples/messenger/javascript/send.html (original)
+++ qpid/proton/branches/fadams-javascript-binding/examples/messenger/javascript/send.html Sat Sep 6 11:23:10 2014
@@ -58,7 +58,17 @@ console.log("body = " + body);
messenger.put(message);
};
-messenger.on('error', function(error) {console.log("Received error " + error);});
+messenger.on('error', function(error) {
+ console.log("Received error " + error);
+
+message.free();
+messenger.free();
+message = new proton.Message();
+messenger = new proton.Messenger();
+messenger.start();
+console.log("Restarted");
+});
+
messenger.start();
</script>
Modified: qpid/proton/branches/fadams-javascript-binding/examples/messenger/perl/recv.pl
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/examples/messenger/perl/recv.pl?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/examples/messenger/perl/recv.pl (original)
+++ qpid/proton/branches/fadams-javascript-binding/examples/messenger/perl/recv.pl Sat Sep 6 11:23:10 2014
@@ -18,9 +18,11 @@
# under the License.
#
-use strict;
use warnings;
+use Scalar::Util qw(reftype);
+use Data::Dumper;
+
use qpid_proton;
sub usage {
@@ -48,10 +50,34 @@ for(;;)
while ($messenger->incoming() > 0)
{
$messenger->get($msg);
+
+ print "\n";
print "Address: " . $msg->get_address() . "\n";
- print "Subject: " . $msg->get_subject() . "\n";
- print "Content: " . $msg->get_content() . "\n";
- print "Body: " . $msg->get_body() . "\n";
+ print "Subject: " . $msg->get_subject() . "\n" unless !defined($msg->get_subject());
+ print "Body: ";
+
+ my $body = $msg->get_body();
+ my $body_type = $msg->get_body_type();
+
+ if (!defined($body_type)) {
+ print "The body type wasn't defined!\n";
+ } elsif ($body_type == qpid::proton::BOOL) {
+ print "[BOOL]\n";
+ print "" . ($body ? "TRUE" : "FALSE") . "\n";
+ } elsif ($body_type == qpid::proton::MAP) {
+ print "[HASH]\n";
+ print Dumper(\%{$body}) . "\n";
+ } elsif ($body_type == qpid::proton::ARRAY) {
+ print "[ARRAY]\n";
+ print Data::Dumper->Dump($body) . "\n";
+ } elsif ($body_type == qpid::proton::LIST) {
+ print "[LIST]\n";
+ print Data::Dumper->Dump($body) . "\n";
+ } else {
+ print "[$body_type]\n";
+ print "$body\n";
+ }
+
print "Properties:\n";
my $props = $msg->get_properties();
foreach (keys $props) {
Modified: qpid/proton/branches/fadams-javascript-binding/examples/messenger/perl/send.pl
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/examples/messenger/perl/send.pl?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/examples/messenger/perl/send.pl (original)
+++ qpid/proton/branches/fadams-javascript-binding/examples/messenger/perl/send.pl Sat Sep 6 11:23:10 2014
@@ -34,11 +34,14 @@ sub HELP_MESSAGE() {
print "Options:\n";
print "\t-s - the message subject\n";
print "\t-C - the message content\n";
- print "\t<ADDRESS> - amqp://<domain>[/<name>]";
+ print "\t<ADDRESS> - amqp://<domain>[/<name>]\n";
+ print "\t-h - this message\n";
+
+ exit;
}
my %options = ();
-getopts("a:C:s:", \%options) or usage();
+getopts("a:C:s:h:", \%options) or HELP_MESSAGE();
my $address = $options{a} || "amqp://0.0.0.0";
my $subject = $options{s} || localtime(time);
@@ -58,7 +61,7 @@ foreach (@messages)
$msg->set_subject($subject);
$msg->set_content($content);
# try a few different body types
- my $body_type = int(rand(4));
+ my $body_type = int(rand(6));
$msg->set_property("sent", "" . localtime(time));
$msg->get_instructions->{"fold"} = "yes";
$msg->get_instructions->{"spindle"} = "no";
@@ -68,12 +71,15 @@ foreach (@messages)
SWITCH: {
$body_type == 0 && do { $msg->set_body("It is now " . localtime(time));};
- $body_type == 1 && do { $msg->set_body(rand(65536), qpid::proton::FLOAT); };
+ $body_type == 1 && do { $msg->set_body(rand(65536)); };
$body_type == 2 && do { $msg->set_body(int(rand(2)), qpid::proton::BOOL); };
- $body_type == 3 && do { $msg->set_body({"foo" => "bar"}, qpid::proton::MAP); };
+ $body_type == 3 && do { $msg->set_body({"foo" => "bar"}); };
+ $body_type == 4 && do { $msg->set_body([4, [1, 2, 3.1, 3.4E-5], 8, 15, 16, 23, 42]); };
+ $body_type == 5 && do { $msg->set_body(int(rand(65535))); }
}
$messenger->put($msg);
+ print "Sent: " . $msg->get_body . " [CONTENT TYPE: " . $msg->get_body_type . "]\n";
}
$messenger->send();
Modified: qpid/proton/branches/fadams-javascript-binding/examples/messenger/perl/server.pl
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/examples/messenger/perl/server.pl?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/examples/messenger/perl/server.pl (original)
+++ qpid/proton/branches/fadams-javascript-binding/examples/messenger/perl/server.pl Sat Sep 6 11:23:10 2014
@@ -58,8 +58,10 @@ sub dispatch {
$reply->set_properties($request->get_properties);
print "Dispatched " . $request->get_subject . "\n";
- foreach (keys $request->get_properties) {
- print "\t$_:" . $request->get_properties->{$_} . "\n";
+ my $properties = $request->get_properties;
+ foreach (keys %{$properties}) {
+ my $value = $properties->{%_};
+ print "\t$_: $value\n";
}
}
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/CMakeLists.txt?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/CMakeLists.txt (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/CMakeLists.txt Sat Sep 6 11:23:10 2014
@@ -58,26 +58,30 @@ configure_file (
"${CMAKE_CURRENT_BINARY_DIR}/include/proton/version.h"
)
-include_directories ("${CMAKE_CURRENT_BINARY_DIR}")
+include_directories ("${CMAKE_CURRENT_BINARY_DIR}/src")
include_directories ("${CMAKE_CURRENT_BINARY_DIR}/include")
+include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/src")
include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/include")
-include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/../examples/include")
+
+# TODO: This is only needed because the proton executable can use getopt on windows
+# if/when this executable gets sorted out remove
+include_directories ("${CMAKE_SOURCE_DIR}/examples/include")
add_custom_command (
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/encodings.h
- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/env.py PYTHONPATH=${CMAKE_CURRENT_SOURCE_DIR} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/src/codec/encodings.h.py > ${CMAKE_CURRENT_BINARY_DIR}/encodings.h
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/encodings.h
+ COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/env.py PYTHONPATH=${CMAKE_CURRENT_SOURCE_DIR} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/src/codec/encodings.h.py > ${CMAKE_CURRENT_BINARY_DIR}/src/encodings.h
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/codec/encodings.h.py
)
add_custom_command (
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/protocol.h
- COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/env.py PYTHONPATH=${CMAKE_CURRENT_SOURCE_DIR} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/src/protocol.h.py > ${CMAKE_CURRENT_BINARY_DIR}/protocol.h
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/src/protocol.h
+ COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/env.py PYTHONPATH=${CMAKE_CURRENT_SOURCE_DIR} ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/src/protocol.h.py > ${CMAKE_CURRENT_BINARY_DIR}/src/protocol.h
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/protocol.h.py
)
# Select driver
if(PN_WINAPI)
- set (pn_io_impl src/windows/io.c)
+ set (pn_io_impl src/windows/io.c src/windows/iocp.c src/windows/write_pipeline.c)
set (pn_selector_impl src/windows/selector.c)
set (pn_driver_impl src/windows/driver.c)
else(PN_WINAPI)
@@ -89,6 +93,7 @@ endif(PN_WINAPI)
# Link in openssl if present
if (SSL_IMPL STREQUAL openssl)
set (pn_driver_ssl_impl src/ssl/openssl.c)
+ include_directories ("${OPENSSL_INCLUDE_DIR}")
set (SSL_LIB ${OPENSSL_LIBRARIES})
else (SSL_IMPL STREQUAL openssl)
set (pn_driver_ssl_impl src/ssl/ssl_stub.c)
@@ -220,7 +225,13 @@ if (CMAKE_COMPILER_IS_GNUCC)
endif (CMAKE_COMPILER_IS_GNUCC)
if (MSVC)
- set(CMAKE_DEBUG_POSTFIX "d")
+ set(CMAKE_DEBUG_POSTFIX "d")
+ add_definitions(
+ /wd4244
+ /wd4267
+ /wd4800
+ /wd4996
+ )
endif (MSVC)
macro (pn_absolute_install_dir NAME VALUE PREFIX)
@@ -293,8 +304,8 @@ set (qpid-proton-core
src/messenger/transform.c
src/selectable.c
- ${CMAKE_CURRENT_BINARY_DIR}/encodings.h
- ${CMAKE_CURRENT_BINARY_DIR}/protocol.h
+ ${CMAKE_CURRENT_BINARY_DIR}/src/encodings.h
+ ${CMAKE_CURRENT_BINARY_DIR}/src/protocol.h
)
set_source_files_properties (
@@ -368,6 +379,18 @@ install (TARGETS qpid-proton
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
LIBRARY DESTINATION ${LIB_INSTALL_DIR})
+# Install windows qpid-proton pdb files
+if (MSVC)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/qpid-proton${CMAKE_DEBUG_POSTFIX}.pdb
+ DESTINATION bin
+ CONFIGURATIONS Debug
+ OPTIONAL)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo/qpid-proton.pdb
+ DESTINATION bin
+ CONFIGURATIONS RelWithDebInfo
+ OPTIONAL)
+endif (MSVC)
+
# Install header files
file(GLOB headers "include/proton/*.[hi]")
install (FILES ${headers} DESTINATION ${INCLUDE_INSTALL_DIR}/proton)
@@ -464,10 +487,10 @@ set (py_bin "${CMAKE_CURRENT_BINARY_DIR}
set (py_bld "${CMAKE_CURRENT_BINARY_DIR}${bld_suffix}") # For windows
set (app_path "${pn_test_bin}/tools/apps/c${bld_suffix}")
set (app_path "${app_path}:${pn_test_root}/tools/apps/python")
-set_path (py_path "$ENV{PATH}:${py_bin}:${py_bld}:${app_path}")
-set_path (py_pythonpath "$ENV{PYTHONPATH}:${py_root}:${py_src}:${py_bin}:${py_bld}")
+set_path (py_path "${py_bin}:${py_bld}:${app_path}:$ENV{PATH}")
+set_path (py_pythonpath "${py_root}:${py_src}:${py_bin}:${py_bld}|$ENV{PYTHONPATH}")
if (CMAKE_SYSTEM_NAME STREQUAL Windows)
- set_path (py_pythonpath "${py_pythonpath}:${py_bin}${bld_suffix}")
+ set_path (py_pythonpath "${py_bin}${bld_suffix}:${py_pythonpath}")
endif (CMAKE_SYSTEM_NAME STREQUAL Windows)
add_test (python-test ${PYTHON_EXECUTABLE} ${env_py}
"PATH=${py_path}" "PYTHONPATH=${py_pythonpath}" ${VALGRIND_ENV}
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/CMakeLists.txt?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/CMakeLists.txt (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/CMakeLists.txt Sat Sep 6 11:23:10 2014
@@ -62,7 +62,9 @@ if (RUBY_FOUND)
if (HAS_RUBY_GEM_RSPEC AND HAS_RUBY_GEM_SIMPLECOV)
set (DEFAULT_RUBY_TESTING ON CACHE INTERNAL "")
else()
+ message(STATUS "Skipping Ruby bindings due to missing dependencies...")
set (DEFAULT_RUBY_TESTING OFF CACHE INTERNAL "")
+ set (DEFAULT_RUBY OFF)
endif (HAS_RUBY_GEM_RSPEC AND HAS_RUBY_GEM_SIMPLECOV)
endif (RUBY_FOUND)
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/javascript/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/javascript/CMakeLists.txt?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/javascript/CMakeLists.txt (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/javascript/CMakeLists.txt Sat Sep 6 11:23:10 2014
@@ -43,10 +43,14 @@ set(CMAKE_C_COMPILER "${EMCC}")
include(CMakeForceCompiler)
CMAKE_FORCE_C_COMPILER("${CMAKE_C_COMPILER}" Clang)
-if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
- message(STATUS "DEBUG JavaScript build")
+# The Proton default build type is RelWithDebInfo, but for JavaScript the C debug
+# mechanism is irrelevant. If Debug is explicitly set we turn off optimisations
+# and don't run the closure compiler so any error/profiling messages are readable.
+if (CMAKE_BUILD_TYPE STREQUAL "Debug")
+ message(STATUS "JavaScript build type is \"Debug\"")
else()
- message(STATUS "RELEASE JavaScript build")
+ set (CMAKE_BUILD_TYPE Release)
+ message(STATUS "JavaScript build type is \"Release\"")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3")
set(EMSCRIPTEN_LINK_OPTIMISATIONS "-O2 --closure 1")
endif()
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/CMakeLists.txt?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/CMakeLists.txt (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/CMakeLists.txt Sat Sep 6 11:23:10 2014
@@ -43,7 +43,9 @@ if (NOT PERL_VENDORARCH_DIR)
endif()
set (CMAKE_C_FLAGS ${PERLCFLAGS})
-
+list(APPEND SWIG_MODULE_cproton_perl_EXTRA_DEPS
+ ${CMAKE_SOURCE_DIR}/proton-c/include/proton/cproton.i
+)
swig_add_module(cproton_perl perl perl.i)
swig_link_libraries(cproton_perl ${BINDING_DEPS} ${PERL_LIBRARY})
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Constants.pm
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Constants.pm?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Constants.pm (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Constants.pm Sat Sep 6 11:23:10 2014
@@ -20,6 +20,9 @@
package qpid::proton;
use constant {
+ VERSION_MAJOR => $cproton_perl::PN_VERSION_MAJOR,
+ VERSION_MINOR => $cproton_perl::PN_VERSION_MINOR,
+
NULL => $cproton_perl::PN_NULL,
BOOL => qpid::proton::Mapping->new(
"bool",
@@ -129,8 +132,8 @@ use constant {
LIST => qpid::proton::Mapping->new(
"list",
$cproton_perl::PN_LIST,
- "put_list",
- "get_list"),
+ "put_list_helper",
+ "get_list_helper"),
MAP => qpid::proton::Mapping->new(
"map",
$cproton_perl::PN_MAP,
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Data.pm
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Data.pm?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Data.pm (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Data.pm Sat Sep 6 11:23:10 2014
@@ -17,7 +17,7 @@
# under the License.
#
-use Scalar::Util qw(looks_like_number);
+use Scalar::Util qw(reftype looks_like_number);
=pod
@@ -321,9 +321,7 @@ Handles a boolean (B<true>/B<false>) nod
sub put_bool {
my ($self) = @_;
my $impl = $self->{_impl};
- my $value = $_[1];
-
- die "bool must be defined" if !defined($value);
+ my $value = $_[1] || 0;
cproton_perl::pn_data_put_bool($impl, $value);
}
@@ -1159,16 +1157,90 @@ sub get_map {
cproton_perl::pn_data_get_map($impl);
}
+sub put_list_helper {
+ my ($self) = @_;
+ my ($array) = $_[1];
+
+ $self->put_list;
+ $self->enter;
+
+ for my $value (@{$array}) {
+ if (qpid::proton::is_num($value)) {
+ if (qpid::proton::is_float($value)) {
+ $self->put_float($value);
+ } else {
+ $self->put_int($value);
+ }
+ } elsif (!defined($value)) {
+ $self->put_null;
+ } elsif ($value eq '') {
+ $self->put_string($value);
+ } elsif (ref($value) eq 'HASH') {
+ $self->put_map_helper($value);
+ } elsif (ref($value) eq 'ARRAY') {
+ $self->put_list_helper($value);
+ } else {
+ $self->put_string($value);
+ }
+ }
+
+ $self->exit;
+}
+
+sub get_list_helper {
+ my ($self) = @_;
+ my $result = [];
+ my $type = $self->get_type;
+
+ if ($cproton_perl::PN_LIST == $type->get_type_value) {
+ my $size = $self->get_list;
+
+ $self->enter;
+
+ for(my $count = 0; $count < $size; $count++) {
+ if ($self->next) {
+ my $value_type = $self->get_type;
+ my $value = $value_type->get($self);
+
+ push(@{$result}, $value);
+ }
+ }
+
+ $self->exit;
+ }
+
+ return $result;
+}
+
sub put_map_helper {
my ($self) = @_;
- my ($hash) = $_[1];
+ my $hash = $_[1];
$self->put_map;
$self->enter;
- foreach(keys $hash) {
- $self->put_string("$_");
- $self->put_string("$hash->{$_}");
+ foreach(keys %{$hash}) {
+ my $key = $_;
+ my $value = $hash->{$key};
+
+ my $keytype = ::reftype($key);
+ my $valtype = ::reftype($value);
+
+ if ($keytype eq ARRAY) {
+ $self->put_list_helper($key);
+ } elsif ($keytype eq "HASH") {
+ $self->put_map_helper($key);
+ } else {
+ $self->put_string("$key");
+ }
+
+ if (::reftype($value) eq HASH) {
+ $self->put_map_helper($value);
+ } elsif (::reftype($value) eq ARRAY) {
+ $self->put_list_helper($value);
+ } else {
+ $self->put_string("$value");
+ }
}
$self->exit;
@@ -1193,9 +1265,10 @@ sub get_map_helper {
}
}
}
- }
- $self->exit;
+ $self->exit;
+
+ }
return $result;
}
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Message.pm
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Message.pm?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Message.pm (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/Message.pm Sat Sep 6 11:23:10 2014
@@ -443,7 +443,29 @@ B<qpid::proton::STRING>.
sub set_body {
my ($self) = @_;
my $body = $_[1];
- my $body_type = $_[2] || qpid::proton::STRING;
+ my $body_type = $_[2] || undef;
+
+ # if no body type was defined, then attempt to infer what it should
+ # be, which is going to be a best guess
+ if (!defined($body_type)) {
+ if (qpid::proton::is_num($body)) {
+ if (qpid::proton::is_float($body)) {
+ $body_type = qpid::proton::FLOAT;
+ } else {
+ $body_type = qpid::proton::INT;
+ }
+ } elsif (!defined($body)) {
+ $body_type = qpid::proton::NULL;
+ } elsif ($body eq '') {
+ $body_type = qpid::proton::STRING;
+ } elsif (ref($body) eq 'HASH') {
+ $body_type = qpid::proton::MAP;
+ } elsif (ref($body) eq 'ARRAY') {
+ $body_type = qpid::proton::LIST;
+ } else {
+ $body_type = qpid::proton::STRING;
+ }
+ }
$self->{_body} = $body;
$self->{_body_type} = $body_type;
@@ -465,12 +487,12 @@ sub get_body_type {
sub preencode() {
my ($self) = @_;
my $impl = $self->{_impl};
-
my $my_body = $self->{_body};
my $body_type = $self->{_body_type};
my $body = new qpid::proton::Data(cproton_perl::pn_message_body($impl));
+
$body->clear();
- $body_type->put($body, $my_body) if($my_body && $body_type);
+ $body_type->put($body, $my_body) if(defined($my_body) && $body_type);
my $my_props = $self->{_properties};
my $props = new qpid::proton::Data(cproton_perl::pn_message_properties($impl));
Added: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/utils.pm
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/utils.pm?rev=1622849&view=auto
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/utils.pm (added)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid/proton/utils.pm Sat Sep 6 11:23:10 2014
@@ -0,0 +1,31 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+package qpid::proton;
+
+sub is_num {
+ my $val = $_[0];
+
+ return 0 if !defined($val);
+ return 0 if $val eq '';
+
+ $_[0] ^ $_[0] ? 0 : 1
+}
+
+1;
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid_proton.pm
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid_proton.pm?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid_proton.pm (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/lib/qpid_proton.pm Sat Sep 6 11:23:10 2014
@@ -21,6 +21,7 @@ use strict;
use warnings;
use cproton_perl;
+use qpid::proton::utils;
use qpid::proton::ExceptionHandling;
use qpid::proton::Data;
use qpid::proton::Mapping;
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/perl.i
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/perl.i?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/perl.i (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/perl/perl.i Sat Sep 6 11:23:10 2014
@@ -10,13 +10,6 @@
#include <proton/driver_extras.h>
%}
-typedef unsigned int size_t;
-typedef signed int ssize_t;
-typedef unsigned char uint8_t;
-typedef unsigned int uint32_t;
-typedef unsigned long int uint64_t;
-typedef int int32_t;
-
%include <cstring.i>
%typemap(in) pn_atom_t
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/php/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/php/CMakeLists.txt?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/php/CMakeLists.txt (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/php/CMakeLists.txt Sat Sep 6 11:23:10 2014
@@ -30,6 +30,9 @@ execute_process(COMMAND ${PHP_CONFIG_EXE
OUTPUT_STRIP_TRAILING_WHITESPACE)
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/php.i PROPERTIES SWIG_FLAGS "-I${PROJECT_SOURCE_DIR}/include")
+list(APPEND SWIG_MODULE_cproton_EXTRA_DEPS
+ ${CMAKE_SOURCE_DIR}/proton-c/include/proton/cproton.i
+)
swig_add_module(cproton php ${CMAKE_CURRENT_SOURCE_DIR}/php.i)
set_source_files_properties(${swig_generated_file_fullname} PROPERTIES COMPILE_FLAGS "${PHP_INCLUDES}")
swig_link_libraries(cproton ${BINDING_DEPS})
Modified: qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/php/proton.php
URL: http://svn.apache.org/viewvc/qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/php/proton.php?rev=1622849&r1=1622848&r2=1622849&view=diff
==============================================================================
--- qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/php/proton.php (original)
+++ qpid/proton/branches/fadams-javascript-binding/proton-c/bindings/php/proton.php Sat Sep 6 11:23:10 2014
@@ -286,7 +286,7 @@ class Message {
if ($ann->next())
$this->annotations = $ann->get_object();
else
- $self->annotations = null;
+ $this->annotations = null;
if ($props->next())
$this->properties = $props->get_object();
else
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org