8000 Refactor ConnectionParams to setters · panchenko/rabbitmq-java-client@907ddfb · GitHub
[go: up one dir, main page]

Skip to content

Commit 907ddfb

Browse files
Refactor ConnectionParams to setters
Before we introduce another field.
1 parent b145f02 commit 907ddfb

File tree

2 files changed

+89
-56
lines changed

2 files changed

+89
-56
lines changed

src/com/rabbitmq/client/ConnectionFactory.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -665,10 +665,21 @@ public Connection newConnection(ExecutorService executor, Address[] addrs)
665665
}
666666

667667
public ConnectionParams params(ExecutorService executor) {
668-
// TODO: switch to use setters for all fields
669-
ConnectionParams result = new ConnectionParams(username, password, executor, virtualHost, getClientProperties(),
670-
requestedFrameMax, requestedChannelMax, requestedHeartbeat, shutdownTimeout, saslConfig,
671-
networkRecoveryInterval, topologyRecovery, exceptionHandler, threadFactory);
668+
ConnectionParams result = new ConnectionParams();
669+
670+
result.setUsername(username);
671+
result.setPassword(password);
672+
result.setExecutor(executor);
673+
result.setVirtualHost(virtualHost);
674+
result.setClientProperties(getClientProperties());
675+
result.setRequestedFrameMax(requestedFrameMax);
676+
result.setRequestedChannelMax(requestedChannelMax);
677+
result.setShutdownTimeout(shutdownTimeout);
678+
result.setSaslConfig(saslConfig);
679+
result.setNetworkRecoveryInterval(networkRecoveryInterval);
680+
result.setTopologyRecovery(topologyRecovery);
681+
result.setExceptionHandler(exceptionHandler);
682+
result.setThreadFactory(threadFactory);
672683
result.setHandshakeTimeout(handshakeTimeout);
673684
return result;
674685
}

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

Lines changed: 74 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -8,58 +8,24 @@
88
import java.util.concurrent.ThreadFactory;
99

1010
public class ConnectionParams {
11-
private final String username;
12-
private final String password;
13-
private final ExecutorService executor;
14-
private final String virtualHost;
15-
private final Map<String, Object> clientProperties;
16-
private final int requestedFrameMax;
17-
private final int requestedChannelMax;
18-
private final int requestedHeartbeat;
11+
private String username;
12+
private String password;
13+
private ExecutorService executor;
14+
private String virtualHost;
15+
private Map<String, Object> clientProperties;
16+
private int requestedFrameMax;
17+
private int requestedChannelMax;
18+
private int requestedHeartbeat;
1919
private int handshakeTimeout;
20-
private final int shutdownTimeout;
21-
private final SaslConfig saslConfig;
22-
private final long networkRecoveryInterval;
23-
private final boolean topologyRecovery;
24-
25-
private final ExceptionHandler exceptionHandler;
26-
private final ThreadFactory threadFactory;
27-
28-
/**
29-
* @param username name used to establish connection
30-
* @param password for <code><b>username</b></code>
31-
* @param executor thread pool service for consumer threads for channels on this connection
32-
* @param virtualHost virtual host of this connection
33-
* @param clientProperties client info used in negotiating with the server
34-
* @param requestedFrameMax max size of frame offered
35-
* @param requestedChannelMax max number of channels offered
36-
* @param requestedHeartbeat heart-beat in seconds offered
37-
* @param saslConfig sasl configuration hook
38-
* @param networkRecoveryInterval interval used when recovering from network failure
39-
* @param topologyRecovery should topology (queues, exchanges, bindings, consumers) recovery be performed?
40-
* @param threadFactory factory that instantiates threads used by the client
41-
* @param exceptionHandler handles unhandled consumer exceptions
42-
*/
43< 8000 code class="diff-text syntax-highlighted-line deletion">-
public ConnectionParams(String username, String password, ExecutorService executor,
44-
String virtualHost, Map<String, Object> clientProperties,
45-
int requestedFrameMax, int requestedChannelMax, int requestedHeartbeat,
46-
int shutdownTimeout, SaslConfig saslConfig, long networkRecoveryInterval,
47-
boolean topologyRecovery, ExceptionHandler exceptionHandler, ThreadFactory threadFactory) {
48-
this.username = username;
49-
this.password = password;
50-
this.executor = executor;
51-
this.virtualHost = virtualHost;
52-
this.clientProperties = clientProperties;
53-
this.requestedFrameMax = requestedFrameMax;
54-
this.requestedChannelMax = requestedChannelMax;
55-
this.requestedHeartbeat = requestedHeartbeat;
56-
this.shutdownTimeout = shutdownTimeout;
57-
this.saslConfig = saslConfig;
58-
this.networkRecoveryInterval = networkRecoveryInterval;
59-
this.topologyRecovery = topologyRecovery;
60-
this.exceptionHandler = exceptionHandler;
61-
this.threadFactory = threadFactory;
62-
}
20+
private int shutdownTimeout;
21+
private SaslConfig saslConfig;
22+
private long networkRecoveryInterval;
23+
private boolean topologyRecovery;
24+
25+
private ExceptionHandler exceptionHandler;
26+
private ThreadFactory threadFactory;
27+
28+
public ConnectionParams() {}
6329

6430
public String getUsername() {
6531
return username;
@@ -121,7 +87,63 @@ public boolean isTopologyRecoveryEnabled() {
12187
return topologyRecovery;
12288
}
12389

124-
public ThreadFactory getThreadFactory() {
90+
public ThreadFactory getThreadFactory() {
12591
return threadFactory;
12692
}
93+
94+
public void setUsername(String username) {
95+
this.username = username;
96+
}
97+
98+
public void setPassword(String password) {
99+
this.password = password;
100+
}
101+
102+
public void setExecutor(ExecutorService executor) {
103+
this.executor = executor;
104+
}
105+
106+
public void setVirtualHost(String virtualHost) {
107+
this.virtualHost = virtualHost;
108+
}
109+
110+
public void setClientProperties(Map<String, Object> clientProperties) {
111+
this.clientProperties = clientProperties;
112+
}
113+
114+
public void setRequestedFrameMax(int requestedFrameMax) {
115+
this.requestedFrameMax = requestedFrameMax;
116+
}
117+
118+
public void setRequestedChannelMax(int requestedChannelMax) {
119+
this.requestedChannelMax = requestedChannelMax;
120+
}
121+
122+
public void setRequestedHeartbeat(int requestedHeartbeat) {
123+
this.requestedHeartbeat = requestedHeartbeat;
124+
}
125+
126+
public void setShutdownTimeout(int shutdownTimeout) {
127+
this.shutdownTimeout = shutdownTimeout;
128+
}
129+
130+
public void setSaslConfig(SaslConfig saslConfig) {
131+
this.saslConfig = saslConfig;
132+
}
133+
134+
public void setNetworkRecoveryInterval(long networkRecoveryInterval) {
135+
this.networkRecoveryInterval = networkRecoveryInterval;
136+
}
137+
138+
public void setTopologyRecovery(boolean topologyRecovery) {
139+
this.topologyRecovery = topologyRecovery;
140+
}
141+
142+
public void setExceptionHandler(ExceptionHandler exceptionHandler) {
143+
this.exceptionHandler = exceptionHandler;
144+
}
145+
146+
public void setThreadFactory(ThreadFactory threadFactory) {
147+
this.threadFactory = threadFactory;
148+
}
127149
}

0 commit comments

Comments
 (0)
0