View Javadoc

1   /*
2    *  Copyright 2010 Felix Roethenbacher
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   */
16  package ch.syabru.nagios.broker;
17  
18  import java.util.Calendar;
19  
20  import javax.annotation.PostConstruct;
21  
22  import org.slf4j.Logger;
23  import org.slf4j.LoggerFactory;
24  
25  /**
26   * Version.
27   *
28   * Loads version information from properties file.
29   *
30   * @author Felix Roethenbacher
31   *
32   */
33  public class Version {
34      private final Logger logger = LoggerFactory.getLogger(Version.class);
35  
36      private String version;
37      private String inceptionYear;
38      private String copyright;
39  
40      /**
41       * Init method.
42       */
43      @PostConstruct
44      public void init() {
45          int year = Calendar.getInstance().get(Calendar.YEAR);
46          if (inceptionYear != null &&
47                  inceptionYear.equals(Integer.valueOf(year).toString()))
48          {
49              copyright = "Copyright " + year + " Felix Roethenbacher";
50          } else {
51              copyright = "Copyright " + inceptionYear + " - " + year +
52                  " Felix Roethenbacher";
53          }
54          logger.info("Syabru Nagios Message Broker - Version {}", version);
55          logger.info(copyright);
56      }
57  
58      public String getVersion() {
59          return version;
60      }
61  
62      public void setVersion(String version) {
63          this.version = version;
64      }
65  
66      public String getCopyright() {
67          return copyright;
68      }
69  
70      public void setInceptionYear(String inceptionYear) {
71          this.inceptionYear = inceptionYear;
72      }
73  
74  }