mirror of
https://github.com/Telecominfraproject/wlan-cloud-base.git
synced 2026-03-20 14:39:00 +00:00
Compare commits
2 Commits
release/v1
...
AJ
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
137e8596a2 | ||
|
|
cbad366ac3 |
@@ -0,0 +1,44 @@
|
||||
package com.telecominfraproject.wlan.core.server.container;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class CommitProperties {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CommitProperties.class);
|
||||
|
||||
private static final String PROP_FILE = "commit.properties";
|
||||
private final Properties prop = new Properties();
|
||||
private final String date;
|
||||
private final String commitId;
|
||||
private final String version;
|
||||
|
||||
public CommitProperties() {
|
||||
loadStream(prop);
|
||||
this.date = prop.getProperty("date", "");
|
||||
this.commitId = prop.getProperty("commitId", "");
|
||||
this.version = prop.getProperty("projectVersion", "");
|
||||
}
|
||||
|
||||
public String getCommitDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public String getCommitID() {
|
||||
return commitId;
|
||||
}
|
||||
|
||||
public String getProjectVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
private void loadStream(final Properties prop) {
|
||||
try (final InputStream inputStream = getClass().getClassLoader().getResourceAsStream(PROP_FILE)) {
|
||||
prop.load(inputStream);
|
||||
} catch (final Exception e) {
|
||||
LOG.info("Properties file not present");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,12 @@ public abstract class ServletContainerCustomizer implements WebServerFactoryCust
|
||||
@Bean ConnectorProperties connectorProperties(){
|
||||
return new ConnectorPropertiesImpl(appContext.getEnvironment());
|
||||
}
|
||||
|
||||
@Bean
|
||||
CommitProperties commitProperties(){
|
||||
return new CommitProperties();
|
||||
}
|
||||
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ServletContainerCustomizer.class);
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import com.telecominfraproject.wlan.core.server.container.CommitProperties;
|
||||
|
||||
import com.telecominfraproject.wlan.core.server.container.ConnectorProperties;
|
||||
|
||||
@@ -21,19 +22,26 @@ public class PingController {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(PingController.class);
|
||||
@Autowired private ApplicationContext applicationContext;
|
||||
@Autowired private ConnectorProperties connectorProperties;
|
||||
@Autowired private CommitProperties commitProperties;
|
||||
|
||||
|
||||
|
||||
@GetMapping("/ping")
|
||||
public @ResponseBody PingResponse ping() {
|
||||
|
||||
PingResponse ret = new PingResponse(
|
||||
applicationContext.getStartupDate(),
|
||||
System.currentTimeMillis(),
|
||||
applicationContext.getEnvironment().getProperty("app.name"),
|
||||
applicationContext.getEnvironment().getProperty("elb", connectorProperties.getExternalHostName()));
|
||||
|
||||
applicationContext.getEnvironment().getProperty("elb", connectorProperties.getExternalHostName()),
|
||||
commitProperties.getCommitID(),
|
||||
commitProperties.getCommitDate(),
|
||||
commitProperties.getProjectVersion()
|
||||
);
|
||||
|
||||
LOG.debug("ping: {} / {}", ret.getStartupTime(), ret.getCurrentTime());
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,13 @@ public class PingResponse extends BaseJsonModel {
|
||||
private long currentTime;
|
||||
private String applicationName;
|
||||
private String hostName;
|
||||
|
||||
|
||||
private String commitID;
|
||||
private String commitDate;
|
||||
private String projectVersion;
|
||||
|
||||
|
||||
|
||||
protected PingResponse()
|
||||
{
|
||||
super();
|
||||
@@ -23,7 +29,14 @@ public class PingResponse extends BaseJsonModel {
|
||||
this.startupTime = startupTime;
|
||||
this.currentTime = currentTime;
|
||||
this.applicationName = applicationName;
|
||||
this.hostName = hostName;
|
||||
this.hostName = hostName;
|
||||
}
|
||||
|
||||
public PingResponse(long startupTime, long currentTime, String applicationName, String hostName, String commitID, String commitDate, String projectVersion){
|
||||
this(startupTime, currentTime, applicationName, hostName);
|
||||
this.commitID = commitID;
|
||||
this.commitDate = commitDate;
|
||||
this.projectVersion = projectVersion;
|
||||
}
|
||||
|
||||
public long getStartupTime() {
|
||||
@@ -39,5 +52,18 @@ public class PingResponse extends BaseJsonModel {
|
||||
public String getHostName() {
|
||||
return hostName;
|
||||
}
|
||||
|
||||
public String getCommitID() {
|
||||
return commitID;
|
||||
}
|
||||
|
||||
public String getCommitDate() {
|
||||
return commitDate;
|
||||
}
|
||||
|
||||
public String getProjectVersion() {
|
||||
return projectVersion;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user