001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.examples.rest.springboot;
014
015import org.apache.juneau.examples.rest.*;
016import org.apache.juneau.rest.springboot.*;
017import org.apache.juneau.rest.springboot.annotation.*;
018import org.springframework.boot.autoconfigure.SpringBootApplication;
019import org.springframework.boot.builder.*;
020import org.springframework.boot.web.servlet.*;
021import org.springframework.context.annotation.*;
022import org.springframework.stereotype.Controller;
023import org.springframework.web.filter.*;
024
025/**
026 * Entry point for Examples REST application when deployed as a Spring Boot application.
027 *
028 * <ul class='seealso'>
029 *    <li class='extlink'>{@source}
030 * </ul>
031 */
032@SpringBootApplication
033@Controller
034public class App {
035
036   /**
037    * Entry point method.
038    * @param args Command-line arguments.
039    */
040   public static void main(String[] args) {
041      new SpringApplicationBuilder(App.class)
042         .initializers(new JuneauRestInitializer(App.class))
043         .run(args);
044
045      System.err.println(System.getProperty("server.port"));
046   }
047
048   /**
049    * @return Our root resource.
050    */
051   @Bean @JuneauRestRoot
052   public RootResources getRootResources() {
053      return new RootResources();
054   }
055
056   /**
057    * We want to be able to consume url-encoded-form-post bodies, but HiddenHttpMethodFilter triggers the HTTP
058    * body to be consumed.  So disable it.
059    *
060    * @param filter The filter.
061    * @return Filter registration bean.
062    */
063   @Bean
064   public FilterRegistrationBean<HiddenHttpMethodFilter> registration(HiddenHttpMethodFilter filter) {
065       FilterRegistrationBean<HiddenHttpMethodFilter> registration = new FilterRegistrationBean<>(filter);
066       registration.setEnabled(false);
067       return registration;
068   }
069}