SystemInfoServiceImpl.java

  1. package edu.ucsb.cs156.example.services;


  2. import edu.ucsb.cs156.example.models.SystemInfo;
  3. import lombok.extern.slf4j.Slf4j;
  4. import org.springframework.beans.factory.annotation.Value;
  5. import org.springframework.boot.context.properties.ConfigurationProperties;
  6. import org.springframework.stereotype.Service;

  7. /**
  8.  * This is a service for getting information about the system.
  9.  *
  10.  * This class relies on property values. For hints on testing, see: <a href="https://www.baeldung.com/spring-boot-testing-configurationproperties">https://www.baeldung.com/spring-boot-testing-configurationproperties</a>
  11.  *
  12.  */

  13. @Slf4j
  14. @Service("systemInfo")
  15. @ConfigurationProperties
  16. public class SystemInfoServiceImpl extends SystemInfoService {
  17.  
  18.   @Value("${spring.h2.console.enabled:false}")
  19.   private boolean springH2ConsoleEnabled;

  20.   @Value("${app.showSwaggerUILink:false}")
  21.   private boolean showSwaggerUILink;

  22.   @Value("${app.oauth.login:/oauth2/authorization/google}")
  23.   private String oauthLogin;

  24.   /**
  25.    * This method returns the system information.
  26.    * @see edu.ucsb.cs156.example.models.SystemInfo
  27.    * @return the system information
  28.    */
  29.   public SystemInfo getSystemInfo() {
  30.     SystemInfo si = SystemInfo.builder()
  31.     .springH2ConsoleEnabled(this.springH2ConsoleEnabled)
  32.     .showSwaggerUILink(this.showSwaggerUILink)
  33.     .oauthLogin(this.oauthLogin)
  34.     .build();
  35.   log.info("getSystemInfo returns {}",si);
  36.   return si;
  37.   }

  38. }