Fixes #1120 Ability to specify release number / timestamp during project build

This commit is contained in:
Konstantin Krivopustov 2012-02-14 06:17:28 +00:00
parent 00e5a753f5
commit 550c3af0dc
2 changed files with 24 additions and 4 deletions

View File

@ -105,8 +105,25 @@ public interface ServerConfig extends Config {
@DefaultBoolean(false)
boolean getCutLoadListQueries();
/**
* @return Scheduled tasks execution control.
*/
@Property("cuba.schedulingActive")
@DefaultBoolean(false)
boolean getSchedulingActive();
void setSchedulingActive(boolean value);
/**
* @return Path to resource containing the release number
*/
@Property("cuba.releaseNumberPath")
@DefaultString("/com/haulmont/cuba/core/global/release.number")
String getReleaseNumberPath();
/**
* @return Path to resource containing the release timestamp
*/
@Property("cuba.releaseTimestampPath")
@DefaultString("/com/haulmont/cuba/core/global/release.timestamp")
String getReleaseTimestampPath();
}

View File

@ -34,13 +34,16 @@ public class ServerInfo implements ServerInfoAPI, ServerInfoMBean
private String releaseNumber = "?";
private String releaseTimestamp = "?";
@Inject
private Configuration configuration;
private volatile String serverId;
public ServerInfo() {
InputStream stream = getClass().getResourceAsStream("/com/haulmont/cuba/core/global/release.number");
@Inject
public void setConfiguration(Configuration configuration) {
this.configuration = configuration;
ServerConfig config = configuration.getConfig(ServerConfig.class);
InputStream stream = getClass().getResourceAsStream(config.getReleaseNumberPath());
if (stream != null)
try {
releaseNumber = IOUtils.toString(stream);
@ -48,7 +51,7 @@ public class ServerInfo implements ServerInfoAPI, ServerInfoMBean
log.warn("Unable to read release number", e);
}
stream = getClass().getResourceAsStream("/com/haulmont/cuba/core/global/release.timestamp");
stream = getClass().getResourceAsStream(config.getReleaseTimestampPath());
if (stream != null)
try {
releaseTimestamp = IOUtils.toString(stream);