Skip to content

Commit eb3509a

Browse files
committed
Polishing
1 parent 93ad7f8 commit eb3509a

File tree

3 files changed

+34
-41
lines changed

3 files changed

+34
-41
lines changed

spring-messaging/src/main/java/org/springframework/messaging/simp/config/MessageBrokerRegistry.java

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ public class MessageBrokerRegistry {
4141

4242
private StompBrokerRelayRegistration brokerRelayRegistration;
4343

44+
private final ChannelRegistration brokerChannelRegistration = new ChannelRegistration();
45+
4446
private String[] applicationDestinationPrefixes;
4547

4648
private String userDestinationPrefix;
4749

48-
private ChannelRegistration brokerChannelRegistration = new ChannelRegistration();
49-
5050

5151
public MessageBrokerRegistry(SubscribableChannel clientInboundChannel, MessageChannel clientOutboundChannel) {
5252
Assert.notNull(clientInboundChannel);
@@ -55,6 +55,7 @@ public MessageBrokerRegistry(SubscribableChannel clientInboundChannel, MessageCh
5555
this.clientOutboundChannel = clientOutboundChannel;
5656
}
5757

58+
5859
/**
5960
* Enable a simple message broker and configure one or more prefixes to filter
6061
* destinations targeting the broker (e.g. destinations prefixed with "/topic").
@@ -76,6 +77,21 @@ public StompBrokerRelayRegistration enableStompBrokerRelay(String... destination
7677
return this.brokerRelayRegistration;
7778
}
7879

80+
/**
81+
* Customize the channel used to send messages from the application to the message
82+
* broker. By default, messages from the application to the message broker are sent
83+
* synchronously, which means application code sending a message will find out
84+
* if the message cannot be sent through an exception. However, this can be changed
85+
* if the broker channel is configured here with task executor properties.
86+
*/
87+
public ChannelRegistration configureBrokerChannel() {
88+
return this.brokerChannelRegistration;
89+
}
90+
91+
protected ChannelRegistration getBrokerChannelRegistration() {
92+
return this.brokerChannelRegistration;
93+
}
94+
7995
/**
8096
* Configure one or more prefixes to filter destinations targeting application
8197
* annotated methods. For example destinations prefixed with "/app" may be
@@ -91,6 +107,11 @@ public MessageBrokerRegistry setApplicationDestinationPrefixes(String... prefixe
91107
return this;
92108
}
93109

110+
protected Collection<String> getApplicationDestinationPrefixes() {
111+
return (this.applicationDestinationPrefixes != null ?
112+
Arrays.asList(this.applicationDestinationPrefixes) : null);
113+
}
114+
94115
/**
95116
* Configure the prefix used to identify user destinations. User destinations
96117
* provide the ability for a user to subscribe to queue names unique to their
@@ -108,19 +129,13 @@ public MessageBrokerRegistry setUserDestinationPrefix(String destinationPrefix)
108129
return this;
109130
}
110131

111-
/**
112-
* Customize the channel used to send messages from the application to the message
113-
* broker. By default messages from the application to the message broker are sent
114-
* synchronously, which means application code sending a message will find out
115-
* if the message cannot be sent through an exception. However, this can be changed
116-
* if the broker channel is configured here with task executor properties.
117-
*/
118-
public ChannelRegistration configureBrokerChannel() {
119-
return this.brokerChannelRegistration;
132+
protected String getUserDestinationPrefix() {
133+
return this.userDestinationPrefix;
120134
}
121135

136+
122137
protected SimpleBrokerMessageHandler getSimpleBroker(SubscribableChannel brokerChannel) {
123-
if ((this.simpleBrokerRegistration == null) && (this.brokerRelayRegistration == null)) {
138+
if (this.simpleBrokerRegistration == null && this.brokerRelayRegistration == null) {
124139
enableSimpleBroker();
125140
}
126141
if (this.simpleBrokerRegistration != null) {
@@ -136,16 +151,4 @@ protected StompBrokerRelayMessageHandler getStompBrokerRelay(SubscribableChannel
136151
return null;
137152
}
138153

139-
protected Collection<String> getApplicationDestinationPrefixes() {
140-
return (this.applicationDestinationPrefixes != null)
141-
? Arrays.asList(this.applicationDestinationPrefixes) : null;
142-
}
143-
144-
protected String getUserDestinationPrefix() {
145-
return this.userDestinationPrefix;
146-
}
147-
148-
protected ChannelRegistration getBrokerChannelRegistration() {
149-
return this.brokerChannelRegistration;
150-
}
151154
}

spring-messaging/src/main/java/org/springframework/messaging/simp/config/SimpleBrokerRegistration.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -28,14 +28,10 @@
2828
*/
2929
public class SimpleBrokerRegistration extends AbstractBrokerRegistration {
3030

31-
32-
public SimpleBrokerRegistration(SubscribableChannel clientInboundChannel,
33-
MessageChannel clientOutboundChannel, String[] destinationPrefixes) {
34-
35-
super(clientInboundChannel, clientOutboundChannel, destinationPrefixes);
31+
public SimpleBrokerRegistration(SubscribableChannel inChannel, MessageChannel outChannel, String[] prefixes) {
32+
super(inChannel, outChannel, prefixes);
3633
}
3734

38-
3935
@Override
4036
protected SimpleBrokerMessageHandler getMessageHandler(SubscribableChannel brokerChannel) {
4137
return new SimpleBrokerMessageHandler(getClientInboundChannel(),

spring-messaging/src/main/java/org/springframework/messaging/simp/config/StompBrokerRelayRegistration.java

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,10 @@ public StompBrokerRelayRegistration setRelayPort(int relayPort) {
7474
return this;
7575
}
7676

77-
7877
/**
7978
* Set the login to use when creating connections to the STOMP broker on
8079
* behalf of connected clients.
81-
* <p>
82-
* By default this is set to "guest".
80+
* <p>By default this is set to "guest".
8381
*/
8482
public StompBrokerRelayRegistration setClientLogin(String login) {
8583
Assert.hasText(login, "clientLogin must not be empty");
@@ -90,8 +88,7 @@ public StompBrokerRelayRegistration setClientLogin(String login) {
9088
/**
9189
* Set the passcode to use when creating connections to the STOMP broker on
9290
* behalf of connected clients.
93-
* <p>
94-
* By default this is set to "guest".
91+
* <p>By default this is set to "guest".
9592
*/
9693
public StompBrokerRelayRegistration setClientPasscode(String passcode) {
9794
Assert.hasText(passcode, "clientPasscode must not be empty");
@@ -103,8 +100,7 @@ public StompBrokerRelayRegistration setClientPasscode(String passcode) {
103100
* Set the login for the shared "system" connection used to send messages to
104101
* the STOMP broker from within the application, i.e. messages not associated
105102
* with a specific client session (e.g. REST/HTTP request handling method).
106-
* <p>
107-
* By default this is set to "guest".
103+
* <p>By default this is set to "guest".
108104
*/
109105
public StompBrokerRelayRegistration setSystemLogin(String login) {
110106
Assert.hasText(login, "systemLogin must not be empty");
@@ -116,8 +112,7 @@ public StompBrokerRelayRegistration setSystemLogin(String login) {
116112
* Set the passcode for the shared "system" connection used to send messages to
117113
* the STOMP broker from within the application, i.e. messages not associated
118114
* with a specific client session (e.g. REST/HTTP request handling method).
119-
* <p>
120-
* By default this is set to "guest".
115+
* <p>By default this is set to "guest".
121116
*/
122117
public StompBrokerRelayRegistration setSystemPasscode(String passcode) {
123118
Assert.hasText(passcode, "systemPasscode must not be empty");
@@ -173,7 +168,6 @@ public StompBrokerRelayRegistration setAutoStartup(boolean autoStartup) {
173168

174169

175170
protected StompBrokerRelayMessageHandler getMessageHandler(SubscribableChannel brokerChannel) {
176-
177171
StompBrokerRelayMessageHandler handler = new StompBrokerRelayMessageHandler(getClientInboundChannel(),
178172
getClientOutboundChannel(), brokerChannel, getDestinationPrefixes());
179173

0 commit comments

Comments
 (0)