Allow the negociation protocol to be used when not inserted as a transport filter.

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@754959 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2009-03-16 17:13:20 +00:00
parent 3b06e128f9
commit 95ff01053a
1 changed files with 51 additions and 43 deletions

View File

@ -71,6 +71,11 @@ public class WireFormatNegotiator extends TransportFilter {
public void start() throws Exception {
super.start();
if (firstStart.compareAndSet(true, false)) {
sendWireFormat();
}
}
public void sendWireFormat() throws IOException {
try {
WireFormatInfo info = wireFormat.getPreferedWireFormatInfo();
if (LOG.isDebugEnabled()) {
@ -81,7 +86,6 @@ public class WireFormatNegotiator extends TransportFilter {
wireInfoSentDownLatch.countDown();
}
}
}
public void stop() throws Exception {
super.stop();
@ -104,6 +108,12 @@ public class WireFormatNegotiator extends TransportFilter {
Command command = (Command)o;
if (command.isWireFormatInfo()) {
WireFormatInfo info = (WireFormatInfo)command;
negociate(info);
}
getTransportListener().onCommand(command);
}
public void negociate(WireFormatInfo info) {
if (LOG.isDebugEnabled()) {
LOG.debug("Received WireFormat: " + info);
}
@ -140,8 +150,6 @@ public class WireFormatNegotiator extends TransportFilter {
readyCountDownLatch.countDown();
onWireFormatNegotiated(info);
}
getTransportListener().onCommand(command);
}
public void onException(IOException error) {
readyCountDownLatch.countDown();