summaryrefslogtreecommitdiff
path: root/qpid/java/common
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/java/common')
-rw-r--r--qpid/java/common/bin/qpid-run17
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/AMQException.java58
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyException.java10
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java8
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/framing/AMQFrameDecodingException.java20
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java2
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java4
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java2
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java261
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/framing/VersionSpecificRegistry.java24
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/pool/Event.java23
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/pool/PoolingFilter.java107
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/url/AMQBindingURL.java53
-rw-r--r--qpid/java/common/src/main/java/org/apache/qpid/url/URLHelper.java44
14 files changed, 312 insertions, 321 deletions
diff --git a/qpid/java/common/bin/qpid-run b/qpid/java/common/bin/qpid-run
index 6d7837c120..fe8fd0e9cc 100644
--- a/qpid/java/common/bin/qpid-run
+++ b/qpid/java/common/bin/qpid-run
@@ -106,15 +106,20 @@ usage() {
export EXTERNAL_CLASSPATH=$CLASSPATH
unset CLASSPATH
-conf=$QPID_HOME/etc/$program.conf
-if [ ! -e $conf ]; then
- conf=$QPID_HOME/etc/$(basename ${sourced}).conf
+#Use QPID_CLASSPATH if set
+if [ -n "$QPID_CLASSPATH" ]; then
+ export CLASSPATH=$QPID_CLASSPATH
+ echo "Using QPID_CLASSPATH" $QPID_CLASSPATH
+else
+ echo "Warning: Qpid classpath not set. CLASSPATH must include qpid jars."
fi
-if [ -r $conf ]; then
- . $conf
+#Use QPID_JAVA_MEM if set
+if [ -n "$QPID_JAVA_MEM" ]; then
+ export JAVA_MEM=$QPID_JAVA_MEM
+ echo "Using QPID_JAVA_MEM setting" $QPID_JAVA_MEM
else
- die "unable to source $conf"
+ echo "Info: QPID_JAVA_MEM not set. Defaulting to JAVA_MEM" $JAVA_MEM
fi
declare -a RUN_ARGS JAVA_ARGS
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java b/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java
index 0222fd9b4e..3e93243a1d 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/AMQException.java
@@ -23,11 +23,41 @@ package org.apache.qpid;
import org.apache.log4j.Logger;
import org.apache.qpid.protocol.AMQConstant;
-/** Generic AMQ exception. */
+/**
+ * AMQException forms the root exception of all exceptions relating to the AMQ protocol. It provides space to associate
+ * an AMQ error code with the exception, which is a numberic value, with a meaning defined by the protocol.
+ *
+ * <p/><table id="crc"><caption>CRC Card</caption>
+ * <tr><th> Responsibilities <th> Collaborations
+ * <tr><td> Represents an exception condition associated with an AMQ protocol error code.
+ * </table>
+ *
+ * @todo This exception class is also used as a generic exception throughout Qpid code. This usage may not be strictly
+ * correct if this is to signify a protocol exception. Should review.
+ */
public class AMQException extends Exception
{
+ /** Holds the AMQ error code constant associated with this exception. */
private AMQConstant _errorCode;
+ /**
+ * Creates an exception with an optional error code, optional message and optional underlying cause.
+ *
+ * @param errorCode The error code. May be null if not to be set.
+ * @param msg The exception message. May be null if not to be set.
+ * @param t The underlying cause of the exception. May be null if not to be set.
+ */
+ public AMQException(AMQConstant errorCode, String msg, Throwable t)
+ {
+ super(((msg == null) ? "" : msg) + ((errorCode == null) ? "" : (" [error code " + errorCode + "]")), t);
+ _errorCode = errorCode;
+ }
+
+ /**
+ * @param message
+ *
+ * @deprecated Use {@link #AMQException(org.apache.qpid.protocol.AMQConstant, String, Throwable)} instead.
+ */
public AMQException(String message)
{
super(message);
@@ -35,6 +65,12 @@ public class AMQException extends Exception
_errorCode = AMQConstant.getConstant(-1);
}
+ /**
+ * @param msg
+ * @param t
+ *
+ * @deprecated Use {@link #AMQException(org.apache.qpid.protocol.AMQConstant, String, Throwable)} instead.
+ */
public AMQException(String msg, Throwable t)
{
super(msg, t);
@@ -42,18 +78,19 @@ public class AMQException extends Exception
_errorCode = AMQConstant.getConstant(-1);
}
- public AMQException(AMQConstant errorCode, String msg, Throwable t)
- {
- super(msg + " [error code " + errorCode + ']', t);
- _errorCode = errorCode;
- }
-
+ /**
+ * @param errorCode
+ * @param msg
+ *
+ * @deprecated Use {@link #AMQException(org.apache.qpid.protocol.AMQConstant, String, Throwable)} instead.
+ */
public AMQException(AMQConstant errorCode, String msg)
{
super(msg + " [error code " + errorCode + ']');
_errorCode = errorCode;
}
+ /*
public AMQException(Logger logger, String msg, Throwable t)
{
this(msg, t);
@@ -71,10 +108,15 @@ public class AMQException extends Exception
this(errorCode, msg);
logger.error(getMessage(), this);
}
+ */
+ /**
+ * Gets the AMQ protocol exception code associated with this exception.
+ *
+ * @return The AMQ protocol exception code associated with this exception.
+ */
public AMQConstant getErrorCode()
{
return _errorCode;
}
-
}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyException.java b/qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyException.java
index 958f59191f..7c85a08e11 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyException.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/configuration/PropertyException.java
@@ -1,3 +1,4 @@
+/* Copyright Rupert Smith, 2005 to 2006, all rights reserved. */
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -7,9 +8,9 @@
* 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
@@ -21,6 +22,7 @@
package org.apache.qpid.configuration;
import org.apache.log4j.Logger;
+
import org.apache.qpid.AMQException;
import org.apache.qpid.protocol.AMQConstant;
@@ -49,7 +51,7 @@ public class PropertyException extends AMQException
super(errorCode, msg);
}
- public PropertyException(Logger logger, String msg, Throwable t)
+ /*public PropertyException(Logger logger, String msg, Throwable t)
{
super(logger, msg, t);
}
@@ -62,5 +64,5 @@ public class PropertyException extends AMQException
public PropertyException(Logger logger, AMQConstant errorCode, String msg)
{
super(logger, errorCode, msg);
- }
+ }*/
}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java
index 43f888c029..9f36448986 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQDataBlockDecoder.java
@@ -94,7 +94,7 @@ public class AMQDataBlockDecoder
if(bodyFactory == null)
{
- throw new AMQFrameDecodingException("Unsupported frame type: " + type);
+ throw new AMQFrameDecodingException(null, "Unsupported frame type: " + type, null);
}
final int channel = in.getUnsignedShort();
@@ -103,8 +103,8 @@ public class AMQDataBlockDecoder
// bodySize can be zero
if (channel < 0 || bodySize < 0)
{
- throw new AMQFrameDecodingException("Undecodable frame: type = " + type + " channel = " + channel +
- " bodySize = " + bodySize);
+ throw new AMQFrameDecodingException(null, "Undecodable frame: type = " + type + " channel = " + channel +
+ " bodySize = " + bodySize, null);
}
AMQFrame frame = new AMQFrame(in, channel, bodySize, bodyFactory);
@@ -113,7 +113,7 @@ public class AMQDataBlockDecoder
byte marker = in.get();
if ((marker & 0xFF) != 0xCE)
{
- throw new AMQFrameDecodingException("End of frame marker not found. Read " + marker + " length=" + bodySize + " type=" + type);
+ throw new AMQFrameDecodingException(null, "End of frame marker not found. Read " + marker + " length=" + bodySize + " type=" + type, null);
}
return frame;
}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQFrameDecodingException.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQFrameDecodingException.java
index a24bd6aaa9..c462dec2a3 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQFrameDecodingException.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQFrameDecodingException.java
@@ -1,3 +1,4 @@
+/* Copyright Rupert Smith, 2005 to 2006, all rights reserved. */
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
@@ -7,9 +8,9 @@
* 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
@@ -21,21 +22,23 @@
package org.apache.qpid.framing;
import org.apache.log4j.Logger;
+
import org.apache.qpid.AMQException;
+import org.apache.qpid.protocol.AMQConstant;
public class AMQFrameDecodingException extends AMQException
{
- public AMQFrameDecodingException(String message)
+ /*public AMQFrameDecodingException(String message)
{
super(message);
- }
+ }*/
- public AMQFrameDecodingException(String message, Throwable t)
+ public AMQFrameDecodingException(AMQConstant errorCode, String message, Throwable t)
{
- super(message, t);
+ super(errorCode, message, t);
}
- public AMQFrameDecodingException(Logger log, String message)
+ /*public AMQFrameDecodingException(Logger log, String message)
{
super(log, message);
}
@@ -43,6 +46,5 @@ public class AMQFrameDecodingException extends AMQException
public AMQFrameDecodingException(Logger log, String message, Throwable t)
{
super(log, message, t);
- }
-
+ }*/
}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java
index f51296dafc..f2492585bc 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/AMQShortString.java
@@ -9,7 +9,7 @@ import org.apache.mina.common.ByteBuffer;
* and thus can be held more effectively in a byte buffer.
*
*/
-public final class AMQShortString implements CharSequence
+public final class AMQShortString implements CharSequence, Comparable<AMQShortString>
{
private static final Logger _logger = Logger.getLogger(AMQShortString.class);
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java
index 8b784fa3f7..008afb490e 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/BasicContentHeaderProperties.java
@@ -341,7 +341,7 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti
}
catch (AMQFrameDecodingException e)
{
- throw new RuntimeException("Error in content header data: " + e);
+ throw new RuntimeException("Error in content header data: " + e, e);
}
final int endPos = buffer.position();
@@ -381,7 +381,7 @@ public class BasicContentHeaderProperties implements CommonContentHeaderProperti
}
catch (AMQFrameDecodingException e)
{
- throw new RuntimeException("Error in content header data: " + e);
+ throw new RuntimeException("Error in content header data: " + e, e);
}
}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java
index 7dac018872..712eb437db 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/ContentHeaderPropertiesFactory.java
@@ -49,7 +49,7 @@ public class ContentHeaderPropertiesFactory
}
else
{
- throw new AMQFrameDecodingException("Unsupport content header class id: " + classId);
+ throw new AMQFrameDecodingException(null, "Unsupport content header class id: " + classId, null);
}
properties.populatePropertiesFromBuffer(buffer, propertyFlags, size);
return properties;
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java
index f94cd4934c..f0cdda487c 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/EncodingUtils.java
@@ -7,9 +7,9 @@
* 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
@@ -23,6 +23,7 @@ package org.apache.qpid.framing;
import java.nio.charset.Charset;
import org.apache.log4j.Logger;
+
import org.apache.mina.common.ByteBuffer;
public class EncodingUtils
@@ -49,96 +50,95 @@ public class EncodingUtils
}
}
-
public static int encodedShortStringLength(short s)
{
- if( s == 0 )
+ if (s == 0)
{
return 1 + 1;
}
int len = 0;
- if(s < 0)
+ if (s < 0)
{
- len=1;
+ len = 1;
// sloppy - doesn't work of Integer.MIN_VALUE
- s=(short)-s;
+ s = (short) -s;
}
- if(s>9999)
+ if (s > 9999)
{
- return 1+5;
+ return 1 + 5;
}
- else if(s>999)
+ else if (s > 999)
{
- return 1+4;
+ return 1 + 4;
}
- else if(s>99)
+ else if (s > 99)
{
- return 1+3;
+ return 1 + 3;
}
- else if(s>9)
+ else if (s > 9)
{
- return 1+2;
+ return 1 + 2;
}
else
{
- return 1+1;
+ return 1 + 1;
}
}
-
public static int encodedShortStringLength(int i)
{
- if( i == 0 )
+ if (i == 0)
{
return 1 + 1;
}
int len = 0;
- if(i < 0)
+ if (i < 0)
{
- len=1;
+ len = 1;
// sloppy - doesn't work of Integer.MIN_VALUE
- i=-i;
+ i = -i;
}
// range is now 1 - 2147483647
- if(i < Short.MAX_VALUE)
+ if (i < Short.MAX_VALUE)
{
- return len + encodedShortStringLength((short)i);
+ return len + encodedShortStringLength((short) i);
}
else if (i > 999999)
{
- return len + 6 + encodedShortStringLength((short)(i/1000000));
+ return len + 6 + encodedShortStringLength((short) (i / 1000000));
}
else // if (i > 99999)
{
- return len + 5 + encodedShortStringLength((short)(i/100000));
+ return len + 5 + encodedShortStringLength((short) (i / 100000));
}
}
public static int encodedShortStringLength(long l)
{
- if(l == 0)
+ if (l == 0)
{
return 1 + 1;
}
int len = 0;
- if(l < 0)
+ if (l < 0)
{
- len=1;
+ len = 1;
// sloppy - doesn't work of Long.MIN_VALUE
- l=-l;
+ l = -l;
}
- if(l < Integer.MAX_VALUE)
+
+ if (l < Integer.MAX_VALUE)
{
return len + encodedShortStringLength((int) l);
}
- else if(l > 9999999999L)
+ else if (l > 9999999999L)
{
return len + 10 + encodedShortStringLength((int) (l / 10000000000L));
}
@@ -149,7 +149,6 @@ public class EncodingUtils
}
-
public static int encodedShortStringLength(AMQShortString s)
{
if (s == null)
@@ -162,7 +161,6 @@ public class EncodingUtils
}
}
-
public static int encodedLongStringLength(String s)
{
if (s == null)
@@ -219,7 +217,6 @@ public class EncodingUtils
return 0;
}
-
public static void writeShortStringBytes(ByteBuffer buffer, String s)
{
if (s != null)
@@ -230,6 +227,7 @@ public class EncodingUtils
{
encodedString[i] = (byte) cha[i];
}
+
writeBytes(buffer, encodedString);
}
else
@@ -239,7 +237,6 @@ public class EncodingUtils
}
}
-
public static void writeShortStringBytes(ByteBuffer buffer, AMQShortString s)
{
if (s != null)
@@ -256,7 +253,7 @@ public class EncodingUtils
public static void writeLongStringBytes(ByteBuffer buffer, String s)
{
- assert s == null || s.length() <= 0xFFFE;
+ assert (s == null) || (s.length() <= 0xFFFE);
if (s != null)
{
int len = s.length();
@@ -267,6 +264,7 @@ public class EncodingUtils
{
encodedString[i] = (byte) cha[i];
}
+
buffer.put(encodedString);
}
else
@@ -277,7 +275,7 @@ public class EncodingUtils
public static void writeLongStringBytes(ByteBuffer buffer, char[] s)
{
- assert s == null || s.length <= 0xFFFE;
+ assert (s == null) || (s.length <= 0xFFFE);
if (s != null)
{
int len = s.length;
@@ -287,6 +285,7 @@ public class EncodingUtils
{
encodedString[i] = (byte) s[i];
}
+
buffer.put(encodedString);
}
else
@@ -297,7 +296,7 @@ public class EncodingUtils
public static void writeLongStringBytes(ByteBuffer buffer, byte[] bytes)
{
- assert bytes == null || bytes.length <= 0xFFFE;
+ assert (bytes == null) || (bytes.length <= 0xFFFE);
if (bytes != null)
{
writeUnsignedInteger(buffer, bytes.length);
@@ -330,7 +329,6 @@ public class EncodingUtils
}
}
-
public static int unsignedIntegerLength()
{
return 4;
@@ -356,7 +354,6 @@ public class EncodingUtils
}
}
-
public static void writeFieldTableBytes(ByteBuffer buffer, FieldTable table)
{
if (table != null)
@@ -400,10 +397,9 @@ public class EncodingUtils
if (value1)
{
- packedValue = (byte) (packedValue | (byte)(1 << 1));
+ packedValue = (byte) (packedValue | (byte) (1 << 1));
}
-
buffer.put(packedValue);
}
@@ -413,213 +409,181 @@ public class EncodingUtils
if (value1)
{
- packedValue = (byte) (packedValue | (byte)(1 << 1));
+ packedValue = (byte) (packedValue | (byte) (1 << 1));
}
if (value2)
{
- packedValue = (byte) (packedValue | (byte)(1 << 2));
+ packedValue = (byte) (packedValue | (byte) (1 << 2));
}
-
buffer.put(packedValue);
}
-
-
- public static void writeBooleans(ByteBuffer buffer,
- boolean value0,
- boolean value1,
- boolean value2,
- boolean value3)
+ public static void writeBooleans(ByteBuffer buffer, boolean value0, boolean value1, boolean value2, boolean value3)
{
byte packedValue = value0 ? (byte) 1 : (byte) 0;
if (value1)
{
- packedValue = (byte) (packedValue | (byte)(1 << 1));
+ packedValue = (byte) (packedValue | (byte) (1 << 1));
}
if (value2)
{
- packedValue = (byte) (packedValue | (byte)(1 << 2));
+ packedValue = (byte) (packedValue | (byte) (1 << 2));
}
if (value3)
{
- packedValue = (byte) (packedValue | (byte)(1 << 3));
+ packedValue = (byte) (packedValue | (byte) (1 << 3));
}
buffer.put(packedValue);
}
- public static void writeBooleans(ByteBuffer buffer,
- boolean value0,
- boolean value1,
- boolean value2,
- boolean value3,
- boolean value4)
+ public static void writeBooleans(ByteBuffer buffer, boolean value0, boolean value1, boolean value2, boolean value3,
+ boolean value4)
{
byte packedValue = value0 ? (byte) 1 : (byte) 0;
if (value1)
{
- packedValue = (byte) (packedValue | (byte)(1 << 1));
+ packedValue = (byte) (packedValue | (byte) (1 << 1));
}
if (value2)
{
- packedValue = (byte) (packedValue | (byte)(1 << 2));
+ packedValue = (byte) (packedValue | (byte) (1 << 2));
}
if (value3)
{
- packedValue = (byte) (packedValue | (byte)(1 << 3));
+ packedValue = (byte) (packedValue | (byte) (1 << 3));
}
if (value4)
{
- packedValue = (byte) (packedValue | (byte)(1 << 4));
+ packedValue = (byte) (packedValue | (byte) (1 << 4));
}
buffer.put(packedValue);
}
- public static void writeBooleans(ByteBuffer buffer,
- boolean value0,
- boolean value1,
- boolean value2,
- boolean value3,
- boolean value4,
- boolean value5)
+ public static void writeBooleans(ByteBuffer buffer, boolean value0, boolean value1, boolean value2, boolean value3,
+ boolean value4, boolean value5)
{
byte packedValue = value0 ? (byte) 1 : (byte) 0;
if (value1)
{
- packedValue = (byte) (packedValue | (byte)(1 << 1));
+ packedValue = (byte) (packedValue | (byte) (1 << 1));
}
if (value2)
{
- packedValue = (byte) (packedValue | (byte)(1 << 2));
+ packedValue = (byte) (packedValue | (byte) (1 << 2));
}
if (value3)
{
- packedValue = (byte) (packedValue | (byte)(1 << 3));
+ packedValue = (byte) (packedValue | (byte) (1 << 3));
}
if (value4)
{
- packedValue = (byte) (packedValue | (byte)(1 << 4));
+ packedValue = (byte) (packedValue | (byte) (1 << 4));
}
if (value5)
{
- packedValue = (byte) (packedValue | (byte)(1 << 5));
+ packedValue = (byte) (packedValue | (byte) (1 << 5));
}
buffer.put(packedValue);
}
- public static void writeBooleans(ByteBuffer buffer,
- boolean value0,
- boolean value1,
- boolean value2,
- boolean value3,
- boolean value4,
- boolean value5,
- boolean value6)
+ public static void writeBooleans(ByteBuffer buffer, boolean value0, boolean value1, boolean value2, boolean value3,
+ boolean value4, boolean value5, boolean value6)
{
byte packedValue = value0 ? (byte) 1 : (byte) 0;
if (value1)
{
- packedValue = (byte) (packedValue | (byte)(1 << 1));
+ packedValue = (byte) (packedValue | (byte) (1 << 1));
}
if (value2)
{
- packedValue = (byte) (packedValue | (byte)(1 << 2));
+ packedValue = (byte) (packedValue | (byte) (1 << 2));
}
if (value3)
{
- packedValue = (byte) (packedValue | (byte)(1 << 3));
+ packedValue = (byte) (packedValue | (byte) (1 << 3));
}
if (value4)
{
- packedValue = (byte) (packedValue | (byte)(1 << 4));
+ packedValue = (byte) (packedValue | (byte) (1 << 4));
}
if (value5)
{
- packedValue = (byte) (packedValue | (byte)(1 << 5));
+ packedValue = (byte) (packedValue | (byte) (1 << 5));
}
if (value6)
{
- packedValue = (byte) (packedValue | (byte)(1 << 6));
+ packedValue = (byte) (packedValue | (byte) (1 << 6));
}
buffer.put(packedValue);
}
- public static void writeBooleans(ByteBuffer buffer,
- boolean value0,
- boolean value1,
- boolean value2,
- boolean value3,
- boolean value4,
- boolean value5,
- boolean value6,
- boolean value7)
+ public static void writeBooleans(ByteBuffer buffer, boolean value0, boolean value1, boolean value2, boolean value3,
+ boolean value4, boolean value5, boolean value6, boolean value7)
{
byte packedValue = value0 ? (byte) 1 : (byte) 0;
if (value1)
{
- packedValue = (byte) (packedValue | (byte)(1 << 1));
+ packedValue = (byte) (packedValue | (byte) (1 << 1));
}
if (value2)
{
- packedValue = (byte) (packedValue | (byte)(1 << 2));
+ packedValue = (byte) (packedValue | (byte) (1 << 2));
}
if (value3)
{
- packedValue = (byte) (packedValue | (byte)(1 << 3));
+ packedValue = (byte) (packedValue | (byte) (1 << 3));
}
if (value4)
{
- packedValue = (byte) (packedValue | (byte)(1 << 4));
+ packedValue = (byte) (packedValue | (byte) (1 << 4));
}
if (value5)
{
- packedValue = (byte) (packedValue | (byte)(1 << 5));
+ packedValue = (byte) (packedValue | (byte) (1 << 5));
}
if (value6)
{
- packedValue = (byte) (packedValue | (byte)(1 << 6));
+ packedValue = (byte) (packedValue | (byte) (1 << 6));
}
if (value7)
{
- packedValue = (byte) (packedValue | (byte)(1 << 7));
+ packedValue = (byte) (packedValue | (byte) (1 << 7));
}
buffer.put(packedValue);
}
-
-
-
/**
* This is used for writing longstrs.
*
@@ -647,26 +611,27 @@ public class EncodingUtils
public static boolean[] readBooleans(ByteBuffer buffer)
{
final byte packedValue = buffer.get();
- if(packedValue == 0)
+ if (packedValue == 0)
{
return ALL_FALSE_ARRAY;
}
+
final boolean[] result = new boolean[8];
result[0] = ((packedValue & 1) != 0);
result[1] = ((packedValue & (1 << 1)) != 0);
result[2] = ((packedValue & (1 << 2)) != 0);
result[3] = ((packedValue & (1 << 3)) != 0);
- if((packedValue & 0xF0) == 0)
+ if ((packedValue & 0xF0) == 0)
{
result[0] = ((packedValue & 1) != 0);
}
+
result[4] = ((packedValue & (1 << 4)) != 0);
result[5] = ((packedValue & (1 << 5)) != 0);
result[6] = ((packedValue & (1 << 6)) != 0);
result[7] = ((packedValue & (1 << 7)) != 0);
-
return result;
}
@@ -742,6 +707,7 @@ public class EncodingUtils
{
stringChars[i] = (char) stringBytes[i];
}
+
return new String(stringChars);
}
}
@@ -757,6 +723,7 @@ public class EncodingUtils
{
byte[] result = new byte[(int) length];
buffer.get(result);
+
return result;
}
}
@@ -764,15 +731,14 @@ public class EncodingUtils
public static long readTimestamp(ByteBuffer buffer)
{
// Discard msb from AMQ timestamp
- //buffer.getUnsignedInt();
+ // buffer.getUnsignedInt();
return buffer.getLong();
}
-
static byte[] hexToByteArray(String id)
{
// Should check param for null, long enough for this check, upper-case and trailing char
- String s = (id.charAt(1) == 'x') ? id.substring(2) : id; // strip 0x
+ String s = (id.charAt(1) == 'x') ? id.substring(2) : id; // strip 0x
int len = s.length();
int byte_len = len / 2;
@@ -786,7 +752,7 @@ public class EncodingUtils
byte b1 = Byte.parseByte(s.substring(ch, ch + 1), 16);
byte b2 = Byte.parseByte(s.substring(ch + 1, ch + 2), 16);
- b[i] = (byte) (b1 * 16 + b2);
+ b[i] = (byte) ((b1 * 16) + b2);
}
return (b);
@@ -795,7 +761,7 @@ public class EncodingUtils
public static char[] convertToHexCharArray(byte[] from)
{
int length = from.length;
- char[] result_buff = new char[length * 2 + 2];
+ char[] result_buff = new char[(length * 2) + 2];
result_buff[0] = '0';
result_buff[1] = 'x';
@@ -831,7 +797,7 @@ public class EncodingUtils
byte[] from = new byte[size];
// Is this not the same.
- //bb.get(from, 0, length);
+ // bb.get(from, 0, length);
for (int i = 0; i < size; i++)
{
from[i] = bb.get(i);
@@ -840,9 +806,9 @@ public class EncodingUtils
return (new String(convertToHexCharArray(from)));
}
- private static char hex_chars[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
+ private static char[] hex_chars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
- //**** new methods
+ // **** new methods
// AMQP_BOOLEAN_PROPERTY_PREFIX
@@ -854,6 +820,7 @@ public class EncodingUtils
public static boolean readBoolean(ByteBuffer buffer)
{
byte packedValue = buffer.get();
+
return (packedValue == 1);
}
@@ -878,7 +845,6 @@ public class EncodingUtils
return 1;
}
-
// AMQP_SHORT_PROPERTY_PREFIX
public static void writeShort(ByteBuffer buffer, Short aShort)
{
@@ -943,7 +909,6 @@ public class EncodingUtils
return 4;
}
-
// Double_PROPERTY_PREFIX
public static void writeDouble(ByteBuffer buffer, Double aDouble)
{
@@ -960,7 +925,6 @@ public class EncodingUtils
return 8;
}
-
public static byte[] readBytes(ByteBuffer buffer)
{
short length = buffer.getUnsigned();
@@ -981,7 +945,7 @@ public class EncodingUtils
{
if (data != null)
{
- // TODO: check length fits in an unsigned byte
+ // TODO: check length fits in an unsigned byte
writeUnsignedByte(buffer, (short) data.length);
buffer.put(data);
}
@@ -992,7 +956,7 @@ public class EncodingUtils
}
}
- //CHAR_PROPERTY
+ // CHAR_PROPERTY
public static int encodedCharLength()
{
return encodedByteLength();
@@ -1000,31 +964,29 @@ public class EncodingUtils
public static char readChar(ByteBuffer buffer)
{
- //This is valid as we know that the Character is ASCII 0..127
+ // This is valid as we know that the Character is ASCII 0..127
return (char) buffer.get();
}
public static void writeChar(ByteBuffer buffer, char character)
{
- //This is valid as we know that the Character is ASCII 0..127
+ // This is valid as we know that the Character is ASCII 0..127
writeByte(buffer, (byte) character);
}
-
-
-
public static long readLongAsShortString(ByteBuffer buffer)
{
short length = buffer.getUnsigned();
short pos = 0;
- if(length == 0)
+ if (length == 0)
{
return 0L;
}
+
byte digit = buffer.get();
boolean isNegative;
long result = 0;
- if(digit == (byte)'-')
+ if (digit == (byte) '-')
{
isNegative = true;
pos++;
@@ -1034,15 +996,16 @@ public class EncodingUtils
{
isNegative = false;
}
- result = digit - (byte)'0';
+
+ result = digit - (byte) '0';
pos++;
- while(pos < length)
+ while (pos < length)
{
pos++;
digit = buffer.get();
result = (result << 3) + (result << 1);
- result += digit - (byte)'0';
+ result += digit - (byte) '0';
}
return result;
@@ -1051,33 +1014,13 @@ public class EncodingUtils
public static long readUnsignedInteger(ByteBuffer buffer)
{
long l = 0xFF & buffer.get();
- l <<=8;
+ l <<= 8;
l = l | (0xFF & buffer.get());
- l <<=8;
+ l <<= 8;
l = l | (0xFF & buffer.get());
- l <<=8;
+ l <<= 8;
l = l | (0xFF & buffer.get());
return l;
}
-
-
- public static void main(String[] args)
- {
- ByteBuffer buf = ByteBuffer.allocate(8);
- buf.setAutoExpand(true);
-
- long l = (long) Integer.MAX_VALUE;
- l += 1024L;
-
- writeUnsignedInteger(buf, l);
-
- buf.flip();
-
- long l2 = readUnsignedInteger(buf);
-
- System.out.println("before: " + l);
- System.out.println("after: " + l2);
- }
-
}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/framing/VersionSpecificRegistry.java b/qpid/java/common/src/main/java/org/apache/qpid/framing/VersionSpecificRegistry.java
index ec371453aa..faa7cc1e82 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/framing/VersionSpecificRegistry.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/framing/VersionSpecificRegistry.java
@@ -148,34 +148,30 @@ public class VersionSpecificRegistry
}
catch(NullPointerException e)
{
- throw new AMQFrameDecodingException(_log,
- "Class " + classID + " unknown in AMQP version " + _protocolMajorVersion + "-" + _protocolMinorVersion
- + " (while trying to decode class " + classID + " method " + methodID + ".");
+ throw new AMQFrameDecodingException(null, "Class " + classID + " unknown in AMQP version " + _protocolMajorVersion
+ + "-" + _protocolMinorVersion + " (while trying to decode class " + classID + " method " + methodID + ".", e);
}
catch(IndexOutOfBoundsException e)
{
if(classID >= _registry.length)
{
- throw new AMQFrameDecodingException(_log,
- "Class " + classID + " unknown in AMQP version " + _protocolMajorVersion + "-" + _protocolMinorVersion
- + " (while trying to decode class " + classID + " method " + methodID + ".");
-
+ throw new AMQFrameDecodingException(null, "Class " + classID + " unknown in AMQP version " + _protocolMajorVersion
+ + "-" + _protocolMinorVersion + " (while trying to decode class " + classID + " method " + methodID
+ + ".", e);
}
else
{
- throw new AMQFrameDecodingException(_log,
- "Method " + methodID + " unknown in AMQP version " + _protocolMajorVersion + "-" + _protocolMinorVersion
- + " (while trying to decode class " + classID + " method " + methodID + ".");
-
+ throw new AMQFrameDecodingException(null, "Method " + methodID + " unknown in AMQP version "
+ + _protocolMajorVersion + "-" + _protocolMinorVersion + " (while trying to decode class " + classID
+ + " method " + methodID + ".", e);
}
}
if (bodyFactory == null)
{
- throw new AMQFrameDecodingException(_log,
- "Method " + methodID + " unknown in AMQP version " + _protocolMajorVersion + "-" + _protocolMinorVersion
- + " (while trying to decode class " + classID + " method " + methodID + ".");
+ throw new AMQFrameDecodingException(null, "Method " + methodID + " unknown in AMQP version " + _protocolMajorVersion
+ + "-" + _protocolMinorVersion + " (while trying to decode class " + classID + " method " + methodID + ".", null);
}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/pool/Event.java b/qpid/java/common/src/main/java/org/apache/qpid/pool/Event.java
index 09890a103d..7300ec8c3f 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/pool/Event.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/pool/Event.java
@@ -85,4 +85,27 @@ abstract public class Event
}
+
+ public static final class CloseEvent extends Event
+ {
+ private final IoFilter.NextFilter _nextFilter;
+
+ public CloseEvent(final IoFilter.NextFilter nextFilter)
+ {
+ super();
+ _nextFilter = nextFilter;
+ }
+
+
+ public void process(IoSession session)
+ {
+ _nextFilter.sessionClosed(session);
+ }
+
+ public IoFilter.NextFilter getNextFilter()
+ {
+ return _nextFilter;
+ }
+ }
+
}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/pool/PoolingFilter.java b/qpid/java/common/src/main/java/org/apache/qpid/pool/PoolingFilter.java
index 8126ca4bc8..c9c96925cb 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/pool/PoolingFilter.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/pool/PoolingFilter.java
@@ -7,9 +7,9 @@
* 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
@@ -24,10 +24,13 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import org.apache.log4j.Logger;
+
import org.apache.mina.common.IdleStatus;
import org.apache.mina.common.IoFilterAdapter;
import org.apache.mina.common.IoSession;
+import org.apache.qpid.pool.Event.CloseEvent;
+
public class PoolingFilter extends IoFilterAdapter implements Job.JobCompletionHandler
{
private static final Logger _logger = Logger.getLogger(PoolingFilter.class);
@@ -47,12 +50,12 @@ public class PoolingFilter extends IoFilterAdapter implements Job.JobCompletionH
void fireAsynchEvent(IoSession session, Event event)
{
Job job = getJobForSession(session);
- // job.acquire(); //prevents this job being removed from _jobs
+ // job.acquire(); //prevents this job being removed from _jobs
job.add(event);
- //Additional checks on pool to check that it hasn't shutdown.
+ // Additional checks on pool to check that it hasn't shutdown.
// The alternative is to catch the RejectedExecutionException that will result from executing on a shutdown pool
- if (job.activate() && _poolReference.getPool() != null && !_poolReference.getPool().isShutdown())
+ if (job.activate() && (_poolReference.getPool() != null) && !_poolReference.getPool().isShutdown())
{
_poolReference.getPool().execute(job);
}
@@ -68,16 +71,6 @@ public class PoolingFilter extends IoFilterAdapter implements Job.JobCompletionH
private Job getJobForSession(IoSession session)
{
return (Job) session.getAttribute(_name);
-
-/* if(job == null)
- {
- System.err.println("Error in " + _name);
- Thread.dumpStack();
- }
-
-
- job = _jobs.get(session);
- return job == null ? createJobForSession(session) : job;*/
}
private Job createJobForSession(IoSession session)
@@ -87,35 +80,36 @@ public class PoolingFilter extends IoFilterAdapter implements Job.JobCompletionH
private Job addJobForSession(IoSession session, Job job)
{
- //atomic so ensures all threads agree on the same job
+ // atomic so ensures all threads agree on the same job
Job existing = _jobs.putIfAbsent(session, job);
- return existing == null ? job : existing;
+
+ return (existing == null) ? job : existing;
}
- //Job.JobCompletionHandler
+ // Job.JobCompletionHandler
public void completed(IoSession session, Job job)
{
-// if (job.isComplete())
-// {
-// job.release();
-// if (!job.isReferenced())
-// {
-// _jobs.remove(session);
-// }
-// }
-// else
- if(!job.isComplete())
+ // if (job.isComplete())
+ // {
+ // job.release();
+ // if (!job.isReferenced())
+ // {
+ // _jobs.remove(session);
+ // }
+ // }
+ // else
+ if (!job.isComplete())
{
// ritchiem : 2006-12-13 Do we need to perform the additional checks here?
- // Can the pool be shutdown at this point?
- if (job.activate() && _poolReference.getPool() != null && !_poolReference.getPool().isShutdown())
+ // Can the pool be shutdown at this point?
+ if (job.activate() && (_poolReference.getPool() != null) && !_poolReference.getPool().isShutdown())
{
_poolReference.getPool().execute(job);
}
}
}
- //IoFilter methods that are processed by threads on the pool
+ // IoFilter methods that are processed by threads on the pool
public void sessionOpened(final NextFilter nextFilter, final IoSession session) throws Exception
{
@@ -127,37 +121,33 @@ public class PoolingFilter extends IoFilterAdapter implements Job.JobCompletionH
nextFilter.sessionClosed(session);
}
- public void sessionIdle(final NextFilter nextFilter, final IoSession session,
- final IdleStatus status) throws Exception
+ public void sessionIdle(final NextFilter nextFilter, final IoSession session, final IdleStatus status) throws Exception
{
nextFilter.sessionIdle(session, status);
}
- public void exceptionCaught(final NextFilter nextFilter, final IoSession session,
- final Throwable cause) throws Exception
+ public void exceptionCaught(final NextFilter nextFilter, final IoSession session, final Throwable cause) throws Exception
{
- nextFilter.exceptionCaught(session,cause);
+ nextFilter.exceptionCaught(session, cause);
}
- public void messageReceived(final NextFilter nextFilter, final IoSession session,
- final Object message) throws Exception
+ public void messageReceived(final NextFilter nextFilter, final IoSession session, final Object message) throws Exception
{
- nextFilter.messageReceived(session,message);
+ nextFilter.messageReceived(session, message);
}
- public void messageSent(final NextFilter nextFilter, final IoSession session,
- final Object message) throws Exception
+ public void messageSent(final NextFilter nextFilter, final IoSession session, final Object message) throws Exception
{
nextFilter.messageSent(session, message);
}
- public void filterWrite(final NextFilter nextFilter, final IoSession session,
- final WriteRequest writeRequest) throws Exception
+ public void filterWrite(final NextFilter nextFilter, final IoSession session, final WriteRequest writeRequest)
+ throws Exception
{
nextFilter.filterWrite(session, writeRequest);
}
- //IoFilter methods that are processed on current thread (NOT on pooled thread)
+ // IoFilter methods that are processed on current thread (NOT on pooled thread)
public void filterClose(NextFilter nextFilter, IoSession session) throws Exception
{
@@ -199,13 +189,17 @@ public class PoolingFilter extends IoFilterAdapter implements Job.JobCompletionH
super(refCountingPool, name);
}
- public void messageReceived(final NextFilter nextFilter, final IoSession session,
- final Object message) throws Exception
+ public void messageReceived(final NextFilter nextFilter, final IoSession session, final Object message)
+ throws Exception
{
fireAsynchEvent(session, new Event.ReceivedEvent(nextFilter, message));
}
+ public void sessionClosed(final NextFilter nextFilter, final IoSession session) throws Exception
+ {
+ fireAsynchEvent(session, new CloseEvent(nextFilter));
+ }
}
@@ -217,26 +211,27 @@ public class PoolingFilter extends IoFilterAdapter implements Job.JobCompletionH
super(refCountingPool, name);
}
-
- public void filterWrite(final NextFilter nextFilter, final IoSession session,
- final WriteRequest writeRequest) throws Exception
+ public void filterWrite(final NextFilter nextFilter, final IoSession session, final WriteRequest writeRequest)
+ throws Exception
{
fireAsynchEvent(session, new Event.WriteEvent(nextFilter, writeRequest));
}
+ public void sessionClosed(final NextFilter nextFilter, final IoSession session) throws Exception
+ {
+ fireAsynchEvent(session, new CloseEvent(nextFilter));
+ }
+
}
- public static PoolingFilter createAynschReadPoolingFilter(ReferenceCountingExecutorService refCountingPool,String name)
+ public static PoolingFilter createAynschReadPoolingFilter(ReferenceCountingExecutorService refCountingPool, String name)
{
- return new AsynchReadPoolingFilter(refCountingPool,name);
+ return new AsynchReadPoolingFilter(refCountingPool, name);
}
-
- public static PoolingFilter createAynschWritePoolingFilter(ReferenceCountingExecutorService refCountingPool,String name)
+ public static PoolingFilter createAynschWritePoolingFilter(ReferenceCountingExecutorService refCountingPool, String name)
{
- return new AsynchWritePoolingFilter(refCountingPool,name);
+ return new AsynchWritePoolingFilter(refCountingPool, name);
}
}
-
-
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/url/AMQBindingURL.java b/qpid/java/common/src/main/java/org/apache/qpid/url/AMQBindingURL.java
index f558523864..353c0d39c2 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/url/AMQBindingURL.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/url/AMQBindingURL.java
@@ -7,9 +7,9 @@
* 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
@@ -24,9 +24,10 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
+import org.apache.log4j.Logger;
+
import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.framing.AMQShortString;
-import org.apache.log4j.Logger;
public class AMQBindingURL implements BindingURL
{
@@ -39,10 +40,9 @@ public class AMQBindingURL implements BindingURL
AMQShortString _queueName;
private HashMap<String, String> _options;
-
public AMQBindingURL(String url) throws URLSyntaxException
{
- //format:
+ // format:
// <exch_class>://<exch_name>/[<destination>]/[<queue>]?<option>='<value>'[,<option>='<value>']*
_logger.debug("Parsing URL: " + url);
_url = url;
@@ -61,10 +61,10 @@ public class AMQBindingURL implements BindingURL
if (exchangeClass == null)
{
- _url = ExchangeDefaults.DIRECT_EXCHANGE_CLASS + "://" +
- "" + "//" + _url;
- //URLHelper.parseError(-1, "Exchange Class not specified.", _url);
+ _url = ExchangeDefaults.DIRECT_EXCHANGE_CLASS + "://" + "" + "//" + _url;
+ // URLHelper.parseError(-1, "Exchange Class not specified.", _url);
parseBindingURL();
+
return;
}
else
@@ -76,7 +76,7 @@ public class AMQBindingURL implements BindingURL
if (exchangeName == null)
{
- if(getExchangeClass().equals(ExchangeDefaults.DIRECT_EXCHANGE_CLASS))
+ if (getExchangeClass().equals(ExchangeDefaults.DIRECT_EXCHANGE_CLASS))
{
setExchangeName("");
}
@@ -92,11 +92,10 @@ public class AMQBindingURL implements BindingURL
String queueName;
- if (connection.getPath() == null ||
- connection.getPath().equals(""))
+ if ((connection.getPath() == null) || connection.getPath().equals(""))
{
throw URLHelper.parseError(_url.indexOf(_exchangeName.toString()) + _exchangeName.length(),
- "Destination or Queue requried", _url);
+ "Destination or Queue requried", _url);
}
else
{
@@ -104,7 +103,7 @@ public class AMQBindingURL implements BindingURL
if (slash == -1)
{
throw URLHelper.parseError(_url.indexOf(_exchangeName.toString()) + _exchangeName.length(),
- "Destination requried", _url);
+ "Destination requried", _url);
}
else
{
@@ -127,9 +126,8 @@ public class AMQBindingURL implements BindingURL
setQueueName(queueName);
- //Fragment is #string (not used)
- //System.out.println(connection.getFragment());
- _logger.debug("URL Parsed: " + this);
+ // Fragment is #string (not used)
+ _logger.debug("URL Parsed: " + this);
}
catch (URISyntaxException uris)
@@ -162,7 +160,7 @@ public class AMQBindingURL implements BindingURL
private void processOptions()
{
- //this is where we would parse any options that needed more than just storage.
+ // this is where we would parse any options that needed more than just storage.
}
public String getURL()
@@ -219,11 +217,13 @@ public class AMQBindingURL implements BindingURL
{
if (containsOption(BindingURL.OPTION_CLIENTID) && containsOption(BindingURL.OPTION_SUBSCRIPTION))
{
- _queueName = new AMQShortString(getOption(BindingURL.OPTION_CLIENTID + ":" + BindingURL.OPTION_SUBSCRIPTION));
+ _queueName =
+ new AMQShortString(getOption(BindingURL.OPTION_CLIENTID + ":" + BindingURL.OPTION_SUBSCRIPTION));
}
else
{
- throw URLHelper.parseError(-1, "Durable subscription must have values for " + BindingURL.OPTION_CLIENTID + " and " + BindingURL.OPTION_SUBSCRIPTION + ".", _url);
+ throw URLHelper.parseError(-1, "Durable subscription must have values for " + BindingURL.OPTION_CLIENTID
+ + " and " + BindingURL.OPTION_SUBSCRIPTION + ".", _url);
}
}
@@ -237,7 +237,6 @@ public class AMQBindingURL implements BindingURL
_queueName = name;
}
-
}
public String getOption(String key)
@@ -275,7 +274,6 @@ public class AMQBindingURL implements BindingURL
setOption(OPTION_ROUTING_KEY, key.toString());
}
-
public String toString()
{
StringBuffer sb = new StringBuffer();
@@ -289,18 +287,7 @@ public class AMQBindingURL implements BindingURL
sb.append(_queueName);
sb.append(URLHelper.printOptions(_options));
- return sb.toString();
- }
-
- public static void main(String args[]) throws URLSyntaxException
- {
- String url = "exchangeClass://exchangeName/Destination/Queue?option='value',option2='value2'";
-
- AMQBindingURL dest = new AMQBindingURL(url);
-
- System.out.println(url);
- System.out.println(dest);
+ return sb.toString();
}
-
}
diff --git a/qpid/java/common/src/main/java/org/apache/qpid/url/URLHelper.java b/qpid/java/common/src/main/java/org/apache/qpid/url/URLHelper.java
index 806f879818..c08b443acf 100644
--- a/qpid/java/common/src/main/java/org/apache/qpid/url/URLHelper.java
+++ b/qpid/java/common/src/main/java/org/apache/qpid/url/URLHelper.java
@@ -7,9 +7,9 @@
* 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
@@ -30,10 +30,10 @@ public class URLHelper
public static void parseOptions(HashMap<String, String> optionMap, String options) throws URLSyntaxException
{
- //options looks like this
- //brokerlist='tcp://host:port?option='value',option='value';vm://:3/virtualpath?option='value'',failover='method?option='value',option='value''
+ // options looks like this
+ // brokerlist='tcp://host:port?option='value',option='value';vm://:3/virtualpath?option='value'',failover='method?option='value',option='value''
- if (options == null || options.indexOf('=') == -1)
+ if ((options == null) || (options.indexOf('=') == -1))
{
return;
}
@@ -49,8 +49,8 @@ public class URLHelper
// to store index of final "'"
int valueIndex = optionIndex;
- //Walk remainder of url.
- while (nestedQuotes > 0 || valueIndex < length)
+ // Walk remainder of url.
+ while ((nestedQuotes > 0) || (valueIndex < length))
{
valueIndex++;
@@ -61,27 +61,24 @@ public class URLHelper
if (options.charAt(valueIndex) == '\'')
{
- if (valueIndex + 1 < options.length())
+ if ((valueIndex + 1) < options.length())
{
- if (options.charAt(valueIndex + 1) == DEFAULT_OPTION_SEPERATOR ||
- options.charAt(valueIndex + 1) == ALTERNATIVE_OPTION_SEPARATOR ||
- options.charAt(valueIndex + 1) == BROKER_SEPARATOR ||
- options.charAt(valueIndex + 1) == '\'')
+ if ((options.charAt(valueIndex + 1) == DEFAULT_OPTION_SEPERATOR)
+ || (options.charAt(valueIndex + 1) == ALTERNATIVE_OPTION_SEPARATOR)
+ || (options.charAt(valueIndex + 1) == BROKER_SEPARATOR)
+ || (options.charAt(valueIndex + 1) == '\''))
{
nestedQuotes--;
-// System.out.println(
-// options + "\n" + "-" + nestedQuotes + ":" + getPositionString(valueIndex - 2, 1));
+
if (nestedQuotes == 0)
{
- //We've found the value of an option
+ // We've found the value of an option
break;
}
}
else
{
nestedQuotes++;
-// System.out.println(
-// options + "\n" + "+" + nestedQuotes + ":" + getPositionString(valueIndex - 2, 1));
}
}
else
@@ -98,11 +95,11 @@ public class URLHelper
}
}
- if (nestedQuotes != 0 || valueIndex < (optionIndex + 2))
+ if ((nestedQuotes != 0) || (valueIndex < (optionIndex + 2)))
{
int sepIndex = 0;
- //Try and identify illegal separator character
+ // Try and identify illegal separator character
if (nestedQuotes > 1)
{
for (int i = 0; i < nestedQuotes; i++)
@@ -112,14 +109,14 @@ public class URLHelper
}
}
- if (sepIndex >= options.length() || sepIndex == 0)
+ if ((sepIndex >= options.length()) || (sepIndex == 0))
{
throw parseError(valueIndex, "Unterminated option", options);
}
else
{
- throw parseError(sepIndex, "Unterminated option. Possible illegal option separator:'" +
- options.charAt(sepIndex) + "'", options);
+ throw parseError(sepIndex, "Unterminated option. Possible illegal option separator:'"
+ + options.charAt(sepIndex) + "'", options);
}
}
@@ -130,12 +127,11 @@ public class URLHelper
if (valueIndex < (options.length() - 1))
{
- //Recurse to get remaining options
+ // Recurse to get remaining options
parseOptions(optionMap, options.substring(valueIndex + 2));
}
}
-
public static URLSyntaxException parseError(int index, String error, String url)
{
return parseError(index, 1, error, url);