/* * Copyright 2014-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package io.pivotal.strepsirrhini.chaoslemur; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.concurrent.ThreadPoolExecutorFactoryBean; import org.springframework.web.client.RestTemplate; import java.security.SecureRandom; import java.util.Random; /** * Main entry point and configuration class */ @SpringBootApplication @EnableScheduling public class Application { /** * Start method * * @param args command line argument * @throws Exception */ public static void main(String[] args) throws Exception { SpringApplication.run(Application.class, args); } @Bean(destroyMethod = "shutdown") ThreadPoolExecutorFactoryBean executor() { ThreadPoolExecutorFactoryBean factoryBean = new ThreadPoolExecutorFactoryBean(); factoryBean.setQueueCapacity(5); factoryBean.setCorePoolSize(5); factoryBean.setMaxPoolSize(20); factoryBean.setThreadNamePrefix("destroyer-"); return factoryBean; } @Bean ObjectMapper objectMapper() { return new ObjectMapper().disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); } @Bean Random random() { return new SecureRandom(); } @Bean RestTemplate restTemplate() { return new RestTemplate(); } }