Skip to content

Commit cb904b7

Browse files
committed
code-style improvements
1 parent 0ddaf44 commit cb904b7

File tree

11 files changed

+43
-6
lines changed

11 files changed

+43
-6
lines changed

app/server/src/main/java/io/zerodi/server/handler/PingHandler.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
import io.zerodi.messaging.amqp.MessageHandler;
99
import io.zerodi.ping.PingMessage;
1010

11+
/**
12+
* Handles incoming ping messages, responding with pong.
13+
*/
1114
@Component
1215
public class PingHandler implements MessageHandler<PingMessage, PingMessage> {
1316

component/messaging/src/main/java/io/zerodi/messaging/amqp/AmqpTemplateFactory.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
import io.zerodi.messaging.core.UniqueId;
2626
import io.zerodi.messaging.core.UniqueIdFactory;
2727

28+
/**
29+
* {@link org.springframework.beans.factory.FactoryBean} which will be used to obtain preconfigured instances
30+
* of {@link org.springframework.amqp.core.AmqpTemplate}
31+
*/
2832
@Primary
2933
@Component
3034
public class AmqpTemplateFactory implements FactoryBean<AmqpTemplate> {

component/messaging/src/main/java/io/zerodi/messaging/amqp/MessageHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* When dealing with AMQP, spring allows us to use an adapter (
55
* {@link org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter}, which can be instantiated with a delegate object, to
6-
* which the adapter will be passing incoming requests, expecting an object being sent back, which will be serialized and sent as the
6+
* which the adapter will be passing incoming messages, expecting an object being sent back, which will be serialized and sent as the
77
* response. Spring is the doing some "guessing game" on finding specific method in the delegate, which should be called to handle the
88
* message - implementing this interface enforces the presence of that method (<code>handleMessage</code>)
99
*

component/messaging/src/main/java/io/zerodi/messaging/amqp/MessageHandlerFactory.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66
import org.springframework.beans.factory.annotation.Autowired;
77
import org.springframework.stereotype.Component;
88

9+
/**
10+
* Factory which can be used to obtain preconfigured instances of {@link org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter}
11+
* <p/>
12+
* <p>(messages being sent are serialized to JSON, using a {@link org.springframework.amqp.support.converter.MessageConverter},
13+
* this factory makes sure that the same converter will be used in our handlers.)</p>
14+
*/
915
@Component
1016
public class MessageHandlerFactory {
1117

component/messaging/src/main/java/io/zerodi/messaging/amqp/SimpleMessageListenerContainerFactory.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
import com.google.common.base.Preconditions;
1111
import io.zerodi.messaging.configuration.MessagingConfiguration;
1212

13+
/**
14+
* Factory which can be used to obtain preconfigured instances of {@link org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer}
15+
*/
1316
@Component
1417
public class SimpleMessageListenerContainerFactory {
1518

@@ -31,7 +34,8 @@ public SimpleMessageListenerContainer createMessageListenerContainer(MessageList
3134
}
3235

3336
private void validateInput(final Object messageListener, final Queue[] queuesToListenOn) {
34-
Preconditions.checkNotNull(queuesToListenOn, "queuesToListenOn cannot be null!");
3537
Preconditions.checkNotNull(messageListener, "messageListener cannot be null!");
38+
Preconditions.checkNotNull(queuesToListenOn, "queuesToListenOn cannot be null!");
39+
Preconditions.checkArgument(queuesToListenOn.length > 0, "queuesToListenOn.length > 0 is not fulfilled!");
3640
}
3741
}

component/messaging/src/main/java/io/zerodi/messaging/async/response/ResponseContainer.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ public class ResponseContainer {
3232
/**
3333
* Notifies future (identified by id <code>uniqueId</code>, which is awaiting a response, with incoming response
3434
*/
35-
@SuppressWarnings("unchecked")
36-
<T> void notifyWithResponse(@Nonnull UniqueId uniqueId, @Nonnull T response) {
35+
@SuppressWarnings("unchecked") <T> void notifyWithResponse(@Nonnull UniqueId uniqueId, @Nonnull T response) {
3736
SettableFuture<?> future = pendingResponses.remove(uniqueId);
3837

3938
if (future == null) {
@@ -43,7 +42,7 @@ <T> void notifyWithResponse(@Nonnull UniqueId uniqueId, @Nonnull T response) {
4342

4443
logger.debug("notifying [ {} ] with [ {} ]", uniqueId, response);
4544

46-
// TODO I couldn't come with a better way of doing this, unchecked cast was the only thing which came to mind.
45+
// TODO I couldn't come with a better way of doing this given the time constraints.
4746
((SettableFuture<Object>) future).set(response);
4847
}
4948

component/messaging/src/main/java/io/zerodi/messaging/async/response/ResponseListener.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
import io.zerodi.messaging.core.UniqueId;
1010

11+
/**
12+
* Listener, which, when given an {@link io.zerodi.messaging.core.UniqueId}, will create a {@link java.util.concurrent.Future} which can
13+
* be passed to interested parties, which will be notified when a response comes in for given id.
14+
*/
1115
public interface ResponseListener extends MessageListener {
1216

1317
<T> Future<T> awaitResponse(@Nonnull UniqueId uniqueId);

component/messaging/src/main/java/io/zerodi/messaging/core/UniqueId.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package io.zerodi.messaging.core;
22

3+
/**
4+
* Simple "unique-ish" id.
5+
*/
36
public interface UniqueId {
47

58
public String asString();

component/messaging/src/main/java/io/zerodi/messaging/service/AddressingPostProcessor.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,16 @@
1111
import com.google.common.base.Preconditions;
1212
import io.zerodi.messaging.core.UniqueId;
1313

14+
/**
15+
* <p>
16+
* {@link org.springframework.amqp.core.MessagePostProcessor} which is addressing outgoing messages with the details of a queue, to which
17+
* responses need to be sent back
18+
* </p>
19+
* <p/>
20+
* <p>
21+
* It also sets message id & correlation id.
22+
* </p>
23+
*/
1424
class AddressingPostProcessor implements MessagePostProcessor {
1525

1626
private final Address responseAddress;

component/messaging/src/main/java/io/zerodi/messaging/service/AmqpMessagingService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
import io.zerodi.messaging.core.UniqueId;
1616
import io.zerodi.messaging.core.UniqueIdFactory;
1717

18-
@Service class AmqpMessagingService implements MessagingService {
18+
@Service
19+
class AmqpMessagingService implements MessagingService {
1920
private static final Logger logger = LoggerFactory.getLogger(AmqpMessagingService.class);
2021

2122
@Autowired

0 commit comments

Comments
 (0)