Skip to content

Commit f505ab2

Browse files
author
Steve Powell
committed
Clean impl.Method from Channel and Command interfaces and propagate (+ tests).
1 parent 4157d97 commit f505ab2

File tree

8 files changed

+25
-22
lines changed

8 files changed

+25
-22
lines changed

src/com/rabbitmq/client/Channel.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -707,8 +707,8 @@ void basicNack(long deliveryTag, boolean multiple, boolean requeue)
707707
/**
708708
* Synchronously send a method over this channel.
709709
* @param method method to transmit over this channel.
710-
* @return response to method. Caller should cast as appropriate.
710+
* @return command response to method. Caller should cast as appropriate.
711711
* @throws IOException Problem transmitting method.
712712
*/
713-
Method rpc(Method method) throws IOException;
713+
Command rpc(Method method) throws IOException;
714714
}

src/com/rabbitmq/client/Command.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717

1818
package com.rabbitmq.client;
1919

20-
import com.rabbitmq.client.impl.Method;
21-
22-
2320
/**
2421
* Interface to a container for an AMQP method-and-arguments, with optional content header and body.
2522
*/

src/com/rabbitmq/client/impl/AMQChannel.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import com.rabbitmq.client.AlreadyClosedException;
2424
import com.rabbitmq.client.Command;
25+
import com.rabbitmq.client.Method;
2526
import com.rabbitmq.client.Connection;
2627
import com.rabbitmq.client.ShutdownSignalException;
2728
import com.rabbitmq.utility.BlockingValueOrException;
@@ -118,11 +119,11 @@ public static IOException wrap(ShutdownSignalException ex, String message) {
118119
/**
119120
* Placeholder until we address bug 15786 (implementing a proper exception hierarchy).
120121
*/
121-
public AMQCommand exnWrappingRpc(com.rabbitmq.client.Method m)
122+
public AMQCommand exnWrappingRpc(Method m)
122123
throws IOException
123124
{
124125
try {
125-
return rpc((com.rabbitmq.client.impl.Method)m);
126+
return rpc(m);
126127
} catch (AlreadyClosedException ace) {
127128
// Do not wrap it since it means that connection/channel
128129
// was closed in some action in the past
@@ -183,8 +184,8 @@ public void ensureIsOpen()
183184
}
184185

185186
/**
186-
* Protected API - sends a Command to the broker and waits for the
187-
* next inbound Command from the broker: only for use from
187+
* Protected API - sends a {@link Method} to the broker and waits for the
188+
* next in-bound Command from the broker: only for use from
188189
* non-connection-MainLoop threads!
189190
*/
190191
public AMQCommand rpc(Method m)

src/com/rabbitmq/client/impl/AMQConnection.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.util.concurrent.TimeoutException;
2727

2828
import com.rabbitmq.client.AMQP;
29+
import com.rabbitmq.client.Method;
2930
import com.rabbitmq.client.AlreadyClosedException;
3031
import com.rabbitmq.client.Channel;
3132
import com.rabbitmq.client.Command;

src/com/rabbitmq/client/impl/ChannelN.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import com.rabbitmq.client.Envelope;
3232
import com.rabbitmq.client.FlowListener;
3333
import com.rabbitmq.client.GetResponse;
34+
import com.rabbitmq.client.Method;
3435
import com.rabbitmq.client.MessageProperties;
3536
import com.rabbitmq.client.ReturnListener;
3637
import com.rabbitmq.client.ShutdownSignalException;
@@ -106,7 +107,7 @@ public ChannelN(AMQConnection connection, int channelNumber) {
106107

107108
/**
108109
* Package method: open the channel.
109-
* This is only called from AMQConnection.
110+
* This is only called from {@link ChannelManager}.
110111
* @throws java.io.IOException if any problem is encountered
111112
*/
112113
public void open() throws IOException {
@@ -967,13 +968,12 @@ public long getNextPublishSeqNo() {
967968
return nextPublishSeqNo;
968969
}
969970

970-
public void asyncRpc(com.rabbitmq.client.Method method) throws IOException {
971-
// This cast should eventually go
972-
transmit((com.rabbitmq.client.impl.Method)method);
971+
public void asyncRpc(Method method) throws IOException {
972+
transmit(method);
973973
}
974974

975-
public Method rpc(com.rabbitmq.client.Method method) throws IOException {
976-
return exnWrappingRpc((com.rabbitmq.client.impl.Method)method).getMethod();
975+
public AMQCommand rpc(Method method) throws IOException {
976+
return exnWrappingRpc(method);
977977
}
978978

979979
}

test/src/com/rabbitmq/client/test/AMQBuilderApiTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ public void testParticularBuilderForBasicSanityWithRpc() throws IOException
3333
.type("direct")
3434
.durable(false)
3535
.build()
36-
);
36+
).getMethod();
3737

3838
assertTrue("Channel should still be open.", channel.isOpen());
3939
assertTrue(retVal instanceof AMQP.Exchange.DeclareOk);
4040

4141
retVal = channel.rpc(new AMQP.Exchange.Delete.Builder()
4242
.exchange(XCHG_NAME)
4343
.build()
44-
);
44+
).getMethod();
4545

4646
assertTrue("Channel should still be open.", channel.isOpen());
4747
assertTrue(retVal instanceof AMQP.Exchange.DeleteOk);

test/src/com/rabbitmq/client/test/functional/ConnectionOpen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import com.rabbitmq.client.AMQP;
2424
import com.rabbitmq.client.MalformedFrameException;
25-
import com.rabbitmq.client.impl.Method;
25+
import com.rabbitmq.client.Method;
2626
import com.rabbitmq.client.impl.SocketFrameHandler;
2727
import com.rabbitmq.client.impl.AMQCommand;
2828
import com.rabbitmq.client.ConnectionFactory;

test/src/com/rabbitmq/examples/TestMain.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,11 @@
2929
import com.rabbitmq.client.Envelope;
3030
import com.rabbitmq.client.GetResponse;
3131
import com.rabbitmq.client.MessageProperties;
32+
import com.rabbitmq.client.Method;
3233
import com.rabbitmq.client.ReturnListener;
3334
import com.rabbitmq.client.ShutdownSignalException;
3435
import com.rabbitmq.client.impl.AMQConnection;
35-
import com.rabbitmq.client.impl.AMQImpl;
3636
import com.rabbitmq.client.impl.FrameHandler;
37-
import com.rabbitmq.client.impl.Method;
3837
import com.rabbitmq.client.impl.SocketFrameHandler;
3938
import com.rabbitmq.utility.BlockingCell;
4039
import com.rabbitmq.utility.Utility;
@@ -233,7 +232,12 @@ public void run() throws IOException {
233232
_ch1.setReturnListener(new ReturnListener() {
234233
public void handleReturn(int replyCode, String replyText, String exchange, String routingKey, AMQP.BasicProperties properties, byte[] body)
235234
throws IOException {
236-
Method method = new AMQImpl.Basic.Return(replyCode, replyText, exchange, routingKey);
235+
Method method = new AMQP.Basic.Return.Builder()
236+
.replyCode(replyCode)
237+
.replyText(replyText)
238+
.exchange(exchange)
239+
.routingKey(routingKey)
240+
.build();
237241
log("Handling return with body " + new String(body));
238242
returnCell.set(new Object[] { method, properties, body });
239243
}
@@ -430,7 +434,7 @@ public void tryTopics() throws IOException {
430434

431435
public void doBasicReturn(BlockingCell<Object> cell, int expectedCode) {
432436
Object[] a = (Object[]) cell.uninterruptibleGet();
433-
AMQImpl.Basic.Return method = (AMQImpl.Basic.Return) a[0];
437+
AMQP.Basic.Return method = (AMQP.Basic.Return) a[0];
434438
log("Returned: " + method);
435439
log(" - props: " + a[1]);
436440
log(" - body: " + new String((byte[]) a[2]));

0 commit comments

Comments
 (0)