View Javadoc
1   /*-
2    * #%L
3    * Spring Stomp Server
4    * ===============================================================
5    * Copyright (C) 2020 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;
21  
22  import org.slf4j.Logger;
23  import org.slf4j.LoggerFactory;
24  import org.springframework.beans.factory.InitializingBean;
25  import org.springframework.boot.Banner.Mode;
26  import org.springframework.boot.WebApplicationType;
27  import org.springframework.boot.autoconfigure.SpringBootApplication;
28  import org.springframework.boot.builder.SpringApplicationBuilder;
29  import org.springframework.boot.context.properties.EnableConfigurationProperties;
30  
31  /**
32   * Simple Spring Stomp Server as described in <a href="https://spring.io/guides/gs/messaging-stomp-websocket/">Spring Websocket Guide</a> .
33   */
34  @SpringBootApplication
35  @EnableConfigurationProperties
36  @SuppressWarnings("PMD.UseUtilityClass")
37  public class SpringStompServerApplication {
38  
39      /**
40       * Spring boot start.
41       *
42       * @param args Override Config-Properties. See: {@link net.brabenetz.app.springstompserver.config.WebSocketConfigProperties}.
43       */
44      @SuppressWarnings("resource")
45      public static void main(final String[] args) {
46          if (System.getProperty("spring.config.name") == null) {
47              System.setProperty("spring.config.name", "spring-stomp-server");
48          }
49  
50          new SpringApplicationBuilder(SpringStompServerApplication.class)
51                  .bannerMode(Mode.OFF)
52                  .parent(new SpringApplicationBuilder(AppPrepare.class)
53                          .banner(new SpringStompServerBanner())
54                          .web(WebApplicationType.NONE)
55                          .run(args))
56                  .run(args);
57      }
58  
59      /**
60       * AppPrepare to run before SpringStompServerApplication starts.
61       */
62      public static class AppPrepare implements InitializingBean {
63          private static final Logger LOG = LoggerFactory.getLogger(AppPrepare.class);
64  
65          @Override
66          public void afterPropertiesSet() throws Exception {
67              LOG.info("Current Java-Version: {}; OS: {}; Timezone: {}; Lang: {}",
68                      System.getProperty("java.version"),
69                      System.getProperty("os.name"),
70                      System.getProperty("user.timezone"),
71                      System.getProperty("user.language"));
72          }
73      }
74  
75  }