From 430412d3c6439d4745adf1ae5617153ccaaf7d73 Mon Sep 17 00:00:00 2001 From: madun Date: Fri, 9 Jul 2021 16:47:42 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=201=E3=80=81optimize=20class=20code?= =?UTF-8?q?=20structure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/rabbitmq/client/impl/recovery/RecordedEntity.java | 2 +- .../com/rabbitmq/client/impl/recovery/RecordedExchange.java | 1 + .../rabbitmq/client/impl/recovery/RecordedNamedEntity.java | 5 ++++- .../com/rabbitmq/client/impl/recovery/RecordedQueue.java | 5 +++-- .../rabbitmq/client/impl/recovery/RecordedQueueBinding.java | 2 +- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/rabbitmq/client/impl/recovery/RecordedEntity.java b/src/main/java/com/rabbitmq/client/impl/recovery/RecordedEntity.java index a9fae4c3ae..a56f58b88a 100644 --- a/src/main/java/com/rabbitmq/client/impl/recovery/RecordedEntity.java +++ b/src/main/java/com/rabbitmq/client/impl/recovery/RecordedEntity.java @@ -20,7 +20,7 @@ /** * @since 3.3.0 */ -public class RecordedEntity { +public abstract class RecordedEntity { protected final AutorecoveringChannel channel; public RecordedEntity(AutorecoveringChannel channel) { diff --git a/src/main/java/com/rabbitmq/client/impl/recovery/RecordedExchange.java b/src/main/java/com/rabbitmq/client/impl/recovery/RecordedExchange.java index 7625b5a870..aaedcbbf58 100644 --- a/src/main/java/com/rabbitmq/client/impl/recovery/RecordedExchange.java +++ b/src/main/java/com/rabbitmq/client/impl/recovery/RecordedExchange.java @@ -31,6 +31,7 @@ public RecordedExchange(AutorecoveringChannel channel, String name) { super(channel, name); } + @Override public void recover() throws IOException { this.channel.getDelegate().exchangeDeclare(this.name, this.type, this.durable, this.autoDelete, this.arguments); } diff --git a/src/main/java/com/rabbitmq/client/impl/recovery/RecordedNamedEntity.java b/src/main/java/com/rabbitmq/client/impl/recovery/RecordedNamedEntity.java index 6ea8b6fa96..7b5a86a8f9 100644 --- a/src/main/java/com/rabbitmq/client/impl/recovery/RecordedNamedEntity.java +++ b/src/main/java/com/rabbitmq/client/impl/recovery/RecordedNamedEntity.java @@ -15,10 +15,11 @@ package com.rabbitmq.client.impl.recovery; +import java.io.IOException; /** * @since 3.3.0 */ -public class RecordedNamedEntity extends RecordedEntity { +public abstract class RecordedNamedEntity extends RecordedEntity { protected String name; public RecordedNamedEntity(AutorecoveringChannel channel, String name) { @@ -26,6 +27,8 @@ public RecordedNamedEntity(AutorecoveringChannel channel, String name) { this.name = name; } + public abstract void recover() throws IOException; + public String getName() { return name; } diff --git a/src/main/java/com/rabbitmq/client/impl/recovery/RecordedQueue.java b/src/main/java/com/rabbitmq/client/impl/recovery/RecordedQueue.java index 52caced2af..b41ecdc302 100644 --- a/src/main/java/com/rabbitmq/client/impl/recovery/RecordedQueue.java +++ b/src/main/java/com/rabbitmq/client/impl/recovery/RecordedQueue.java @@ -55,6 +55,7 @@ public boolean isServerNamed() { return this.serverNamed; } + @Override public void recover() throws IOException { this.name = this.channel.getDelegate().queueDeclare(this.getNameToUseForRecovery(), this.durable, @@ -71,7 +72,7 @@ public RecordedQueue durable(boolean value) { this.durable = value; return this; } - + public boolean isDurable() { return this.durable; } @@ -80,7 +81,7 @@ public RecordedQueue autoDelete(boolean value) { this.autoDelete = value; return this; } - + public boolean isAutoDelete() { return this.autoDelete; } diff --git a/src/main/java/com/rabbitmq/client/impl/recovery/RecordedQueueBinding.java b/src/main/java/com/rabbitmq/client/impl/recovery/RecordedQueueBinding.java index 12ed3d48bb..37bbb14fe5 100644 --- a/src/main/java/com/rabbitmq/client/impl/recovery/RecordedQueueBinding.java +++ b/src/main/java/com/rabbitmq/client/impl/recovery/RecordedQueueBinding.java @@ -27,7 +27,7 @@ public RecordedQueueBinding(AutorecoveringChannel channel) { @Override public void recover() throws IOException { - this.channel.getDelegate().queueBind(this.getDestination(), this.getSource(), this.routingKey, this.arguments); + this.channel.getDelegate().queueBind(this.destination, this.source, this.routingKey, this.arguments); } @Override