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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
/*
* Copyright (c) 2017-present Robert Jaros
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package pl.treksoft.kvision.remote
import org.reactivestreams.Publisher
import org.springframework.core.ParameterizedTypeReference
import org.springframework.core.io.buffer.DataBuffer
import org.springframework.core.io.buffer.DataBufferFactory
import org.springframework.http.HttpCookie
import org.springframework.http.codec.HttpMessageReader
import org.springframework.http.codec.multipart.Part
import org.springframework.http.server.reactive.ServerHttpRequest
import org.springframework.util.MultiValueMap
import org.springframework.web.reactive.function.BodyExtractor
import org.springframework.web.reactive.function.server.ServerRequest
import org.springframework.web.reactive.socket.CloseStatus
import org.springframework.web.reactive.socket.HandshakeInfo
import org.springframework.web.reactive.socket.WebSocketMessage
import org.springframework.web.reactive.socket.WebSocketSession
import org.springframework.web.server.ServerWebExchange
import org.springframework.web.server.WebSession
import org.springframework.web.util.UriBuilder
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono
import java.net.InetSocketAddress
import java.net.URI
import java.security.Principal
import java.util.*
import java.util.function.Function
/**
* Empty implementation of the ServerRequest interface
*/
internal class KVServerRequest : ServerRequest {
override fun <T : Any?> body(extractor: BodyExtractor<T, in ServerHttpRequest>): T {
throw IllegalStateException("Empty implementation")
}
override fun <T : Any?> body(extractor: BodyExtractor<T, in ServerHttpRequest>, hints: MutableMap<String, Any>): T {
throw IllegalStateException("Empty implementation")
}
override fun remoteAddress(): Optional<InetSocketAddress> {
throw IllegalStateException("Empty implementation")
}
override fun attributes(): MutableMap<String, Any> {
throw IllegalStateException("Empty implementation")
}
override fun session(): Mono<WebSession> {
throw IllegalStateException("Empty implementation")
}
override fun principal(): Mono<out Principal> {
throw IllegalStateException("Empty implementation")
}
override fun multipartData(): Mono<MultiValueMap<String, Part>> {
throw IllegalStateException("Empty implementation")
}
override fun messageReaders(): MutableList<HttpMessageReader<*>> {
throw IllegalStateException("Empty implementation")
}
override fun uri(): URI {
throw IllegalStateException("Empty implementation")
}
override fun exchange(): ServerWebExchange {
throw IllegalStateException("Empty implementation")
}
override fun <T : Any?> bodyToFlux(elementClass: Class<out T>): Flux<T> {
throw IllegalStateException("Empty implementation")
}
override fun <T : Any?> bodyToFlux(typeReference: ParameterizedTypeReference<T>): Flux<T> {
throw IllegalStateException("Empty implementation")
}
override fun formData(): Mono<MultiValueMap<String, String>> {
throw IllegalStateException("Empty implementation")
}
override fun queryParams(): MultiValueMap<String, String> {
throw IllegalStateException("Empty implementation")
}
override fun pathVariables(): MutableMap<String, String> {
throw IllegalStateException("Empty implementation")
}
override fun localAddress(): Optional<InetSocketAddress> {
throw IllegalStateException("Empty implementation")
}
override fun uriBuilder(): UriBuilder {
throw IllegalStateException("Empty implementation")
}
override fun methodName(): String {
throw IllegalStateException("Empty implementation")
}
override fun <T : Any?> bodyToMono(elementClass: Class<out T>): Mono<T> {
throw IllegalStateException("Empty implementation")
}
override fun <T : Any?> bodyToMono(typeReference: ParameterizedTypeReference<T>): Mono<T> {
throw IllegalStateException("Empty implementation")
}
override fun cookies(): MultiValueMap<String, HttpCookie> {
throw IllegalStateException("Empty implementation")
}
override fun headers(): ServerRequest.Headers {
throw IllegalStateException("Empty implementation")
}
}
/**
* Empty implementation of the WebSocketSession interface
*/
internal class KVWebSocketSession : WebSocketSession {
override fun getId(): String {
throw IllegalStateException("Empty implementation")
}
override fun binaryMessage(payloadFactory: Function<DataBufferFactory, DataBuffer>): WebSocketMessage {
throw IllegalStateException("Empty implementation")
}
override fun pingMessage(payloadFactory: Function<DataBufferFactory, DataBuffer>): WebSocketMessage {
throw IllegalStateException("Empty implementation")
}
override fun bufferFactory(): DataBufferFactory {
throw IllegalStateException("Empty implementation")
}
override fun getAttributes(): MutableMap<String, Any> {
throw IllegalStateException("Empty implementation")
}
override fun receive(): Flux<WebSocketMessage> {
throw IllegalStateException("Empty implementation")
}
override fun pongMessage(payloadFactory: Function<DataBufferFactory, DataBuffer>): WebSocketMessage {
throw IllegalStateException("Empty implementation")
}
override fun getHandshakeInfo(): HandshakeInfo {
throw IllegalStateException("Empty implementation")
}
override fun send(messages: Publisher<WebSocketMessage>): Mono<Void> {
throw IllegalStateException("Empty implementation")
}
override fun close(status: CloseStatus): Mono<Void> {
throw IllegalStateException("Empty implementation")
}
override fun textMessage(payload: String): WebSocketMessage {
throw IllegalStateException("Empty implementation")
}
}
|