git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1390931 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2012-09-27 10:28:20 +00:00
parent c02acbd3d4
commit 3f49df7d70

View File

@ -24,7 +24,7 @@ import java.util.concurrent.locks.ReentrantLock;
*/ */
public class MutexTransport extends TransportFilter { public class MutexTransport extends TransportFilter {
private final ReentrantLock wreiteLock = new ReentrantLock(); private final ReentrantLock writeLock = new ReentrantLock();
private boolean syncOnCommand; private boolean syncOnCommand;
public MutexTransport(Transport next) { public MutexTransport(Transport next) {
@ -40,11 +40,11 @@ public class MutexTransport extends TransportFilter {
@Override @Override
public void onCommand(Object command) { public void onCommand(Object command) {
if (syncOnCommand) { if (syncOnCommand) {
wreiteLock.lock(); writeLock.lock();
try { try {
transportListener.onCommand(command); transportListener.onCommand(command);
} finally { } finally {
wreiteLock.unlock(); writeLock.unlock();
} }
} else { } else {
transportListener.onCommand(command); transportListener.onCommand(command);
@ -53,41 +53,41 @@ public class MutexTransport extends TransportFilter {
@Override @Override
public FutureResponse asyncRequest(Object command, ResponseCallback responseCallback) throws IOException { public FutureResponse asyncRequest(Object command, ResponseCallback responseCallback) throws IOException {
wreiteLock.lock(); writeLock.lock();
try { try {
return next.asyncRequest(command, null); return next.asyncRequest(command, null);
} finally { } finally {
wreiteLock.unlock(); writeLock.unlock();
} }
} }
@Override @Override
public void oneway(Object command) throws IOException { public void oneway(Object command) throws IOException {
wreiteLock.lock(); writeLock.lock();
try { try {
next.oneway(command); next.oneway(command);
} finally { } finally {
wreiteLock.unlock(); writeLock.unlock();
} }
} }
@Override @Override
public Object request(Object command) throws IOException { public Object request(Object command) throws IOException {
wreiteLock.lock(); writeLock.lock();
try { try {
return next.request(command); return next.request(command);
} finally { } finally {
wreiteLock.unlock(); writeLock.unlock();
} }
} }
@Override @Override
public Object request(Object command, int timeout) throws IOException { public Object request(Object command, int timeout) throws IOException {
wreiteLock.lock(); writeLock.lock();
try { try {
return next.request(command, timeout); return next.request(command, timeout);
} finally { } finally {
wreiteLock.unlock(); writeLock.unlock();
} }
} }