22
22
23
23
import com .devicehive .messages .handler .DeviceCreateHandler ;
24
24
import com .devicehive .messages .handler .PluginSubscribeRequestHandler ;
25
- import com .devicehive .messages .handler .command .*;
26
- import com .devicehive .messages .handler .dao .list .*;
25
+ import com .devicehive .messages .handler .PluginUnsubscribeRequestHandler ;
26
+ import com .devicehive .messages .handler .command .CommandGetSubscriptionRequestHandler ;
27
+ import com .devicehive .messages .handler .command .CommandInsertHandler ;
28
+ import com .devicehive .messages .handler .command .CommandSearchHandler ;
29
+ import com .devicehive .messages .handler .command .CommandSubscribeRequestHandler ;
30
+ import com .devicehive .messages .handler .command .CommandUpdateHandler ;
31
+ import com .devicehive .messages .handler .command .CommandUpdateSubscribeRequestHandler ;
32
+ import com .devicehive .messages .handler .command .CommandsUpdateHandler ;
33
+ import com .devicehive .messages .handler .dao .list .ListDeviceHandler ;
34
+ import com .devicehive .messages .handler .dao .list .ListNetworkHandler ;
35
+ import com .devicehive .messages .handler .dao .list .ListSubscribeHandler ;
36
+ import com .devicehive .messages .handler .dao .list .ListUserHandler ;
27
37
import com .devicehive .messages .handler .notification .NotificationSubscribeRequestHandler ;
28
38
import com .devicehive .messages .handler .command .CommandUnsubscribeRequestHandler ;
29
39
import com .devicehive .messages .handler .notification .NotificationInsertHandler ;
30
40
import com .devicehive .messages .handler .notification .NotificationSearchHandler ;
31
41
import com .devicehive .messages .handler .notification .NotificationUnsubscribeRequestHandler ;
32
42
import com .devicehive .shim .api .Action ;
33
43
import com .devicehive .shim .api .server .RequestHandler ;
44
+ import com .google .common .collect .ImmutableMap ;
34
45
import org .springframework .beans .factory .annotation .Autowired ;
35
46
import org .springframework .stereotype .Component ;
36
47
@@ -59,6 +70,7 @@ public class RequestHandlersMapper {
59
70
private final ListSubscribeHandler listSubscribeHandler ;
60
71
private final DeviceCreateHandler deviceCreateHandler ;
61
72
private final PluginSubscribeRequestHandler pluginSubscribeRequestHandler ;
73
+ private final PluginUnsubscribeRequestHandler pluginUnsubscribeRequestHandler ;
62
74
63
75
private Map <Action , RequestHandler > requestHandlerMap ;
64
76
@@ -81,7 +93,8 @@ public RequestHandlersMapper(CommandUpdateHandler commandUpdateHandler,
81
93
CommandSubscribeRequestHandler commandSubscribeRequestHandler ,
82
94
CommandUnsubscribeRequestHandler commandUnsubscribeRequestHandler ,
83
95
CommandUpdateSubscribeRequestHandler commandUpdateSubscribeRequestHandler ,
84
- PluginSubscribeRequestHandler pluginSubscribeRequestHandler ) {
96
+ PluginSubscribeRequestHandler pluginSubscribeRequestHandler ,
97
+ PluginUnsubscribeRequestHandler pluginUnsubscribeRequestHandler ) {
85
98
this .commandUpdateHandler = commandUpdateHandler ;
86
99
this .notificationSearchHandler = notificationSearchHandler ;
87
100
this .notificationInsertHandler = notificationInsertHandler ;
@@ -100,35 +113,32 @@ public RequestHandlersMapper(CommandUpdateHandler commandUpdateHandler,
100
113
this .commandUnsubscribeRequestHandler = commandUnsubscribeRequestHandler ;
101
114
this .commandUpdateSubscribeRequestHandler = commandUpdateSubscribeRequestHandler ;
102
115
this .pluginSubscribeRequestHandler = pluginSubscribeRequestHandler ;
116
+ this .pluginUnsubscribeRequestHandler = pluginUnsubscribeRequestHandler ;
103
117
}
104
118
105
119
@ PostConstruct
106
120
public void init () {
107
- requestHandlerMap = new HashMap <Action , RequestHandler >() {{
108
- put (Action .NOTIFICATION_SEARCH_REQUEST , notificationSearchHandler );
109
- put (Action .NOTIFICATION_INSERT_REQUEST , notificationInsertHandler );
110
- put (Action .NOTIFICATION_SUBSCRIBE_REQUEST , notificationSubscribeRequestHandler );
111
- put (Action .NOTIFICATION_UNSUBSCRIBE_REQUEST , notificationUnsubscribeRequestHandler );
112
- put (Action .COMMAND_INSERT_REQUEST , commandInsertHandler );
113
- put (Action .COMMAND_SEARCH_REQUEST , commandSearchHandler );
114
- put (Action .COMMAND_UPDATE_REQUEST , commandUpdateHandler );
115
- put (Action .COMMANDS_UPDATE_REQUEST , commandsUpdateHandler );
116
- put (Action .COMMAND_SUBSCRIBE_REQUEST , commandSubscribeRequestHandler );
117
- put (Action .COMMAND_UNSUBSCRIBE_REQUEST , commandUnsubscribeRequestHandler );
118
- put (Action .COMMAND_UPDATE_SUBSCRIBE_REQUEST , commandUpdateSubscribeRequestHandler );
119
- put (Action .COMMAND_GET_SUBSCRIPTION_REQUEST , commandGetSubscriptionRequestHandler );
120
- put (Action .PLUGIN_SUBSCRIBE_REQUEST , pluginSubscribeRequestHandler );
121
-
122
- put (Action .LIST_USER_REQUEST , listUserHandler );
123
-
124
- put (Action .LIST_NETWORK_REQUEST , listNetworkHandler );
125
-
126
- put (Action .LIST_DEVICE_REQUEST , listDeviceHandler );
127
-
128
- put (Action .LIST_SUBSCRIBE_REQUEST , listSubscribeHandler );
129
-
130
- put (Action .DEVICE_CREATE_REQUEST , deviceCreateHandler );
131
- }};
121
+ requestHandlerMap = ImmutableMap .<Action , RequestHandler >builder ()
122
+ .put (Action .NOTIFICATION_SEARCH_REQUEST , notificationSearchHandler )
123
+ .put (Action .NOTIFICATION_INSERT_REQUEST , notificationInsertHandler )
124
+ .put (Action .NOTIFICATION_SUBSCRIBE_REQUEST , notificationSubscribeRequestHandler )
125
+ .put (Action .NOTIFICATION_UNSUBSCRIBE_REQUEST , notificationUnsubscribeRequestHandler )
126
+ .put (Action .COMMAND_INSERT_REQUEST , commandInsertHandler )
127
+ .put (Action .COMMAND_SEARCH_REQUEST , commandSearchHandler )
128
+ .put (Action .COMMAND_UPDATE_REQUEST , commandUpdateHandler )
129
+ .put (Action .COMMANDS_UPDATE_REQUEST , commandsUpdateHandler )
130
+ .put (Action .COMMAND_SUBSCRIBE_REQUEST , commandSubscribeRequestHandler )
131
+ .put (Action .COMMAND_UNSUBSCRIBE_REQUEST , commandUnsubscribeRequestHandler )
132
+ .put (Action .COMMAND_UPDATE_SUBSCRIBE_REQUEST , commandUpdateSubscribeRequestHandler )
133
+ .put (Action .COMMAND_GET_SUBSCRIPTION_REQUEST , commandGetSubscriptionRequestHandler )
134
+ .put (Action .PLUGIN_SUBSCRIBE_REQUEST , pluginSubscribeRequestHandler )
135
+ .put (Action .PLUGIN_UNSUBSCRIBE_REQUEST , pluginUnsubscribeRequestHandler )
136
+ .put (Action .LIST_USER_REQUEST , listUserHandler )
137
+ .put (Action .LIST_NETWORK_REQUEST , listNetworkHandler )
138
+ .put (Action .LIST_DEVICE_REQUEST , listDeviceHandler )
139
+ .put (Action .LIST_SUBSCRIBE_REQUEST , listSubscribeHandler )
140
+ .put (Action .DEVICE_CREATE_REQUEST , deviceCreateHandler )
141
+ .build ();
132
142
}
133
143
134
144
public Map <Action , RequestHandler > requestHandlerMap () {
0 commit comments