This closes #255

This commit is contained in:
Clebert Suconic 2015-12-07 13:38:35 -05:00
commit deb84857a6
1541 changed files with 7631 additions and 138 deletions

View File

@ -88,6 +88,7 @@ public class Artemis {
// Sort the list by file name..
Collections.sort(files, new Comparator<File>() {
@Override
public int compare(File file, File file1) {
return file.getName().compareTo(file1.getName());
}

View File

@ -47,6 +47,7 @@ public abstract class ActionAbstract implements Action {
}
}
@Override
public String getBrokerInstance() {
if (brokerInstance == null) {
/* We use File URI for locating files. The ARTEMIS_HOME variable is used to determine file paths. For Windows
@ -61,6 +62,7 @@ public abstract class ActionAbstract implements Action {
return brokerInstance;
}
@Override
public String getBrokerHome() {
if (brokerHome == null) {
/* We use File URI for locating files. The ARTEMIS_HOME variable is used to determine file paths. For Windows
@ -80,6 +82,7 @@ public abstract class ActionAbstract implements Action {
return brokerHome;
}
@Override
public Object execute(ActionContext context) throws Exception {
this.context = context;

View File

@ -635,6 +635,7 @@ public class Create extends InputAbstract {
File dir = new File(path(getHome().toString(), false) + "/lib");
File[] matches = dir.listFiles(new FilenameFilter() {
@Override
public boolean accept(File dir, String name) {
return name.startsWith("jboss-logmanager") && name.endsWith(".jar");
}

View File

@ -160,6 +160,7 @@ public class Run extends Configurable {
}, 500, 500);
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
try {
server.stop();

View File

@ -54,6 +54,7 @@ public class DecodeJournal extends LockAbstract {
@Option(name = "--input", description = "The input file name (default=exp.dmp)", required = true)
public String input = "exp.dmp";
@Override
public Object execute(ActionContext context) throws Exception {
super.execute(context);
try {

View File

@ -48,6 +48,7 @@ public class EncodeJournal extends LockAbstract {
@Option(name = "--file-size", description = "The journal size (default 10485760)")
public int size = 10485760;
@Override
public Object execute(ActionContext context) throws Exception {
super.execute(context);
try {
@ -122,18 +123,22 @@ public class EncodeJournal extends LockAbstract {
final JournalFile file) throws Exception {
JournalImpl.readJournalFile(fileFactory, file, new JournalReaderCallback() {
@Override
public void onReadUpdateRecordTX(final long transactionID, final RecordInfo recordInfo) throws Exception {
out.println("operation@UpdateTX,txID@" + transactionID + "," + describeRecord(recordInfo));
}
@Override
public void onReadUpdateRecord(final RecordInfo recordInfo) throws Exception {
out.println("operation@Update," + describeRecord(recordInfo));
}
@Override
public void onReadRollbackRecord(final long transactionID) throws Exception {
out.println("operation@Rollback,txID@" + transactionID);
}
@Override
public void onReadPrepareRecord(final long transactionID,
final byte[] extraData,
final int numberOfRecords) throws Exception {
@ -144,28 +149,34 @@ public class EncodeJournal extends LockAbstract {
encode(extraData));
}
@Override
public void onReadDeleteRecordTX(final long transactionID, final RecordInfo recordInfo) throws Exception {
out.println("operation@DeleteRecordTX,txID@" + transactionID +
"," +
describeRecord(recordInfo));
}
@Override
public void onReadDeleteRecord(final long recordID) throws Exception {
out.println("operation@DeleteRecord,id@" + recordID);
}
@Override
public void onReadCommitRecord(final long transactionID, final int numberOfRecords) throws Exception {
out.println("operation@Commit,txID@" + transactionID + ",numberOfRecords@" + numberOfRecords);
}
@Override
public void onReadAddRecordTX(final long transactionID, final RecordInfo recordInfo) throws Exception {
out.println("operation@AddRecordTX,txID@" + transactionID + "," + describeRecord(recordInfo));
}
@Override
public void onReadAddRecord(final RecordInfo recordInfo) throws Exception {
out.println("operation@AddRecord," + describeRecord(recordInfo));
}
@Override
public void markAsDataFile(final JournalFile file) {
}
});

View File

@ -64,6 +64,7 @@ public class ProducerThread extends Thread {
this.session = session;
}
@Override
public void run() {
MessageProducer producer = null;
String threadName = Thread.currentThread().getName();

View File

@ -30,6 +30,7 @@ public class ProcessBuilder {
static {
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
for (Process p : processes) {
// if (p.isAlive())

View File

@ -43,6 +43,7 @@ public class FileBroker implements Broker {
this.configurationUrl = broker.configuration;
}
@Override
public synchronized void start() throws Exception {
if (started) {
return;

View File

@ -54,6 +54,7 @@ public class ServerUtil {
final Process process = builder.start();
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
process.destroy();
}

View File

@ -634,6 +634,7 @@ public interface ActiveMQBuffer extends DataInput {
* @return a byte at the current {@code readerIndex}
* @throws IndexOutOfBoundsException if {@code this.readableBytes} is less than {@code 1}
*/
@Override
byte readByte();
/**
@ -643,6 +644,7 @@ public interface ActiveMQBuffer extends DataInput {
* @return an unsigned byte at the current {@code readerIndex}
* @throws IndexOutOfBoundsException if {@code this.readableBytes} is less than {@code 1}
*/
@Override
int readUnsignedByte();
/**
@ -652,6 +654,7 @@ public interface ActiveMQBuffer extends DataInput {
* @return a 16-bit short integer at the current {@code readerIndex}
* @throws IndexOutOfBoundsException if {@code this.readableBytes} is less than {@code 2}
*/
@Override
short readShort();
/**
@ -661,6 +664,7 @@ public interface ActiveMQBuffer extends DataInput {
* @return an unsigned 16-bit short integer at the current {@code readerIndex}
* @throws IndexOutOfBoundsException if {@code this.readableBytes} is less than {@code 2}
*/
@Override
int readUnsignedShort();
/**
@ -670,6 +674,7 @@ public interface ActiveMQBuffer extends DataInput {
* @return a 32-bit integer at the current {@code readerIndex}
* @throws IndexOutOfBoundsException if {@code this.readableBytes} is less than {@code 4}
*/
@Override
int readInt();
/**
@ -688,6 +693,7 @@ public interface ActiveMQBuffer extends DataInput {
* @return a 64-bit integer at the current {@code readerIndex}
* @throws IndexOutOfBoundsException if {@code this.readableBytes} is less than {@code 8}
*/
@Override
long readLong();
/**
@ -697,6 +703,7 @@ public interface ActiveMQBuffer extends DataInput {
* @return a char at the current {@code readerIndex}
* @throws IndexOutOfBoundsException if {@code this.readableBytes} is less than {@code 2}
*/
@Override
char readChar();
/**
@ -706,6 +713,7 @@ public interface ActiveMQBuffer extends DataInput {
* @return a float at the current {@code readerIndex}
* @throws IndexOutOfBoundsException if {@code this.readableBytes} is less than {@code 4}
*/
@Override
float readFloat();
/**
@ -715,6 +723,7 @@ public interface ActiveMQBuffer extends DataInput {
* @return a double at the current {@code readerIndex}
* @throws IndexOutOfBoundsException if {@code this.readableBytes} is less than {@code 8}
*/
@Override
double readDouble();
/**
@ -724,6 +733,7 @@ public interface ActiveMQBuffer extends DataInput {
* @return a boolean at the current {@code readerIndex}
* @throws IndexOutOfBoundsException if {@code this.readableBytes} is less than {@code 1}
*/
@Override
boolean readBoolean();
/**
@ -759,6 +769,7 @@ public interface ActiveMQBuffer extends DataInput {
*
* @return a UTF-8 String at the current {@code readerIndex}
*/
@Override
String readUTF();
/**
@ -875,6 +886,7 @@ public interface ActiveMQBuffer extends DataInput {
* @param length The number of bytes to skip
* @throws IndexOutOfBoundsException if {@code length} is greater than {@code this.readableBytes}
*/
@Override
int skipBytes(int length);
/**

View File

@ -101,10 +101,12 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
// CharSequence implementation
// ---------------------------------------------------------------------------
@Override
public int length() {
return data.length >> 1;
}
@Override
public char charAt(int pos) {
if (pos < 0 || pos >= data.length >> 1) {
throw new IndexOutOfBoundsException();
@ -114,6 +116,7 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
return (char) ((data[pos] & 0xFF) | (data[pos + 1] << 8) & 0xFF00);
}
@Override
public CharSequence subSequence(final int start, final int end) {
int len = data.length >> 1;
@ -132,6 +135,7 @@ public final class SimpleString implements CharSequence, Serializable, Comparabl
// Comparable implementation -------------------------------------
@Override
public int compareTo(final SimpleString o) {
return toString().compareTo(o.toString());
}

View File

@ -56,10 +56,12 @@ public class ChannelBufferWrapper implements ActiveMQBuffer {
this.releasable = releasable;
}
@Override
public boolean readBoolean() {
return readByte() != 0;
}
@Override
public SimpleString readNullableSimpleString() {
int b = buffer.readByte();
if (b == DataConstants.NULL) {
@ -68,6 +70,7 @@ public class ChannelBufferWrapper implements ActiveMQBuffer {
return readSimpleStringInternal();
}
@Override
public String readNullableString() {
int b = buffer.readByte();
if (b == DataConstants.NULL) {
@ -76,6 +79,7 @@ public class ChannelBufferWrapper implements ActiveMQBuffer {
return readStringInternal();
}
@Override
public SimpleString readSimpleString() {
return readSimpleStringInternal();
}
@ -87,6 +91,7 @@ public class ChannelBufferWrapper implements ActiveMQBuffer {
return new SimpleString(data);
}
@Override
public String readString() {
return readStringInternal();
}
@ -109,14 +114,17 @@ public class ChannelBufferWrapper implements ActiveMQBuffer {
}
}
@Override
public String readUTF() {
return UTF8Util.readUTF(this);
}
@Override
public void writeBoolean(final boolean val) {
buffer.writeByte((byte) (val ? -1 : 0));
}
@Override
public void writeNullableSimpleString(final SimpleString val) {
if (val == null) {
buffer.writeByte(DataConstants.NULL);
@ -127,6 +135,7 @@ public class ChannelBufferWrapper implements ActiveMQBuffer {
}
}
@Override
public void writeNullableString(final String val) {
if (val == null) {
buffer.writeByte(DataConstants.NULL);
@ -137,6 +146,7 @@ public class ChannelBufferWrapper implements ActiveMQBuffer {
}
}
@Override
public void writeSimpleString(final SimpleString val) {
writeSimpleStringInternal(val);
}
@ -147,6 +157,7 @@ public class ChannelBufferWrapper implements ActiveMQBuffer {
buffer.writeBytes(data);
}
@Override
public void writeString(final String val) {
writeStringInternal(val);
}
@ -172,343 +183,428 @@ public class ChannelBufferWrapper implements ActiveMQBuffer {
}
}
@Override
public void writeUTF(final String utf) {
UTF8Util.saveUTF(this, utf);
}
@Override
public int capacity() {
return buffer.capacity();
}
@Override
public ByteBuf byteBuf() {
return buffer;
}
@Override
public void clear() {
buffer.clear();
}
@Override
public ActiveMQBuffer copy() {
return new ChannelBufferWrapper(buffer.copy(), releasable);
}
@Override
public ActiveMQBuffer copy(final int index, final int length) {
return new ChannelBufferWrapper(buffer.copy(index, length), releasable);
}
@Override
public void discardReadBytes() {
buffer.discardReadBytes();
}
@Override
public ActiveMQBuffer duplicate() {
return new ChannelBufferWrapper(buffer.duplicate(), releasable);
}
@Override
public byte getByte(final int index) {
return buffer.getByte(index);
}
@Override
public void getBytes(final int index, final byte[] dst, final int dstIndex, final int length) {
buffer.getBytes(index, dst, dstIndex, length);
}
@Override
public void getBytes(final int index, final byte[] dst) {
buffer.getBytes(index, dst);
}
@Override
public void getBytes(final int index, final ByteBuffer dst) {
buffer.getBytes(index, dst);
}
@Override
public void getBytes(final int index, final ActiveMQBuffer dst, final int dstIndex, final int length) {
buffer.getBytes(index, dst.byteBuf(), dstIndex, length);
}
@Override
public void getBytes(final int index, final ActiveMQBuffer dst, final int length) {
buffer.getBytes(index, dst.byteBuf(), length);
}
@Override
public void getBytes(final int index, final ActiveMQBuffer dst) {
buffer.getBytes(index, dst.byteBuf());
}
@Override
public char getChar(final int index) {
return (char) buffer.getShort(index);
}
@Override
public double getDouble(final int index) {
return Double.longBitsToDouble(buffer.getLong(index));
}
@Override
public float getFloat(final int index) {
return Float.intBitsToFloat(buffer.getInt(index));
}
@Override
public int getInt(final int index) {
return buffer.getInt(index);
}
@Override
public long getLong(final int index) {
return buffer.getLong(index);
}
@Override
public short getShort(final int index) {
return buffer.getShort(index);
}
@Override
public short getUnsignedByte(final int index) {
return buffer.getUnsignedByte(index);
}
@Override
public long getUnsignedInt(final int index) {
return buffer.getUnsignedInt(index);
}
@Override
public int getUnsignedShort(final int index) {
return buffer.getUnsignedShort(index);
}
@Override
public void markReaderIndex() {
buffer.markReaderIndex();
}
@Override
public void markWriterIndex() {
buffer.markWriterIndex();
}
@Override
public boolean readable() {
return buffer.isReadable();
}
@Override
public int readableBytes() {
return buffer.readableBytes();
}
@Override
public byte readByte() {
return buffer.readByte();
}
@Override
public void readBytes(final byte[] dst, final int dstIndex, final int length) {
buffer.readBytes(dst, dstIndex, length);
}
@Override
public void readBytes(final byte[] dst) {
buffer.readBytes(dst);
}
@Override
public void readBytes(final ByteBuffer dst) {
buffer.readBytes(dst);
}
@Override
public void readBytes(final ActiveMQBuffer dst, final int dstIndex, final int length) {
buffer.readBytes(dst.byteBuf(), dstIndex, length);
}
@Override
public void readBytes(final ActiveMQBuffer dst, final int length) {
buffer.readBytes(dst.byteBuf(), length);
}
@Override
public void readBytes(final ActiveMQBuffer dst) {
buffer.readBytes(dst.byteBuf());
}
@Override
public ActiveMQBuffer readBytes(final int length) {
return new ChannelBufferWrapper(buffer.readBytes(length), releasable);
}
@Override
public char readChar() {
return (char) buffer.readShort();
}
@Override
public double readDouble() {
return Double.longBitsToDouble(buffer.readLong());
}
@Override
public int readerIndex() {
return buffer.readerIndex();
}
@Override
public void readerIndex(final int readerIndex) {
buffer.readerIndex(readerIndex);
}
@Override
public float readFloat() {
return Float.intBitsToFloat(buffer.readInt());
}
@Override
public int readInt() {
return buffer.readInt();
}
@Override
public long readLong() {
return buffer.readLong();
}
@Override
public short readShort() {
return buffer.readShort();
}
@Override
public ActiveMQBuffer readSlice(final int length) {
return new ChannelBufferWrapper(buffer.readSlice(length), releasable);
}
@Override
public int readUnsignedByte() {
return buffer.readUnsignedByte();
}
@Override
public long readUnsignedInt() {
return buffer.readUnsignedInt();
}
@Override
public int readUnsignedShort() {
return buffer.readUnsignedShort();
}
@Override
public void resetReaderIndex() {
buffer.resetReaderIndex();
}
@Override
public void resetWriterIndex() {
buffer.resetWriterIndex();
}
@Override
public void setByte(final int index, final byte value) {
buffer.setByte(index, value);
}
@Override
public void setBytes(final int index, final byte[] src, final int srcIndex, final int length) {
buffer.setBytes(index, src, srcIndex, length);
}
@Override
public void setBytes(final int index, final byte[] src) {
buffer.setBytes(index, src);
}
@Override
public void setBytes(final int index, final ByteBuffer src) {
buffer.setBytes(index, src);
}
@Override
public void setBytes(final int index, final ActiveMQBuffer src, final int srcIndex, final int length) {
buffer.setBytes(index, src.byteBuf(), srcIndex, length);
}
@Override
public void setBytes(final int index, final ActiveMQBuffer src, final int length) {
buffer.setBytes(index, src.byteBuf(), length);
}
@Override
public void setBytes(final int index, final ActiveMQBuffer src) {
buffer.setBytes(index, src.byteBuf());
}
@Override
public void setChar(final int index, final char value) {
buffer.setShort(index, (short) value);
}
@Override
public void setDouble(final int index, final double value) {
buffer.setLong(index, Double.doubleToLongBits(value));
}
@Override
public void setFloat(final int index, final float value) {
buffer.setInt(index, Float.floatToIntBits(value));
}
@Override
public void setIndex(final int readerIndex, final int writerIndex) {
buffer.setIndex(readerIndex, writerIndex);
}
@Override
public void setInt(final int index, final int value) {
buffer.setInt(index, value);
}
@Override
public void setLong(final int index, final long value) {
buffer.setLong(index, value);
}
@Override
public void setShort(final int index, final short value) {
buffer.setShort(index, value);
}
@Override
public int skipBytes(final int length) {
buffer.skipBytes(length);
return length;
}
@Override
public ActiveMQBuffer slice() {
return new ChannelBufferWrapper(buffer.slice(), releasable);
}
@Override
public ActiveMQBuffer slice(final int index, final int length) {
return new ChannelBufferWrapper(buffer.slice(index, length), releasable);
}
@Override
public ByteBuffer toByteBuffer() {
return buffer.nioBuffer();
}
@Override
public ByteBuffer toByteBuffer(final int index, final int length) {
return buffer.nioBuffer(index, length);
}
@Override
public boolean writable() {
return buffer.isWritable();
}
@Override
public int writableBytes() {
return buffer.writableBytes();
}
@Override
public void writeByte(final byte value) {
buffer.writeByte(value);
}
@Override
public void writeBytes(final byte[] src, final int srcIndex, final int length) {
buffer.writeBytes(src, srcIndex, length);
}
@Override
public void writeBytes(final byte[] src) {
buffer.writeBytes(src);
}
@Override
public void writeBytes(final ByteBuffer src) {
buffer.writeBytes(src);
}
@Override
public void writeBytes(final ActiveMQBuffer src, final int srcIndex, final int length) {
buffer.writeBytes(src.byteBuf(), srcIndex, length);
}
@Override
public void writeBytes(final ActiveMQBuffer src, final int length) {
buffer.writeBytes(src.byteBuf(), length);
}
@Override
public void writeChar(final char chr) {
buffer.writeShort((short) chr);
}
@Override
public void writeDouble(final double value) {
buffer.writeLong(Double.doubleToLongBits(value));
}
@Override
public void writeFloat(final float value) {
buffer.writeInt(Float.floatToIntBits(value));
}
@Override
public void writeInt(final int value) {
buffer.writeInt(value);
}
@Override
public void writeLong(final long value) {
buffer.writeLong(value);
}
@Override
public int writerIndex() {
return buffer.writerIndex();
}
@Override
public void writerIndex(final int writerIndex) {
buffer.writerIndex(writerIndex);
}
@Override
public void writeShort(final short value) {
buffer.writeShort(value);
}

View File

@ -56,6 +56,7 @@ public final class ActiveMQThreadFactory implements ThreadFactory {
this.acc = AccessController.getContext();
}
@Override
public Thread newThread(final Runnable command) {
// create a thread in a privileged block if running with Security Manager
if (acc != null) {
@ -74,6 +75,7 @@ public final class ActiveMQThreadFactory implements ThreadFactory {
this.target = target;
}
@Override
public Thread run() {
return createThread(target);
}

View File

@ -71,6 +71,7 @@ public class ConcurrentHashSet<E> extends AbstractSet<E> implements ConcurrentSe
return theMap.remove(o) == ConcurrentHashSet.dummy;
}
@Override
public boolean addIfAbsent(final E o) {
Object obj = theMap.putIfAbsent(o, ConcurrentHashSet.dummy);

View File

@ -42,6 +42,7 @@ public class DefaultSensitiveStringCodec implements SensitiveDataCodec<String> {
private byte[] internalKey = "clusterpassword".getBytes();
@Override
public String decode(Object secret) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeyException, BadPaddingException, IllegalBlockSizeException {
SecretKeySpec key = new SecretKeySpec(internalKey, "Blowfish");
@ -77,6 +78,7 @@ public class DefaultSensitiveStringCodec implements SensitiveDataCodec<String> {
return n.toString(16);
}
@Override
public void init(Map<String, String> params) {
String key = params.get("key");
if (key != null) {

View File

@ -54,6 +54,7 @@ public class FactoryFinder {
final ConcurrentMap<String, Class> classMap = new ConcurrentHashMap<String, Class>();
@Override
public Object create(final String path) throws InstantiationException, IllegalAccessException, ClassNotFoundException, IOException {
Class clazz = classMap.get(path);
if (clazz == null) {

View File

@ -49,6 +49,7 @@ public class PasswordMaskingUtil {
// load class
codecInstance = AccessController.doPrivileged(new PrivilegedAction<SensitiveDataCodec<String>>() {
@Override
public SensitiveDataCodec<String> run() {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
try {

View File

@ -279,6 +279,7 @@ public final class UUIDGenerator {
for (final NetworkInterface networkInterface : ifaces) {
tasks.add(new Callable<byte[]>() {
@Override
public byte[] call() throws Exception {
boolean up = (Boolean) isUpMethod.invoke(networkInterface);
boolean loopback = (Boolean) isLoopbackMethod.invoke(networkInterface);

View File

@ -34,6 +34,7 @@ public class ReferenceCounterTest extends Assert {
final AtomicInteger counts = new AtomicInteger(0);
volatile Thread lastThreadUsed;
@Override
public void run() {
counts.incrementAndGet();
latch.countDown();
@ -83,6 +84,7 @@ public class ReferenceCounterTest extends Assert {
for (int i = 0; i < t.length; i++) {
t[i] = new Thread() {
@Override
public void run() {
ref.increment();
}
@ -96,6 +98,7 @@ public class ReferenceCounterTest extends Assert {
for (int i = 0; i < t.length; i++) {
t[i] = new Thread() {
@Override
public void run() {
ref.decrement();
}

View File

@ -46,6 +46,7 @@ public abstract class JGroupsBroadcastEndpoint implements BroadcastEndpoint {
this.channelName = channelName;
}
@Override
public void broadcast(final byte[] data) throws Exception {
if (broadcastOpened) {
org.jgroups.Message msg = new org.jgroups.Message();
@ -56,6 +57,7 @@ public abstract class JGroupsBroadcastEndpoint implements BroadcastEndpoint {
}
}
@Override
public byte[] receiveBroadcast() throws Exception {
if (clientOpened) {
return receiver.receiveBroadcast();
@ -65,6 +67,7 @@ public abstract class JGroupsBroadcastEndpoint implements BroadcastEndpoint {
}
}
@Override
public byte[] receiveBroadcast(long time, TimeUnit unit) throws Exception {
if (clientOpened) {
return receiver.receiveBroadcast(time, unit);
@ -74,6 +77,7 @@ public abstract class JGroupsBroadcastEndpoint implements BroadcastEndpoint {
}
}
@Override
public synchronized void openClient() throws Exception {
if (clientOpened) {
return;
@ -84,6 +88,7 @@ public abstract class JGroupsBroadcastEndpoint implements BroadcastEndpoint {
clientOpened = true;
}
@Override
public synchronized void openBroadcaster() throws Exception {
if (broadcastOpened)
return;
@ -102,6 +107,7 @@ public abstract class JGroupsBroadcastEndpoint implements BroadcastEndpoint {
channel.connect();
}
@Override
public synchronized void close(boolean isBroadcast) throws Exception {
if (isBroadcast) {
broadcastOpened = false;

View File

@ -32,6 +32,7 @@ public final class JGroupsFileBroadcastEndpoint extends JGroupsBroadcastEndpoint
this.file = file;
}
@Override
public JChannel createChannel() throws Exception {
URL configURL = Thread.currentThread().getContextClassLoader().getResource(file);

View File

@ -50,6 +50,7 @@ public final class UDPBroadcastEndpointFactory implements BroadcastEndpointFacto
public UDPBroadcastEndpointFactory() {
}
@Override
public BroadcastEndpoint createBroadcastEndpoint() throws Exception {
return new UDPBroadcastEndpoint().setGroupAddress(groupAddress != null ? InetAddress.getByName(groupAddress) : null).setGroupPort(groupPort).setLocalBindAddress(localBindAddress != null ? InetAddress.getByName(localBindAddress) : null).setLocalBindPort(localBindPort);
}
@ -135,11 +136,13 @@ public final class UDPBroadcastEndpointFactory implements BroadcastEndpointFacto
return this;
}
@Override
public void broadcast(byte[] data) throws Exception {
DatagramPacket packet = new DatagramPacket(data, data.length, groupAddress, groupPort);
broadcastingSocket.send(packet);
}
@Override
public byte[] receiveBroadcast() throws Exception {
final byte[] data = new byte[65535];
final DatagramPacket packet = new DatagramPacket(data, data.length);
@ -162,12 +165,14 @@ public final class UDPBroadcastEndpointFactory implements BroadcastEndpointFacto
return data;
}
@Override
public byte[] receiveBroadcast(long time, TimeUnit unit) throws Exception {
// We just use the regular method on UDP, there's no timeout support
// and this is basically for tests only
return receiveBroadcast();
}
@Override
public void openBroadcaster() throws Exception {
if (localBindPort != -1) {
broadcastingSocket = new DatagramSocket(localBindPort, localAddress);
@ -196,6 +201,7 @@ public final class UDPBroadcastEndpointFactory implements BroadcastEndpointFacto
open = true;
}
@Override
public void openClient() throws Exception {
// HORNETQ-874
if (checkForLinux() || checkForSolaris() || checkForHp()) {
@ -224,6 +230,7 @@ public final class UDPBroadcastEndpointFactory implements BroadcastEndpointFacto
}
//@Todo: using isBroadcast to share endpoint between broadcast and receiving
@Override
public void close(boolean isBroadcast) throws Exception {
open = false;

View File

@ -111,6 +111,7 @@ public interface ClientConsumer extends AutoCloseable {
*
* @throws ActiveMQException
*/
@Override
void close() throws ActiveMQException;
/**

View File

@ -125,111 +125,133 @@ public interface ClientMessage extends Message {
/**
* Overridden from {@link Message} to enable fluent API
*/
@Override
ClientMessage putBooleanProperty(SimpleString key, boolean value);
/**
* Overridden from {@link Message} to enable fluent API
*/
@Override
ClientMessage putBooleanProperty(String key, boolean value);
/**
* Overridden from {@link Message} to enable fluent API
*/
@Override
ClientMessage putByteProperty(SimpleString key, byte value);
/**
* Overridden from {@link Message} to enable fluent API
*/
@Override
ClientMessage putByteProperty(String key, byte value);
/**
* Overridden from {@link Message} to enable fluent API
*/
@Override
ClientMessage putBytesProperty(SimpleString key, byte[] value);
/**
* Overridden from {@link Message} to enable fluent API
*/
@Override
ClientMessage putBytesProperty(String key, byte[] value);
/**
* Overridden from {@link Message} to enable fluent API
*/
@Override
ClientMessage putShortProperty(SimpleString key, short value);
/**
* Overridden from {@link Message} to enable fluent API
*/
@Override
ClientMessage putShortProperty(String key, short value);
/**
* Overridden from {@link Message} to enable fluent API
*/
@Override
ClientMessage putCharProperty(SimpleString key, char value);
/**
* Overridden from {@link Message} to enable fluent API
*/
@Override
ClientMessage putCharProperty(String key, char value);
/**
* Overridden from {@link Message} to enable fluent API
*/
@Override
ClientMessage putIntProperty(SimpleString key, int value);
/**
* Overridden from {@link Message} to enable fluent API
*/
@Override
ClientMessage putIntProperty(String key, int value);
/**
* Overridden from {@link Message} to enable fluent API
*/
@Override
ClientMessage putLongProperty(SimpleString key, long value);
/**
* Overridden from {@link Message} to enable fluent API
*/
@Override
ClientMessage putLongProperty(String key, long value);
/**
* Overridden from {@link Message} to enable fluent API
*/
@Override
ClientMessage putFloatProperty(SimpleString key, float value);
/**
* Overridden from {@link Message} to enable fluent API
*/
@Override
ClientMessage putFloatProperty(String key, float value);
/**
* Overridden from {@link Message} to enable fluent API
*/
@Override
ClientMessage putDoubleProperty(SimpleString key, double value);
/**
* Overridden from {@link Message} to enable fluent API
*/
@Override
ClientMessage putDoubleProperty(String key, double value);
/**
* Overridden from {@link Message} to enable fluent API
*/
@Override
ClientMessage putStringProperty(SimpleString key, SimpleString value);
/**
* Overridden from {@link Message} to enable fluent API
*/
@Override
ClientMessage putStringProperty(String key, String value);
/**
* Overridden from {@link Message} to enable fluent API
*/
@Override
ClientMessage writeBodyBufferBytes(byte[] bytes);
/**
* Overridden from {@link Message} to enable fluent API
*/
@Override
ClientMessage writeBodyBufferString(String string);
}

View File

@ -124,6 +124,7 @@ public interface ClientProducer extends AutoCloseable {
*
* @throws ActiveMQException if an exception occurs while closing the producer
*/
@Override
void close() throws ActiveMQException;
/**

View File

@ -145,6 +145,7 @@ public interface ClientSession extends XAResource, AutoCloseable {
*
* @throws ActiveMQException if an exception occurs while closing the session
*/
@Override
void close() throws ActiveMQException;
/**

View File

@ -138,6 +138,7 @@ public interface ClientSessionFactory extends AutoCloseable {
/**
* Closes this factory and any session created by it.
*/
@Override
void close();
/**

View File

@ -722,6 +722,7 @@ public interface ServerLocator extends AutoCloseable {
/**
* Closes this factory and release all its resources
*/
@Override
void close();
/**

View File

@ -25,6 +25,7 @@ public final class FirstElementConnectionLoadBalancingPolicy implements Connecti
* @param max param is ignored
* @return 0
*/
@Override
public int select(final int max) {
return 0;
}

View File

@ -32,6 +32,7 @@ public final class RandomConnectionLoadBalancingPolicy implements ConnectionLoad
* @param max the upper limit of the random number selection
* @see java.util.Random#nextInt(int)
*/
@Override
public int select(final int max) {
return random.getRandom().nextInt(max);
}

View File

@ -30,6 +30,7 @@ public final class RandomStickyConnectionLoadBalancingPolicy implements Connecti
/**
* @see java.util.Random#nextInt(int)
*/
@Override
public int select(final int max) {
if (pos == -1) {
pos = random.getRandom().nextInt(max);

View File

@ -37,6 +37,7 @@ public final class RoundRobinConnectionLoadBalancingPolicy implements Connection
private int pos;
@Override
public int select(final int max) {
if (first) {
// We start on a random one

View File

@ -47,6 +47,7 @@ public enum CoreNotificationType implements NotificationType {
this.value = value;
}
@Override
public int getType() {
return value;
}

View File

@ -38,14 +38,17 @@ public class AddressQueryImpl implements ClientSession.AddressQuery {
this.autoCreateJmsQueues = autoCreateJmsQueues;
}
@Override
public List<SimpleString> getQueueNames() {
return queueNames;
}
@Override
public boolean isExists() {
return exists;
}
@Override
public boolean isAutoCreateJmsQueues() {
return autoCreateJmsQueues;
}

View File

@ -175,6 +175,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal {
// ClientConsumer implementation
// -----------------------------------------------------------------
@Override
public ConsumerContext getConsumerContext() {
return consumerContext;
}
@ -348,6 +349,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal {
}
}
@Override
public ClientMessage receive(final long timeout) throws ActiveMQException {
ClientMessage msg = receive(timeout, false);
@ -358,14 +360,17 @@ public final class ClientConsumerImpl implements ClientConsumerInternal {
return msg;
}
@Override
public ClientMessage receive() throws ActiveMQException {
return receive(0, false);
}
@Override
public ClientMessage receiveImmediate() throws ActiveMQException {
return receive(0, true);
}
@Override
public MessageHandler getMessageHandler() throws ActiveMQException {
checkClosed();
@ -374,6 +379,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal {
// Must be synchronized since messages may be arriving while handler is being set and might otherwise end
// up not queueing enough executors - so messages get stranded
@Override
public synchronized ClientConsumerImpl setMessageHandler(final MessageHandler theHandler) throws ActiveMQException {
checkClosed();
@ -401,6 +407,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal {
return this;
}
@Override
public void close() throws ActiveMQException {
doCleanUp(true);
}
@ -411,6 +418,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal {
* @param future the future to run once the onMessage Thread has completed
* @throws ActiveMQException
*/
@Override
public Thread prepareForClose(final FutureLatch future) throws ActiveMQException {
closing = true;
@ -427,6 +435,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal {
return onMessageThread;
}
@Override
public void cleanUp() {
try {
doCleanUp(false);
@ -436,10 +445,12 @@ public final class ClientConsumerImpl implements ClientConsumerInternal {
}
}
@Override
public boolean isClosed() {
return closed;
}
@Override
public void stop(final boolean waitForOnMessage) throws ActiveMQException {
waitForOnMessageToComplete(waitForOnMessage);
@ -457,6 +468,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal {
}
}
@Override
public void clearAtFailover() {
clearBuffer();
@ -474,12 +486,14 @@ public final class ClientConsumerImpl implements ClientConsumerInternal {
ackIndividually = false;
}
@Override
public synchronized void start() {
stopped = false;
requeueExecutors();
}
@Override
public Exception getLastException() {
return lastException;
}
@ -487,22 +501,27 @@ public final class ClientConsumerImpl implements ClientConsumerInternal {
// ClientConsumerInternal implementation
// --------------------------------------------------------------
@Override
public ClientSession.QueueQuery getQueueInfo() {
return queueInfo;
}
@Override
public SimpleString getFilterString() {
return filterString;
}
@Override
public SimpleString getQueueName() {
return queueName;
}
@Override
public boolean isBrowseOnly() {
return browseOnly;
}
@Override
public synchronized void handleMessage(final ClientMessageInternal message) throws Exception {
if (closing) {
// This is ok - we just ignore the message
@ -586,6 +605,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal {
handleRegularMessage(largeMessage);
}
@Override
public synchronized void handleLargeMessage(final ClientLargeMessageInternal clientLargeMessage,
long largeMessageSize) throws Exception {
if (closing) {
@ -617,6 +637,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal {
handleRegularMessage(clientLargeMessage);
}
@Override
public synchronized void handleLargeMessageContinuation(final byte[] chunk,
final int flowControlSize,
final boolean isContinues) throws Exception {
@ -634,6 +655,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal {
}
}
@Override
public void clear(boolean waitForOnMessage) throws ActiveMQException {
synchronized (this) {
// Need to send credits for the messages in the buffer
@ -681,14 +703,17 @@ public final class ClientConsumerImpl implements ClientConsumerInternal {
}
}
@Override
public int getClientWindowSize() {
return clientWindowSize;
}
@Override
public int getBufferSize() {
return buffer.size();
}
@Override
public void acknowledge(final ClientMessage message) throws ActiveMQException {
ClientMessageInternal cmi = (ClientMessageInternal) message;
@ -707,6 +732,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal {
}
}
@Override
public void individualAcknowledge(ClientMessage message) throws ActiveMQException {
if (lastAckedMessage != null) {
flushAcks();
@ -715,6 +741,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal {
session.individualAcknowledge(this, message);
}
@Override
public void flushAcks() throws ActiveMQException {
if (lastAckedMessage != null) {
doAck(lastAckedMessage);
@ -727,6 +754,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal {
*
* @param discountSlowConsumer When dealing with slowConsumers, we need to discount one credit that was pre-sent when the first receive was called. For largeMessage that is only done at the latest packet
*/
@Override
public void flowControl(final int messageBytes, final boolean discountSlowConsumer) throws ActiveMQException {
if (clientWindowSize >= 0) {
creditsToSend += messageBytes;
@ -803,6 +831,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal {
// If resetting a slow consumer, we need to wait the execution
final CountDownLatch latch = new CountDownLatch(1);
flowControlExecutor.execute(new Runnable() {
@Override
public void run() {
latch.countDown();
}
@ -837,6 +866,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal {
private void sendCredits(final int credits) {
pendingFlowControl.countUp();
flowControlExecutor.execute(new Runnable() {
@Override
public void run() {
try {
sessionContext.sendConsumerCredits(ClientConsumerImpl.this, credits);
@ -918,6 +948,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal {
ActiveMQClientLogger.LOGGER.trace("Calling handler.onMessage");
}
final ClassLoader originalLoader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
@Override
public ClassLoader run() {
ClassLoader originalLoader = Thread.currentThread().getContextClassLoader();
@ -934,6 +965,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal {
finally {
try {
AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override
public Object run() {
Thread.currentThread().setContextClassLoader(originalLoader);
return null;
@ -1040,6 +1072,7 @@ public final class ClientConsumerImpl implements ClientConsumerInternal {
private class Runner implements Runnable {
@Override
public void run() {
try {
callOnMessage();

View File

@ -41,6 +41,7 @@ public final class ClientLargeMessageImpl extends ClientMessageImpl implements C
/**
* @param largeMessageSize the largeMessageSize to set
*/
@Override
public void setLargeMessageSize(long largeMessageSize) {
this.largeMessageSize = largeMessageSize;
}
@ -74,10 +75,12 @@ public final class ClientLargeMessageImpl extends ClientMessageImpl implements C
return true;
}
@Override
public void setLargeMessageController(final LargeMessageController controller) {
largeMessageController = controller;
}
@Override
public void checkCompletion() throws ActiveMQException {
checkBuffer();
}
@ -100,6 +103,7 @@ public final class ClientLargeMessageImpl extends ClientMessageImpl implements C
return getLongProperty(Message.HDR_LARGE_BODY_SIZE).intValue();
}
@Override
public LargeMessageController getLargeMessageController() {
return largeMessageController;
}

View File

@ -41,6 +41,7 @@ public class ClientProducerCreditManagerImpl implements ClientProducerCreditMana
this.windowSize = windowSize;
}
@Override
public synchronized ClientProducerCredits getCredits(final SimpleString address,
final boolean anon,
SessionContext context) {
@ -84,6 +85,7 @@ public class ClientProducerCreditManagerImpl implements ClientProducerCreditMana
}
}
@Override
public synchronized void returnCredits(final SimpleString address) {
ClientProducerCredits credits = producerCredits.get(address);
@ -92,6 +94,7 @@ public class ClientProducerCreditManagerImpl implements ClientProducerCreditMana
}
}
@Override
public synchronized void receiveCredits(final SimpleString address, final int credits) {
ClientProducerCredits cr = producerCredits.get(address);
@ -100,6 +103,7 @@ public class ClientProducerCreditManagerImpl implements ClientProducerCreditMana
}
}
@Override
public synchronized void receiveFailCredits(final SimpleString address, int credits) {
ClientProducerCredits cr = producerCredits.get(address);
@ -108,12 +112,14 @@ public class ClientProducerCreditManagerImpl implements ClientProducerCreditMana
}
}
@Override
public synchronized void reset() {
for (ClientProducerCredits credits : producerCredits.values()) {
credits.reset();
}
}
@Override
public synchronized void close() {
windowSize = -1;
@ -126,10 +132,12 @@ public class ClientProducerCreditManagerImpl implements ClientProducerCreditMana
unReferencedCredits.clear();
}
@Override
public synchronized int creditsMapSize() {
return producerCredits.size();
}
@Override
public synchronized int unReferencedCreditsSize() {
return unReferencedCredits.size();
}
@ -162,35 +170,45 @@ public class ClientProducerCreditManagerImpl implements ClientProducerCreditMana
static ClientProducerCreditsNoFlowControl instance = new ClientProducerCreditsNoFlowControl();
@Override
public void acquireCredits(int credits) throws InterruptedException {
}
@Override
public void receiveCredits(int credits) {
}
@Override
public void receiveFailCredits(int credits) {
}
@Override
public boolean isBlocked() {
return false;
}
@Override
public void init(SessionContext ctx) {
}
@Override
public void reset() {
}
@Override
public void close() {
}
@Override
public void incrementRefCount() {
}
@Override
public int decrementRefCount() {
return 1;
}
@Override
public void releaseOutstanding() {
}

View File

@ -63,6 +63,7 @@ public class ClientProducerCreditsImpl implements ClientProducerCredits {
semaphore = new Semaphore(0, false);
}
@Override
public void init(SessionContext sessionContext) {
// We initial request twice as many credits as we request in subsequent requests
// This allows the producer to keep sending as more arrive, minimising pauses
@ -73,6 +74,7 @@ public class ClientProducerCreditsImpl implements ClientProducerCredits {
this.sessionContext.linkFlowControl(address, this);
}
@Override
public void acquireCredits(final int credits) throws InterruptedException, ActiveMQException {
checkCredits(credits);
@ -117,6 +119,7 @@ public class ClientProducerCreditsImpl implements ClientProducerCredits {
}
}
@Override
public boolean isBlocked() {
return blocked;
}
@ -125,6 +128,7 @@ public class ClientProducerCreditsImpl implements ClientProducerCredits {
return semaphore.availablePermits();
}
@Override
public void receiveCredits(final int credits) {
synchronized (this) {
arriving -= credits;
@ -133,12 +137,14 @@ public class ClientProducerCreditsImpl implements ClientProducerCredits {
semaphore.release(credits);
}
@Override
public void receiveFailCredits(final int credits) {
serverRespondedWithFail = true;
// receive credits like normal to keep the sender from blocking
receiveCredits(credits);
}
@Override
public synchronized void reset() {
// Any pendingCredits credits from before failover won't arrive, so we re-initialise
@ -154,6 +160,7 @@ public class ClientProducerCreditsImpl implements ClientProducerCredits {
checkCredits(Math.max(windowSize * 2, beforeFailure));
}
@Override
public void close() {
// Closing a producer that is blocking should make it return
closed = true;
@ -161,14 +168,17 @@ public class ClientProducerCreditsImpl implements ClientProducerCredits {
semaphore.release(Integer.MAX_VALUE / 2);
}
@Override
public synchronized void incrementRefCount() {
refCount++;
}
@Override
public synchronized int decrementRefCount() {
return --refCount;
}
@Override
public synchronized void releaseOutstanding() {
semaphore.drainPermits();
}

View File

@ -108,22 +108,26 @@ public class ClientProducerImpl implements ClientProducerInternal {
// ClientProducer implementation ----------------------------------------------------------------
@Override
public SimpleString getAddress() {
return address;
}
@Override
public void send(final Message msg) throws ActiveMQException {
checkClosed();
doSend(null, msg, null, false);
}
@Override
public void send(final SimpleString address1, final Message msg) throws ActiveMQException {
checkClosed();
doSend(address1, msg, null, false);
}
@Override
public void send(final String address1, final Message message) throws ActiveMQException {
send(SimpleString.toSimpleString(address1), message);
}
@ -150,6 +154,7 @@ public class ClientProducerImpl implements ClientProducerInternal {
send(null, message, handler);
}
@Override
public synchronized void close() throws ActiveMQException {
if (closed) {
return;
@ -158,6 +163,7 @@ public class ClientProducerImpl implements ClientProducerInternal {
doCleanup();
}
@Override
public void cleanUp() {
if (closed) {
return;
@ -166,24 +172,29 @@ public class ClientProducerImpl implements ClientProducerInternal {
doCleanup();
}
@Override
public boolean isClosed() {
return closed;
}
@Override
public boolean isBlockOnDurableSend() {
return blockOnDurableSend;
}
@Override
public boolean isBlockOnNonDurableSend() {
return blockOnNonDurableSend;
}
@Override
public int getMaxRate() {
return rateLimiter == null ? -1 : rateLimiter.getRate();
}
// Public ---------------------------------------------------------------------------------------
@Override
public ClientProducerCredits getProducerCredits() {
return producerCredits;
}

View File

@ -227,10 +227,12 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C
connectionReadyForWrites = true;
}
@Override
public void disableFinalizeCheck() {
finalizeCheck = false;
}
@Override
public Lock lockFailover() {
newFailoverLock.lock();
return newFailoverLock;
@ -244,6 +246,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C
}
}
@Override
public void connect(final int initialConnectAttempts,
final boolean failoverOnInitialConnection) throws ActiveMQException {
// Get the connection
@ -259,10 +262,12 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C
}
@Override
public TransportConfiguration getConnectorConfiguration() {
return connectorConfig;
}
@Override
public void setBackupConnector(final TransportConfiguration live, final TransportConfiguration backUp) {
Connector localConnector = connector;
@ -290,10 +295,12 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C
}
}
@Override
public Object getBackupConnector() {
return backupConfig;
}
@Override
public ClientSession createSession(final String username,
final String password,
final boolean xa,
@ -304,35 +311,42 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C
return createSessionInternal(username, password, xa, autoCommitSends, autoCommitAcks, preAcknowledge, ackBatchSize);
}
@Override
public ClientSession createSession(final boolean autoCommitSends,
final boolean autoCommitAcks,
final int ackBatchSize) throws ActiveMQException {
return createSessionInternal(null, null, false, autoCommitSends, autoCommitAcks, serverLocator.isPreAcknowledge(), ackBatchSize);
}
@Override
public ClientSession createXASession() throws ActiveMQException {
return createSessionInternal(null, null, true, false, false, serverLocator.isPreAcknowledge(), serverLocator.getAckBatchSize());
}
@Override
public ClientSession createTransactedSession() throws ActiveMQException {
return createSessionInternal(null, null, false, false, false, serverLocator.isPreAcknowledge(), serverLocator.getAckBatchSize());
}
@Override
public ClientSession createSession() throws ActiveMQException {
return createSessionInternal(null, null, false, true, true, serverLocator.isPreAcknowledge(), serverLocator.getAckBatchSize());
}
@Override
public ClientSession createSession(final boolean autoCommitSends,
final boolean autoCommitAcks) throws ActiveMQException {
return createSessionInternal(null, null, false, autoCommitSends, autoCommitAcks, serverLocator.isPreAcknowledge(), serverLocator.getAckBatchSize());
}
@Override
public ClientSession createSession(final boolean xa,
final boolean autoCommitSends,
final boolean autoCommitAcks) throws ActiveMQException {
return createSessionInternal(null, null, xa, autoCommitSends, autoCommitAcks, serverLocator.isPreAcknowledge(), serverLocator.getAckBatchSize());
}
@Override
public ClientSession createSession(final boolean xa,
final boolean autoCommitSends,
final boolean autoCommitAcks,
@ -342,11 +356,13 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C
// ConnectionLifeCycleListener implementation --------------------------------------------------
@Override
public void connectionCreated(final ActiveMQComponent component,
final Connection connection,
final String protocol) {
}
@Override
public void connectionDestroyed(final Object connectionID) {
// The exception has to be created in the same thread where it's being called
// as to avoid a different stack trace cause
@ -355,6 +371,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C
// It has to use the same executor as the disconnect message is being sent through
closeExecutor.execute(new Runnable() {
@Override
public void run() {
handleConnectionFailure(connectionID, ex);
}
@ -362,18 +379,21 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C
}
@Override
public void connectionException(final Object connectionID, final ActiveMQException me) {
handleConnectionFailure(connectionID, me);
}
// Must be synchronized to prevent it happening concurrently with failover which can lead to
// inconsistencies
@Override
public void removeSession(final ClientSessionInternal session, final boolean failingOver) {
synchronized (sessions) {
sessions.remove(session);
}
}
@Override
public void connectionReadyForWrites(final Object connectionID, final boolean ready) {
synchronized (connectionReadyLock) {
if (connectionReadyForWrites != ready) {
@ -385,31 +405,38 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C
}
}
@Override
public synchronized int numConnections() {
return connection != null ? 1 : 0;
}
@Override
public int numSessions() {
return sessions.size();
}
@Override
public void addFailureListener(final SessionFailureListener listener) {
listeners.add(listener);
}
@Override
public boolean removeFailureListener(final SessionFailureListener listener) {
return listeners.remove(listener);
}
@Override
public ClientSessionFactoryImpl addFailoverListener(FailoverEventListener listener) {
failoverListeners.add(listener);
return this;
}
@Override
public boolean removeFailoverListener(FailoverEventListener listener) {
return failoverListeners.remove(listener);
}
@Override
public void causeExit() {
clientProtocolManager.stop();
}
@ -447,6 +474,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C
checkCloseConnection();
}
@Override
public void close() {
if (closed) {
return;
@ -456,6 +484,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C
serverLocator.factoryClosed(this);
}
@Override
public void cleanup() {
if (closed) {
return;
@ -464,6 +493,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C
interruptConnectAndCloseAllSessions(false);
}
@Override
public boolean isClosed() {
return closed || serverLocator.isClosed();
}
@ -856,6 +886,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C
}
}
@Override
public RemotingConnection getConnection() {
if (closed)
throw new IllegalStateException("ClientSessionFactory is closed!");
@ -948,6 +979,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C
// else... we will try to instantiate a new one
return AccessController.doPrivileged(new PrivilegedAction<ConnectorFactory>() {
@Override
public ConnectorFactory run() {
return (ConnectorFactory) ClassloadingUtil.newInstanceFromClassLoader(connectorFactoryClassName);
}
@ -966,6 +998,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C
// Must be executed on new thread since cannot block the Netty thread for a long time and fail
// can cause reconnect loop
@Override
public void run() {
try {
CLOSE_RUNNABLES.add(this);
@ -990,10 +1023,12 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C
}
@Override
public void setReconnectAttempts(final int attempts) {
reconnectAttempts = attempts;
}
@Override
public Object getConnector() {
return connector;
}
@ -1117,6 +1152,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C
private class DelegatingBufferHandler implements BufferHandler {
@Override
public void bufferReceived(final Object connectionID, final ActiveMQBuffer buffer) {
RemotingConnection theConn = connection;
@ -1162,6 +1198,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C
pingRunnable = new WeakReference<PingRunnable>(runnable);
}
@Override
public void run() {
PingRunnable runnable = pingRunnable.get();
@ -1180,6 +1217,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C
private long lastCheck = System.currentTimeMillis();
@Override
public synchronized void run() {
if (cancelled || stopPingingAfterOne && !first) {
return;
@ -1200,6 +1238,7 @@ public class ClientSessionFactoryImpl implements ClientSessionFactoryInternal, C
threadPool.execute(new Runnable() {
// Must be executed on different thread
@Override
public void run() {
connection.fail(me);
}

View File

@ -234,28 +234,33 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
// ClientSession implementation
// -----------------------------------------------------------------
@Override
public void createQueue(final SimpleString address, final SimpleString queueName) throws ActiveMQException {
internalCreateQueue(address, queueName, null, false, false);
}
@Override
public void createQueue(final SimpleString address,
final SimpleString queueName,
final boolean durable) throws ActiveMQException {
internalCreateQueue(address, queueName, null, durable, false);
}
@Override
public void createQueue(final String address,
final String queueName,
final boolean durable) throws ActiveMQException {
createQueue(SimpleString.toSimpleString(address), SimpleString.toSimpleString(queueName), durable);
}
@Override
public void createSharedQueue(SimpleString address,
SimpleString queueName,
boolean durable) throws ActiveMQException {
createSharedQueue(address, queueName, null, durable);
}
@Override
public void createSharedQueue(SimpleString address,
SimpleString queueName,
SimpleString filterString,
@ -273,6 +278,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
}
@Override
public void createQueue(final SimpleString address,
final SimpleString queueName,
final SimpleString filterString,
@ -280,6 +286,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
internalCreateQueue(address, queueName, filterString, durable, false);
}
@Override
public void createQueue(final String address,
final String queueName,
final String filterString,
@ -287,26 +294,31 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
createQueue(SimpleString.toSimpleString(address), SimpleString.toSimpleString(queueName), SimpleString.toSimpleString(filterString), durable);
}
@Override
public void createTemporaryQueue(final SimpleString address, final SimpleString queueName) throws ActiveMQException {
internalCreateQueue(address, queueName, null, false, true);
}
@Override
public void createTemporaryQueue(final String address, final String queueName) throws ActiveMQException {
internalCreateQueue(SimpleString.toSimpleString(address), SimpleString.toSimpleString(queueName), null, false, true);
}
@Override
public void createTemporaryQueue(final SimpleString address,
final SimpleString queueName,
final SimpleString filter) throws ActiveMQException {
internalCreateQueue(address, queueName, filter, false, true);
}
@Override
public void createTemporaryQueue(final String address,
final String queueName,
final String filter) throws ActiveMQException {
internalCreateQueue(SimpleString.toSimpleString(address), SimpleString.toSimpleString(queueName), SimpleString.toSimpleString(filter), false, true);
}
@Override
public void deleteQueue(final SimpleString queueName) throws ActiveMQException {
checkClosed();
@ -319,10 +331,12 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
}
}
@Override
public void deleteQueue(final String queueName) throws ActiveMQException {
deleteQueue(SimpleString.toSimpleString(queueName));
}
@Override
public QueueQuery queueQuery(final SimpleString queueName) throws ActiveMQException {
checkClosed();
@ -336,50 +350,60 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
}
@Override
public AddressQuery addressQuery(final SimpleString address) throws ActiveMQException {
checkClosed();
return sessionContext.addressQuery(address);
}
@Override
public ClientConsumer createConsumer(final SimpleString queueName) throws ActiveMQException {
return createConsumer(queueName, null, false);
}
@Override
public ClientConsumer createConsumer(final String queueName) throws ActiveMQException {
return createConsumer(SimpleString.toSimpleString(queueName));
}
@Override
public ClientConsumer createConsumer(final SimpleString queueName,
final SimpleString filterString) throws ActiveMQException {
return createConsumer(queueName, filterString, consumerWindowSize, consumerMaxRate, false);
}
@Override
public void createQueue(final String address, final String queueName) throws ActiveMQException {
createQueue(SimpleString.toSimpleString(address), SimpleString.toSimpleString(queueName));
}
@Override
public ClientConsumer createConsumer(final String queueName, final String filterString) throws ActiveMQException {
return createConsumer(SimpleString.toSimpleString(queueName), SimpleString.toSimpleString(filterString));
}
@Override
public ClientConsumer createConsumer(final SimpleString queueName,
final SimpleString filterString,
final boolean browseOnly) throws ActiveMQException {
return createConsumer(queueName, filterString, consumerWindowSize, consumerMaxRate, browseOnly);
}
@Override
public ClientConsumer createConsumer(final SimpleString queueName,
final boolean browseOnly) throws ActiveMQException {
return createConsumer(queueName, null, consumerWindowSize, consumerMaxRate, browseOnly);
}
@Override
public ClientConsumer createConsumer(final String queueName,
final String filterString,
final boolean browseOnly) throws ActiveMQException {
return createConsumer(SimpleString.toSimpleString(queueName), SimpleString.toSimpleString(filterString), browseOnly);
}
@Override
public ClientConsumer createConsumer(final String queueName, final boolean browseOnly) throws ActiveMQException {
return createConsumer(SimpleString.toSimpleString(queueName), null, browseOnly);
}
@ -394,6 +418,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
* the client during that period, so failover won't occur. If we want direct consumers we need to
* rethink how they work.
*/
@Override
public ClientConsumer createConsumer(final SimpleString queueName,
final SimpleString filterString,
final int windowSize,
@ -402,6 +427,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
return internalCreateConsumer(queueName, filterString, windowSize, maxRate, browseOnly);
}
@Override
public ClientConsumer createConsumer(final String queueName,
final String filterString,
final int windowSize,
@ -410,18 +436,22 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
return createConsumer(SimpleString.toSimpleString(queueName), SimpleString.toSimpleString(filterString), windowSize, maxRate, browseOnly);
}
@Override
public ClientProducer createProducer() throws ActiveMQException {
return createProducer((SimpleString) null);
}
@Override
public ClientProducer createProducer(final SimpleString address) throws ActiveMQException {
return createProducer(address, producerMaxRate);
}
@Override
public ClientProducer createProducer(final String address) throws ActiveMQException {
return createProducer(SimpleString.toSimpleString(address));
}
@Override
public ClientProducer createProducer(final SimpleString address, final int maxRate) throws ActiveMQException {
return internalCreateProducer(address, maxRate);
}
@ -430,6 +460,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
return createProducer(SimpleString.toSimpleString(address), rate);
}
@Override
public XAResource getXAResource() {
return this;
}
@ -444,6 +475,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
throw ActiveMQClientMessageBundle.BUNDLE.txOutcomeUnknown();
}
@Override
public void commit() throws ActiveMQException {
checkClosed();
@ -490,14 +522,17 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
workDone = false;
}
@Override
public boolean isRollbackOnly() {
return rollbackOnly;
}
@Override
public void rollback() throws ActiveMQException {
rollback(false);
}
@Override
public void rollback(final boolean isLastMessageAsDelivered) throws ActiveMQException {
if (ActiveMQClientLogger.LOGGER.isTraceEnabled()) {
ActiveMQClientLogger.LOGGER.trace("calling rollback(isLastMessageAsDelivered=" + isLastMessageAsDelivered + ")");
@ -532,10 +567,12 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
rollbackOnly = false;
}
@Override
public void markRollbackOnly() {
rollbackOnly = true;
}
@Override
public ClientMessage createMessage(final byte type,
final boolean durable,
final long expiration,
@ -544,34 +581,42 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
return new ClientMessageImpl(type, durable, expiration, timestamp, priority, initialMessagePacketSize);
}
@Override
public ClientMessage createMessage(final byte type, final boolean durable) {
return this.createMessage(type, durable, 0, System.currentTimeMillis(), (byte) 4);
}
@Override
public ClientMessage createMessage(final boolean durable) {
return this.createMessage((byte) 0, durable);
}
@Override
public boolean isClosed() {
return closed;
}
@Override
public boolean isAutoCommitSends() {
return autoCommitSends;
}
@Override
public boolean isAutoCommitAcks() {
return autoCommitAcks;
}
@Override
public boolean isBlockOnAcknowledge() {
return blockOnAcknowledge;
}
@Override
public boolean isXA() {
return xa;
}
@Override
public void resetIfNeeded() throws ActiveMQException {
if (rollbackOnly) {
ActiveMQClientLogger.LOGGER.resettingSessionAfterFailure();
@ -579,6 +624,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
}
}
@Override
public ClientSessionImpl start() throws ActiveMQException {
checkClosed();
@ -595,6 +641,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
return this;
}
@Override
public void stop() throws ActiveMQException {
stop(true);
}
@ -613,26 +660,32 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
}
}
@Override
public void addFailureListener(final SessionFailureListener listener) {
sessionFactory.addFailureListener(listener);
}
@Override
public boolean removeFailureListener(final SessionFailureListener listener) {
return sessionFactory.removeFailureListener(listener);
}
@Override
public void addFailoverListener(FailoverEventListener listener) {
sessionFactory.addFailoverListener(listener);
}
@Override
public boolean removeFailoverListener(FailoverEventListener listener) {
return sessionFactory.removeFailoverListener(listener);
}
@Override
public int getVersion() {
return sessionContext.getServerVersion();
}
@Override
public boolean isClosing() {
return inClose;
}
@ -650,10 +703,12 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
// ClientSessionInternal implementation
// ------------------------------------------------------------
@Override
public int getMinLargeMessageSize() {
return minLargeMessageSize;
}
@Override
public boolean isCompressLargeMessages() {
return compressLargeMessages;
}
@ -661,10 +716,12 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
/**
* @return the cacheLargeMessageClient
*/
@Override
public boolean isCacheLargeMessageClient() {
return cacheLargeMessageClient;
}
@Override
public String getName() {
return name;
}
@ -672,6 +729,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
/**
* Acknowledges all messages received by the consumer so far.
*/
@Override
public void acknowledge(final ClientConsumer consumer, final Message message) throws ActiveMQException {
// if we're pre-acknowledging then we don't need to do anything
if (preAcknowledge) {
@ -692,6 +750,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
}
}
@Override
public void individualAcknowledge(final ClientConsumer consumer, final Message message) throws ActiveMQException {
// if we're pre-acknowledging then we don't need to do anything
if (preAcknowledge) {
@ -710,6 +769,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
}
}
@Override
public void expire(final ClientConsumer consumer, final Message message) throws ActiveMQException {
checkClosed();
@ -719,30 +779,35 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
}
}
@Override
public void addConsumer(final ClientConsumerInternal consumer) {
synchronized (consumers) {
consumers.put(consumer.getConsumerContext(), consumer);
}
}
@Override
public void addProducer(final ClientProducerInternal producer) {
synchronized (producers) {
producers.add(producer);
}
}
@Override
public void removeConsumer(final ClientConsumerInternal consumer) throws ActiveMQException {
synchronized (consumers) {
consumers.remove(consumer.getConsumerContext());
}
}
@Override
public void removeProducer(final ClientProducerInternal producer) {
synchronized (producers) {
producers.remove(producer);
}
}
@Override
public void handleReceiveMessage(final ConsumerContext consumerID,
final ClientMessageInternal message) throws Exception {
ClientConsumerInternal consumer = getConsumer(consumerID);
@ -752,6 +817,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
}
}
@Override
public void handleReceiveLargeMessage(final ConsumerContext consumerID,
ClientLargeMessageInternal clientLargeMessage,
long largeMessageSize) throws Exception {
@ -762,6 +828,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
}
}
@Override
public void handleReceiveContinuation(final ConsumerContext consumerID,
byte[] chunk,
int flowControlSize,
@ -792,6 +859,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
}
}
@Override
public void close() throws ActiveMQException {
if (closed) {
ActiveMQClientLogger.LOGGER.debug("Session was already closed, giving up now, this=" + this);
@ -821,6 +889,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
doCleanup(false);
}
@Override
public synchronized void cleanUp(boolean failingOver) throws ActiveMQException {
if (closed) {
return;
@ -833,11 +902,13 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
doCleanup(failingOver);
}
@Override
public ClientSessionImpl setSendAcknowledgementHandler(final SendAcknowledgementHandler handler) {
sessionContext.setSendAcknowledgementHandler(handler);
return this;
}
@Override
public void preHandleFailover(RemotingConnection connection) {
// We lock the channel to prevent any packets to be added to the re-send
// cache during the failover process
@ -847,6 +918,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
// Needs to be synchronized to prevent issues with occurring concurrently with close()
@Override
public void handleFailover(final RemotingConnection backupConnection, ActiveMQException cause) {
synchronized (this) {
if (closed) {
@ -947,6 +1019,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
}
@Override
public void addMetaData(String key, String data) throws ActiveMQException {
synchronized (metadata) {
metadata.put(key, data);
@ -955,14 +1028,17 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
sessionContext.addSessionMetadata(key, data);
}
@Override
public void addUniqueMetaData(String key, String data) throws ActiveMQException {
sessionContext.addUniqueMetaData(key, data);
}
@Override
public ClientSessionFactory getSessionFactory() {
return sessionFactory;
}
@Override
public void setAddress(final Message message, final SimpleString address) {
if (defaultAddress == null) {
defaultAddress = address;
@ -979,48 +1055,58 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
}
}
@Override
public void setPacketSize(final int packetSize) {
if (packetSize > this.initialMessagePacketSize) {
this.initialMessagePacketSize = (int) (packetSize * 1.2);
}
}
@Override
public void workDone() {
workDone = true;
}
@Override
public void sendProducerCreditsMessage(final int credits, final SimpleString address) {
sessionContext.sendProducerCreditsMessage(credits, address);
}
@Override
public synchronized ClientProducerCredits getCredits(final SimpleString address, final boolean anon) {
ClientProducerCredits credits = producerCreditManager.getCredits(address, anon, sessionContext);
return credits;
}
@Override
public void returnCredits(final SimpleString address) {
producerCreditManager.returnCredits(address);
}
@Override
public void handleReceiveProducerCredits(final SimpleString address, final int credits) {
producerCreditManager.receiveCredits(address, credits);
}
@Override
public void handleReceiveProducerFailCredits(final SimpleString address, int credits) {
producerCreditManager.receiveFailCredits(address, credits);
}
@Override
public ClientProducerCreditManager getProducerCreditManager() {
return producerCreditManager;
}
@Override
public void startCall() {
if (concurrentCall.incrementAndGet() > 1) {
ActiveMQClientLogger.LOGGER.invalidConcurrentSessionUsage(new Exception("trace"));
}
}
@Override
public void endCall() {
concurrentCall.decrementAndGet();
}
@ -1032,6 +1118,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
// XAResource implementation
// --------------------------------------------------------------------
@Override
public void commit(final Xid xid, final boolean onePhase) throws XAException {
if (ActiveMQClientLogger.LOGGER.isTraceEnabled()) {
ActiveMQClientLogger.LOGGER.trace("call commit(xid=" + convert(xid));
@ -1073,6 +1160,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
}
}
@Override
public void end(final Xid xid, final int flags) throws XAException {
if (ActiveMQClientLogger.LOGGER.isTraceEnabled()) {
ActiveMQClientLogger.LOGGER.trace("Calling end:: " + convert(xid) + ", flags=" + convertTXFlag(flags));
@ -1118,6 +1206,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
}
}
@Override
public void forget(final Xid xid) throws XAException {
checkXA();
startCall();
@ -1138,6 +1227,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
}
}
@Override
public int getTransactionTimeout() throws XAException {
checkXA();
@ -1152,6 +1242,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
}
}
@Override
public boolean setTransactionTimeout(final int seconds) throws XAException {
checkXA();
@ -1166,6 +1257,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
}
}
@Override
public boolean isSameRM(final XAResource xares) throws XAException {
checkXA();
@ -1203,6 +1295,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
return null;
}
@Override
public int prepare(final Xid xid) throws XAException {
checkXA();
if (ActiveMQClientLogger.LOGGER.isTraceEnabled()) {
@ -1269,6 +1362,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
}
}
@Override
public Xid[] recover(final int flags) throws XAException {
checkXA();
@ -1287,6 +1381,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
return new Xid[0];
}
@Override
public void rollback(final Xid xid) throws XAException {
checkXA();
@ -1341,6 +1436,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
}
}
@Override
public void start(final Xid xid, final int flags) throws XAException {
if (ActiveMQClientLogger.LOGGER.isTraceEnabled()) {
ActiveMQClientLogger.LOGGER.trace("Calling start:: " + convert(xid) + " clientXID=" + xid + " flags = " + convertTXFlag(flags));
@ -1388,6 +1484,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
// FailureListener implementation --------------------------------------------
@Override
public void connectionFailed(final ActiveMQException me, boolean failedOver) {
try {
cleanUp(false);
@ -1397,6 +1494,7 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
}
}
@Override
public void connectionFailed(final ActiveMQException me, boolean failedOver, String scaleDownTargetNodeID) {
connectionFailed(me, failedOver);
}
@ -1404,10 +1502,12 @@ public final class ClientSessionImpl implements ClientSessionInternal, FailureLi
// Public
// ----------------------------------------------------------------------------
@Override
public void setForceNotSameRM(final boolean force) {
forceNotSameRM = force;
}
@Override
public RemotingConnection getConnection() {
return sessionContext.getRemotingConnection();
}

View File

@ -47,6 +47,7 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll
/**
*
*/
@Override
public void discardUnusedPackets() {
bufferDelegate.discardUnusedPackets();
}
@ -54,22 +55,27 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll
/**
* Add a buff to the List, or save it to the OutputStream if set
*/
@Override
public void addPacket(byte[] chunk, int flowControlSize, boolean isContinues) {
bufferDelegate.addPacket(chunk, flowControlSize, isContinues);
}
@Override
public synchronized void cancel() {
bufferDelegate.cancel();
}
@Override
public synchronized void close() {
bufferDelegate.cancel();
}
@Override
public void setOutputStream(final OutputStream output) throws ActiveMQException {
bufferDelegate.setOutputStream(new InflaterWriter(output));
}
@Override
public synchronized void saveBuffer(final OutputStream output) throws ActiveMQException {
setOutputStream(output);
waitCompletion(0);
@ -78,6 +84,7 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll
/**
* @param timeWait Milliseconds to Wait. 0 means forever
*/
@Override
public synchronized boolean waitCompletion(final long timeWait) throws ActiveMQException {
return bufferDelegate.waitCompletion(timeWait);
}
@ -108,6 +115,7 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll
throw new IllegalStateException("Position not supported over compressed large messages");
}
@Override
public byte readByte() {
try {
return getStream().readByte();
@ -196,82 +204,102 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}
@Override
public int readerIndex() {
return 0;
}
@Override
public void readerIndex(final int readerIndex) {
// TODO
}
@Override
public int writerIndex() {
// TODO
return 0;
}
@Override
public long getSize() {
return this.bufferDelegate.getSize();
}
@Override
public void writerIndex(final int writerIndex) {
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}
@Override
public void setIndex(final int readerIndex, final int writerIndex) {
positioningNotSupported();
}
@Override
public void clear() {
}
@Override
public boolean readable() {
return true;
}
@Override
public boolean writable() {
return false;
}
@Override
public int readableBytes() {
return 1;
}
@Override
public int writableBytes() {
return 0;
}
@Override
public void markReaderIndex() {
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}
@Override
public void resetReaderIndex() {
// TODO: reset positioning if possible
}
@Override
public void markWriterIndex() {
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}
@Override
public void resetWriterIndex() {
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}
@Override
public void discardReadBytes() {
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}
@Override
public short getUnsignedByte(final int index) {
return (short) (getByte(index) & 0xFF);
}
@Override
public int getUnsignedShort(final int index) {
return getShort(index) & 0xFFFF;
}
@Override
public long getUnsignedInt(final int index) {
return getInt(index) & 0xFFFFFFFFL;
}
@Override
public void getBytes(int index, final byte[] dst) {
// TODO: optimize this by using System.arraycopy
for (int i = 0; i < dst.length; i++) {
@ -279,10 +307,12 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll
}
}
@Override
public void getBytes(final int index, final ActiveMQBuffer dst) {
getBytes(index, dst, dst.writableBytes());
}
@Override
public void getBytes(final int index, final ActiveMQBuffer dst, final int length) {
if (length > dst.writableBytes()) {
throw new IndexOutOfBoundsException();
@ -291,18 +321,22 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll
dst.writerIndex(dst.writerIndex() + length);
}
@Override
public void setBytes(final int index, final byte[] src) {
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}
@Override
public void setBytes(final int index, final ActiveMQBuffer src) {
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}
@Override
public void setBytes(final int index, final ActiveMQBuffer src, final int length) {
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}
@Override
public int readUnsignedByte() {
try {
return getStream().readUnsignedByte();
@ -312,6 +346,7 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll
}
}
@Override
public short readShort() {
try {
return getStream().readShort();
@ -321,6 +356,7 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll
}
}
@Override
public int readUnsignedShort() {
try {
return getStream().readUnsignedShort();
@ -330,6 +366,7 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll
}
}
@Override
public int readInt() {
try {
return getStream().readInt();
@ -339,10 +376,12 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll
}
}
@Override
public long readUnsignedInt() {
return readInt() & 0xFFFFFFFFL;
}
@Override
public long readLong() {
try {
return getStream().readLong();
@ -352,6 +391,7 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll
}
}
@Override
public void readBytes(final byte[] dst, final int dstIndex, final int length) {
try {
int nReadBytes = getStream().read(dst, dstIndex, length);
@ -364,14 +404,17 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll
}
}
@Override
public void readBytes(final byte[] dst) {
readBytes(dst, 0, dst.length);
}
@Override
public void readBytes(final ActiveMQBuffer dst) {
readBytes(dst, dst.writableBytes());
}
@Override
public void readBytes(final ActiveMQBuffer dst, final int length) {
if (length > dst.writableBytes()) {
throw new IndexOutOfBoundsException();
@ -380,18 +423,21 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll
dst.writerIndex(dst.writerIndex() + length);
}
@Override
public void readBytes(final ActiveMQBuffer dst, final int dstIndex, final int length) {
byte[] destBytes = new byte[length];
readBytes(destBytes);
dst.setBytes(dstIndex, destBytes);
}
@Override
public void readBytes(final ByteBuffer dst) {
byte[] bytesToGet = new byte[dst.remaining()];
readBytes(bytesToGet);
dst.put(bytesToGet);
}
@Override
public int skipBytes(final int length) {
try {
@ -425,38 +471,47 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll
}
@Override
public void writeByte(final byte value) {
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}
@Override
public void writeShort(final short value) {
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}
@Override
public void writeInt(final int value) {
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}
@Override
public void writeLong(final long value) {
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}
@Override
public void writeBytes(final byte[] src, final int srcIndex, final int length) {
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}
@Override
public void writeBytes(final byte[] src) {
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}
@Override
public void writeBytes(final ActiveMQBuffer src, final int length) {
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}
@Override
public void writeBytes(final ByteBuffer src) {
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}
@Override
public ByteBuffer toByteBuffer() {
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}
@ -475,18 +530,22 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll
return (char) readShort();
}
@Override
public char getChar(final int index) {
return (char) getShort(index);
}
@Override
public double getDouble(final int index) {
return Double.longBitsToDouble(getLong(index));
}
@Override
public float getFloat(final int index) {
return Float.intBitsToFloat(getInt(index));
}
@Override
public ActiveMQBuffer readBytes(final int length) {
byte[] bytesToGet = new byte[length];
readBytes(bytesToGet);
@ -604,48 +663,59 @@ final class CompressedLargeMessageControllerImpl implements LargeMessageControll
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}
@Override
public ActiveMQBuffer copy() {
throw new UnsupportedOperationException();
}
@Override
public ActiveMQBuffer slice(final int index, final int length) {
throw new UnsupportedOperationException();
}
// Inner classes -------------------------------------------------
@Override
public ByteBuf byteBuf() {
return null;
}
@Override
public ActiveMQBuffer copy(final int index, final int length) {
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}
@Override
public ActiveMQBuffer duplicate() {
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}
@Override
public ActiveMQBuffer readSlice(final int length) {
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}
@Override
public void setChar(final int index, final char value) {
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}
@Override
public void setDouble(final int index, final double value) {
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}
@Override
public void setFloat(final int index, final float value) {
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}
@Override
public ActiveMQBuffer slice() {
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}
@Override
public void writeBytes(final ActiveMQBuffer src, final int srcIndex, final int length) {
throw new IllegalAccessError(OPERATION_NOT_SUPPORTED);
}

View File

@ -90,10 +90,12 @@ public class DelegatingSession implements ClientSessionInternal {
}
}
@Override
public boolean isClosing() {
return session.isClosing();
}
@Override
public void acknowledge(final ClientConsumer consumer, final Message message) throws ActiveMQException {
session.acknowledge(consumer, message);
}
@ -103,34 +105,42 @@ public class DelegatingSession implements ClientSessionInternal {
session.addLifeCycleListener(lifeCycleListener);
}
@Override
public void individualAcknowledge(final ClientConsumer consumer, final Message message) throws ActiveMQException {
session.individualAcknowledge(consumer, message);
}
@Override
public void addConsumer(final ClientConsumerInternal consumer) {
session.addConsumer(consumer);
}
@Override
public void addFailureListener(final SessionFailureListener listener) {
session.addFailureListener(listener);
}
@Override
public void addFailoverListener(FailoverEventListener listener) {
session.addFailoverListener(listener);
}
@Override
public void addProducer(final ClientProducerInternal producer) {
session.addProducer(producer);
}
@Override
public AddressQuery addressQuery(final SimpleString address) throws ActiveMQException {
return session.addressQuery(address);
}
@Override
public void cleanUp(boolean failingOver) throws ActiveMQException {
session.cleanUp(failingOver);
}
@Override
public void close() throws ActiveMQException {
closed = true;
@ -141,22 +151,27 @@ public class DelegatingSession implements ClientSessionInternal {
session.close();
}
@Override
public void markRollbackOnly() {
session.markRollbackOnly();
}
@Override
public void commit() throws ActiveMQException {
session.commit();
}
@Override
public void commit(final Xid xid, final boolean onePhase) throws XAException {
session.commit(xid, onePhase);
}
@Override
public ClientMessage createMessage(final boolean durable) {
return session.createMessage(durable);
}
@Override
public ClientMessage createMessage(final byte type,
final boolean durable,
final long expiration,
@ -165,16 +180,19 @@ public class DelegatingSession implements ClientSessionInternal {
return session.createMessage(type, durable, expiration, timestamp, priority);
}
@Override
public ClientMessage createMessage(final byte type, final boolean durable) {
return session.createMessage(type, durable);
}
@Override
public ClientConsumer createConsumer(final SimpleString queueName,
final SimpleString filterString,
final boolean browseOnly) throws ActiveMQException {
return session.createConsumer(queueName, filterString, browseOnly);
}
@Override
public ClientConsumer createConsumer(final SimpleString queueName,
final SimpleString filterString,
final int windowSize,
@ -183,21 +201,25 @@ public class DelegatingSession implements ClientSessionInternal {
return session.createConsumer(queueName, filterString, windowSize, maxRate, browseOnly);
}
@Override
public ClientConsumer createConsumer(final SimpleString queueName,
final SimpleString filterString) throws ActiveMQException {
return session.createConsumer(queueName, filterString);
}
@Override
public ClientConsumer createConsumer(final SimpleString queueName) throws ActiveMQException {
return session.createConsumer(queueName);
}
@Override
public ClientConsumer createConsumer(final String queueName,
final String filterString,
final boolean browseOnly) throws ActiveMQException {
return session.createConsumer(queueName, filterString, browseOnly);
}
@Override
public ClientConsumer createConsumer(final String queueName,
final String filterString,
final int windowSize,
@ -206,47 +228,58 @@ public class DelegatingSession implements ClientSessionInternal {
return session.createConsumer(queueName, filterString, windowSize, maxRate, browseOnly);
}
@Override
public ClientConsumer createConsumer(final String queueName, final String filterString) throws ActiveMQException {
return session.createConsumer(queueName, filterString);
}
@Override
public ClientConsumer createConsumer(final String queueName) throws ActiveMQException {
return session.createConsumer(queueName);
}
@Override
public ClientConsumer createConsumer(final SimpleString queueName,
final boolean browseOnly) throws ActiveMQException {
return session.createConsumer(queueName, browseOnly);
}
@Override
public ClientConsumer createConsumer(final String queueName, final boolean browseOnly) throws ActiveMQException {
return session.createConsumer(queueName, browseOnly);
}
@Override
public ClientProducer createProducer() throws ActiveMQException {
return session.createProducer();
}
@Override
public ClientProducer createProducer(final SimpleString address, final int rate) throws ActiveMQException {
return session.createProducer(address, rate);
}
@Override
public ClientProducer createProducer(final SimpleString address) throws ActiveMQException {
return session.createProducer(address);
}
@Override
public ClientProducer createProducer(final String address) throws ActiveMQException {
return session.createProducer(address);
}
@Override
public void createQueue(final String address, final String queueName) throws ActiveMQException {
session.createQueue(address, queueName);
}
@Override
public void createQueue(final SimpleString address, final SimpleString queueName) throws ActiveMQException {
session.createQueue(address, queueName);
}
@Override
public void createQueue(final SimpleString address,
final SimpleString queueName,
final boolean durable) throws ActiveMQException {
@ -268,6 +301,7 @@ public class DelegatingSession implements ClientSessionInternal {
session.createSharedQueue(address, queueName, filter, durable);
}
@Override
public void createQueue(final SimpleString address,
final SimpleString queueName,
final SimpleString filterString,
@ -275,12 +309,14 @@ public class DelegatingSession implements ClientSessionInternal {
session.createQueue(address, queueName, filterString, durable);
}
@Override
public void createQueue(final String address,
final String queueName,
final boolean durable) throws ActiveMQException {
session.createQueue(address, queueName, durable);
}
@Override
public void createQueue(final String address,
final String queueName,
final String filterString,
@ -288,74 +324,91 @@ public class DelegatingSession implements ClientSessionInternal {
session.createQueue(address, queueName, filterString, durable);
}
@Override
public void createTemporaryQueue(final SimpleString address,
final SimpleString queueName,
final SimpleString filter) throws ActiveMQException {
session.createTemporaryQueue(address, queueName, filter);
}
@Override
public void createTemporaryQueue(final SimpleString address, final SimpleString queueName) throws ActiveMQException {
session.createTemporaryQueue(address, queueName);
}
@Override
public void createTemporaryQueue(final String address,
final String queueName,
final String filter) throws ActiveMQException {
session.createTemporaryQueue(address, queueName, filter);
}
@Override
public void createTemporaryQueue(final String address, final String queueName) throws ActiveMQException {
session.createTemporaryQueue(address, queueName);
}
@Override
public void deleteQueue(final SimpleString queueName) throws ActiveMQException {
session.deleteQueue(queueName);
}
@Override
public void deleteQueue(final String queueName) throws ActiveMQException {
session.deleteQueue(queueName);
}
@Override
public void end(final Xid xid, final int flags) throws XAException {
session.end(xid, flags);
}
@Override
public void expire(final ClientConsumer consumer, final Message message) throws ActiveMQException {
session.expire(consumer, message);
}
@Override
public void forget(final Xid xid) throws XAException {
session.forget(xid);
}
@Override
public RemotingConnection getConnection() {
return session.getConnection();
}
@Override
public int getMinLargeMessageSize() {
return session.getMinLargeMessageSize();
}
@Override
public String getName() {
return session.getName();
}
@Override
public int getTransactionTimeout() throws XAException {
return session.getTransactionTimeout();
}
@Override
public int getVersion() {
return session.getVersion();
}
@Override
public XAResource getXAResource() {
return session.getXAResource();
}
@Override
public void preHandleFailover(RemotingConnection connection) {
session.preHandleFailover(connection);
}
@Override
public void handleFailover(final RemotingConnection backupConnection, ActiveMQException cause) {
session.handleFailover(backupConnection, cause);
}
@ -385,152 +438,189 @@ public class DelegatingSession implements ClientSessionInternal {
session.handleConsumerDisconnect(consumerContext);
}
@Override
public boolean isAutoCommitAcks() {
return session.isAutoCommitAcks();
}
@Override
public boolean isAutoCommitSends() {
return session.isAutoCommitSends();
}
@Override
public boolean isBlockOnAcknowledge() {
return session.isBlockOnAcknowledge();
}
@Override
public boolean isCacheLargeMessageClient() {
return session.isCacheLargeMessageClient();
}
@Override
public boolean isClosed() {
return session.isClosed();
}
@Override
public boolean isSameRM(final XAResource xares) throws XAException {
return session.isSameRM(xares);
}
@Override
public boolean isXA() {
return session.isXA();
}
@Override
public int prepare(final Xid xid) throws XAException {
return session.prepare(xid);
}
@Override
public QueueQuery queueQuery(final SimpleString queueName) throws ActiveMQException {
return session.queueQuery(queueName);
}
@Override
public Xid[] recover(final int flag) throws XAException {
return session.recover(flag);
}
@Override
public void removeConsumer(final ClientConsumerInternal consumer) throws ActiveMQException {
session.removeConsumer(consumer);
}
@Override
public boolean removeFailureListener(final SessionFailureListener listener) {
return session.removeFailureListener(listener);
}
@Override
public boolean removeFailoverListener(FailoverEventListener listener) {
return session.removeFailoverListener(listener);
}
@Override
public void removeProducer(final ClientProducerInternal producer) {
session.removeProducer(producer);
}
@Override
public void rollback() throws ActiveMQException {
session.rollback();
}
@Override
public boolean isRollbackOnly() {
return session.isRollbackOnly();
}
@Override
public void rollback(final boolean considerLastMessageAsDelivered) throws ActiveMQException {
session.rollback(considerLastMessageAsDelivered);
}
@Override
public void rollback(final Xid xid) throws XAException {
session.rollback(xid);
}
@Override
public DelegatingSession setSendAcknowledgementHandler(final SendAcknowledgementHandler handler) {
session.setSendAcknowledgementHandler(handler);
return this;
}
@Override
public boolean setTransactionTimeout(final int seconds) throws XAException {
return session.setTransactionTimeout(seconds);
}
@Override
public void resetIfNeeded() throws ActiveMQException {
session.resetIfNeeded();
}
@Override
public DelegatingSession start() throws ActiveMQException {
session.start();
return this;
}
@Override
public void start(final Xid xid, final int flags) throws XAException {
session.start(xid, flags);
}
@Override
public void stop() throws ActiveMQException {
session.stop();
}
@Override
public ClientSessionFactory getSessionFactory() {
return session.getSessionFactory();
}
@Override
public void setForceNotSameRM(final boolean force) {
session.setForceNotSameRM(force);
}
@Override
public void workDone() {
session.workDone();
}
@Override
public void sendProducerCreditsMessage(final int credits, final SimpleString address) {
session.sendProducerCreditsMessage(credits, address);
}
@Override
public ClientProducerCredits getCredits(final SimpleString address, final boolean anon) {
return session.getCredits(address, anon);
}
@Override
public void returnCredits(final SimpleString address) {
session.returnCredits(address);
}
@Override
public void handleReceiveProducerCredits(final SimpleString address, final int credits) {
session.handleReceiveProducerCredits(address, credits);
}
@Override
public void handleReceiveProducerFailCredits(final SimpleString address, final int credits) {
session.handleReceiveProducerFailCredits(address, credits);
}
@Override
public ClientProducerCreditManager getProducerCreditManager() {
return session.getProducerCreditManager();
}
@Override
public void setAddress(Message message, SimpleString address) {
session.setAddress(message, address);
}
@Override
public void setPacketSize(int packetSize) {
session.setPacketSize(packetSize);
}
@Override
public void addMetaData(String key, String data) throws ActiveMQException {
session.addMetaData(key, data);
}
@Override
public boolean isCompressLargeMessages() {
return session.isCompressLargeMessages();
}
@ -546,10 +636,12 @@ public class DelegatingSession implements ClientSessionInternal {
}
@Override
public void startCall() {
session.startCall();
}
@Override
public void endCall() {
session.endCall();
}

View File

@ -134,6 +134,7 @@ public class LargeMessageControllerImpl implements LargeMessageController {
this.local = local;
}
@Override
public void discardUnusedPackets() {
if (outStream == null) {
if (local)
@ -150,6 +151,7 @@ public class LargeMessageControllerImpl implements LargeMessageController {
* TODO: move this to ConsumerContext as large message is a protocol specific thing
* Add a buff to the List, or save it to the OutputStream if set
*/
@Override
public void addPacket(byte[] chunk, int flowControlSize, boolean isContinues) {
int flowControlCredit = 0;
@ -206,6 +208,7 @@ public class LargeMessageControllerImpl implements LargeMessageController {
}
}
@Override
public void cancel() {
this.handledException = ActiveMQClientMessageBundle.BUNDLE.largeMessageInterrupted();
@ -232,12 +235,14 @@ public class LargeMessageControllerImpl implements LargeMessageController {
}
}
@Override
public synchronized void close() {
if (fileCache != null) {
fileCache.close();
}
}
@Override
public void setOutputStream(final OutputStream output) throws ActiveMQException {
int totalFlowControl = 0;
@ -268,6 +273,7 @@ public class LargeMessageControllerImpl implements LargeMessageController {
}
}
@Override
public synchronized void saveBuffer(final OutputStream output) throws ActiveMQException {
if (streamClosed) {
throw ActiveMQClientMessageBundle.BUNDLE.largeMessageLostSession();
@ -280,6 +286,7 @@ public class LargeMessageControllerImpl implements LargeMessageController {
* @param timeWait Milliseconds to Wait. 0 means forever
* @throws ActiveMQException
*/
@Override
public synchronized boolean waitCompletion(final long timeWait) throws ActiveMQException {
if (outStream == null) {
// There is no stream.. it will never achieve the end of streaming
@ -344,6 +351,7 @@ public class LargeMessageControllerImpl implements LargeMessageController {
return -1;
}
@Override
public byte readByte() {
return getByte(readerIndex++);
}
@ -425,6 +433,7 @@ public class LargeMessageControllerImpl implements LargeMessageController {
return out.write(ByteBuffer.wrap(bytesToGet));
}
@Override
public int getInt(final int index) {
return (getByte(index) & 0xff) << 24 | (getByte(index + 1) & 0xff) << 16 |
(getByte(index + 2) & 0xff) << 8 |
@ -515,10 +524,12 @@ public class LargeMessageControllerImpl implements LargeMessageController {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@Override
public int readerIndex() {
return (int) readerIndex;
}
@Override
public void readerIndex(final int readerIndex) {
try {
checkForPacket(readerIndex);
@ -530,18 +541,22 @@ public class LargeMessageControllerImpl implements LargeMessageController {
this.readerIndex = readerIndex;
}
@Override
public int writerIndex() {
return (int) totalSize;
}
@Override
public long getSize() {
return totalSize;
}
@Override
public void writerIndex(final int writerIndex) {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@Override
public void setIndex(final int readerIndex, final int writerIndex) {
try {
checkForPacket(readerIndex);
@ -553,17 +568,21 @@ public class LargeMessageControllerImpl implements LargeMessageController {
this.readerIndex = readerIndex;
}
@Override
public void clear() {
}
@Override
public boolean readable() {
return true;
}
@Override
public boolean writable() {
return false;
}
@Override
public int readableBytes() {
long readableBytes = totalSize - readerIndex;
@ -575,14 +594,17 @@ public class LargeMessageControllerImpl implements LargeMessageController {
}
}
@Override
public int writableBytes() {
return 0;
}
@Override
public void markReaderIndex() {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@Override
public void resetReaderIndex() {
try {
checkForPacket(0);
@ -593,22 +615,27 @@ public class LargeMessageControllerImpl implements LargeMessageController {
}
}
@Override
public void markWriterIndex() {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@Override
public void resetWriterIndex() {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@Override
public void discardReadBytes() {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@Override
public short getUnsignedByte(final int index) {
return (short) (getByte(index) & 0xFF);
}
@Override
public int getUnsignedShort(final int index) {
return getShort(index) & 0xFFFF;
}
@ -621,10 +648,12 @@ public class LargeMessageControllerImpl implements LargeMessageController {
return value;
}
@Override
public long getUnsignedInt(final int index) {
return getInt(index) & 0xFFFFFFFFL;
}
@Override
public void getBytes(int index, final byte[] dst) {
// TODO: optimize this by using System.arraycopy
for (int i = 0; i < dst.length; i++) {
@ -639,10 +668,12 @@ public class LargeMessageControllerImpl implements LargeMessageController {
}
}
@Override
public void getBytes(final int index, final ActiveMQBuffer dst) {
getBytes(index, dst, dst.writableBytes());
}
@Override
public void getBytes(final int index, final ActiveMQBuffer dst, final int length) {
if (length > dst.writableBytes()) {
throw new IndexOutOfBoundsException();
@ -651,14 +682,17 @@ public class LargeMessageControllerImpl implements LargeMessageController {
dst.writerIndex(dst.writerIndex() + length);
}
@Override
public void setBytes(final int index, final byte[] src) {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@Override
public void setBytes(final int index, final ActiveMQBuffer src) {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@Override
public void setBytes(final int index, final ActiveMQBuffer src, final int length) {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@ -667,16 +701,19 @@ public class LargeMessageControllerImpl implements LargeMessageController {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@Override
public int readUnsignedByte() {
return (short) (readByte() & 0xFF);
}
@Override
public short readShort() {
short v = getShort(readerIndex);
readerIndex += 2;
return v;
}
@Override
public int readUnsignedShort() {
return readShort() & 0xFFFF;
}
@ -695,6 +732,7 @@ public class LargeMessageControllerImpl implements LargeMessageController {
return v;
}
@Override
public int readInt() {
int v = getInt(readerIndex);
readerIndex += 4;
@ -706,29 +744,35 @@ public class LargeMessageControllerImpl implements LargeMessageController {
return v;
}
@Override
public long readUnsignedInt() {
return readInt() & 0xFFFFFFFFL;
}
@Override
public long readLong() {
long v = getLong(readerIndex);
readerIndex += 8;
return v;
}
@Override
public void readBytes(final byte[] dst, final int dstIndex, final int length) {
getBytes(readerIndex, dst, dstIndex, length);
readerIndex += length;
}
@Override
public void readBytes(final byte[] dst) {
readBytes(dst, 0, dst.length);
}
@Override
public void readBytes(final ActiveMQBuffer dst) {
readBytes(dst, dst.writableBytes());
}
@Override
public void readBytes(final ActiveMQBuffer dst, final int length) {
if (length > dst.writableBytes()) {
throw new IndexOutOfBoundsException();
@ -737,11 +781,13 @@ public class LargeMessageControllerImpl implements LargeMessageController {
dst.writerIndex(dst.writerIndex() + length);
}
@Override
public void readBytes(final ActiveMQBuffer dst, final int dstIndex, final int length) {
getBytes(readerIndex, dst, dstIndex, length);
readerIndex += length;
}
@Override
public void readBytes(final ByteBuffer dst) {
int length = dst.remaining();
getBytes(readerIndex, dst);
@ -759,6 +805,7 @@ public class LargeMessageControllerImpl implements LargeMessageController {
readerIndex += length;
}
@Override
public int skipBytes(final int length) {
long newReaderIndex = readerIndex + length;
@ -767,10 +814,12 @@ public class LargeMessageControllerImpl implements LargeMessageController {
return length;
}
@Override
public void writeByte(final byte value) {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@Override
public void writeShort(final short value) {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@ -779,18 +828,22 @@ public class LargeMessageControllerImpl implements LargeMessageController {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@Override
public void writeInt(final int value) {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@Override
public void writeLong(final long value) {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@Override
public void writeBytes(final byte[] src, final int srcIndex, final int length) {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@Override
public void writeBytes(final byte[] src) {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@ -799,10 +852,12 @@ public class LargeMessageControllerImpl implements LargeMessageController {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@Override
public void writeBytes(final ActiveMQBuffer src, final int length) {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@Override
public void writeBytes(final ByteBuffer src) {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@ -819,6 +874,7 @@ public class LargeMessageControllerImpl implements LargeMessageController {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@Override
public ByteBuffer toByteBuffer() {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@ -849,18 +905,22 @@ public class LargeMessageControllerImpl implements LargeMessageController {
return (char) readShort();
}
@Override
public char getChar(final int index) {
return (char) getShort(index);
}
@Override
public double getDouble(final int index) {
return Double.longBitsToDouble(getLong(index));
}
@Override
public float getFloat(final int index) {
return Float.intBitsToFloat(getInt(index));
}
@Override
public ActiveMQBuffer readBytes(final int length) {
byte[] bytesToGet = new byte[length];
getBytes(readerIndex, bytesToGet);
@ -979,10 +1039,12 @@ public class LargeMessageControllerImpl implements LargeMessageController {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@Override
public ActiveMQBuffer copy() {
throw new UnsupportedOperationException();
}
@Override
public ActiveMQBuffer slice(final int index, final int length) {
throw new UnsupportedOperationException();
}
@ -1198,38 +1260,47 @@ public class LargeMessageControllerImpl implements LargeMessageController {
return ByteUtil.readLine(this);
}
@Override
public ByteBuf byteBuf() {
return null;
}
@Override
public ActiveMQBuffer copy(final int index, final int length) {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@Override
public ActiveMQBuffer duplicate() {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@Override
public ActiveMQBuffer readSlice(final int length) {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@Override
public void setChar(final int index, final char value) {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@Override
public void setDouble(final int index, final double value) {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@Override
public void setFloat(final int index, final float value) {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@Override
public ActiveMQBuffer slice() {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}
@Override
public void writeBytes(final ActiveMQBuffer src, final int srcIndex, final int length) {
throw new IllegalAccessError(LargeMessageControllerImpl.READ_ONLY_ERROR_MESSAGE);
}

View File

@ -70,38 +70,47 @@ public class QueueQueryImpl implements ClientSession.QueueQuery {
this.autoCreateJmsQueues = autoCreateJmsQueues;
}
@Override
public SimpleString getName() {
return name;
}
@Override
public SimpleString getAddress() {
return address;
}
@Override
public int getConsumerCount() {
return consumerCount;
}
@Override
public SimpleString getFilterString() {
return filterString;
}
@Override
public long getMessageCount() {
return messageCount;
}
@Override
public boolean isDurable() {
return durable;
}
@Override
public boolean isAutoCreateJmsQueues() {
return autoCreateJmsQueues;
}
@Override
public boolean isTemporary() {
return temporary;
}
@Override
public boolean isExists() {
return exists;
}

View File

@ -314,6 +314,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
throw new IllegalStateException("Please specify a load balancing policy class name on the session factory");
}
AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override
public Object run() {
loadBalancingPolicy = (ConnectionLoadBalancingPolicy) ClassloadingUtil.newInstanceFromClassLoader(connectionLoadBalancingPolicyClassName);
return null;
@ -500,6 +501,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
this(topology, useHA, null, transportConfigs);
}
@Override
public void resetToInitialConnectors() {
synchronized (topologyArrayGuard) {
receivedTopology = false;
@ -511,6 +513,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
/*
* I'm not using isAllInVM here otherwsie BeanProperties would translate this as a property for the URL
*/
@Override
public boolean allInVM() {
for (TransportConfiguration config : getStaticTransportConfigurations()) {
if (!config.getFactoryClassName().contains("InVMConnectorFactory")) {
@ -597,6 +600,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
}
}
@Override
public void start(Executor executor) throws Exception {
initialise();
@ -604,6 +608,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
if (executor != null) {
executor.execute(new Runnable() {
@Override
public void run() {
try {
connect();
@ -618,10 +623,12 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
}
}
@Override
public ClientProtocolManager newProtocolManager() {
return getProtocolManagerFactory().newProtocolManager();
}
@Override
public ClientProtocolManagerFactory getProtocolManagerFactory() {
if (protocolManagerFactory == null) {
// Default one in case it's null
@ -630,12 +637,14 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
return protocolManagerFactory;
}
@Override
public ServerLocator setProtocolManagerFactory(ClientProtocolManagerFactory protocolManagerFactory) {
this.protocolManagerFactory = protocolManagerFactory;
protocolManagerFactory.setLocator(this);
return this;
}
@Override
public void disableFinalizeCheck() {
finalizeCheck = false;
}
@ -670,15 +679,18 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
return connect(true);
}
@Override
public ServerLocatorImpl setAfterConnectionInternalListener(AfterConnectInternalListener listener) {
this.afterConnectListener = listener;
return this;
}
@Override
public AfterConnectInternalListener getAfterConnectInternalListener() {
return afterConnectListener;
}
@Override
public ClientSessionFactory createSessionFactory(String nodeID) throws Exception {
TopologyMember topologyMember = topology.getMember(nodeID);
@ -705,6 +717,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
return null;
}
@Override
public ClientSessionFactory createSessionFactory(final TransportConfiguration transportConfiguration) throws Exception {
assertOpen();
@ -730,6 +743,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
}
}
@Override
public ClientSessionFactory createSessionFactory(final TransportConfiguration transportConfiguration,
int reconnectAttempts,
boolean failoverOnInitialConnection) throws Exception {
@ -770,6 +784,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
}
}
@Override
public ClientSessionFactory createSessionFactory() throws ActiveMQException {
assertOpen();
@ -902,327 +917,393 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
return fromInterceptors(outgoingInterceptors);
}
@Override
public boolean isCacheLargeMessagesClient() {
return cacheLargeMessagesClient;
}
@Override
public ServerLocatorImpl setCacheLargeMessagesClient(final boolean cached) {
cacheLargeMessagesClient = cached;
return this;
}
@Override
public long getClientFailureCheckPeriod() {
return clientFailureCheckPeriod;
}
@Override
public ServerLocatorImpl setClientFailureCheckPeriod(final long clientFailureCheckPeriod) {
checkWrite();
this.clientFailureCheckPeriod = clientFailureCheckPeriod;
return this;
}
@Override
public long getConnectionTTL() {
return connectionTTL;
}
@Override
public ServerLocatorImpl setConnectionTTL(final long connectionTTL) {
checkWrite();
this.connectionTTL = connectionTTL;
return this;
}
@Override
public long getCallTimeout() {
return callTimeout;
}
@Override
public ServerLocatorImpl setCallTimeout(final long callTimeout) {
checkWrite();
this.callTimeout = callTimeout;
return this;
}
@Override
public long getCallFailoverTimeout() {
return callFailoverTimeout;
}
@Override
public ServerLocatorImpl setCallFailoverTimeout(long callFailoverTimeout) {
checkWrite();
this.callFailoverTimeout = callFailoverTimeout;
return this;
}
@Override
public int getMinLargeMessageSize() {
return minLargeMessageSize;
}
@Override
public ServerLocatorImpl setMinLargeMessageSize(final int minLargeMessageSize) {
checkWrite();
this.minLargeMessageSize = minLargeMessageSize;
return this;
}
@Override
public int getConsumerWindowSize() {
return consumerWindowSize;
}
@Override
public ServerLocatorImpl setConsumerWindowSize(final int consumerWindowSize) {
checkWrite();
this.consumerWindowSize = consumerWindowSize;
return this;
}
@Override
public int getConsumerMaxRate() {
return consumerMaxRate;
}
@Override
public ServerLocatorImpl setConsumerMaxRate(final int consumerMaxRate) {
checkWrite();
this.consumerMaxRate = consumerMaxRate;
return this;
}
@Override
public int getConfirmationWindowSize() {
return confirmationWindowSize;
}
@Override
public ServerLocatorImpl setConfirmationWindowSize(final int confirmationWindowSize) {
checkWrite();
this.confirmationWindowSize = confirmationWindowSize;
return this;
}
@Override
public int getProducerWindowSize() {
return producerWindowSize;
}
@Override
public ServerLocatorImpl setProducerWindowSize(final int producerWindowSize) {
checkWrite();
this.producerWindowSize = producerWindowSize;
return this;
}
@Override
public int getProducerMaxRate() {
return producerMaxRate;
}
@Override
public ServerLocatorImpl setProducerMaxRate(final int producerMaxRate) {
checkWrite();
this.producerMaxRate = producerMaxRate;
return this;
}
@Override
public boolean isBlockOnAcknowledge() {
return blockOnAcknowledge;
}
@Override
public ServerLocatorImpl setBlockOnAcknowledge(final boolean blockOnAcknowledge) {
checkWrite();
this.blockOnAcknowledge = blockOnAcknowledge;
return this;
}
@Override
public boolean isBlockOnDurableSend() {
return blockOnDurableSend;
}
@Override
public ServerLocatorImpl setBlockOnDurableSend(final boolean blockOnDurableSend) {
checkWrite();
this.blockOnDurableSend = blockOnDurableSend;
return this;
}
@Override
public boolean isBlockOnNonDurableSend() {
return blockOnNonDurableSend;
}
@Override
public ServerLocatorImpl setBlockOnNonDurableSend(final boolean blockOnNonDurableSend) {
checkWrite();
this.blockOnNonDurableSend = blockOnNonDurableSend;
return this;
}
@Override
public boolean isAutoGroup() {
return autoGroup;
}
@Override
public ServerLocatorImpl setAutoGroup(final boolean autoGroup) {
checkWrite();
this.autoGroup = autoGroup;
return this;
}
@Override
public boolean isPreAcknowledge() {
return preAcknowledge;
}
@Override
public ServerLocatorImpl setPreAcknowledge(final boolean preAcknowledge) {
checkWrite();
this.preAcknowledge = preAcknowledge;
return this;
}
@Override
public int getAckBatchSize() {
return ackBatchSize;
}
@Override
public ServerLocatorImpl setAckBatchSize(final int ackBatchSize) {
checkWrite();
this.ackBatchSize = ackBatchSize;
return this;
}
@Override
public boolean isUseGlobalPools() {
return useGlobalPools;
}
@Override
public ServerLocatorImpl setUseGlobalPools(final boolean useGlobalPools) {
checkWrite();
this.useGlobalPools = useGlobalPools;
return this;
}
@Override
public int getScheduledThreadPoolMaxSize() {
return scheduledThreadPoolMaxSize;
}
@Override
public ServerLocatorImpl setScheduledThreadPoolMaxSize(final int scheduledThreadPoolMaxSize) {
checkWrite();
this.scheduledThreadPoolMaxSize = scheduledThreadPoolMaxSize;
return this;
}
@Override
public int getThreadPoolMaxSize() {
return threadPoolMaxSize;
}
@Override
public ServerLocatorImpl setThreadPoolMaxSize(final int threadPoolMaxSize) {
checkWrite();
this.threadPoolMaxSize = threadPoolMaxSize;
return this;
}
@Override
public long getRetryInterval() {
return retryInterval;
}
@Override
public ServerLocatorImpl setRetryInterval(final long retryInterval) {
checkWrite();
this.retryInterval = retryInterval;
return this;
}
@Override
public long getMaxRetryInterval() {
return maxRetryInterval;
}
@Override
public ServerLocatorImpl setMaxRetryInterval(final long retryInterval) {
checkWrite();
maxRetryInterval = retryInterval;
return this;
}
@Override
public double getRetryIntervalMultiplier() {
return retryIntervalMultiplier;
}
@Override
public ServerLocatorImpl setRetryIntervalMultiplier(final double retryIntervalMultiplier) {
checkWrite();
this.retryIntervalMultiplier = retryIntervalMultiplier;
return this;
}
@Override
public int getReconnectAttempts() {
return reconnectAttempts;
}
@Override
public ServerLocatorImpl setReconnectAttempts(final int reconnectAttempts) {
checkWrite();
this.reconnectAttempts = reconnectAttempts;
return this;
}
@Override
public ServerLocatorImpl setInitialConnectAttempts(int initialConnectAttempts) {
checkWrite();
this.initialConnectAttempts = initialConnectAttempts;
return this;
}
@Override
public int getInitialConnectAttempts() {
return initialConnectAttempts;
}
@Override
public boolean isFailoverOnInitialConnection() {
return this.failoverOnInitialConnection;
}
@Override
public ServerLocatorImpl setFailoverOnInitialConnection(final boolean failover) {
checkWrite();
this.failoverOnInitialConnection = failover;
return this;
}
@Override
public String getConnectionLoadBalancingPolicyClassName() {
return connectionLoadBalancingPolicyClassName;
}
@Override
public ServerLocatorImpl setConnectionLoadBalancingPolicyClassName(final String loadBalancingPolicyClassName) {
checkWrite();
connectionLoadBalancingPolicyClassName = loadBalancingPolicyClassName;
return this;
}
@Override
public TransportConfiguration[] getStaticTransportConfigurations() {
if (initialConnectors == null)
return new TransportConfiguration[]{};
return Arrays.copyOf(initialConnectors, initialConnectors.length);
}
@Override
public DiscoveryGroupConfiguration getDiscoveryGroupConfiguration() {
return discoveryGroupConfiguration;
}
@Override
public ServerLocatorImpl addIncomingInterceptor(final Interceptor interceptor) {
incomingInterceptors.add(interceptor);
return this;
}
@Override
public ServerLocatorImpl addOutgoingInterceptor(final Interceptor interceptor) {
outgoingInterceptors.add(interceptor);
return this;
}
@Override
public boolean removeIncomingInterceptor(final Interceptor interceptor) {
return incomingInterceptors.remove(interceptor);
}
@Override
public boolean removeOutgoingInterceptor(final Interceptor interceptor) {
return outgoingInterceptors.remove(interceptor);
}
@Override
public int getInitialMessagePacketSize() {
return initialMessagePacketSize;
}
@Override
public ServerLocatorImpl setInitialMessagePacketSize(final int size) {
checkWrite();
initialMessagePacketSize = size;
return this;
}
@Override
public ServerLocatorImpl setGroupID(final String groupID) {
checkWrite();
this.groupID = groupID;
return this;
}
@Override
public String getGroupID() {
return groupID;
}
@Override
public boolean isCompressLargeMessage() {
return compressLargeMessage;
}
@Override
public ServerLocatorImpl setCompressLargeMessage(boolean avoid) {
this.compressLargeMessage = avoid;
return this;
@ -1242,33 +1323,40 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
return initialConnectors.length;
}
@Override
public ServerLocatorImpl setIdentity(String identity) {
this.identity = identity;
return this;
}
@Override
public ServerLocatorImpl setNodeID(String nodeID) {
this.nodeID = nodeID;
return this;
}
@Override
public String getNodeID() {
return nodeID;
}
@Override
public ServerLocatorImpl setClusterConnection(boolean clusterConnection) {
this.clusterConnection = clusterConnection;
return this;
}
@Override
public boolean isClusterConnection() {
return clusterConnection;
}
@Override
public TransportConfiguration getClusterTransportConfiguration() {
return clusterTransportConfiguration;
}
@Override
public ServerLocatorImpl setClusterTransportConfiguration(TransportConfiguration tc) {
this.clusterTransportConfiguration = tc;
return this;
@ -1283,10 +1371,12 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
super.finalize();
}
@Override
public void cleanup() {
doClose(false);
}
@Override
public void close() {
doClose(true);
}
@ -1428,6 +1518,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
}
@Override
public void notifyNodeUp(long uniqueEventID,
final String nodeID,
final String backupGroupName,
@ -1498,6 +1589,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
}
}
@Override
public synchronized void connectorsChanged(List<DiscoveryEntry> newConnectors) {
if (receivedTopology) {
return;
@ -1522,6 +1614,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
// to trigger the node notification to form the cluster.
Runnable connectRunnable = new Runnable() {
@Override
public void run() {
try {
connect();
@ -1540,6 +1633,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
}
}
@Override
public void factoryClosed(final ClientSessionFactory factory) {
boolean isEmpty;
synchronized (factories) {
@ -1557,6 +1651,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
}
}
@Override
public Topology getTopology() {
return topology;
}
@ -1566,11 +1661,13 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
return getNumInitialConnectors() > 0 || getDiscoveryGroupConfiguration() != null;
}
@Override
public ServerLocatorImpl addClusterTopologyListener(final ClusterTopologyListener listener) {
topology.addClusterTopologyListener(listener);
return this;
}
@Override
public void removeClusterTopologyListener(final ClusterTopologyListener listener) {
topology.removeClusterTopologyListener(listener);
}
@ -1799,6 +1896,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
}
}
@Override
public boolean isClosed() {
synchronized (stateGuard) {
return state != STATE.INITIALIZED;
@ -1835,6 +1933,7 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
return;
}
AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override
public Object run() {
String[] arrayInterceptor = interceptorList.split(",");

View File

@ -81,6 +81,7 @@ public interface ServerLocatorInternal extends ServerLocator {
ServerLocatorInternal setClusterTransportConfiguration(TransportConfiguration tc);
@Override
Topology getTopology();
ClientProtocolManager newProtocolManager();

View File

@ -58,6 +58,7 @@ public final class Topology {
private static final class DirectExecutor implements Executor {
@Override
public void execute(final Runnable runnable) {
runnable.run();
}
@ -246,6 +247,7 @@ public final class Topology {
if (copy.size() > 0) {
executor.execute(new Runnable() {
@Override
public void run() {
for (ClusterTopologyListener listener : copy) {
if (ActiveMQClientLogger.LOGGER.isTraceEnabled()) {
@ -311,6 +313,7 @@ public final class Topology {
final ArrayList<ClusterTopologyListener> copy = copyListeners();
executor.execute(new Runnable() {
@Override
public void run() {
for (ClusterTopologyListener listener : copy) {
if (ActiveMQClientLogger.LOGGER.isTraceEnabled()) {
@ -335,6 +338,7 @@ public final class Topology {
}
executor.execute(new Runnable() {
@Override
public void run() {
int count = 0;

View File

@ -99,6 +99,7 @@ public final class TopologyMemberImpl implements TopologyMember {
return connector;
}
@Override
public boolean isMember(RemotingConnection connection) {
TransportConfiguration connectorConfig = connection.getTransportConnection() != null ? connection.getTransportConnection().getConnectorConfig() : null;
@ -106,6 +107,7 @@ public final class TopologyMemberImpl implements TopologyMember {
}
@Override
public boolean isMember(TransportConfiguration configuration) {
if (getConnector().getA() != null && getConnector().getA().isSameParams(configuration) || getConnector().getB() != null && getConnector().getB().isSameParams(configuration)) {
return true;

View File

@ -95,6 +95,7 @@ public final class DiscoveryGroup implements ActiveMQComponent {
this.notificationService = service;
}
@Override
public synchronized void start() throws Exception {
if (started) {
return;
@ -132,6 +133,7 @@ public final class DiscoveryGroup implements ActiveMQComponent {
runnable.run();
}
@Override
public void stop() {
synchronized (this) {
if (!started) {
@ -180,6 +182,7 @@ public final class DiscoveryGroup implements ActiveMQComponent {
}
}
@Override
public boolean isStarted() {
return started;
}
@ -245,6 +248,7 @@ public final class DiscoveryGroup implements ActiveMQComponent {
class DiscoveryRunnable implements Runnable {
@Override
public void run() {
byte[] data = null;

View File

@ -170,6 +170,7 @@ public abstract class MessageImpl implements MessageInternal {
// Message implementation ----------------------------------------
@Override
public int getEncodeSize() {
int headersPropsSize = getHeadersAndPropertiesEncodeSize();
@ -180,6 +181,7 @@ public abstract class MessageImpl implements MessageInternal {
return DataConstants.SIZE_INT + bodySize + DataConstants.SIZE_INT + headersPropsSize;
}
@Override
public int getHeadersAndPropertiesEncodeSize() {
return DataConstants.SIZE_LONG + // Message ID
DataConstants.SIZE_BYTE + // user id null?
@ -193,6 +195,7 @@ public abstract class MessageImpl implements MessageInternal {
/* PropertySize and Properties */properties.getEncodeSize();
}
@Override
public void encodeHeadersAndProperties(final ActiveMQBuffer buffer) {
buffer.writeLong(messageID);
buffer.writeNullableSimpleString(address);
@ -211,6 +214,7 @@ public abstract class MessageImpl implements MessageInternal {
properties.encode(buffer);
}
@Override
public void decodeHeadersAndProperties(final ActiveMQBuffer buffer) {
messageID = buffer.readLong();
address = buffer.readNullableSimpleString();
@ -242,6 +246,7 @@ public abstract class MessageImpl implements MessageInternal {
properties = msg.getTypedProperties();
}
@Override
public ActiveMQBuffer getBodyBuffer() {
if (bodyBuffer == null) {
bodyBuffer = new ResetLimitWrappedActiveMQBuffer(BODY_OFFSET, buffer, this);
@ -250,12 +255,14 @@ public abstract class MessageImpl implements MessageInternal {
return bodyBuffer;
}
@Override
public Message writeBodyBufferBytes(byte[] bytes) {
getBodyBuffer().writeBytes(bytes);
return this;
}
@Override
public Message writeBodyBufferString(String string) {
getBodyBuffer().writeString(string);
@ -266,6 +273,7 @@ public abstract class MessageImpl implements MessageInternal {
// no op on regular messages
}
@Override
public synchronized ActiveMQBuffer getBodyBufferCopy() {
// Must copy buffer before sending it
@ -276,14 +284,17 @@ public abstract class MessageImpl implements MessageInternal {
return new ResetLimitWrappedActiveMQBuffer(BODY_OFFSET, newBuffer, null);
}
@Override
public long getMessageID() {
return messageID;
}
@Override
public UUID getUserID() {
return userID;
}
@Override
public MessageImpl setUserID(final UUID userID) {
this.userID = userID;
return this;
@ -293,6 +304,7 @@ public abstract class MessageImpl implements MessageInternal {
* this doesn't need to be synchronized as setAddress is protecting the buffer,
* not the address
*/
@Override
public SimpleString getAddress() {
return address;
}
@ -302,6 +314,7 @@ public abstract class MessageImpl implements MessageInternal {
* This synchronization can probably be removed since setAddress is always called from a single thread.
* However I will keep it as it's harmless and it's been well tested
*/
@Override
public Message setAddress(final SimpleString address) {
// This is protecting the buffer
synchronized (this) {
@ -315,6 +328,7 @@ public abstract class MessageImpl implements MessageInternal {
return this;
}
@Override
public byte getType() {
return type;
}
@ -323,10 +337,12 @@ public abstract class MessageImpl implements MessageInternal {
this.type = type;
}
@Override
public boolean isDurable() {
return durable;
}
@Override
public MessageImpl setDurable(final boolean durable) {
if (this.durable != durable) {
this.durable = durable;
@ -336,10 +352,12 @@ public abstract class MessageImpl implements MessageInternal {
return this;
}
@Override
public long getExpiration() {
return expiration;
}
@Override
public MessageImpl setExpiration(final long expiration) {
if (this.expiration != expiration) {
this.expiration = expiration;
@ -349,10 +367,12 @@ public abstract class MessageImpl implements MessageInternal {
return this;
}
@Override
public long getTimestamp() {
return timestamp;
}
@Override
public MessageImpl setTimestamp(final long timestamp) {
if (this.timestamp != timestamp) {
this.timestamp = timestamp;
@ -362,10 +382,12 @@ public abstract class MessageImpl implements MessageInternal {
return this;
}
@Override
public byte getPriority() {
return priority;
}
@Override
public MessageImpl setPriority(final byte priority) {
if (this.priority != priority) {
this.priority = priority;
@ -375,6 +397,7 @@ public abstract class MessageImpl implements MessageInternal {
return this;
}
@Override
public boolean isExpired() {
if (expiration == 0) {
return false;
@ -383,6 +406,7 @@ public abstract class MessageImpl implements MessageInternal {
return System.currentTimeMillis() - expiration >= 0;
}
@Override
public Map<String, Object> toMap() {
Map<String, Object> map = new HashMap<String, Object>();
@ -402,12 +426,14 @@ public abstract class MessageImpl implements MessageInternal {
return map;
}
@Override
public void decodeFromBuffer(final ActiveMQBuffer buffer) {
this.buffer = buffer;
decode();
}
@Override
public void bodyChanged() {
// If the body is changed we must copy the buffer otherwise can affect the previously sent message
// which might be in the Netty write queue
@ -418,6 +444,7 @@ public abstract class MessageImpl implements MessageInternal {
endOfBodyPosition = -1;
}
@Override
public synchronized void checkCopy() {
if (!copied) {
forceCopy();
@ -426,14 +453,17 @@ public abstract class MessageImpl implements MessageInternal {
}
}
@Override
public synchronized void resetCopied() {
copied = false;
}
@Override
public int getEndOfMessagePosition() {
return endOfMessagePosition;
}
@Override
public int getEndOfBodyPosition() {
if (endOfBodyPosition < 0) {
endOfBodyPosition = buffer.writerIndex();
@ -467,6 +497,7 @@ public abstract class MessageImpl implements MessageInternal {
buff.readerIndex(start + length);
}
@Override
public synchronized ActiveMQBuffer getEncodedBuffer() {
ActiveMQBuffer buff = encodeToBuffer();
@ -486,6 +517,7 @@ public abstract class MessageImpl implements MessageInternal {
}
}
@Override
public void setAddressTransient(final SimpleString address) {
this.address = address;
}
@ -493,6 +525,7 @@ public abstract class MessageImpl implements MessageInternal {
// Properties
// ---------------------------------------------------------------------------------------
@Override
public Message putBooleanProperty(final SimpleString key, final boolean value) {
properties.putBooleanProperty(key, value);
@ -501,6 +534,7 @@ public abstract class MessageImpl implements MessageInternal {
return this;
}
@Override
public Message putByteProperty(final SimpleString key, final byte value) {
properties.putByteProperty(key, value);
@ -509,6 +543,7 @@ public abstract class MessageImpl implements MessageInternal {
return this;
}
@Override
public Message putBytesProperty(final SimpleString key, final byte[] value) {
properties.putBytesProperty(key, value);
@ -533,6 +568,7 @@ public abstract class MessageImpl implements MessageInternal {
return this;
}
@Override
public Message putShortProperty(final SimpleString key, final short value) {
properties.putShortProperty(key, value);
bufferValid = false;
@ -540,6 +576,7 @@ public abstract class MessageImpl implements MessageInternal {
return this;
}
@Override
public Message putIntProperty(final SimpleString key, final int value) {
properties.putIntProperty(key, value);
bufferValid = false;
@ -547,6 +584,7 @@ public abstract class MessageImpl implements MessageInternal {
return this;
}
@Override
public Message putLongProperty(final SimpleString key, final long value) {
properties.putLongProperty(key, value);
bufferValid = false;
@ -554,6 +592,7 @@ public abstract class MessageImpl implements MessageInternal {
return this;
}
@Override
public Message putFloatProperty(final SimpleString key, final float value) {
properties.putFloatProperty(key, value);
@ -562,6 +601,7 @@ public abstract class MessageImpl implements MessageInternal {
return this;
}
@Override
public Message putDoubleProperty(final SimpleString key, final double value) {
properties.putDoubleProperty(key, value);
@ -570,6 +610,7 @@ public abstract class MessageImpl implements MessageInternal {
return this;
}
@Override
public Message putStringProperty(final SimpleString key, final SimpleString value) {
properties.putSimpleStringProperty(key, value);
@ -578,6 +619,7 @@ public abstract class MessageImpl implements MessageInternal {
return this;
}
@Override
public Message putObjectProperty(final SimpleString key,
final Object value) throws ActiveMQPropertyConversionException {
TypedProperties.setObjectProperty(key, value, properties);
@ -586,6 +628,7 @@ public abstract class MessageImpl implements MessageInternal {
return this;
}
@Override
public Message putObjectProperty(final String key, final Object value) throws ActiveMQPropertyConversionException {
putObjectProperty(new SimpleString(key), value);
@ -594,6 +637,7 @@ public abstract class MessageImpl implements MessageInternal {
return this;
}
@Override
public Message putBooleanProperty(final String key, final boolean value) {
properties.putBooleanProperty(new SimpleString(key), value);
@ -602,6 +646,7 @@ public abstract class MessageImpl implements MessageInternal {
return this;
}
@Override
public Message putByteProperty(final String key, final byte value) {
properties.putByteProperty(new SimpleString(key), value);
@ -610,6 +655,7 @@ public abstract class MessageImpl implements MessageInternal {
return this;
}
@Override
public Message putBytesProperty(final String key, final byte[] value) {
properties.putBytesProperty(new SimpleString(key), value);
@ -618,6 +664,7 @@ public abstract class MessageImpl implements MessageInternal {
return this;
}
@Override
public Message putShortProperty(final String key, final short value) {
properties.putShortProperty(new SimpleString(key), value);
@ -626,6 +673,7 @@ public abstract class MessageImpl implements MessageInternal {
return this;
}
@Override
public Message putIntProperty(final String key, final int value) {
properties.putIntProperty(new SimpleString(key), value);
@ -634,6 +682,7 @@ public abstract class MessageImpl implements MessageInternal {
return this;
}
@Override
public Message putLongProperty(final String key, final long value) {
properties.putLongProperty(new SimpleString(key), value);
@ -642,6 +691,7 @@ public abstract class MessageImpl implements MessageInternal {
return this;
}
@Override
public Message putFloatProperty(final String key, final float value) {
properties.putFloatProperty(new SimpleString(key), value);
@ -650,6 +700,7 @@ public abstract class MessageImpl implements MessageInternal {
return this;
}
@Override
public Message putDoubleProperty(final String key, final double value) {
properties.putDoubleProperty(new SimpleString(key), value);
@ -658,6 +709,7 @@ public abstract class MessageImpl implements MessageInternal {
return this;
}
@Override
public Message putStringProperty(final String key, final String value) {
properties.putSimpleStringProperty(new SimpleString(key), SimpleString.toSimpleString(value));
@ -674,74 +726,92 @@ public abstract class MessageImpl implements MessageInternal {
return this;
}
@Override
public Object getObjectProperty(final SimpleString key) {
return properties.getProperty(key);
}
@Override
public Boolean getBooleanProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
return properties.getBooleanProperty(key);
}
@Override
public Boolean getBooleanProperty(final String key) throws ActiveMQPropertyConversionException {
return properties.getBooleanProperty(new SimpleString(key));
}
@Override
public Byte getByteProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
return properties.getByteProperty(key);
}
@Override
public Byte getByteProperty(final String key) throws ActiveMQPropertyConversionException {
return properties.getByteProperty(new SimpleString(key));
}
@Override
public byte[] getBytesProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
return properties.getBytesProperty(key);
}
@Override
public byte[] getBytesProperty(final String key) throws ActiveMQPropertyConversionException {
return getBytesProperty(new SimpleString(key));
}
@Override
public Double getDoubleProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
return properties.getDoubleProperty(key);
}
@Override
public Double getDoubleProperty(final String key) throws ActiveMQPropertyConversionException {
return properties.getDoubleProperty(new SimpleString(key));
}
@Override
public Integer getIntProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
return properties.getIntProperty(key);
}
@Override
public Integer getIntProperty(final String key) throws ActiveMQPropertyConversionException {
return properties.getIntProperty(new SimpleString(key));
}
@Override
public Long getLongProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
return properties.getLongProperty(key);
}
@Override
public Long getLongProperty(final String key) throws ActiveMQPropertyConversionException {
return properties.getLongProperty(new SimpleString(key));
}
@Override
public Short getShortProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
return properties.getShortProperty(key);
}
@Override
public Short getShortProperty(final String key) throws ActiveMQPropertyConversionException {
return properties.getShortProperty(new SimpleString(key));
}
@Override
public Float getFloatProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
return properties.getFloatProperty(key);
}
@Override
public Float getFloatProperty(final String key) throws ActiveMQPropertyConversionException {
return properties.getFloatProperty(new SimpleString(key));
}
@Override
public String getStringProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
SimpleString str = getSimpleStringProperty(key);
@ -753,54 +823,66 @@ public abstract class MessageImpl implements MessageInternal {
}
}
@Override
public String getStringProperty(final String key) throws ActiveMQPropertyConversionException {
return getStringProperty(new SimpleString(key));
}
@Override
public SimpleString getSimpleStringProperty(final SimpleString key) throws ActiveMQPropertyConversionException {
return properties.getSimpleStringProperty(key);
}
@Override
public SimpleString getSimpleStringProperty(final String key) throws ActiveMQPropertyConversionException {
return properties.getSimpleStringProperty(new SimpleString(key));
}
@Override
public Object getObjectProperty(final String key) {
return properties.getProperty(new SimpleString(key));
}
@Override
public Object removeProperty(final SimpleString key) {
bufferValid = false;
return properties.removeProperty(key);
}
@Override
public Object removeProperty(final String key) {
bufferValid = false;
return properties.removeProperty(new SimpleString(key));
}
@Override
public boolean containsProperty(final SimpleString key) {
return properties.containsProperty(key);
}
@Override
public boolean containsProperty(final String key) {
return properties.containsProperty(new SimpleString(key));
}
@Override
public Set<SimpleString> getPropertyNames() {
return properties.getPropertyNames();
}
@Override
public ActiveMQBuffer getWholeBuffer() {
return buffer;
}
@Override
public BodyEncoder getBodyEncoder() throws ActiveMQException {
return new DecodingContext();
}
@Override
public TypedProperties getTypedProperties() {
return this.properties;
}
@ -956,21 +1038,26 @@ public abstract class MessageImpl implements MessageInternal {
public DecodingContext() {
}
@Override
public void open() {
}
@Override
public void close() {
}
@Override
public long getLargeBodySize() {
return buffer.writerIndex();
}
@Override
public int encode(final ByteBuffer bufferRead) throws ActiveMQException {
ActiveMQBuffer buffer = ActiveMQBuffers.wrappedBuffer(bufferRead);
return encode(buffer, bufferRead.capacity());
}
@Override
public int encode(final ActiveMQBuffer bufferOut, final int size) {
bufferOut.writeBytes(getWholeBuffer(), lastPos, size);
lastPos += size;

View File

@ -109,14 +109,17 @@ public class ActiveMQClientProtocolManager implements ClientProtocolManager {
public ActiveMQClientProtocolManager() {
}
@Override
public String getName() {
return ActiveMQClient.DEFAULT_CORE_PROTOCOL;
}
@Override
public void setSessionFactory(ClientSessionFactory factory) {
this.factoryInternal = (ClientSessionFactoryInternal) factory;
}
@Override
public ClientSessionFactory getSessionFactory() {
return this.factoryInternal;
}
@ -126,6 +129,7 @@ public class ActiveMQClientProtocolManager implements ClientProtocolManager {
pipeline.addLast("activemq-decoder", new ActiveMQFrameDecoder2());
}
@Override
public boolean waitOnLatch(long milliseconds) throws InterruptedException {
return waitLatch.await(milliseconds, TimeUnit.MILLISECONDS);
}
@ -139,6 +143,7 @@ public class ActiveMQClientProtocolManager implements ClientProtocolManager {
}
}
@Override
public RemotingConnection getCurrentConnection() {
return connection;
}
@ -152,6 +157,7 @@ public class ActiveMQClientProtocolManager implements ClientProtocolManager {
}
}
@Override
public Lock lockSessionCreation() {
try {
Lock localFailoverLock = factoryInternal.lockFailover();
@ -179,6 +185,7 @@ public class ActiveMQClientProtocolManager implements ClientProtocolManager {
}
}
@Override
public void stop() {
alive = false;
@ -196,6 +203,7 @@ public class ActiveMQClientProtocolManager implements ClientProtocolManager {
}
@Override
public boolean isAlive() {
return alive;
}
@ -351,6 +359,7 @@ public class ActiveMQClientProtocolManager implements ClientProtocolManager {
return new ActiveMQSessionContext(name, connection, sessionChannel, response.getServerVersion(), confirmationWindowSize);
}
@Override
public boolean cleanupBeforeFailover(ActiveMQException cause) {
boolean needToInterrupt;
@ -401,6 +410,7 @@ public class ActiveMQClientProtocolManager implements ClientProtocolManager {
return message.isOkToFailover();
}
@Override
public RemotingConnection connect(Connection transportConnection,
long callTimeout,
long callFailoverTimeout,
@ -435,6 +445,7 @@ public class ActiveMQClientProtocolManager implements ClientProtocolManager {
this.conn = conn;
}
@Override
public void handlePacket(final Packet packet) {
final byte type = packet.getType();

View File

@ -45,6 +45,7 @@ public class ActiveMQClientProtocolManagerFactory implements ClientProtocolManag
return factory;
}
@Override
public ClientProtocolManager newProtocolManager() {
return new ActiveMQClientProtocolManager();
}

View File

@ -122,6 +122,7 @@ public class ActiveMQSessionContext extends SessionContext {
return name;
}
@Override
public void resetName(String name) {
this.name = name;
}
@ -153,6 +154,7 @@ public class ActiveMQSessionContext extends SessionContext {
}
private final CommandConfirmationHandler confirmationHandler = new CommandConfirmationHandler() {
@Override
public void commandConfirmed(final Packet packet) {
if (packet.getType() == PacketImpl.SESS_SEND) {
SessionSendMessage ssm = (SessionSendMessage) packet;
@ -195,6 +197,7 @@ public class ActiveMQSessionContext extends SessionContext {
sessionChannel.unlock();
}
@Override
public void cleanup() {
sessionChannel.close();
@ -208,11 +211,13 @@ public class ActiveMQSessionContext extends SessionContext {
// nothing to be done here... Flow control here is done on the core side
}
@Override
public void setSendAcknowledgementHandler(final SendAcknowledgementHandler handler) {
sessionChannel.setCommandConfirmationHandler(confirmationHandler);
this.sendAckHandler = handler;
}
@Override
public void createSharedQueue(SimpleString address,
SimpleString queueName,
SimpleString filterString,
@ -220,10 +225,12 @@ public class ActiveMQSessionContext extends SessionContext {
sessionChannel.sendBlocking(new CreateSharedQueueMessage(address, queueName, filterString, durable, true), PacketImpl.NULL_RESPONSE);
}
@Override
public void deleteQueue(final SimpleString queueName) throws ActiveMQException {
sessionChannel.sendBlocking(new SessionDeleteQueueMessage(queueName), PacketImpl.NULL_RESPONSE);
}
@Override
public ClientSession.QueueQuery queueQuery(final SimpleString queueName) throws ActiveMQException {
SessionQueueQueryMessage request = new SessionQueueQueryMessage(queueName);
SessionQueueQueryResponseMessage_V2 response = (SessionQueueQueryResponseMessage_V2) sessionChannel.sendBlocking(request, PacketImpl.SESS_QUEUEQUERY_RESP_V2);
@ -231,6 +238,7 @@ public class ActiveMQSessionContext extends SessionContext {
return response.toQueueQuery();
}
@Override
public ClientConsumerInternal createConsumer(SimpleString queueName,
SimpleString filterString,
int windowSize,
@ -254,10 +262,12 @@ public class ActiveMQSessionContext extends SessionContext {
return new ClientConsumerImpl(session, consumerContext, queueName, filterString, browseOnly, calcWindowSize(windowSize), ackBatchSize, maxRate > 0 ? new TokenBucketLimiterImpl(maxRate, false) : null, executor, flowControlExecutor, this, queueInfo.toQueueQuery(), lookupTCCL());
}
@Override
public int getServerVersion() {
return serverVersion;
}
@Override
public ClientSession.AddressQuery addressQuery(final SimpleString address) throws ActiveMQException {
SessionBindingQueryResponseMessage_V2 response = (SessionBindingQueryResponseMessage_V2) sessionChannel.sendBlocking(new SessionBindingQueryMessage(address), PacketImpl.SESS_BINDINGQUERY_RESP_V2);
@ -269,39 +279,48 @@ public class ActiveMQSessionContext extends SessionContext {
sessionChannel.sendBlocking(new SessionConsumerCloseMessage(getConsumerID(consumer)), PacketImpl.NULL_RESPONSE);
}
@Override
public void sendConsumerCredits(final ClientConsumer consumer, final int credits) {
sessionChannel.send(new SessionConsumerFlowCreditMessage(getConsumerID(consumer), credits));
}
@Override
public void forceDelivery(final ClientConsumer consumer, final long sequence) throws ActiveMQException {
SessionForceConsumerDelivery request = new SessionForceConsumerDelivery(getConsumerID(consumer), sequence);
sessionChannel.send(request);
}
@Override
public void simpleCommit() throws ActiveMQException {
sessionChannel.sendBlocking(new PacketImpl(PacketImpl.SESS_COMMIT), PacketImpl.NULL_RESPONSE);
}
@Override
public void simpleRollback(boolean lastMessageAsDelivered) throws ActiveMQException {
sessionChannel.sendBlocking(new RollbackMessage(lastMessageAsDelivered), PacketImpl.NULL_RESPONSE);
}
@Override
public void sessionStart() throws ActiveMQException {
sessionChannel.send(new PacketImpl(PacketImpl.SESS_START));
}
@Override
public void sessionStop() throws ActiveMQException {
sessionChannel.sendBlocking(new PacketImpl(PacketImpl.SESS_STOP), PacketImpl.NULL_RESPONSE);
}
@Override
public void addSessionMetadata(String key, String data) throws ActiveMQException {
sessionChannel.sendBlocking(new SessionAddMetaDataMessageV2(key, data), PacketImpl.NULL_RESPONSE);
}
@Override
public void addUniqueMetaData(String key, String data) throws ActiveMQException {
sessionChannel.sendBlocking(new SessionUniqueAddMetaDataMessage(key, data), PacketImpl.NULL_RESPONSE);
}
@Override
public void xaCommit(Xid xid, boolean onePhase) throws XAException, ActiveMQException {
SessionXACommitMessage packet = new SessionXACommitMessage(xid, onePhase);
SessionXAResponseMessage response = (SessionXAResponseMessage) sessionChannel.sendBlocking(packet, PacketImpl.SESS_XA_RESP);
@ -315,6 +334,7 @@ public class ActiveMQSessionContext extends SessionContext {
}
}
@Override
public void xaEnd(Xid xid, int flags) throws XAException, ActiveMQException {
Packet packet;
if (flags == XAResource.TMSUSPEND) {
@ -337,6 +357,7 @@ public class ActiveMQSessionContext extends SessionContext {
}
}
@Override
public void sendProducerCreditsMessage(final int credits, final SimpleString address) {
sessionChannel.send(new SessionRequestProducerCreditsMessage(credits, address));
}
@ -346,6 +367,7 @@ public class ActiveMQSessionContext extends SessionContext {
*
* @return
*/
@Override
public boolean supportsLargeMessage() {
return true;
}
@ -355,6 +377,7 @@ public class ActiveMQSessionContext extends SessionContext {
return msgI.getEncodeSize();
}
@Override
public void sendFullMessage(MessageInternal msgI,
boolean sendBlocking,
SendAcknowledgementHandler handler,
@ -399,6 +422,7 @@ public class ActiveMQSessionContext extends SessionContext {
return chunkPacket.getPacketSize();
}
@Override
public void sendACK(boolean individual,
boolean block,
final ClientConsumer consumer,
@ -419,16 +443,19 @@ public class ActiveMQSessionContext extends SessionContext {
}
}
@Override
public void expireMessage(final ClientConsumer consumer, Message message) throws ActiveMQException {
SessionExpireMessage messagePacket = new SessionExpireMessage(getConsumerID(consumer), message.getMessageID());
sessionChannel.send(messagePacket);
}
@Override
public void sessionClose() throws ActiveMQException {
sessionChannel.sendBlocking(new SessionCloseMessage(), PacketImpl.NULL_RESPONSE);
}
@Override
public void xaForget(Xid xid) throws XAException, ActiveMQException {
SessionXAResponseMessage response = (SessionXAResponseMessage) sessionChannel.sendBlocking(new SessionXAForgetMessage(xid), PacketImpl.SESS_XA_RESP);
@ -437,6 +464,7 @@ public class ActiveMQSessionContext extends SessionContext {
}
}
@Override
public int xaPrepare(Xid xid) throws XAException, ActiveMQException {
SessionXAPrepareMessage packet = new SessionXAPrepareMessage(xid);
@ -450,6 +478,7 @@ public class ActiveMQSessionContext extends SessionContext {
}
}
@Override
public Xid[] xaScan() throws ActiveMQException {
SessionXAGetInDoubtXidsResponseMessage response = (SessionXAGetInDoubtXidsResponseMessage) sessionChannel.sendBlocking(new PacketImpl(PacketImpl.SESS_XA_INDOUBT_XIDS), PacketImpl.SESS_XA_INDOUBT_XIDS_RESP);
@ -460,6 +489,7 @@ public class ActiveMQSessionContext extends SessionContext {
return xidArray;
}
@Override
public void xaRollback(Xid xid, boolean wasStarted) throws ActiveMQException, XAException {
SessionXARollbackMessage packet = new SessionXARollbackMessage(xid);
@ -470,6 +500,7 @@ public class ActiveMQSessionContext extends SessionContext {
}
}
@Override
public void xaStart(Xid xid, int flags) throws XAException, ActiveMQException {
Packet packet;
if (flags == XAResource.TMJOIN) {
@ -494,18 +525,21 @@ public class ActiveMQSessionContext extends SessionContext {
}
}
@Override
public boolean configureTransactionTimeout(int seconds) throws ActiveMQException {
SessionXASetTimeoutResponseMessage response = (SessionXASetTimeoutResponseMessage) sessionChannel.sendBlocking(new SessionXASetTimeoutMessage(seconds), PacketImpl.SESS_XA_SET_TIMEOUT_RESP);
return response.isOK();
}
@Override
public int recoverSessionTimeout() throws ActiveMQException {
SessionXAGetTimeoutResponseMessage response = (SessionXAGetTimeoutResponseMessage) sessionChannel.sendBlocking(new PacketImpl(PacketImpl.SESS_XA_GET_TIMEOUT), PacketImpl.SESS_XA_GET_TIMEOUT_RESP);
return response.getTimeoutSeconds();
}
@Override
public void createQueue(SimpleString address,
SimpleString queueName,
SimpleString filterString,
@ -546,6 +580,7 @@ public class ActiveMQSessionContext extends SessionContext {
}
@Override
public void recreateSession(final String username,
final String password,
final int minLargeMessageSize,
@ -624,10 +659,12 @@ public class ActiveMQSessionContext extends SessionContext {
}
}
@Override
public void xaFailed(Xid xid) throws ActiveMQException {
sendPacketWithoutLock(sessionChannel, new SessionXAAfterFailedMessage(xid));
}
@Override
public void restartSession() throws ActiveMQException {
sendPacketWithoutLock(sessionChannel, new PacketImpl(PacketImpl.SESS_START));
}
@ -693,6 +730,7 @@ public class ActiveMQSessionContext extends SessionContext {
class ClientSessionPacketHandler implements ChannelHandler {
@Override
public void handlePacket(final Packet packet) {
byte type = packet.getType();
@ -755,6 +793,7 @@ public class ActiveMQSessionContext extends SessionContext {
protected ClassLoader lookupTCCL() {
return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
@Override
public ClassLoader run() {
return Thread.currentThread().getContextClassLoader();
}

View File

@ -139,6 +139,7 @@ public final class ChannelImpl implements Channel {
this.interceptors = interceptors;
}
@Override
public boolean supports(final byte packetType) {
int version = connection.getClientVersion();
@ -160,26 +161,32 @@ public final class ChannelImpl implements Channel {
}
}
@Override
public long getID() {
return id;
}
@Override
public int getLastConfirmedCommandID() {
return lastConfirmedCommandID.get();
}
@Override
public Lock getLock() {
return lock;
}
@Override
public int getConfirmationWindowSize() {
return confWindowSize;
}
@Override
public void returnBlocking() {
returnBlocking(null);
}
@Override
public void returnBlocking(Throwable cause) {
lock.lock();
@ -193,18 +200,22 @@ public final class ChannelImpl implements Channel {
}
}
@Override
public boolean sendAndFlush(final Packet packet) {
return send(packet, true, false);
}
@Override
public boolean send(final Packet packet) {
return send(packet, false, false);
}
@Override
public boolean sendBatched(final Packet packet) {
return send(packet, false, true);
}
@Override
public void setTransferring(boolean transferring) {
this.transferring = transferring;
}
@ -273,6 +284,7 @@ public final class ChannelImpl implements Channel {
* and the client could eventually retry another call, but the server could then answer a previous command issuing a class-cast-exception.
* The expectedPacket will be used to filter out undesirable packets that would belong to previous calls.
*/
@Override
public Packet sendBlocking(final Packet packet, byte expectedPacket) throws ActiveMQException {
String interceptionResult = invokeInterceptors(packet, interceptors, connection);
@ -408,6 +420,7 @@ public final class ChannelImpl implements Channel {
return null;
}
@Override
public void setCommandConfirmationHandler(final CommandConfirmationHandler handler) {
if (confWindowSize < 0) {
final String msg = "You can't set confirmationHandler on a connection with confirmation-window-size < 0." + " Look at the documentation for more information.";
@ -416,14 +429,17 @@ public final class ChannelImpl implements Channel {
commandConfirmationHandler = handler;
}
@Override
public void setHandler(final ChannelHandler handler) {
this.handler = handler;
}
@Override
public ChannelHandler getHandler() {
return handler;
}
@Override
public void close() {
if (closed) {
return;
@ -439,6 +455,7 @@ public final class ChannelImpl implements Channel {
closed = true;
}
@Override
public void transferConnection(final CoreRemotingConnection newConnection) {
// Needs to synchronize on the connection to make sure no packets from
// the old connection get processed after transfer has occurred
@ -457,6 +474,7 @@ public final class ChannelImpl implements Channel {
}
}
@Override
public void replayCommands(final int otherLastConfirmedCommandID) {
if (resendCache != null) {
if (isTrace) {
@ -470,6 +488,7 @@ public final class ChannelImpl implements Channel {
}
}
@Override
public void lock() {
lock.lock();
@ -478,6 +497,7 @@ public final class ChannelImpl implements Channel {
lock.unlock();
}
@Override
public void unlock() {
lock.lock();
@ -488,11 +508,13 @@ public final class ChannelImpl implements Channel {
lock.unlock();
}
@Override
public CoreRemotingConnection getConnection() {
return connection;
}
// Needs to be synchronized since can be called by remoting service timer thread too for timeout flush
@Override
public synchronized void flushConfirmations() {
if (resendCache != null && receivedBytes != 0) {
receivedBytes = 0;
@ -505,6 +527,7 @@ public final class ChannelImpl implements Channel {
}
}
@Override
public void confirm(final Packet packet) {
if (resendCache != null && packet.isRequiresConfirmations()) {
lastConfirmedCommandID.incrementAndGet();
@ -523,6 +546,7 @@ public final class ChannelImpl implements Channel {
}
}
@Override
public void clearCommands() {
if (resendCache != null) {
lastConfirmedCommandID.set(-1);
@ -533,6 +557,7 @@ public final class ChannelImpl implements Channel {
}
}
@Override
public void handlePacket(final Packet packet) {
if (packet.getType() == PacketImpl.PACKETS_CONFIRMED) {
if (resendCache != null) {

View File

@ -253,18 +253,22 @@ public class PacketImpl implements Packet {
// Public --------------------------------------------------------
@Override
public byte getType() {
return type;
}
@Override
public long getChannelID() {
return channelID;
}
@Override
public void setChannelID(final long channelID) {
this.channelID = channelID;
}
@Override
public ActiveMQBuffer encode(final RemotingConnection connection) {
ActiveMQBuffer buffer = connection.createTransportBuffer(PacketImpl.INITIAL_PACKET_SIZE);
@ -286,6 +290,7 @@ public class PacketImpl implements Packet {
return buffer;
}
@Override
public void decode(final ActiveMQBuffer buffer) {
channelID = buffer.readLong();
@ -294,6 +299,7 @@ public class PacketImpl implements Packet {
size = buffer.readerIndex();
}
@Override
public int getPacketSize() {
if (size == -1) {
throw new IllegalStateException("Packet hasn't been encoded/decoded yet");
@ -302,6 +308,7 @@ public class PacketImpl implements Packet {
return size;
}
@Override
public boolean isResponse() {
return false;
}
@ -312,6 +319,7 @@ public class PacketImpl implements Packet {
public void decodeRest(final ActiveMQBuffer buffer) {
}
@Override
public boolean isRequiresConfirmations() {
return true;
}

View File

@ -151,6 +151,7 @@ public class RemotingConnectionImpl extends AbstractRemotingConnection implement
/**
* @return the clientVersion
*/
@Override
public int getClientVersion() {
return clientVersion;
}
@ -158,10 +159,12 @@ public class RemotingConnectionImpl extends AbstractRemotingConnection implement
/**
* @param clientVersion the clientVersion to set
*/
@Override
public void setClientVersion(int clientVersion) {
this.clientVersion = clientVersion;
}
@Override
public synchronized Channel getChannel(final long channelID, final int confWindowSize) {
Channel channel = channels.get(channelID);
@ -174,14 +177,17 @@ public class RemotingConnectionImpl extends AbstractRemotingConnection implement
return channel;
}
@Override
public synchronized boolean removeChannel(final long channelID) {
return channels.remove(channelID) != null;
}
@Override
public synchronized void putChannel(final long channelID, final Channel channel) {
channels.put(channelID, channel);
}
@Override
public void fail(final ActiveMQException me, String scaleDownTargetNodeID) {
synchronized (failLock) {
if (destroyed) {
@ -212,6 +218,7 @@ public class RemotingConnectionImpl extends AbstractRemotingConnection implement
}
}
@Override
public void destroy() {
synchronized (failLock) {
if (destroyed) {
@ -226,10 +233,12 @@ public class RemotingConnectionImpl extends AbstractRemotingConnection implement
callClosingListeners();
}
@Override
public void disconnect(final boolean criticalError) {
disconnect(null, criticalError);
}
@Override
public void disconnect(String scaleDownNodeID, final boolean criticalError) {
Channel channel0 = getChannel(ChannelImpl.CHANNEL_ID.PING.id, -1);
@ -266,10 +275,12 @@ public class RemotingConnectionImpl extends AbstractRemotingConnection implement
channel0.sendAndFlush(disconnect);
}
@Override
public long generateChannelID() {
return idGenerator.generateID();
}
@Override
public synchronized void syncIDGeneratorSequence(final long id) {
if (!idGeneratorSynced) {
idGenerator = new SimpleIDGenerator(id);
@ -278,22 +289,27 @@ public class RemotingConnectionImpl extends AbstractRemotingConnection implement
}
}
@Override
public long getIDGeneratorSequence() {
return idGenerator.getCurrentID();
}
@Override
public Object getTransferLock() {
return transferLock;
}
@Override
public boolean isClient() {
return client;
}
@Override
public boolean isDestroyed() {
return destroyed;
}
@Override
public long getBlockingCallTimeout() {
return blockingCallTimeout;
}
@ -305,6 +321,7 @@ public class RemotingConnectionImpl extends AbstractRemotingConnection implement
//We flush any confirmations on the connection - this prevents idle bridges for example
//sitting there with many unacked messages
@Override
public void flush() {
synchronized (transferLock) {
for (Channel channel : channels.values()) {
@ -313,12 +330,14 @@ public class RemotingConnectionImpl extends AbstractRemotingConnection implement
}
}
@Override
public ActiveMQPrincipal getDefaultActiveMQPrincipal() {
return getTransportConnection().getDefaultActiveMQPrincipal();
}
// Buffer Handler implementation
// ----------------------------------------------------
@Override
public void bufferReceived(final Object connectionID, final ActiveMQBuffer buffer) {
try {
final Packet packet = packetDecoder.decode(buffer);

View File

@ -30,10 +30,12 @@ public abstract class MessagePacket extends PacketImpl implements MessagePacketI
this.message = message;
}
@Override
public Message getMessage() {
return message;
}
@Override
public String toString() {
return this.getParentString() + ",message=" + message + "]";

View File

@ -88,6 +88,7 @@ public class SessionQueueQueryResponseMessage_V2 extends SessionQueueQueryRespon
return result;
}
@Override
public ClientSession.QueueQuery toQueueQuery() {
return new QueueQueryImpl(isDurable(), isTemporary(), getConsumerCount(), getMessageCount(), getFilterString(), getAddress(), getName(), isExists(), isAutoCreationEnabled());
}

View File

@ -63,6 +63,7 @@ public class TransportConfigurationUtil {
private static Object instantiateObject(final String className) {
return AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override
public Object run() {
try {
return ClassloadingUtil.newInstanceFromClassLoader(className);

View File

@ -96,6 +96,7 @@ public class NettyConnection implements Connection {
}
// Connection implementation ----------------------------
@Override
public void forceClose() {
if (channel != null) {
try {
@ -116,14 +117,17 @@ public class NettyConnection implements Connection {
return channel;
}
@Override
public RemotingConnection getProtocolConnection() {
return protocolConnection;
}
@Override
public void setProtocolConnection(RemotingConnection protocolConnection) {
this.protocolConnection = protocolConnection;
}
@Override
public void close() {
if (closed) {
return;
@ -150,16 +154,19 @@ public class NettyConnection implements Connection {
listener.connectionDestroyed(getID());
}
@Override
public ActiveMQBuffer createTransportBuffer(final int size) {
return new ChannelBufferWrapper(PartialPooledByteBufAllocator.INSTANCE.directBuffer(size), true);
}
@Override
public Object getID() {
// TODO: Think of it
return channel.hashCode();
}
// This is called periodically to flush the batch buffer
@Override
public void checkFlushBatchBuffer() {
if (!batchingEnabled) {
return;
@ -179,14 +186,17 @@ public class NettyConnection implements Connection {
}
}
@Override
public void write(final ActiveMQBuffer buffer) {
write(buffer, false, false);
}
@Override
public void write(ActiveMQBuffer buffer, final boolean flush, final boolean batched) {
write(buffer, flush, batched, null);
}
@Override
public void write(ActiveMQBuffer buffer,
final boolean flush,
final boolean batched,
@ -291,6 +301,7 @@ public class NettyConnection implements Connection {
}
}
@Override
public String getRemoteAddress() {
SocketAddress address = channel.remoteAddress();
if (address == null) {
@ -299,6 +310,7 @@ public class NettyConnection implements Connection {
return address.toString();
}
@Override
public String getLocalAddress() {
SocketAddress address = channel.localAddress();
if (address == null) {
@ -311,15 +323,18 @@ public class NettyConnection implements Connection {
return directDeliver;
}
@Override
public void addReadyListener(final ReadyListener listener) {
readyListeners.add(listener);
}
@Override
public void removeReadyListener(final ReadyListener listener) {
readyListeners.remove(listener);
}
//never allow this
@Override
public ActiveMQPrincipal getDefaultActiveMQPrincipal() {
return null;
}

View File

@ -346,6 +346,7 @@ public class NettyConnector extends AbstractConnector {
"]";
}
@Override
public synchronized void start() {
if (channelClazz != null) {
return;
@ -454,6 +455,7 @@ public class NettyConnector extends AbstractConnector {
}
bootstrap.handler(new ChannelInitializer<Channel>() {
@Override
public void initChannel(Channel channel) throws Exception {
final ChannelPipeline pipeline = channel.pipeline();
if (sslEnabled && !useServlet) {
@ -528,6 +530,7 @@ public class NettyConnector extends AbstractConnector {
ActiveMQClientLogger.LOGGER.debug("Started Netty Connector version " + TransportConstants.NETTY_VERSION);
}
@Override
public synchronized void close() {
if (channelClazz == null) {
return;
@ -559,10 +562,12 @@ public class NettyConnector extends AbstractConnector {
connections.clear();
}
@Override
public boolean isStarted() {
return channelClazz != null;
}
@Override
public Connection createConnection() {
if (channelClazz == null) {
return null;
@ -866,6 +871,7 @@ public class NettyConnector extends AbstractConnector {
private java.util.concurrent.Future<?> future;
@Override
public synchronized void run() {
if (closed) {
return;
@ -895,6 +901,7 @@ public class NettyConnector extends AbstractConnector {
private class Listener implements ConnectionLifeCycleListener {
@Override
public void connectionCreated(final ActiveMQComponent component,
final Connection connection,
final String protocol) {
@ -903,10 +910,12 @@ public class NettyConnector extends AbstractConnector {
}
}
@Override
public void connectionDestroyed(final Object connectionID) {
if (connections.remove(connectionID) != null) {
// Execute on different thread to avoid deadlocks
closeExecutor.execute(new Runnable() {
@Override
public void run() {
listener.connectionDestroyed(connectionID);
}
@ -914,15 +923,18 @@ public class NettyConnector extends AbstractConnector {
}
}
@Override
public void connectionException(final Object connectionID, final ActiveMQException me) {
// Execute on different thread to avoid deadlocks
closeExecutor.execute(new Runnable() {
@Override
public void run() {
listener.connectionException(connectionID, me);
}
});
}
@Override
public void connectionReadyForWrites(Object connectionID, boolean ready) {
listener.connectionReadyForWrites(connectionID, ready);
}
@ -933,6 +945,7 @@ public class NettyConnector extends AbstractConnector {
private boolean cancelled;
@Override
public synchronized void run() {
if (!cancelled) {
for (Connection connection : connections.values()) {
@ -946,6 +959,7 @@ public class NettyConnector extends AbstractConnector {
}
}
@Override
public boolean isEquivalent(Map<String, Object> configuration) {
//here we only check host and port because these two parameters
//is sufficient to determine the target host
@ -976,6 +990,7 @@ public class NettyConnector extends AbstractConnector {
return result;
}
@Override
public void finalize() throws Throwable {
close();
super.finalize();
@ -992,6 +1007,7 @@ public class NettyConnector extends AbstractConnector {
private static ClassLoader getThisClassLoader() {
return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
@Override
public ClassLoader run() {
return ClientSessionFactoryImpl.class.getClassLoader();
}

View File

@ -28,6 +28,7 @@ import org.apache.activemq.artemis.spi.core.remoting.ConnectorFactory;
public class NettyConnectorFactory implements ConnectorFactory {
@Override
public Connector createConnector(final Map<String, Object> configuration,
final BufferHandler handler,
final ConnectionLifeCycleListener listener,

View File

@ -162,6 +162,7 @@ public class SSLSupport {
*/
private static URL findResource(final String resourceName) {
return AccessController.doPrivileged(new PrivilegedAction<URL>() {
@Override
public URL run() {
return ClassloadingUtil.findResource(resourceName);
}

View File

@ -91,14 +91,17 @@ public class XidImpl implements Xid, Serializable {
// Xid implementation ------------------------------------------------------------------
@Override
public byte[] getBranchQualifier() {
return branchQualifier;
}
@Override
public int getFormatId() {
return formatId;
}
@Override
public byte[] getGlobalTransactionId() {
return globalTransactionId;
}

View File

@ -60,30 +60,37 @@ public class VersionImpl implements Version, Serializable {
// Version implementation ------------------------------------------
@Override
public String getFullVersion() {
return versionName;
}
@Override
public String getVersionName() {
return versionName;
}
@Override
public int getMajorVersion() {
return majorVersion;
}
@Override
public int getMinorVersion() {
return minorVersion;
}
@Override
public int getMicroVersion() {
return microVersion;
}
@Override
public int getIncrementingVersion() {
return incrementingVersion;
}
@Override
public boolean isCompatible(int version) {
for (int element : compatibleVersionList) {
if (element == version) {

View File

@ -45,6 +45,7 @@ public abstract class AbstractRemotingConnection implements RemotingConnection {
this.creationTime = System.currentTimeMillis();
}
@Override
public List<FailureListener> getFailureListeners() {
return new ArrayList<FailureListener>(failureListeners);
}
@ -85,20 +86,24 @@ public abstract class AbstractRemotingConnection implements RemotingConnection {
}
}
@Override
public void setFailureListeners(final List<FailureListener> listeners) {
failureListeners.clear();
failureListeners.addAll(listeners);
}
@Override
public Object getID() {
return transportConnection.getID();
}
@Override
public String getRemoteAddress() {
return transportConnection.getRemoteAddress();
}
@Override
public void addFailureListener(final FailureListener listener) {
if (listener == null) {
throw ActiveMQClientMessageBundle.BUNDLE.failListenerCannotBeNull();
@ -106,6 +111,7 @@ public abstract class AbstractRemotingConnection implements RemotingConnection {
failureListeners.add(listener);
}
@Override
public boolean removeFailureListener(final FailureListener listener) {
if (listener == null) {
throw ActiveMQClientMessageBundle.BUNDLE.failListenerCannotBeNull();
@ -114,6 +120,7 @@ public abstract class AbstractRemotingConnection implements RemotingConnection {
return failureListeners.remove(listener);
}
@Override
public void addCloseListener(final CloseListener listener) {
if (listener == null) {
throw ActiveMQClientMessageBundle.BUNDLE.closeListenerCannotBeNull();
@ -122,6 +129,7 @@ public abstract class AbstractRemotingConnection implements RemotingConnection {
closeListeners.add(listener);
}
@Override
public boolean removeCloseListener(final CloseListener listener) {
if (listener == null) {
throw ActiveMQClientMessageBundle.BUNDLE.closeListenerCannotBeNull();
@ -130,6 +138,7 @@ public abstract class AbstractRemotingConnection implements RemotingConnection {
return closeListeners.remove(listener);
}
@Override
public List<CloseListener> removeCloseListeners() {
List<CloseListener> ret = new ArrayList<CloseListener>(closeListeners);
@ -138,6 +147,7 @@ public abstract class AbstractRemotingConnection implements RemotingConnection {
return ret;
}
@Override
public List<FailureListener> removeFailureListeners() {
List<FailureListener> ret = getFailureListeners();
@ -146,24 +156,29 @@ public abstract class AbstractRemotingConnection implements RemotingConnection {
return ret;
}
@Override
public void setCloseListeners(List<CloseListener> listeners) {
closeListeners.clear();
closeListeners.addAll(listeners);
}
@Override
public ActiveMQBuffer createTransportBuffer(final int size) {
return transportConnection.createTransportBuffer(size);
}
@Override
public Connection getTransportConnection() {
return transportConnection;
}
@Override
public long getCreationTime() {
return creationTime;
}
@Override
public boolean checkDataReceived() {
boolean res = dataReceived;
@ -175,10 +190,12 @@ public abstract class AbstractRemotingConnection implements RemotingConnection {
/*
* This can be called concurrently by more than one thread so needs to be locked
*/
@Override
public void fail(final ActiveMQException me) {
fail(me, null);
}
@Override
public void bufferReceived(final Object connectionID, final ActiveMQBuffer buffer) {
dataReceived = true;
}

View File

@ -42,6 +42,7 @@ public class FutureLatch implements Runnable {
}
}
@Override
public void run() {
latch.countDown();
}

View File

@ -46,6 +46,7 @@ public class InflaterReader extends InputStream {
this.pointer = -1;
}
@Override
public int read() throws IOException {
if (pointer == -1) {
try {

View File

@ -46,6 +46,7 @@ public class LinkedListImpl<E> implements LinkedList<E> {
iters = createIteratorArray(INITIAL_ITERATOR_ARRAY_SIZE);
}
@Override
public void addHead(E e) {
Node<E> node = new Node<E>(e);
@ -66,6 +67,7 @@ public class LinkedListImpl<E> implements LinkedList<E> {
size++;
}
@Override
public void addTail(E e) {
if (size == 0) {
addHead(e);
@ -83,6 +85,7 @@ public class LinkedListImpl<E> implements LinkedList<E> {
}
}
@Override
public E poll() {
Node<E> ret = head.next;
@ -96,20 +99,24 @@ public class LinkedListImpl<E> implements LinkedList<E> {
}
}
@Override
public void clear() {
tail = head.next = null;
size = 0;
}
@Override
public int size() {
return size;
}
@Override
public LinkedListIterator<E> iterator() {
return new Iterator();
}
@Override
public String toString() {
StringBuilder str = new StringBuilder("LinkedListImpl [ ");
@ -227,6 +234,7 @@ public class LinkedListImpl<E> implements LinkedList<E> {
val = e;
}
@Override
public String toString() {
return "Node, value = " + val;
}
@ -248,10 +256,12 @@ public class LinkedListImpl<E> implements LinkedList<E> {
addIter(this);
}
@Override
public void repeat() {
repeat = true;
}
@Override
public boolean hasNext() {
Node<E> e = getNode();
@ -262,6 +272,7 @@ public class LinkedListImpl<E> implements LinkedList<E> {
return canAdvance();
}
@Override
public E next() {
Node<E> e = getNode();
@ -303,6 +314,7 @@ public class LinkedListImpl<E> implements LinkedList<E> {
return e.val;
}
@Override
public void remove() {
if (last == null) {
throw new NoSuchElementException();
@ -317,6 +329,7 @@ public class LinkedListImpl<E> implements LinkedList<E> {
last = null;
}
@Override
public void close() {
removeIter(this);
}

View File

@ -27,5 +27,6 @@ public interface LinkedListIterator<E> extends Iterator<E>, AutoCloseable {
void repeat();
@Override
void close();
}

View File

@ -43,6 +43,7 @@ public final class OrderedExecutorFactory implements ExecutorFactory {
*
* @return an ordered executor
*/
@Override
public Executor getExecutor() {
return new OrderedExecutor(parent);
}
@ -72,6 +73,7 @@ public final class OrderedExecutorFactory implements ExecutorFactory {
public OrderedExecutor(final Executor parent) {
this.parent = parent;
runner = new Runnable() {
@Override
public void run() {
for (;;) {
// Optimization, first try without any locks
@ -110,6 +112,7 @@ public final class OrderedExecutorFactory implements ExecutorFactory {
*
* @param command the task to run.
*/
@Override
public void execute(final Runnable command) {
synchronized (tasks) {
tasks.add(command);
@ -120,6 +123,7 @@ public final class OrderedExecutorFactory implements ExecutorFactory {
}
}
@Override
public String toString() {
return "OrderedExecutor(running=" + running + ", tasks=" + tasks + ")";
}

View File

@ -60,6 +60,7 @@ public class PriorityLinkedListImpl<T> implements PriorityLinkedList<T> {
}
}
@Override
public void addHead(final T t, final int priority) {
checkHighest(priority);
@ -68,6 +69,7 @@ public class PriorityLinkedListImpl<T> implements PriorityLinkedList<T> {
size++;
}
@Override
public void addTail(final T t, final int priority) {
checkHighest(priority);
@ -76,6 +78,7 @@ public class PriorityLinkedListImpl<T> implements PriorityLinkedList<T> {
size++;
}
@Override
public T poll() {
T t = null;
@ -108,6 +111,7 @@ public class PriorityLinkedListImpl<T> implements PriorityLinkedList<T> {
return t;
}
@Override
public void clear() {
for (LinkedListImpl<T> list : levels) {
list.clear();
@ -116,14 +120,17 @@ public class PriorityLinkedListImpl<T> implements PriorityLinkedList<T> {
size = 0;
}
@Override
public int size() {
return size;
}
@Override
public boolean isEmpty() {
return size == 0;
}
@Override
public LinkedListIterator<T> iterator() {
return new PriorityLinkedListIterator();
}
@ -149,6 +156,7 @@ public class PriorityLinkedListImpl<T> implements PriorityLinkedList<T> {
close();
}
@Override
public void repeat() {
if (lastIter == null) {
throw new NoSuchElementException();
@ -157,6 +165,7 @@ public class PriorityLinkedListImpl<T> implements PriorityLinkedList<T> {
lastIter.repeat();
}
@Override
public void close() {
if (!closed) {
closed = true;
@ -178,6 +187,7 @@ public class PriorityLinkedListImpl<T> implements PriorityLinkedList<T> {
}
}
@Override
public boolean hasNext() {
checkReset();
@ -205,6 +215,7 @@ public class PriorityLinkedListImpl<T> implements PriorityLinkedList<T> {
return false;
}
@Override
public T next() {
if (lastIter == null) {
throw new NoSuchElementException();
@ -213,6 +224,7 @@ public class PriorityLinkedListImpl<T> implements PriorityLinkedList<T> {
return lastIter.next();
}
@Override
public void remove() {
if (lastIter == null) {
throw new NoSuchElementException();

View File

@ -26,6 +26,7 @@ public class SimpleIDGenerator implements IDGenerator {
idSequence = startID;
}
@Override
public synchronized long generateID() {
long id = idSequence++;
@ -41,6 +42,7 @@ public class SimpleIDGenerator implements IDGenerator {
return id;
}
@Override
public synchronized long getCurrentID() {
return idSequence;
}

View File

@ -75,6 +75,7 @@ public class SoftValueHashMap<K, V extends SoftValueHashMap.ValueCache> implemen
/**
* @see java.util.Map#size()
*/
@Override
public int size() {
processQueue();
return mapDelegate.size();
@ -83,6 +84,7 @@ public class SoftValueHashMap<K, V extends SoftValueHashMap.ValueCache> implemen
/**
* @see java.util.Map#isEmpty()
*/
@Override
public boolean isEmpty() {
processQueue();
return mapDelegate.isEmpty();
@ -92,6 +94,7 @@ public class SoftValueHashMap<K, V extends SoftValueHashMap.ValueCache> implemen
* @param key
* @see java.util.Map#containsKey(java.lang.Object)
*/
@Override
public boolean containsKey(final Object key) {
processQueue();
return mapDelegate.containsKey(key);
@ -101,6 +104,7 @@ public class SoftValueHashMap<K, V extends SoftValueHashMap.ValueCache> implemen
* @param value
* @see java.util.Map#containsValue(java.lang.Object)
*/
@Override
public boolean containsValue(final Object value) {
processQueue();
for (AggregatedSoftReference valueIter : mapDelegate.values()) {
@ -117,6 +121,7 @@ public class SoftValueHashMap<K, V extends SoftValueHashMap.ValueCache> implemen
* @param key
* @see java.util.Map#get(java.lang.Object)
*/
@Override
public V get(final Object key) {
processQueue();
AggregatedSoftReference value = mapDelegate.get(key);
@ -134,6 +139,7 @@ public class SoftValueHashMap<K, V extends SoftValueHashMap.ValueCache> implemen
* @param value
* @see java.util.Map#put(java.lang.Object, java.lang.Object)
*/
@Override
public V put(final K key, final V value) {
processQueue();
AggregatedSoftReference newRef = createReference(key, value);
@ -178,6 +184,7 @@ public class SoftValueHashMap<K, V extends SoftValueHashMap.ValueCache> implemen
class ComparatorAgregated implements Comparator<AggregatedSoftReference> {
@Override
public int compare(AggregatedSoftReference o1, AggregatedSoftReference o2) {
long k = o1.used - o2.used;
@ -206,6 +213,7 @@ public class SoftValueHashMap<K, V extends SoftValueHashMap.ValueCache> implemen
* @param key
* @see java.util.Map#remove(java.lang.Object)
*/
@Override
public V remove(final Object key) {
processQueue();
AggregatedSoftReference ref = mapDelegate.remove(key);
@ -221,6 +229,7 @@ public class SoftValueHashMap<K, V extends SoftValueHashMap.ValueCache> implemen
* @param m
* @see java.util.Map#putAll(java.util.Map)
*/
@Override
public void putAll(final Map<? extends K, ? extends V> m) {
processQueue();
for (Map.Entry<? extends K, ? extends V> e : m.entrySet()) {
@ -231,6 +240,7 @@ public class SoftValueHashMap<K, V extends SoftValueHashMap.ValueCache> implemen
/**
* @see java.util.Map#clear()
*/
@Override
public void clear() {
mapDelegate.clear();
}
@ -238,6 +248,7 @@ public class SoftValueHashMap<K, V extends SoftValueHashMap.ValueCache> implemen
/**
* @see java.util.Map#keySet()
*/
@Override
public Set<K> keySet() {
processQueue();
return mapDelegate.keySet();
@ -246,6 +257,7 @@ public class SoftValueHashMap<K, V extends SoftValueHashMap.ValueCache> implemen
/**
* @see java.util.Map#values()
*/
@Override
public Collection<V> values() {
processQueue();
ArrayList<V> list = new ArrayList<V>();
@ -263,6 +275,7 @@ public class SoftValueHashMap<K, V extends SoftValueHashMap.ValueCache> implemen
/**
* @see java.util.Map#entrySet()
*/
@Override
public Set<java.util.Map.Entry<K, V>> entrySet() {
processQueue();
HashSet<Map.Entry<K, V>> set = new HashSet<Map.Entry<K, V>>();
@ -353,6 +366,7 @@ public class SoftValueHashMap<K, V extends SoftValueHashMap.ValueCache> implemen
/* (non-Javadoc)
* @see java.util.Map.Entry#getKey()
*/
@Override
public K getKey() {
return key;
}
@ -360,6 +374,7 @@ public class SoftValueHashMap<K, V extends SoftValueHashMap.ValueCache> implemen
/* (non-Javadoc)
* @see java.util.Map.Entry#getValue()
*/
@Override
public V getValue() {
return value;
}
@ -367,6 +382,7 @@ public class SoftValueHashMap<K, V extends SoftValueHashMap.ValueCache> implemen
/* (non-Javadoc)
* @see java.util.Map.Entry#setValue(java.lang.Object)
*/
@Override
public V setValue(final V value) {
this.value = value;
return value;

View File

@ -60,6 +60,7 @@ public class TimeAndCounterIDGenerator implements IDGenerator {
// Public --------------------------------------------------------
@Override
public long generateID() {
long idReturn = counter.incrementAndGet();
@ -93,6 +94,7 @@ public class TimeAndCounterIDGenerator implements IDGenerator {
return idReturn;
}
@Override
public long getCurrentID() {
return counter.get();
}

View File

@ -50,14 +50,17 @@ public class TokenBucketLimiterImpl implements TokenBucketLimiter {
this.window = unit.toMillis(unitAmount);
}
@Override
public int getRate() {
return rate;
}
@Override
public boolean isSpin() {
return spin;
}
@Override
public void limit() {
while (!check()) {
if (spin) {

View File

@ -51,6 +51,7 @@ public final class VersionLoader {
try {
PROP_FILE_NAME = AccessController.doPrivileged(new PrivilegedAction<String>() {
@Override
public String run() {
return System.getProperty(VersionLoader.VERSION_PROP_FILE_KEY);
}

View File

@ -431,6 +431,7 @@ public final class XMLUtil {
private static URL findResource(final String resourceName) {
return AccessController.doPrivileged(new PrivilegedAction<URL>() {
@Override
public URL run() {
return ClassloadingUtil.findResource(resourceName);
}

View File

@ -124,6 +124,7 @@ public interface JMSQueueControl extends DestinationControl {
*
* @return the number of removed messages
*/
@Override
@Operation(desc = "Remove the messages corresponding to the given filter (and returns the number of removed messages)", impact = MBeanOperationInfo.ACTION)
int removeMessages(@Parameter(name = "filter", desc = "A message filter (can be empty)") String filter) throws Exception;

View File

@ -99,6 +99,7 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag
// BytesMessage implementation -----------------------------------
@Override
public boolean readBoolean() throws JMSException {
checkRead();
try {
@ -109,6 +110,7 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag
}
}
@Override
public byte readByte() throws JMSException {
checkRead();
try {
@ -119,6 +121,7 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag
}
}
@Override
public int readUnsignedByte() throws JMSException {
checkRead();
try {
@ -129,6 +132,7 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag
}
}
@Override
public short readShort() throws JMSException {
checkRead();
try {
@ -139,6 +143,7 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag
}
}
@Override
public int readUnsignedShort() throws JMSException {
checkRead();
try {
@ -149,6 +154,7 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag
}
}
@Override
public char readChar() throws JMSException {
checkRead();
try {
@ -159,6 +165,7 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag
}
}
@Override
public int readInt() throws JMSException {
checkRead();
try {
@ -169,6 +176,7 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag
}
}
@Override
public long readLong() throws JMSException {
checkRead();
try {
@ -179,6 +187,7 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag
}
}
@Override
public float readFloat() throws JMSException {
checkRead();
try {
@ -189,6 +198,7 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag
}
}
@Override
public double readDouble() throws JMSException {
checkRead();
try {
@ -199,6 +209,7 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag
}
}
@Override
public String readUTF() throws JMSException {
checkRead();
try {
@ -215,57 +226,68 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag
}
}
@Override
public int readBytes(final byte[] value) throws JMSException {
checkRead();
return bytesReadBytes(message.getBodyBuffer(), value);
}
@Override
public int readBytes(final byte[] value, final int length) throws JMSException {
checkRead();
return bytesReadBytes(message.getBodyBuffer(), value, length);
}
@Override
public void writeBoolean(final boolean value) throws JMSException {
checkWrite();
bytesWriteBoolean(message.getBodyBuffer(), value);
}
@Override
public void writeByte(final byte value) throws JMSException {
checkWrite();
bytesWriteByte(message.getBodyBuffer(), value);
}
@Override
public void writeShort(final short value) throws JMSException {
checkWrite();
bytesWriteShort(message.getBodyBuffer(), value);
}
@Override
public void writeChar(final char value) throws JMSException {
checkWrite();
bytesWriteChar(message.getBodyBuffer(), value);
}
@Override
public void writeInt(final int value) throws JMSException {
checkWrite();
bytesWriteInt(message.getBodyBuffer(), value);
}
@Override
public void writeLong(final long value) throws JMSException {
checkWrite();
bytesWriteLong(message.getBodyBuffer(), value);
}
@Override
public void writeFloat(final float value) throws JMSException {
checkWrite();
bytesWriteFloat(message.getBodyBuffer(), value);
}
@Override
public void writeDouble(final double value) throws JMSException {
checkWrite();
bytesWriteDouble(message.getBodyBuffer(), value);
}
@Override
public void writeUTF(final String value) throws JMSException {
checkWrite();
try {
@ -280,16 +302,19 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag
}
@Override
public void writeBytes(final byte[] value) throws JMSException {
checkWrite();
bytesWriteBytes(message.getBodyBuffer(), value);
}
@Override
public void writeBytes(final byte[] value, final int offset, final int length) throws JMSException {
checkWrite();
bytesWriteBytes(message.getBodyBuffer(), value, offset, length);
}
@Override
public void writeObject(final Object value) throws JMSException {
checkWrite();
if (!bytesWriteObject(message.getBodyBuffer(), value)) {
@ -297,6 +322,7 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag
}
}
@Override
public void reset() throws JMSException {
if (!readOnly) {
readOnly = true;
@ -328,6 +354,7 @@ public class ActiveMQBytesMessage extends ActiveMQMessage implements BytesMessag
}
}
@Override
public long getBodyLength() throws JMSException {
checkRead();

View File

@ -199,18 +199,21 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
// Connection implementation --------------------------------------------------------------------
@Override
public synchronized Session createSession(final boolean transacted, final int acknowledgeMode) throws JMSException {
checkClosed();
return createSessionInternal(false, transacted, checkAck(transacted, acknowledgeMode), ActiveMQConnection.TYPE_GENERIC_CONNECTION);
}
@Override
public String getClientID() throws JMSException {
checkClosed();
return clientID;
}
@Override
public void setClientID(final String clientID) throws JMSException {
checkClosed();
@ -245,6 +248,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
justCreated = false;
}
@Override
public ConnectionMetaData getMetaData() throws JMSException {
checkClosed();
@ -257,6 +261,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
return metaData;
}
@Override
public ExceptionListener getExceptionListener() throws JMSException {
checkClosed();
@ -265,6 +270,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
return exceptionListener;
}
@Override
public void setExceptionListener(final ExceptionListener listener) throws JMSException {
checkClosed();
@ -272,6 +278,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
justCreated = false;
}
@Override
public synchronized void start() throws JMSException {
checkClosed();
@ -294,6 +301,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
}
@Override
public synchronized void stop() throws JMSException {
threadAwareContext.assertNotMessageListenerThread();
@ -307,6 +315,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
started = false;
}
@Override
public final synchronized void close() throws JMSException {
threadAwareContext.assertNotCompletionListenerThread();
threadAwareContext.assertNotMessageListenerThread();
@ -351,6 +360,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
}
}
@Override
public ConnectionConsumer createConnectionConsumer(final Destination destination,
final String messageSelector,
final ServerSessionPool sessionPool,
@ -372,6 +382,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
}
}
@Override
public ConnectionConsumer createDurableConnectionConsumer(final Topic topic,
final String subscriptionName,
final String messageSelector,
@ -403,6 +414,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
// QueueConnection implementation ---------------------------------------------------------------
@Override
public QueueSession createQueueSession(final boolean transacted, int acknowledgeMode) throws JMSException {
checkClosed();
return createSessionInternal(false, transacted, checkAck(transacted, acknowledgeMode), ActiveMQSession.TYPE_QUEUE_SESSION);
@ -420,6 +432,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
return acknowledgeMode;
}
@Override
public ConnectionConsumer createConnectionConsumer(final Queue queue,
final String messageSelector,
final ServerSessionPool sessionPool,
@ -431,11 +444,13 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
// TopicConnection implementation ---------------------------------------------------------------
@Override
public TopicSession createTopicSession(final boolean transacted, final int acknowledgeMode) throws JMSException {
checkClosed();
return createSessionInternal(false, transacted, checkAck(transacted, acknowledgeMode), ActiveMQSession.TYPE_TOPIC_SESSION);
}
@Override
public ConnectionConsumer createConnectionConsumer(final Topic topic,
final String messageSelector,
final ServerSessionPool sessionPool,
@ -695,6 +710,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
je.initCause(me);
new Thread(new Runnable() {
@Override
public void run() {
exceptionListener.onException(je);
}
@ -714,6 +730,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
connectionFailed(me, failedOver);
}
@Override
public void beforeReconnect(final ActiveMQException me) {
}
@ -739,6 +756,7 @@ public class ActiveMQConnection extends ActiveMQConnectionForContextImpl impleme
if (failoverListener != null) {
new Thread(new Runnable() {
@Override
public void run() {
failoverListener.failoverEvent(eventType);
}

View File

@ -79,6 +79,7 @@ public class ActiveMQConnectionFactory implements Externalizable, Referenceable,
private String protocolManagerFactoryStr;
@Override
public void writeExternal(ObjectOutput out) throws IOException {
URI uri = toURI();
@ -135,6 +136,7 @@ public class ActiveMQConnectionFactory implements Externalizable, Referenceable,
if (protocolManagerFactoryStr != null && !protocolManagerFactoryStr.trim().isEmpty()) {
AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override
public Object run() {
ClientProtocolManagerFactory protocolManagerFactory =
@ -148,6 +150,7 @@ public class ActiveMQConnectionFactory implements Externalizable, Referenceable,
}
}
@Override
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
String url = in.readUTF();
ConnectionFactoryParser parser = new ConnectionFactoryParser();
@ -225,10 +228,12 @@ public class ActiveMQConnectionFactory implements Externalizable, Referenceable,
serverLocator.disableFinalizeCheck();
}
@Override
public Connection createConnection() throws JMSException {
return createConnection(user, password);
}
@Override
public Connection createConnection(final String username, final String password) throws JMSException {
return createConnectionInternal(username, password, false, ActiveMQConnection.TYPE_GENERIC_CONNECTION);
}
@ -296,10 +301,12 @@ public class ActiveMQConnectionFactory implements Externalizable, Referenceable,
// XAConnectionFactory implementation -----------------------------------------------------------
@Override
public XAConnection createXAConnection() throws JMSException {
return createXAConnection(null, null);
}
@Override
public XAConnection createXAConnection(final String username, final String password) throws JMSException {
return (XAConnection) createConnectionInternal(username, password, true, ActiveMQConnection.TYPE_GENERIC_CONNECTION);
}
@ -694,6 +701,7 @@ public class ActiveMQConnectionFactory implements Externalizable, Referenceable,
serverLocator.setCompressLargeMessage(avoidLargeMessages);
}
@Override
public void close() {
ServerLocator locator0 = serverLocator;
if (locator0 != null)

View File

@ -29,6 +29,7 @@ import org.apache.activemq.artemis.utils.ReferenceCounterUtil;
public abstract class ActiveMQConnectionForContextImpl implements ActiveMQConnectionForContext {
final Runnable closeRunnable = new Runnable() {
@Override
public void run() {
try {
close();
@ -43,6 +44,7 @@ public abstract class ActiveMQConnectionForContextImpl implements ActiveMQConnec
protected final ThreadAwareContext threadAwareContext = new ThreadAwareContext();
@Override
public JMSContext createContext(int sessionMode) {
switch (sessionMode) {
case Session.AUTO_ACKNOWLEDGE:
@ -60,6 +62,7 @@ public abstract class ActiveMQConnectionForContextImpl implements ActiveMQConnec
return new ActiveMQJMSContext(this, sessionMode, threadAwareContext);
}
@Override
public XAJMSContext createXAContext() {
refCounter.increment();

View File

@ -49,34 +49,42 @@ public class ActiveMQConnectionMetaData implements ConnectionMetaData {
// ConnectionMetaData implementation -----------------------------
@Override
public String getJMSVersion() throws JMSException {
return "2.0";
}
@Override
public int getJMSMajorVersion() throws JMSException {
return 2;
}
@Override
public int getJMSMinorVersion() throws JMSException {
return 0;
}
@Override
public String getJMSProviderName() throws JMSException {
return ActiveMQConnectionMetaData.ACTIVEMQ;
}
@Override
public String getProviderVersion() throws JMSException {
return serverVersion.getFullVersion();
}
@Override
public int getProviderMajorVersion() throws JMSException {
return serverVersion.getMajorVersion();
}
@Override
public int getProviderMinorVersion() throws JMSException {
return serverVersion.getMinorVersion();
}
@Override
public Enumeration getJMSXPropertyNames() throws JMSException {
Vector<Object> v = new Vector<Object>();
v.add("JMSXGroupID");

View File

@ -296,6 +296,7 @@ public class ActiveMQDestination implements Destination, Serializable, Reference
// Referenceable implementation ---------------------------------------
@Override
public Reference getReference() throws NamingException {
return new Reference(this.getClass().getCanonicalName(), new SerializableObjectRefAddr("ActiveMQ-DEST", this), DestinationObjectFactory.class.getCanonicalName(), null);
}

View File

@ -100,66 +100,77 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess
// MapMessage implementation -------------------------------------
@Override
public void setBoolean(final String name, final boolean value) throws JMSException {
checkName(name);
map.putBooleanProperty(new SimpleString(name), value);
invalid = true;
}
@Override
public void setByte(final String name, final byte value) throws JMSException {
checkName(name);
map.putByteProperty(new SimpleString(name), value);
invalid = true;
}
@Override
public void setShort(final String name, final short value) throws JMSException {
checkName(name);
map.putShortProperty(new SimpleString(name), value);
invalid = true;
}
@Override
public void setChar(final String name, final char value) throws JMSException {
checkName(name);
map.putCharProperty(new SimpleString(name), value);
invalid = true;
}
@Override
public void setInt(final String name, final int value) throws JMSException {
checkName(name);
map.putIntProperty(new SimpleString(name), value);
invalid = true;
}
@Override
public void setLong(final String name, final long value) throws JMSException {
checkName(name);
map.putLongProperty(new SimpleString(name), value);
invalid = true;
}
@Override
public void setFloat(final String name, final float value) throws JMSException {
checkName(name);
map.putFloatProperty(new SimpleString(name), value);
invalid = true;
}
@Override
public void setDouble(final String name, final double value) throws JMSException {
checkName(name);
map.putDoubleProperty(new SimpleString(name), value);
invalid = true;
}
@Override
public void setString(final String name, final String value) throws JMSException {
checkName(name);
map.putSimpleStringProperty(new SimpleString(name), value == null ? null : new SimpleString(value));
invalid = true;
}
@Override
public void setBytes(final String name, final byte[] value) throws JMSException {
checkName(name);
map.putBytesProperty(new SimpleString(name), value);
invalid = true;
}
@Override
public void setBytes(final String name, final byte[] value, final int offset, final int length) throws JMSException {
checkName(name);
if (offset + length > value.length) {
@ -171,6 +182,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess
invalid = true;
}
@Override
public void setObject(final String name, final Object value) throws JMSException {
checkName(name);
try {
@ -182,6 +194,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess
invalid = true;
}
@Override
public boolean getBoolean(final String name) throws JMSException {
try {
return map.getBooleanProperty(new SimpleString(name));
@ -191,6 +204,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess
}
}
@Override
public byte getByte(final String name) throws JMSException {
try {
return map.getByteProperty(new SimpleString(name));
@ -200,6 +214,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess
}
}
@Override
public short getShort(final String name) throws JMSException {
try {
return map.getShortProperty(new SimpleString(name));
@ -209,6 +224,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess
}
}
@Override
public char getChar(final String name) throws JMSException {
try {
return map.getCharProperty(new SimpleString(name));
@ -218,6 +234,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess
}
}
@Override
public int getInt(final String name) throws JMSException {
try {
return map.getIntProperty(new SimpleString(name));
@ -227,6 +244,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess
}
}
@Override
public long getLong(final String name) throws JMSException {
try {
return map.getLongProperty(new SimpleString(name));
@ -236,6 +254,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess
}
}
@Override
public float getFloat(final String name) throws JMSException {
try {
return map.getFloatProperty(new SimpleString(name));
@ -245,6 +264,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess
}
}
@Override
public double getDouble(final String name) throws JMSException {
try {
return map.getDoubleProperty(new SimpleString(name));
@ -254,6 +274,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess
}
}
@Override
public String getString(final String name) throws JMSException {
try {
SimpleString str = map.getSimpleStringProperty(new SimpleString(name));
@ -269,6 +290,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess
}
}
@Override
public byte[] getBytes(final String name) throws JMSException {
try {
return map.getBytesProperty(new SimpleString(name));
@ -278,6 +300,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess
}
}
@Override
public Object getObject(final String name) throws JMSException {
Object val = map.getProperty(new SimpleString(name));
@ -288,6 +311,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess
return val;
}
@Override
public Enumeration getMapNames() throws JMSException {
Set<SimpleString> simplePropNames = map.getPropertyNames();
Set<String> propNames = new HashSet<String>(simplePropNames.size());
@ -299,6 +323,7 @@ public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMess
return Collections.enumeration(propNames);
}
@Override
public boolean itemExists(final String name) throws JMSException {
return map.containsProperty(new SimpleString(name));
}

View File

@ -277,6 +277,7 @@ public class ActiveMQMessage implements javax.jms.Message {
// javax.jmx.Message implementation ------------------------------
@Override
public String getJMSMessageID() {
if (msgID == null) {
UUID uid = message.getUserID();
@ -286,6 +287,7 @@ public class ActiveMQMessage implements javax.jms.Message {
return msgID;
}
@Override
public void setJMSMessageID(final String jmsMessageID) throws JMSException {
if (jmsMessageID != null && !jmsMessageID.startsWith("ID:")) {
throw new JMSException("JMSMessageID must start with ID:");
@ -296,18 +298,22 @@ public class ActiveMQMessage implements javax.jms.Message {
msgID = jmsMessageID;
}
@Override
public long getJMSTimestamp() throws JMSException {
return message.getTimestamp();
}
@Override
public void setJMSTimestamp(final long timestamp) throws JMSException {
message.setTimestamp(timestamp);
}
@Override
public byte[] getJMSCorrelationIDAsBytes() throws JMSException {
return MessageUtil.getJMSCorrelationIDAsBytes(message);
}
@Override
public void setJMSCorrelationIDAsBytes(final byte[] correlationID) throws JMSException {
try {
MessageUtil.setJMSCorrelationIDAsBytes(message, correlationID);
@ -319,11 +325,13 @@ public class ActiveMQMessage implements javax.jms.Message {
}
}
@Override
public void setJMSCorrelationID(final String correlationID) throws JMSException {
MessageUtil.setJMSCorrelationID(message, correlationID);
jmsCorrelationID = correlationID;
}
@Override
public String getJMSCorrelationID() throws JMSException {
if (jmsCorrelationID == null) {
jmsCorrelationID = MessageUtil.getJMSCorrelationID(message);
@ -332,6 +340,7 @@ public class ActiveMQMessage implements javax.jms.Message {
return jmsCorrelationID;
}
@Override
public Destination getJMSReplyTo() throws JMSException {
if (replyTo == null) {
@ -344,6 +353,7 @@ public class ActiveMQMessage implements javax.jms.Message {
return replyTo;
}
@Override
public void setJMSReplyTo(final Destination dest) throws JMSException {
if (dest == null) {
@ -363,6 +373,7 @@ public class ActiveMQMessage implements javax.jms.Message {
}
}
@Override
public Destination getJMSDestination() throws JMSException {
if (dest == null) {
SimpleString sdest = message.getAddress();
@ -373,14 +384,17 @@ public class ActiveMQMessage implements javax.jms.Message {
return dest;
}
@Override
public void setJMSDestination(final Destination destination) throws JMSException {
dest = destination;
}
@Override
public int getJMSDeliveryMode() throws JMSException {
return message.isDurable() ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
}
@Override
public void setJMSDeliveryMode(final int deliveryMode) throws JMSException {
if (deliveryMode == DeliveryMode.PERSISTENT) {
message.setDurable(true);
@ -393,10 +407,12 @@ public class ActiveMQMessage implements javax.jms.Message {
}
}
@Override
public boolean getJMSRedelivered() throws JMSException {
return message.getDeliveryCount() > 1;
}
@Override
public void setJMSRedelivered(final boolean redelivered) throws JMSException {
if (!redelivered) {
message.setDeliveryCount(1);
@ -411,6 +427,7 @@ public class ActiveMQMessage implements javax.jms.Message {
}
}
@Override
public void setJMSType(final String type) throws JMSException {
if (type != null) {
MessageUtil.setJMSType(message, type);
@ -419,6 +436,7 @@ public class ActiveMQMessage implements javax.jms.Message {
}
}
@Override
public String getJMSType() throws JMSException {
if (jmsType == null) {
jmsType = MessageUtil.getJMSType(message);
@ -426,24 +444,29 @@ public class ActiveMQMessage implements javax.jms.Message {
return jmsType;
}
@Override
public long getJMSExpiration() throws JMSException {
return message.getExpiration();
}
@Override
public void setJMSExpiration(final long expiration) throws JMSException {
message.setExpiration(expiration);
}
@Override
public int getJMSPriority() throws JMSException {
return message.getPriority();
}
@Override
public void setJMSPriority(final int priority) throws JMSException {
checkPriority(priority);
message.setPriority((byte) priority);
}
@Override
public void clearProperties() throws JMSException {
MessageUtil.clearProperties(message);
@ -451,14 +474,17 @@ public class ActiveMQMessage implements javax.jms.Message {
propertiesReadOnly = false;
}
@Override
public void clearBody() throws JMSException {
readOnly = false;
}
@Override
public boolean propertyExists(final String name) throws JMSException {
return MessageUtil.propertyExists(message, name);
}
@Override
public boolean getBooleanProperty(final String name) throws JMSException {
try {
return message.getBooleanProperty(new SimpleString(name));
@ -468,6 +494,7 @@ public class ActiveMQMessage implements javax.jms.Message {
}
}
@Override
public byte getByteProperty(final String name) throws JMSException {
try {
return message.getByteProperty(new SimpleString(name));
@ -477,6 +504,7 @@ public class ActiveMQMessage implements javax.jms.Message {
}
}
@Override
public short getShortProperty(final String name) throws JMSException {
try {
return message.getShortProperty(new SimpleString(name));
@ -486,6 +514,7 @@ public class ActiveMQMessage implements javax.jms.Message {
}
}
@Override
public int getIntProperty(final String name) throws JMSException {
if (MessageUtil.JMSXDELIVERYCOUNT.equals(name)) {
return message.getDeliveryCount();
@ -499,6 +528,7 @@ public class ActiveMQMessage implements javax.jms.Message {
}
}
@Override
public long getLongProperty(final String name) throws JMSException {
if (MessageUtil.JMSXDELIVERYCOUNT.equals(name)) {
return message.getDeliveryCount();
@ -512,6 +542,7 @@ public class ActiveMQMessage implements javax.jms.Message {
}
}
@Override
public float getFloatProperty(final String name) throws JMSException {
try {
return message.getFloatProperty(new SimpleString(name));
@ -521,6 +552,7 @@ public class ActiveMQMessage implements javax.jms.Message {
}
}
@Override
public double getDoubleProperty(final String name) throws JMSException {
try {
return message.getDoubleProperty(new SimpleString(name));
@ -530,6 +562,7 @@ public class ActiveMQMessage implements javax.jms.Message {
}
}
@Override
public String getStringProperty(final String name) throws JMSException {
if (MessageUtil.JMSXDELIVERYCOUNT.equals(name)) {
return String.valueOf(message.getDeliveryCount());
@ -548,6 +581,7 @@ public class ActiveMQMessage implements javax.jms.Message {
}
}
@Override
public Object getObjectProperty(final String name) throws JMSException {
if (MessageUtil.JMSXDELIVERYCOUNT.equals(name)) {
return String.valueOf(message.getDeliveryCount());
@ -566,42 +600,50 @@ public class ActiveMQMessage implements javax.jms.Message {
return Collections.enumeration(MessageUtil.getPropertyNames(message));
}
@Override
public void setBooleanProperty(final String name, final boolean value) throws JMSException {
checkProperty(name);
message.putBooleanProperty(new SimpleString(name), value);
}
@Override
public void setByteProperty(final String name, final byte value) throws JMSException {
checkProperty(name);
message.putByteProperty(new SimpleString(name), value);
}
@Override
public void setShortProperty(final String name, final short value) throws JMSException {
checkProperty(name);
message.putShortProperty(new SimpleString(name), value);
}
@Override
public void setIntProperty(final String name, final int value) throws JMSException {
checkProperty(name);
message.putIntProperty(new SimpleString(name), value);
}
@Override
public void setLongProperty(final String name, final long value) throws JMSException {
checkProperty(name);
message.putLongProperty(new SimpleString(name), value);
}
@Override
public void setFloatProperty(final String name, final float value) throws JMSException {
checkProperty(name);
message.putFloatProperty(new SimpleString(name), value);
}
@Override
public void setDoubleProperty(final String name, final double value) throws JMSException {
checkProperty(name);
message.putDoubleProperty(new SimpleString(name), value);
}
@Override
public void setStringProperty(final String name, final String value) throws JMSException {
checkProperty(name);
@ -613,6 +655,7 @@ public class ActiveMQMessage implements javax.jms.Message {
}
}
@Override
public void setObjectProperty(final String name, final Object value) throws JMSException {
if (ActiveMQJMSConstants.JMS_ACTIVEMQ_OUTPUT_STREAM.equals(name)) {
setOutputStream((OutputStream) value);
@ -641,6 +684,7 @@ public class ActiveMQMessage implements javax.jms.Message {
}
}
@Override
public void acknowledge() throws JMSException {
if (session != null) {
try {

View File

@ -86,18 +86,21 @@ public final class ActiveMQMessageConsumer implements QueueReceiver, TopicSubscr
// MessageConsumer implementation --------------------------------
@Override
public String getMessageSelector() throws JMSException {
checkClosed();
return selector;
}
@Override
public MessageListener getMessageListener() throws JMSException {
checkClosed();
return listener;
}
@Override
public void setMessageListener(final MessageListener listener) throws JMSException {
this.listener = listener;
@ -111,18 +114,22 @@ public final class ActiveMQMessageConsumer implements QueueReceiver, TopicSubscr
}
}
@Override
public Message receive() throws JMSException {
return getMessage(0, false);
}
@Override
public Message receive(final long timeout) throws JMSException {
return getMessage(timeout, false);
}
@Override
public Message receiveNoWait() throws JMSException {
return getMessage(0, true);
}
@Override
public void close() throws JMSException {
try {
consumer.close();
@ -141,6 +148,7 @@ public final class ActiveMQMessageConsumer implements QueueReceiver, TopicSubscr
// QueueReceiver implementation ----------------------------------
@Override
public Queue getQueue() throws JMSException {
checkClosed();
@ -149,12 +157,14 @@ public final class ActiveMQMessageConsumer implements QueueReceiver, TopicSubscr
// TopicSubscriber implementation --------------------------------
@Override
public Topic getTopic() throws JMSException {
checkClosed();
return (Topic) destination;
}
@Override
public boolean getNoLocal() throws JMSException {
checkClosed();

View File

@ -84,30 +84,35 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To
// MessageProducer implementation --------------------------------
@Override
public void setDisableMessageID(final boolean value) throws JMSException {
checkClosed();
disableMessageID = value;
}
@Override
public boolean getDisableMessageID() throws JMSException {
checkClosed();
return disableMessageID;
}
@Override
public void setDisableMessageTimestamp(final boolean value) throws JMSException {
checkClosed();
disableMessageTimestamp = value;
}
@Override
public boolean getDisableMessageTimestamp() throws JMSException {
checkClosed();
return disableMessageTimestamp;
}
@Override
public void setDeliveryMode(final int deliveryMode) throws JMSException {
checkClosed();
if (deliveryMode != DeliveryMode.NON_PERSISTENT && deliveryMode != DeliveryMode.PERSISTENT) {
@ -117,12 +122,14 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To
defaultDeliveryMode = deliveryMode;
}
@Override
public int getDeliveryMode() throws JMSException {
checkClosed();
return defaultDeliveryMode;
}
@Override
public void setPriority(final int defaultPriority) throws JMSException {
checkClosed();
@ -133,30 +140,35 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To
this.defaultPriority = defaultPriority;
}
@Override
public int getPriority() throws JMSException {
checkClosed();
return defaultPriority;
}
@Override
public void setTimeToLive(final long timeToLive) throws JMSException {
checkClosed();
defaultTimeToLive = timeToLive;
}
@Override
public long getTimeToLive() throws JMSException {
checkClosed();
return defaultTimeToLive;
}
@Override
public Destination getDestination() throws JMSException {
checkClosed();
return defaultDestination;
}
@Override
public void close() throws JMSException {
connection.getThreadAwareContext().assertNotCompletionListenerThread();
try {
@ -167,11 +179,13 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To
}
}
@Override
public void send(final Message message) throws JMSException {
checkDefaultDestination();
doSendx(defaultDestination, message, defaultDeliveryMode, defaultPriority, defaultTimeToLive, null);
}
@Override
public void send(final Message message,
final int deliveryMode,
final int priority,
@ -180,10 +194,12 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To
doSendx(defaultDestination, message, deliveryMode, priority, timeToLive, null);
}
@Override
public void send(final Destination destination, final Message message) throws JMSException {
send(destination, message, defaultDeliveryMode, defaultPriority, defaultTimeToLive);
}
@Override
public void send(final Destination destination,
final Message message,
final int deliveryMode,
@ -247,18 +263,22 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To
// TopicPublisher Implementation ---------------------------------
@Override
public Topic getTopic() throws JMSException {
return (Topic) getDestination();
}
@Override
public void publish(final Message message) throws JMSException {
send(message);
}
@Override
public void publish(final Topic topic, final Message message) throws JMSException {
send(topic, message);
}
@Override
public void publish(final Message message,
final int deliveryMode,
final int priority,
@ -266,6 +286,7 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To
send(message, deliveryMode, priority, timeToLive);
}
@Override
public void publish(final Topic topic,
final Message message,
final int deliveryMode,
@ -277,10 +298,12 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To
// QueueSender Implementation ------------------------------------
@Override
public void send(final Queue queue, final Message message) throws JMSException {
send((Destination) queue, message);
}
@Override
public void send(final Queue queue,
final Message message,
final int deliveryMode,
@ -290,6 +313,7 @@ public class ActiveMQMessageProducer implements MessageProducer, QueueSender, To
doSendx((ActiveMQDestination) queue, message, deliveryMode, priority, timeToLive, null);
}
@Override
public Queue getQueue() throws JMSException {
return (Queue) getDestination();
}

View File

@ -103,6 +103,7 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMess
// ObjectMessage implementation ----------------------------------
@Override
public void setObject(final Serializable object) throws JMSException {
checkWrite();
@ -128,6 +129,7 @@ public class ActiveMQObjectMessage extends ActiveMQMessage implements ObjectMess
}
// lazy deserialize the Object the first time the client requests it
@Override
public Serializable getObject() throws JMSException {
if (data == null || data.length == 0) {
return null;

View File

@ -66,6 +66,7 @@ public class ActiveMQQueue extends ActiveMQDestination implements Queue {
// Public --------------------------------------------------------
@Override
public String getQueueName() {
return name;
}

View File

@ -61,6 +61,7 @@ public final class ActiveMQQueueBrowser implements QueueBrowser {
// QueueBrowser implementation -------------------------------------------------------------------
@Override
public void close() throws JMSException {
if (consumer != null) {
try {
@ -72,6 +73,7 @@ public final class ActiveMQQueueBrowser implements QueueBrowser {
}
}
@Override
public Enumeration getEnumeration() throws JMSException {
try {
close();
@ -86,10 +88,12 @@ public final class ActiveMQQueueBrowser implements QueueBrowser {
}
@Override
public String getMessageSelector() throws JMSException {
return filterString == null ? null : filterString.toString();
}
@Override
public Queue getQueue() throws JMSException {
return queue;
}
@ -113,6 +117,7 @@ public final class ActiveMQQueueBrowser implements QueueBrowser {
ClientMessage current = null;
@Override
public boolean hasMoreElements() {
if (current == null) {
try {
@ -125,6 +130,7 @@ public final class ActiveMQQueueBrowser implements QueueBrowser {
return current != null;
}
@Override
public ActiveMQMessage nextElement() {
ActiveMQMessage msg;
if (hasMoreElements()) {

View File

@ -54,6 +54,7 @@ public class ActiveMQQueueConnectionFactory extends ActiveMQConnectionFactory im
super(ha, initialConnectors);
}
@Override
public int getFactoryType() {
return JMSFactoryType.QUEUE_CF.intValue();
}

View File

@ -115,30 +115,35 @@ public class ActiveMQSession implements QueueSession, TopicSession {
// Session implementation ----------------------------------------
@Override
public BytesMessage createBytesMessage() throws JMSException {
checkClosed();
return new ActiveMQBytesMessage(session);
}
@Override
public MapMessage createMapMessage() throws JMSException {
checkClosed();
return new ActiveMQMapMessage(session);
}
@Override
public Message createMessage() throws JMSException {
checkClosed();
return new ActiveMQMessage(session);
}
@Override
public ObjectMessage createObjectMessage() throws JMSException {
checkClosed();
return new ActiveMQObjectMessage(session);
}
@Override
public ObjectMessage createObjectMessage(final Serializable object) throws JMSException {
checkClosed();
@ -149,12 +154,14 @@ public class ActiveMQSession implements QueueSession, TopicSession {
return msg;
}
@Override
public StreamMessage createStreamMessage() throws JMSException {
checkClosed();
return new ActiveMQStreamMessage(session);
}
@Override
public TextMessage createTextMessage() throws JMSException {
checkClosed();
@ -165,6 +172,7 @@ public class ActiveMQSession implements QueueSession, TopicSession {
return msg;
}
@Override
public TextMessage createTextMessage(final String text) throws JMSException {
checkClosed();
@ -175,12 +183,14 @@ public class ActiveMQSession implements QueueSession, TopicSession {
return msg;
}
@Override
public boolean getTransacted() throws JMSException {
checkClosed();
return transacted;
}
@Override
public int getAcknowledgeMode() throws JMSException {
checkClosed();
@ -191,6 +201,7 @@ public class ActiveMQSession implements QueueSession, TopicSession {
return xa;
}
@Override
public void commit() throws JMSException {
if (!transacted) {
throw new IllegalStateException("Cannot commit a non-transacted session");
@ -206,6 +217,7 @@ public class ActiveMQSession implements QueueSession, TopicSession {
}
}
@Override
public void rollback() throws JMSException {
if (!transacted) {
throw new IllegalStateException("Cannot rollback a non-transacted session");
@ -222,6 +234,7 @@ public class ActiveMQSession implements QueueSession, TopicSession {
}
}
@Override
public void close() throws JMSException {
connection.getThreadAwareContext().assertNotCompletionListenerThread();
connection.getThreadAwareContext().assertNotMessageListenerThread();
@ -241,6 +254,7 @@ public class ActiveMQSession implements QueueSession, TopicSession {
}
}
@Override
public void recover() throws JMSException {
if (transacted) {
throw new IllegalStateException("Cannot recover a transacted session");
@ -256,19 +270,23 @@ public class ActiveMQSession implements QueueSession, TopicSession {
recoverCalled = true;
}
@Override
public MessageListener getMessageListener() throws JMSException {
checkClosed();
return null;
}
@Override
public void setMessageListener(final MessageListener listener) throws JMSException {
checkClosed();
}
@Override
public void run() {
}
@Override
public MessageProducer createProducer(final Destination destination) throws JMSException {
if (destination != null && !(destination instanceof ActiveMQDestination)) {
throw new InvalidDestinationException("Not an ActiveMQ Artemis Destination:" + destination);
@ -301,15 +319,18 @@ public class ActiveMQSession implements QueueSession, TopicSession {
}
}
@Override
public MessageConsumer createConsumer(final Destination destination) throws JMSException {
return createConsumer(destination, null, false);
}
@Override
public MessageConsumer createConsumer(final Destination destination,
final String messageSelector) throws JMSException {
return createConsumer(destination, messageSelector, false);
}
@Override
public MessageConsumer createConsumer(final Destination destination,
final String messageSelector,
final boolean noLocal) throws JMSException {
@ -331,6 +352,7 @@ public class ActiveMQSession implements QueueSession, TopicSession {
return createConsumer(jbdest, null, messageSelector, noLocal, ConsumerDurability.NON_DURABLE);
}
@Override
public Queue createQueue(final String queueName) throws JMSException {
// As per spec. section 4.11
if (sessionType == ActiveMQSession.TYPE_TOPIC_SESSION) {
@ -356,6 +378,7 @@ public class ActiveMQSession implements QueueSession, TopicSession {
}
}
@Override
public Topic createTopic(final String topicName) throws JMSException {
// As per spec. section 4.11
if (sessionType == ActiveMQSession.TYPE_QUEUE_SESSION) {
@ -381,10 +404,12 @@ public class ActiveMQSession implements QueueSession, TopicSession {
}
}
@Override
public TopicSubscriber createDurableSubscriber(final Topic topic, final String name) throws JMSException {
return createDurableSubscriber(topic, name, null, false);
}
@Override
public TopicSubscriber createDurableSubscriber(final Topic topic,
final String name,
String messageSelector,
@ -730,10 +755,12 @@ public class ActiveMQSession implements QueueSession, TopicSession {
checkClosed();
}
@Override
public QueueBrowser createBrowser(final Queue queue) throws JMSException {
return createBrowser(queue, null);
}
@Override
public QueueBrowser createBrowser(final Queue queue, String filterString) throws JMSException {
// As per spec. section 4.11
if (sessionType == ActiveMQSession.TYPE_TOPIC_SESSION) {
@ -784,6 +811,7 @@ public class ActiveMQSession implements QueueSession, TopicSession {
}
@Override
public TemporaryQueue createTemporaryQueue() throws JMSException {
// As per spec. section 4.11
if (sessionType == ActiveMQSession.TYPE_TOPIC_SESSION) {
@ -806,6 +834,7 @@ public class ActiveMQSession implements QueueSession, TopicSession {
}
}
@Override
public TemporaryTopic createTemporaryTopic() throws JMSException {
// As per spec. section 4.11
if (sessionType == ActiveMQSession.TYPE_QUEUE_SESSION) {
@ -833,6 +862,7 @@ public class ActiveMQSession implements QueueSession, TopicSession {
}
}
@Override
public void unsubscribe(final String name) throws JMSException {
// As per spec. section 4.11
if (sessionType == ActiveMQSession.TYPE_QUEUE_SESSION) {
@ -877,14 +907,17 @@ public class ActiveMQSession implements QueueSession, TopicSession {
// QueueSession implementation
@Override
public QueueReceiver createReceiver(final Queue queue, final String messageSelector) throws JMSException {
return (QueueReceiver) createConsumer(queue, messageSelector);
}
@Override
public QueueReceiver createReceiver(final Queue queue) throws JMSException {
return (QueueReceiver) createConsumer(queue);
}
@Override
public QueueSender createSender(final Queue queue) throws JMSException {
return (QueueSender) createProducer(queue);
}
@ -897,16 +930,19 @@ public class ActiveMQSession implements QueueSession, TopicSession {
// TopicSession implementation
@Override
public TopicPublisher createPublisher(final Topic topic) throws JMSException {
return (TopicPublisher) createProducer(topic);
}
@Override
public TopicSubscriber createSubscriber(final Topic topic,
final String messageSelector,
final boolean noLocal) throws JMSException {
return (TopicSubscriber) createConsumer(topic, messageSelector, noLocal);
}
@Override
public TopicSubscriber createSubscriber(final Topic topic) throws JMSException {
return (TopicSubscriber) createConsumer(topic);
}

View File

@ -86,6 +86,7 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre
// StreamMessage implementation ----------------------------------
@Override
public boolean readBoolean() throws JMSException {
checkRead();
try {
@ -99,6 +100,7 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre
}
}
@Override
public byte readByte() throws JMSException {
checkRead();
@ -113,6 +115,7 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre
}
}
@Override
public short readShort() throws JMSException {
checkRead();
try {
@ -126,6 +129,7 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre
}
}
@Override
public char readChar() throws JMSException {
checkRead();
try {
@ -139,6 +143,7 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre
}
}
@Override
public int readInt() throws JMSException {
checkRead();
try {
@ -152,6 +157,7 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre
}
}
@Override
public long readLong() throws JMSException {
checkRead();
try {
@ -165,6 +171,7 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre
}
}
@Override
public float readFloat() throws JMSException {
checkRead();
try {
@ -178,6 +185,7 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre
}
}
@Override
public double readDouble() throws JMSException {
checkRead();
try {
@ -191,6 +199,7 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre
}
}
@Override
public String readString() throws JMSException {
checkRead();
try {
@ -209,6 +218,7 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre
*/
private int len = 0;
@Override
public int readBytes(final byte[] value) throws JMSException {
checkRead();
try {
@ -225,6 +235,7 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre
}
}
@Override
public Object readObject() throws JMSException {
checkRead();
try {
@ -238,60 +249,70 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre
}
}
@Override
public void writeBoolean(final boolean value) throws JMSException {
checkWrite();
getBuffer().writeByte(DataConstants.BOOLEAN);
getBuffer().writeBoolean(value);
}
@Override
public void writeByte(final byte value) throws JMSException {
checkWrite();
getBuffer().writeByte(DataConstants.BYTE);
getBuffer().writeByte(value);
}
@Override
public void writeShort(final short value) throws JMSException {
checkWrite();
getBuffer().writeByte(DataConstants.SHORT);
getBuffer().writeShort(value);
}
@Override
public void writeChar(final char value) throws JMSException {
checkWrite();
getBuffer().writeByte(DataConstants.CHAR);
getBuffer().writeShort((short) value);
}
@Override
public void writeInt(final int value) throws JMSException {
checkWrite();
getBuffer().writeByte(DataConstants.INT);
getBuffer().writeInt(value);
}
@Override
public void writeLong(final long value) throws JMSException {
checkWrite();
getBuffer().writeByte(DataConstants.LONG);
getBuffer().writeLong(value);
}
@Override
public void writeFloat(final float value) throws JMSException {
checkWrite();
getBuffer().writeByte(DataConstants.FLOAT);
getBuffer().writeInt(Float.floatToIntBits(value));
}
@Override
public void writeDouble(final double value) throws JMSException {
checkWrite();
getBuffer().writeByte(DataConstants.DOUBLE);
getBuffer().writeLong(Double.doubleToLongBits(value));
}
@Override
public void writeString(final String value) throws JMSException {
checkWrite();
getBuffer().writeByte(DataConstants.STRING);
getBuffer().writeNullableString(value);
}
@Override
public void writeBytes(final byte[] value) throws JMSException {
checkWrite();
getBuffer().writeByte(DataConstants.BYTES);
@ -299,6 +320,7 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre
getBuffer().writeBytes(value);
}
@Override
public void writeBytes(final byte[] value, final int offset, final int length) throws JMSException {
checkWrite();
getBuffer().writeByte(DataConstants.BYTES);
@ -306,6 +328,7 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre
getBuffer().writeBytes(value, offset, length);
}
@Override
public void writeObject(final Object value) throws JMSException {
if (value instanceof String) {
writeString((String) value);
@ -345,6 +368,7 @@ public final class ActiveMQStreamMessage extends ActiveMQMessage implements Stre
}
}
@Override
public void reset() throws JMSException {
if (!readOnly) {
readOnly = true;

View File

@ -74,6 +74,7 @@ public class ActiveMQTextMessage extends ActiveMQMessage implements TextMessage
// TextMessage implementation ------------------------------------
@Override
public void setText(final String text) throws JMSException {
checkWrite();
@ -87,6 +88,7 @@ public class ActiveMQTextMessage extends ActiveMQMessage implements TextMessage
writeBodyText(message.getBodyBuffer(), this.text);
}
@Override
public String getText() {
if (text != null) {
return text.toString();

View File

@ -59,6 +59,7 @@ public class ActiveMQTopic extends ActiveMQDestination implements Topic {
// Topic implementation ------------------------------------------
@Override
public String getTopicName() {
return name;
}

View File

@ -54,6 +54,7 @@ public class ActiveMQTopicConnectionFactory extends ActiveMQConnectionFactory im
super(ha, initialConnectors);
}
@Override
public int getFactoryType() {
return JMSFactoryType.TOPIC_CF.intValue();
}

Some files were not shown because too many files have changed in this diff Show More