1 /*-
2 * #%L
3 * Spring Stomp Server
4 * ===============================================================
5 * Copyright (C) 2020 - 2023 Brabenetz Harald, Austria
6 * ===============================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * #L%
19 */
20 package net.brabenetz.app.springstompserver.config;
21
22 import org.springframework.boot.context.properties.ConfigurationProperties;
23 import org.springframework.stereotype.Component;
24 import org.springframework.validation.annotation.Validated;
25
26 import java.util.regex.Pattern;
27
28 /**
29 * Websocket Stomp Properties use in the {@link WebSocketConfig}.
30 */
31 @Component
32 @ConfigurationProperties("spring-stomp-server.init-load")
33 @SuppressWarnings("PMD.DataClass")
34 @Validated
35 public class WebSocketInitLoadConfigProperties {
36
37 /**
38 * The Websocket Subscription destination pattern like "/user/00001111-2222-3333-4444-555566667777/topic/...".
39 * <p>
40 * Default is "^/user/[^/]+/topic/(.*)$"
41 */
42 private Pattern destinationPatterns = Pattern.compile("^/user/[^/]+/topic/(.*)$");
43
44 /**
45 * The proxy url from where the init load should be get, like: "http://localhost:8181/my-mock-endpoint/${group-1}".
46 * <p>
47 * Only GET requests are supported.<br>
48 * ${group-1}, ${group-2}, ${group-3}, ... ${group-X} reference to the group-pattern from {@link #getDestinationPatterns()}.<br>
49 * The Proxy-Server can then be a Mock-Server like https://wiremock.org/
50 */
51 private String proxyUrl;
52
53 /**
54 * Gets the Websocket Subscription destination pattern like "/user/00001111-2222-3333-4444-555566667777/topic/..".
55 * <p>
56 * Default is "^/user/[^/]+/topic/(.*)$".
57 *
58 * @return the Websocket Subscription destination pattern like "/user/00001111-2222-3333-4444-555566667777/topic/
59 */
60 public Pattern getDestinationPatterns() {
61 return destinationPatterns;
62 }
63
64 /**
65 * Sets the Websocket Subscription destination pattern like "/user/00001111-2222-3333-4444-555566667777/topic/..".
66 * <p>
67 * Default is "^/user/[^/]+/topic/(.*)$".
68 *
69 * @param destinationPatterns the new Websocket Subscription destination pattern like "/user/00001111-2222-3333-4444-555566667777/topic/
70 */
71 public void setDestinationPatterns(Pattern destinationPatterns) {
72 this.destinationPatterns = destinationPatterns;
73 }
74
75 /**
76 * Gets the proxy url from where the init load should be get, like: "http://localhost:8181/my-mock-endpoint/${group-1}".
77 * <p>
78 * Only GET requests are supported.<br>
79 * ${group-1}, ${group-2}, ${group-3}, .. ${group-X} reference to the group-pattern from {@link #getDestinationPatterns()}.<br>
80 * The Proxy-Server can then be a Mock-Server like https://wiremock.org/.
81 *
82 * @return the proxy url from where the init load should be get, like: "http://localhost:8181/my-mock-endpoint/${group-1}"
83 */
84 public String getProxyUrl() {
85 return proxyUrl;
86 }
87
88 /**
89 * Sets the proxy url from where the init load should be get, like: "http://localhost:8181/my-mock-endpoint/${group-1}".
90 * <p>
91 * Only GET requests are supported.<br>
92 * ${group-1}, ${group-2}, ${group-3}, .. ${group-X} reference to the group-pattern from {@link #getDestinationPatterns()}.<br>
93 * The Proxy-Server can then be a Mock-Server like https://wiremock.org/.
94 *
95 * @param proxyUrl the new proxy url from where the init load should be get, like: "http://localhost:8181/my-mock-endpoint/${group-1}"
96 */
97 public void setProxyUrl(String proxyUrl) {
98 this.proxyUrl = proxyUrl;
99 }
100
101 }