
org.xlcloud.console.controllers.BuildInformationBean Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2012 AMG.lab, a Bull Group Company
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.xlcloud.console.controllers;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.jar.Manifest;
import javax.annotation.PostConstruct;
import javax.enterprise.context.ApplicationScoped;
import javax.faces.context.FacesContext;
import javax.inject.Inject;
import javax.inject.Named;
import org.apache.log4j.Logger;
import org.xlcloud.config.ConfigParam;
/**
* Exposes application information like build time, version, etc.
*
* @author Piotr Kulasek-Szwed, AMG.net
*/
@ApplicationScoped
@Named
public class BuildInformationBean {
private static final Logger logger = Logger.getLogger(BuildInformationBean.class);
@Inject @ConfigParam
private Boolean showBuildInfo;
private Manifest manifest = null;
@PostConstruct
public void init() {
File manifestFile = null;
try {
String home = FacesContext.getCurrentInstance().getExternalContext().getRealPath("/");
manifestFile = new File(home, "META-INF/MANIFEST.MF");
manifest = new Manifest();
manifest.read(new FileInputStream(manifestFile));
} catch (IOException ioe) {
logger.error("Unable to read the Manifest file from '" + manifestFile.getAbsolutePath() + "'", ioe);
}
}
public String getBuildTimestamp(){
return manifest.getMainAttributes().getValue("Build-Time");
}
/**
* Gets the value of {@link #showBuildInfo}.
* @return value of {@link #showBuildInfo}
*/
public Boolean getShowBuildInfo() {
return showBuildInfo;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy