Author: rgodfrey
Date: Tue Jan 31 23:56:32 2012
New Revision: 1238868

URL: http://svn.apache.org/viewvc?rev=1238868&view=rev
Log:
QPID-3789 : [Java] Remove duplication of BytesDataOutput inner class, and 
shared code in SessionAdapt[eo]rs

Added:
    
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/BytesDataOutput.java
Modified:
    
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java
    
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQQueueSessionAdaptor.java
    
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSessionAdapter.java
    
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopicSessionAdaptor.java
    
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java
    qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jms/Session.java

Modified: 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java?rev=1238868&r1=1238867&r2=1238868&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java
 (original)
+++ 
qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/protocol/AMQProtocolEngine.java
 Tue Jan 31 23:56:32 2012
@@ -63,11 +63,11 @@ import org.apache.qpid.server.virtualhos
 import org.apache.qpid.transport.Sender;
 import org.apache.qpid.transport.TransportException;
 import org.apache.qpid.transport.network.NetworkConnection;
+import org.apache.qpid.util.BytesDataOutput;
 
 import javax.management.JMException;
 import javax.security.auth.Subject;
 import javax.security.sasl.SaslServer;
-import java.io.DataOutput;
 import java.io.IOException;
 import java.net.InetSocketAddress;
 import java.net.SocketAddress;
@@ -1481,158 +1481,4 @@ public class AMQProtocolEngine implement
 
     }
 
-    private static class BytesDataOutput implements DataOutput
-    {
-        private int _pos = 0;
-        private byte[] _buf;
-
-        public BytesDataOutput(byte[] buf)
-        {
-            _buf = buf;
-        }
-
-        public void setBuffer(byte[] buf)
-        {
-            _buf = buf;
-            _pos = 0;
-        }
-
-        public void reset()
-        {
-            _pos = 0;
-        }
-
-        public int length()
-        {
-            return _pos;
-        }
-
-        public void write(int b)
-        {
-            _buf[_pos++] = (byte) b;
-        }
-
-        public void write(byte[] b)
-        {
-            System.arraycopy(b, 0, _buf, _pos, b.length);
-            _pos+=b.length;
-        }
-
-
-        public void write(byte[] b, int off, int len)
-        {
-            System.arraycopy(b, off, _buf, _pos, len);
-            _pos+=len;
-
-        }
-
-        public void writeBoolean(boolean v)
-        {
-            _buf[_pos++] = v ? (byte) 1 : (byte) 0;
-        }
-
-        public void writeByte(int v)
-        {
-            _buf[_pos++] = (byte) v;
-        }
-
-        public void writeShort(int v)
-        {
-            _buf[_pos++] = (byte) (v >>> 8);
-            _buf[_pos++] = (byte) v;
-        }
-
-        public void writeChar(int v)
-        {
-            _buf[_pos++] = (byte) (v >>> 8);
-            _buf[_pos++] = (byte) v;
-        }
-
-        public void writeInt(int v)
-        {
-            _buf[_pos++] = (byte) (v >>> 24);
-            _buf[_pos++] = (byte) (v >>> 16);
-            _buf[_pos++] = (byte) (v >>> 8);
-            _buf[_pos++] = (byte) v;
-        }
-
-        public void writeLong(long v)
-        {
-            _buf[_pos++] = (byte) (v >>> 56);
-            _buf[_pos++] = (byte) (v >>> 48);
-            _buf[_pos++] = (byte) (v >>> 40);
-            _buf[_pos++] = (byte) (v >>> 32);
-            _buf[_pos++] = (byte) (v >>> 24);
-            _buf[_pos++] = (byte) (v >>> 16);
-            _buf[_pos++] = (byte) (v >>> 8);
-            _buf[_pos++] = (byte)v;
-        }
-
-        public void writeFloat(float v)
-        {
-            writeInt(Float.floatToIntBits(v));
-        }
-
-        public void writeDouble(double v)
-        {
-            writeLong(Double.doubleToLongBits(v));
-        }
-
-        public void writeBytes(String s)
-        {
-            int len = s.length();
-            for (int i = 0 ; i < len ; i++)
-            {
-                _buf[_pos++] = ((byte)s.charAt(i));
-            }
-        }
-
-        public void writeChars(String s)
-        {
-            int len = s.length();
-            for (int i = 0 ; i < len ; i++)
-            {
-                int v = s.charAt(i);
-                _buf[_pos++] = (byte) (v >>> 8);
-                _buf[_pos++] = (byte) v;
-            }
-        }
-
-        public void writeUTF(String s)
-        {
-            int strlen = s.length();
-
-            int pos = _pos;
-            _pos+=2;
-
-
-            for (int i = 0; i < strlen; i++)
-            {
-                int c = s.charAt(i);
-                if ((c >= 0x0001) && (c <= 0x007F))
-                {
-                    c = s.charAt(i);
-                    _buf[_pos++] = (byte) c;
-
-                }
-                else if (c > 0x07FF)
-                {
-                    _buf[_pos++]  = (byte) (0xE0 | ((c >> 12) & 0x0F));
-                    _buf[_pos++]  = (byte) (0x80 | ((c >>  6) & 0x3F));
-                    _buf[_pos++]  = (byte) (0x80 | (c & 0x3F));
-                }
-                else
-                {
-                    _buf[_pos++] = (byte) (0xC0 | ((c >>  6) & 0x1F));
-                    _buf[_pos++]  = (byte) (0x80 | (c & 0x3F));
-                }
-            }
-
-            int len = _pos - (pos + 2);
-
-            _buf[pos++] = (byte) (len >>> 8);
-            _buf[pos] = (byte) len;
-        }
-
-    }
 }

Modified: 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQQueueSessionAdaptor.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQQueueSessionAdaptor.java?rev=1238868&r1=1238867&r2=1238868&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQQueueSessionAdaptor.java
 (original)
+++ 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQQueueSessionAdaptor.java
 Tue Jan 31 23:56:32 2012
@@ -28,156 +28,57 @@ import java.io.Serializable;
  * Need this adaptor class to conform to JMS spec and throw 
IllegalStateException
  * from createDurableSubscriber, unsubscribe, createTopic & 
createTemporaryTopic
  */
-public class AMQQueueSessionAdaptor implements QueueSession, AMQSessionAdapter
+class AMQQueueSessionAdaptor extends AMQSessionAdapter<QueueSession> 
implements QueueSession
 {
-    //holds a session for delegation
-    private final AMQSession _session;
-
     /**
      * Construct an adaptor with a session to wrap
      * @param session
      */
-    public AMQQueueSessionAdaptor(Session session)
+    protected AMQQueueSessionAdaptor(QueueSession session)
     {
-        _session = (AMQSession) session;
-    }
-
-    public TemporaryQueue createTemporaryQueue() throws JMSException {
-        return _session.createTemporaryQueue();
-    }
-
-    public Queue createQueue(String string) throws JMSException {
-        return _session.createQueue(string);
-    }
-
-    public QueueReceiver createReceiver(Queue queue) throws JMSException {
-        return _session.createReceiver(queue);
-    }
-
-    public QueueReceiver createReceiver(Queue queue, String string) throws 
JMSException {
-        return _session.createReceiver(queue, string);
-    }
-
-    public QueueSender createSender(Queue queue) throws JMSException {
-        return _session.createSender(queue);
-    }
-
-    public QueueBrowser createBrowser(Queue queue) throws JMSException {
-        return _session.createBrowser(queue);
-    }
-
-    public QueueBrowser createBrowser(Queue queue, String string) throws 
JMSException {
-        return _session.createBrowser(queue, string);
-    }
-
-    public BytesMessage createBytesMessage() throws JMSException {
-        return _session.createBytesMessage();
-    }
-
-    public MapMessage createMapMessage() throws JMSException {
-        return _session.createMapMessage();
-    }
-
-    public Message createMessage() throws JMSException {
-        return _session.createMessage();
-    }
-
-    public ObjectMessage createObjectMessage() throws JMSException {
-        return _session.createObjectMessage();
-    }
-
-    public ObjectMessage createObjectMessage(Serializable serializable) throws 
JMSException {
-        return _session.createObjectMessage(serializable);
-    }
-
-    public StreamMessage createStreamMessage() throws JMSException {
-        return _session.createStreamMessage();
-    }
-
-    public TextMessage createTextMessage() throws JMSException {
-        return _session.createTextMessage();
-    }
-
-    public TextMessage createTextMessage(String string) throws JMSException {
-        return _session.createTextMessage(string);
+        super(session);
     }
 
-    public boolean getTransacted() throws JMSException {
-        return _session.getTransacted();
-    }
-
-    public int getAcknowledgeMode() throws JMSException {
-       return _session.getAcknowledgeMode();
-    }
-
-    public void commit() throws JMSException {
-        _session.commit();
-    }
-
-    public void rollback() throws JMSException {
-        _session.rollback();
-    }
-
-    public void close() throws JMSException {
-        _session.close();
-    }
-
-    public void recover() throws JMSException {
-        _session.recover();
-    }
-
-    public MessageListener getMessageListener() throws JMSException {
-       return _session.getMessageListener();
-    }
-
-    public void setMessageListener(MessageListener messageListener) throws 
JMSException {
-        _session.setMessageListener(messageListener);
-    }
-
-    public void run() {
-        _session.run();
-    }
-
-    public MessageProducer createProducer(Destination destination) throws 
JMSException {
-        return _session.createProducer(destination);
-    }
-
-    public MessageConsumer createConsumer(Destination destination) throws 
JMSException {
-        return _session.createConsumer(destination);
+    public QueueReceiver createReceiver(Queue queue) throws JMSException
+    {
+        return getSession().createReceiver(queue);
     }
 
-    public MessageConsumer createConsumer(Destination destination, String 
string) throws JMSException {
-        return _session.createConsumer(destination,string);
+    public QueueReceiver createReceiver(Queue queue, String string) throws 
JMSException
+    {
+        return getSession().createReceiver(queue, string);
     }
 
-    public MessageConsumer createConsumer(Destination destination, String 
string, boolean b) throws JMSException {
-        return _session.createConsumer(destination,string,b);
+    public QueueSender createSender(Queue queue) throws JMSException
+    {
+        return getSession().createSender(queue);
     }
 
     //The following methods cannot be called from a QueueSession as per JMS 
spec
 
-    public Topic createTopic(String string) throws JMSException {
+    public Topic createTopic(String string) throws JMSException
+    {
         throw new IllegalStateException("Cannot call createTopic from 
QueueSession");
     }
 
-    public TopicSubscriber createDurableSubscriber(Topic topic, String string) 
throws JMSException {
+    public TopicSubscriber createDurableSubscriber(Topic topic, String string) 
throws JMSException
+    {
         throw new IllegalStateException("Cannot call createDurableSubscriber 
from QueueSession");
     }
 
-    public TopicSubscriber createDurableSubscriber(Topic topic, String string, 
String string1, boolean b) throws JMSException {
+    public TopicSubscriber createDurableSubscriber(Topic topic, String string, 
String string1, boolean b) throws JMSException
+    {
          throw new IllegalStateException("Cannot call createDurableSubscriber 
from QueueSession");
     }
 
-    public TemporaryTopic createTemporaryTopic() throws JMSException {
+    public TemporaryTopic createTemporaryTopic() throws JMSException
+    {
         throw new IllegalStateException("Cannot call createTemporaryTopic from 
QueueSession");
     }
 
-    public void unsubscribe(String string) throws JMSException {
+    public void unsubscribe(String string) throws JMSException
+    {
         throw new IllegalStateException("Cannot call unsubscribe from 
QueueSession");
     }
 
-    public AMQSession getSession()
-    {
-        return _session;
-    }
 }

Modified: 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSessionAdapter.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSessionAdapter.java?rev=1238868&r1=1238867&r2=1238868&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSessionAdapter.java
 (original)
+++ 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQSessionAdapter.java
 Tue Jan 31 23:56:32 2012
@@ -20,7 +20,172 @@
  */
 package org.apache.qpid.client;
 
-public interface AMQSessionAdapter
+import javax.jms.*;
+import java.io.Serializable;
+
+public abstract class AMQSessionAdapter<T extends Session> implements Session
 {
-    public AMQSession getSession();
+    private final T _session;
+
+    protected AMQSessionAdapter(final T session)
+    {
+        _session = session;
+    }
+
+    public T getSession()
+    {
+        return _session;
+    }
+
+    public BytesMessage createBytesMessage() throws JMSException
+    {
+        return _session.createBytesMessage();
+    }
+
+    public MapMessage createMapMessage() throws JMSException
+    {
+        return _session.createMapMessage();
+    }
+
+    public Message createMessage() throws JMSException
+    {
+        return _session.createMessage();
+    }
+
+    public ObjectMessage createObjectMessage() throws JMSException
+    {
+        return _session.createObjectMessage();
+    }
+
+    public ObjectMessage createObjectMessage(final Serializable serializable) 
throws JMSException
+    {
+        return _session.createObjectMessage(serializable);
+    }
+
+    public StreamMessage createStreamMessage() throws JMSException
+    {
+        return _session.createStreamMessage();
+    }
+
+    public TextMessage createTextMessage() throws JMSException
+    {
+        return _session.createTextMessage();
+    }
+
+    public TextMessage createTextMessage(final String s) throws JMSException
+    {
+        return _session.createTextMessage(s);
+    }
+
+    public boolean getTransacted() throws JMSException
+    {
+        return _session.getTransacted();
+    }
+
+    public int getAcknowledgeMode() throws JMSException
+    {
+        return _session.getAcknowledgeMode();
+    }
+
+    public void commit() throws JMSException
+    {
+        _session.commit();
+    }
+
+    public void rollback() throws JMSException
+    {
+        _session.rollback();
+    }
+
+    public void close() throws JMSException
+    {
+        _session.close();
+    }
+
+    public void recover() throws JMSException
+    {
+        _session.recover();
+    }
+
+    public MessageListener getMessageListener() throws JMSException
+    {
+        return _session.getMessageListener();
+    }
+
+    public void setMessageListener(final MessageListener messageListener) 
throws JMSException
+    {
+        _session.setMessageListener(messageListener);
+    }
+
+    public void run()
+    {
+        _session.run();
+    }
+
+    public MessageProducer createProducer(final Destination destination) 
throws JMSException
+    {
+        return _session.createProducer(destination);
+    }
+
+    public MessageConsumer createConsumer(final Destination destination) 
throws JMSException
+    {
+        return _session.createConsumer(destination);
+    }
+
+    public MessageConsumer createConsumer(final Destination destination, final 
String s) throws JMSException
+    {
+        return _session.createConsumer(destination, s);
+    }
+
+    public MessageConsumer createConsumer(final Destination destination, final 
String s, final boolean b)
+            throws JMSException
+    {
+        return _session.createConsumer(destination, s, b);
+    }
+
+    public Queue createQueue(final String s) throws JMSException
+    {
+        return _session.createQueue(s);
+    }
+
+    public Topic createTopic(final String s) throws JMSException
+    {
+        return _session.createTopic(s);
+    }
+
+    public TopicSubscriber createDurableSubscriber(final Topic topic, final 
String s) throws JMSException
+    {
+        return _session.createDurableSubscriber(topic, s);
+    }
+
+    public TopicSubscriber createDurableSubscriber(final Topic topic, final 
String s, final String s1, final boolean b)
+            throws JMSException
+    {
+        return _session.createDurableSubscriber(topic, s, s1, b);
+    }
+
+    public QueueBrowser createBrowser(final Queue queue) throws JMSException
+    {
+        return _session.createBrowser(queue);
+    }
+
+    public QueueBrowser createBrowser(final Queue queue, final String s) 
throws JMSException
+    {
+        return _session.createBrowser(queue, s);
+    }
+
+    public TemporaryQueue createTemporaryQueue() throws JMSException
+    {
+        return _session.createTemporaryQueue();
+    }
+
+    public TemporaryTopic createTemporaryTopic() throws JMSException
+    {
+        return _session.createTemporaryTopic();
+    }
+
+    public void unsubscribe(final String s) throws JMSException
+    {
+        _session.unsubscribe(s);
+    }
 }

Modified: 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopicSessionAdaptor.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopicSessionAdaptor.java?rev=1238868&r1=1238867&r2=1238868&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopicSessionAdaptor.java
 (original)
+++ 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQTopicSessionAdaptor.java
 Tue Jan 31 23:56:32 2012
@@ -24,158 +24,27 @@ import javax.jms.*;
 import javax.jms.IllegalStateException;
 import java.io.Serializable;
 
-public class AMQTopicSessionAdaptor implements TopicSession, AMQSessionAdapter
+class AMQTopicSessionAdaptor extends AMQSessionAdapter<TopicSession> 
implements TopicSession
 {
-    private final AMQSession _session;
 
-    public AMQTopicSessionAdaptor(Session session)
+    public AMQTopicSessionAdaptor(TopicSession session)
     {
-        _session = (AMQSession) session;
-    }
-
-    public Topic createTopic(String string) throws JMSException
-    {
-        return _session.createTopic(string);
+        super(session);
     }
 
     public TopicSubscriber createSubscriber(Topic topic) throws JMSException
     {
-        return _session.createSubscriber(topic);
+        return getSession().createSubscriber(topic);
     }
 
     public TopicSubscriber createSubscriber(Topic topic, String string, 
boolean b) throws JMSException
     {
-        return _session.createSubscriber(topic, string, b);
-    }
-
-    public TopicSubscriber createDurableSubscriber(Topic topic, String string) 
throws JMSException
-    {
-        return _session.createDurableSubscriber(topic, string);
-    }
-
-    public TopicSubscriber createDurableSubscriber(Topic topic, String string, 
String string1, boolean b) throws JMSException
-    {
-        return _session.createDurableSubscriber(topic, string, string1, b);
+        return getSession().createSubscriber(topic, string, b);
     }
 
     public TopicPublisher createPublisher(Topic topic) throws JMSException
     {
-        return _session.createPublisher(topic);
-    }
-
-    public TemporaryTopic createTemporaryTopic() throws JMSException
-    {
-        return _session.createTemporaryTopic();
-    }
-
-    public void unsubscribe(String string) throws JMSException
-    {
-        _session.unsubscribe(string);
-    }
-
-    public BytesMessage createBytesMessage() throws JMSException
-    {
-        return _session.createBytesMessage();
-    }
-
-    public MapMessage createMapMessage() throws JMSException
-    {
-        return _session.createMapMessage();
-    }
-
-    public Message createMessage() throws JMSException
-    {
-        return _session.createMessage();
-    }
-
-    public ObjectMessage createObjectMessage() throws JMSException
-    {
-        return _session.createObjectMessage();
-    }
-
-    public ObjectMessage createObjectMessage(Serializable serializable) throws 
JMSException
-    {
-        return _session.createObjectMessage(serializable);
-    }
-
-    public StreamMessage createStreamMessage() throws JMSException
-    {
-        return _session.createStreamMessage();
-    }
-
-    public TextMessage createTextMessage() throws JMSException
-    {
-        return _session.createTextMessage();
-    }
-
-    public TextMessage createTextMessage(String string) throws JMSException
-    {
-        return _session.createTextMessage(string);
-    }
-
-    public boolean getTransacted() throws JMSException
-    {
-        return _session.getTransacted();
-    }
-
-    public int getAcknowledgeMode() throws JMSException
-    {
-        return _session.getAcknowledgeMode();
-    }
-
-    public void commit() throws JMSException
-    {
-        _session.commit();
-    }
-
-    public void rollback() throws JMSException
-    {
-        _session.rollback();
-    }
-
-    public void close() throws JMSException
-    {
-        _session.close();
-    }
-
-    public void recover() throws JMSException
-    {
-        _session.recover();
-    }
-
-    public MessageListener getMessageListener() throws JMSException
-    {
-        return _session.getMessageListener();
-    }
-
-    public void setMessageListener(MessageListener messageListener) throws 
JMSException
-    {
-        _session.setMessageListener(messageListener);
-    }
-
-    public void run()
-    {
-        _session.run();
-    }
-
-    public MessageProducer createProducer(Destination destination) throws 
JMSException
-    {
-        return _session.createProducer(destination);
-    }
-
-    public MessageConsumer createConsumer(Destination destination) throws 
JMSException
-    {
-        return _session.createConsumer(destination);
-    }
-
-    public MessageConsumer createConsumer(Destination destination, String 
string) throws JMSException
-    {
-        return _session.createConsumer(destination, string);
-    }
-
-    public MessageConsumer createConsumer(Destination destination, String 
string, boolean b) throws JMSException
-    {
-        return _session.createConsumer(destination, string, b);
+        return getSession().createPublisher(topic);
     }
 
     //The following methods cannot be called from a TopicSession as per JMS 
spec
@@ -199,8 +68,4 @@ public class AMQTopicSessionAdaptor impl
         throw new IllegalStateException("Cannot call createTemporaryQueue from 
TopicSession");
     }
 
-    public AMQSession getSession()
-    {
-        return _session;
-    }
 }

Modified: 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java?rev=1238868&r1=1238867&r2=1238868&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java
 (original)
+++ 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java
 Tue Jan 31 23:56:32 2012
@@ -20,6 +20,7 @@
  */
 package org.apache.qpid.client.protocol;
 
+import org.apache.qpid.util.BytesDataOutput;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -863,160 +864,6 @@ public class AMQProtocolHandler implemen
         return _suggestedProtocolVersion;
     }
 
-    private static class BytesDataOutput implements DataOutput
-    {
-        private int _pos = 0;
-        private byte[] _buf;
-
-        public BytesDataOutput(byte[] buf)
-        {
-            _buf = buf;
-        }
-
-        public void setBuffer(byte[] buf)
-        {
-            _buf = buf;
-            _pos = 0;
-        }
-
-        public void reset()
-        {
-            _pos = 0;
-        }
-
-        public int length()
-        {
-            return _pos;
-        }
-
-        public void write(int b)
-        {
-            _buf[_pos++] = (byte) b;
-        }
-
-        public void write(byte[] b)
-        {
-            System.arraycopy(b, 0, _buf, _pos, b.length);
-            _pos+=b.length;
-        }
-
-
-        public void write(byte[] b, int off, int len)
-        {
-            System.arraycopy(b, off, _buf, _pos, len);
-            _pos+=len;
-
-        }
-
-        public void writeBoolean(boolean v)
-        {
-            _buf[_pos++] = v ? (byte) 1 : (byte) 0;
-        }
-
-        public void writeByte(int v)
-        {
-            _buf[_pos++] = (byte) v;
-        }
-
-        public void writeShort(int v)
-        {
-            _buf[_pos++] = (byte) (v >>> 8);
-            _buf[_pos++] = (byte) v;
-        }
-
-        public void writeChar(int v)
-        {
-            _buf[_pos++] = (byte) (v >>> 8);
-            _buf[_pos++] = (byte) v;
-        }
-
-        public void writeInt(int v)
-        {
-            _buf[_pos++] = (byte) (v >>> 24);
-            _buf[_pos++] = (byte) (v >>> 16);
-            _buf[_pos++] = (byte) (v >>> 8);
-            _buf[_pos++] = (byte) v;
-        }
-
-        public void writeLong(long v)
-        {
-            _buf[_pos++] = (byte) (v >>> 56);
-            _buf[_pos++] = (byte) (v >>> 48);
-            _buf[_pos++] = (byte) (v >>> 40);
-            _buf[_pos++] = (byte) (v >>> 32);
-            _buf[_pos++] = (byte) (v >>> 24);
-            _buf[_pos++] = (byte) (v >>> 16);
-            _buf[_pos++] = (byte) (v >>> 8);
-            _buf[_pos++] = (byte)v;
-        }
-
-        public void writeFloat(float v)
-        {
-            writeInt(Float.floatToIntBits(v));
-        }
-
-        public void writeDouble(double v)
-        {
-            writeLong(Double.doubleToLongBits(v));
-        }
-
-        public void writeBytes(String s)
-        {
-            int len = s.length();
-            for (int i = 0 ; i < len ; i++)
-            {
-                _buf[_pos++] = ((byte)s.charAt(i));
-            }
-        }
-
-        public void writeChars(String s)
-        {
-            int len = s.length();
-            for (int i = 0 ; i < len ; i++)
-            {
-                int v = s.charAt(i);
-                _buf[_pos++] = (byte) (v >>> 8);
-                _buf[_pos++] = (byte) v;
-            }
-        }
-
-        public void writeUTF(String s)
-        {
-            int strlen = s.length();
-
-            int pos = _pos;
-            _pos+=2;
-
-
-            for (int i = 0; i < strlen; i++)
-            {
-                int c = s.charAt(i);
-                if ((c >= 0x0001) && (c <= 0x007F))
-                {
-                    c = s.charAt(i);
-                    _buf[_pos++] = (byte) c;
-
-                }
-                else if (c > 0x07FF)
-                {
-                    _buf[_pos++]  = (byte) (0xE0 | ((c >> 12) & 0x0F));
-                    _buf[_pos++]  = (byte) (0x80 | ((c >>  6) & 0x3F));
-                    _buf[_pos++]  = (byte) (0x80 | (c & 0x3F));
-                }
-                else
-                {
-                    _buf[_pos++] = (byte) (0xC0 | ((c >>  6) & 0x1F));
-                    _buf[_pos++]  = (byte) (0x80 | (c & 0x3F));
-                }
-            }
-
-            int len = _pos - (pos + 2);
-
-            _buf[pos++] = (byte) (len >>> 8);
-            _buf[pos] = (byte) len;
-        }
-
-    }
 
 
 }

Modified: 
qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jms/Session.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jms/Session.java?rev=1238868&r1=1238867&r2=1238868&view=diff
==============================================================================
--- qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jms/Session.java 
(original)
+++ qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jms/Session.java 
Tue Jan 31 23:56:32 2012
@@ -26,9 +26,11 @@ import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.MessageConsumer;
 import javax.jms.MessageProducer;
+import javax.jms.QueueSession;
+import javax.jms.TopicSession;
 
 
-public interface Session extends javax.jms.Session
+public interface Session extends TopicSession, QueueSession
 {
     /**
      * Indicates that no client acknowledgements are required. Broker assumes 
that once it has delivered

Added: 
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/BytesDataOutput.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/BytesDataOutput.java?rev=1238868&view=auto
==============================================================================
--- 
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/BytesDataOutput.java
 (added)
+++ 
qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/util/BytesDataOutput.java
 Tue Jan 31 23:56:32 2012
@@ -0,0 +1,178 @@
+/*
+ *
+ * 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.util;
+
+import java.io.DataOutput;
+
+public class BytesDataOutput implements DataOutput
+{
+    private int _pos = 0;
+    private byte[] _buf;
+
+    public BytesDataOutput(byte[] buf)
+    {
+        _buf = buf;
+    }
+
+    public void setBuffer(byte[] buf)
+    {
+        _buf = buf;
+        _pos = 0;
+    }
+
+    public void reset()
+    {
+        _pos = 0;
+    }
+
+    public int length()
+    {
+        return _pos;
+    }
+
+    public void write(int b)
+    {
+        _buf[_pos++] = (byte) b;
+    }
+
+    public void write(byte[] b)
+    {
+        System.arraycopy(b, 0, _buf, _pos, b.length);
+        _pos+=b.length;
+    }
+
+
+    public void write(byte[] b, int off, int len)
+    {
+        System.arraycopy(b, off, _buf, _pos, len);
+        _pos+=len;
+
+    }
+
+    public void writeBoolean(boolean v)
+    {
+        _buf[_pos++] = v ? (byte) 1 : (byte) 0;
+    }
+
+    public void writeByte(int v)
+    {
+        _buf[_pos++] = (byte) v;
+    }
+
+    public void writeShort(int v)
+    {
+        _buf[_pos++] = (byte) (v >>> 8);
+        _buf[_pos++] = (byte) v;
+    }
+
+    public void writeChar(int v)
+    {
+        _buf[_pos++] = (byte) (v >>> 8);
+        _buf[_pos++] = (byte) v;
+    }
+
+    public void writeInt(int v)
+    {
+        _buf[_pos++] = (byte) (v >>> 24);
+        _buf[_pos++] = (byte) (v >>> 16);
+        _buf[_pos++] = (byte) (v >>> 8);
+        _buf[_pos++] = (byte) v;
+    }
+
+    public void writeLong(long v)
+    {
+        _buf[_pos++] = (byte) (v >>> 56);
+        _buf[_pos++] = (byte) (v >>> 48);
+        _buf[_pos++] = (byte) (v >>> 40);
+        _buf[_pos++] = (byte) (v >>> 32);
+        _buf[_pos++] = (byte) (v >>> 24);
+        _buf[_pos++] = (byte) (v >>> 16);
+        _buf[_pos++] = (byte) (v >>> 8);
+        _buf[_pos++] = (byte)v;
+    }
+
+    public void writeFloat(float v)
+    {
+        writeInt(Float.floatToIntBits(v));
+    }
+
+    public void writeDouble(double v)
+    {
+        writeLong(Double.doubleToLongBits(v));
+    }
+
+    public void writeBytes(String s)
+    {
+        int len = s.length();
+        for (int i = 0 ; i < len ; i++)
+        {
+            _buf[_pos++] = ((byte)s.charAt(i));
+        }
+    }
+
+    public void writeChars(String s)
+    {
+        int len = s.length();
+        for (int i = 0 ; i < len ; i++)
+        {
+            int v = s.charAt(i);
+            _buf[_pos++] = (byte) (v >>> 8);
+            _buf[_pos++] = (byte) v;
+        }
+    }
+
+    public void writeUTF(String s)
+    {
+        int strlen = s.length();
+
+        int pos = _pos;
+        _pos+=2;
+
+
+        for (int i = 0; i < strlen; i++)
+        {
+            int c = s.charAt(i);
+            if ((c >= 0x0001) && (c <= 0x007F))
+            {
+                c = s.charAt(i);
+                _buf[_pos++] = (byte) c;
+
+            }
+            else if (c > 0x07FF)
+            {
+                _buf[_pos++]  = (byte) (0xE0 | ((c >> 12) & 0x0F));
+                _buf[_pos++]  = (byte) (0x80 | ((c >>  6) & 0x3F));
+                _buf[_pos++]  = (byte) (0x80 | (c & 0x3F));
+            }
+            else
+            {
+                _buf[_pos++] = (byte) (0xC0 | ((c >>  6) & 0x1F));
+                _buf[_pos++]  = (byte) (0x80 | (c & 0x3F));
+            }
+        }
+
+        int len = _pos - (pos + 2);
+
+        _buf[pos++] = (byte) (len >>> 8);
+        _buf[pos] = (byte) len;
+    }
+
+}



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]

Reply via email to