blob: 460952b418364d25748820434fdc60382d37d333 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.messagebus;
/**
* To facilitate several configuration parameters to the {@link MessageBus#createIntermediateSession(IntermediateSessionParams)},
* all parameters are held by this class. This class has reasonable default values for each parameter.
*
* @author Simon Thoresen Hult
*/
public class IntermediateSessionParams {
// The session name to register with message bus.
private String name = "intermediate";
// Whether or not to broadcast name on network.
private boolean broadcastName = true;
// The handler to receive incoming replies.
private ReplyHandler replyHandler = null;
// The handler to receive incoming messages.
private MessageHandler msgHandler = null;
/**
* Constructs a new instance of this class with default values.
*/
public IntermediateSessionParams() {
// empty
}
/**
* Implements the copy constructor.
*
* @param params The object to copy.
*/
public IntermediateSessionParams(IntermediateSessionParams params) {
name = params.name;
broadcastName = params.broadcastName;
replyHandler = params.replyHandler;
msgHandler = params.msgHandler;
}
/**
* Returns the name to register with message bus.
*
* @return The name.
*/
public String getName() {
return name;
}
/**
* Sets the name to register with message bus.
*
* @param name The name to set.
* @return This, to allow chaining.
*/
public IntermediateSessionParams setName(String name) {
this.name = name;
return this;
}
/**
* Returns whether or not to broadcast the name of this session on the network.
*
* @return True to broadcast, false otherwise.
*/
public boolean getBroadcastName() {
return broadcastName;
}
/**
* Returns the handler to receive incoming replies.
*
* @return The handler.
*/
public ReplyHandler getReplyHandler() {
return replyHandler;
}
/**
* Sets the handler to recive incoming replies.
*
* @param handler The handler to set.
* @return This, to allow chaining.
*/
public IntermediateSessionParams setReplyHandler(ReplyHandler handler) {
replyHandler = handler;
return this;
}
/**
* Returns the handler to receive incoming messages.
*
* @return The handler.
*/
public MessageHandler getMessageHandler() {
return msgHandler;
}
/**
* Sets the handler to recive incoming messages.
*
* @param handler The handler to set.
* @return This, to allow chaining.
*/
public IntermediateSessionParams setMessageHandler(MessageHandler handler) {
msgHandler = handler;
return this;
}
/**
* Sets whether or not to broadcast the name of this session on the network.
*
* @param broadcastName True to broadcast, false otherwise.
* @return This, to allow chaining.
*/
public IntermediateSessionParams setBroadcastName(boolean broadcastName) {
this.broadcastName = broadcastName;
return this;
}
}
|