This project has retired. For details please refer to its Attic page.
ArchivaRuntimeInfo xref
View Javadoc
1   package org.apache.archiva.web.runtime;
2   /*
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   *   http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing,
14   * software distributed under the License is distributed on an
15   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16   * KIND, either express or implied.  See the License for the
17   * specific language governing permissions and limitations
18   * under the License.
19   */
20  
21  import org.apache.commons.lang.math.NumberUtils;
22  import org.springframework.stereotype.Service;
23  
24  import javax.inject.Inject;
25  import javax.inject.Named;
26  import java.util.Date;
27  import java.util.Properties;
28  
29  /**
30   * @author Olivier Lamy
31   * @since 1.4-M3
32   */
33  @Service( "archivaRuntimeInfo" )
34  public class ArchivaRuntimeInfo
35  {
36  
37      private String version;
38  
39      private String buildNumber;
40  
41      private long timestamp;
42  
43      private boolean devMode;
44  
45  
46      @Inject
47      public ArchivaRuntimeInfo( @Named( value = "archivaRuntimeProperties" ) Properties archivaRuntimeProperties )
48      {
49          this.version = (String) archivaRuntimeProperties.get( "archiva.version" );
50          this.buildNumber = (String) archivaRuntimeProperties.get( "archiva.buildNumber" );
51          String archivaTimeStamp = (String) archivaRuntimeProperties.get( "archiva.timestamp" );
52          if ( NumberUtils.isNumber( archivaTimeStamp ) )
53          {
54              this.timestamp = NumberUtils.createLong( archivaTimeStamp );
55          }
56          else
57          {
58              this.timestamp = new Date().getTime();
59          }
60          this.devMode = Boolean.getBoolean( "archiva.devMode" );
61      }
62  
63      public String getVersion()
64      {
65          return version;
66      }
67  
68      public void setVersion( String version )
69      {
70          this.version = version;
71      }
72  
73      public String getBuildNumber()
74      {
75          return buildNumber;
76      }
77  
78      public void setBuildNumber( String buildNumber )
79      {
80          this.buildNumber = buildNumber;
81      }
82  
83      public long getTimestamp()
84      {
85          return timestamp;
86      }
87  
88      public void setTimestamp( long timestamp )
89      {
90          this.timestamp = timestamp;
91      }
92  
93      public boolean isDevMode()
94      {
95          return devMode;
96      }
97  
98      public void setDevMode( boolean devMode )
99      {
100         this.devMode = devMode;
101     }
102 
103     @Override
104     public String toString()
105     {
106         final StringBuilder sb = new StringBuilder();
107         sb.append( "ArchivaRuntimeInfo" );
108         sb.append( "{version='" ).append( version ).append( '\'' );
109         sb.append( ", buildNumber='" ).append( buildNumber ).append( '\'' );
110         sb.append( ", timestamp=" ).append( timestamp );
111         sb.append( ", devMode=" ).append( devMode );
112         sb.append( '}' );
113         return sb.toString();
114     }
115 }