daily pastebin goal
28%
SHARE
TWEET

Untitled

a guest Aug 16th, 2018 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <build>
  2.     <resources>
  3.         <resource>
  4.             <directory>src/main/resources</directory>
  5.             <filtering>true</filtering>
  6.         </resource>
  7.     </resources>
  8. </build>
  9.    
  10. version=${pom.version}
  11. build.timestamp=${timestamp}
  12.    
  13. @Service
  14. @PropertySource("classpath:mvn.build.properties")
  15. public class BuildInfoProviderImpl implements BuildInfoProvider {
  16.  
  17.     @Value("${build.timestamp}")
  18.     private String dateTime;
  19.     @Value("${version}")
  20.     private String version;
  21.  
  22.     private BuildInfo buildInfo;
  23.  
  24.     @Override
  25.     public BuildInfo getBuildInfo() {
  26.          return buildInfo;
  27.     }
  28.  
  29.     @PostConstruct
  30.     public void activate() {
  31.         buildInfo = new BuildInfo(
  32.                 LocalDateTime.parse(dateTime, Constants.DATE_TIME_FORMATTER),
  33.                 version);
  34.     }
  35. }
  36.    
  37. @Service
  38. @Path("_health")
  39. @Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
  40. public class HealthEndpoint {
  41.  
  42.     private static final Logger LOGGER = LoggerFactory.getLogger(
  43.         HealthEndpoint.class);
  44.  
  45.     private BuildInfoProvider buildInfoProvider;
  46.  
  47.     public HealthEndpoint(BuildInfoProvider buildInfoProvider) {
  48.         this.buildInfoProvider = buildInfoProvider;
  49.     }
  50.  
  51.     @GET
  52.     public BuildInfo getBuildInfo() {
  53.         LOGGER.debug("Build info has been requested");
  54.         return buildInfoProvider.getBuildInfo();
  55.     }
  56. }
  57.    
  58. <bean id="buildInfoProvider" class="service.impl.BuildInfoProviderImpl"/>
  59.  
  60. <bean id="healthEndpoint" class="endpoint.HealthEndpoint">
  61.     <constructor-arg ref="buildInfoProvider"/>
  62. </bean>
  63.    
  64. <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  65. <property name="location">
  66.     <value>classpath:mvn.build.properties</value>
  67. </property>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top