001/* 002 * Copyright 2012-2018 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.boot.docs.context.properties.bind; 018 019import java.time.Duration; 020import java.time.temporal.ChronoUnit; 021 022import org.springframework.boot.context.properties.ConfigurationProperties; 023import org.springframework.boot.convert.DurationUnit; 024 025/** 026 * A {@link ConfigurationProperties} example that uses {@link Duration}. 027 * 028 * @author Stephane Nicoll 029 */ 030// tag::example[] 031@ConfigurationProperties("app.system") 032public class AppSystemProperties { 033 034 @DurationUnit(ChronoUnit.SECONDS) 035 private Duration sessionTimeout = Duration.ofSeconds(30); 036 037 private Duration readTimeout = Duration.ofMillis(1000); 038 039 public Duration getSessionTimeout() { 040 return this.sessionTimeout; 041 } 042 043 public void setSessionTimeout(Duration sessionTimeout) { 044 this.sessionTimeout = sessionTimeout; 045 } 046 047 public Duration getReadTimeout() { 048 return this.readTimeout; 049 } 050 051 public void setReadTimeout(Duration readTimeout) { 052 this.readTimeout = readTimeout; 053 } 054 055} 056// end::example[]