This project has retired. For details please refer to its Attic page.
Source code
001package org.apache.archiva.web.runtime;
002/*
003 * Licensed to the Apache Software Foundation (ASF) under one
004 * or more contributor license agreements.  See the NOTICE file
005 * distributed with this work for additional information
006 * regarding copyright ownership.  The ASF licenses this file
007 * to you under the Apache License, Version 2.0 (the
008 * "License"); you may not use this file except in compliance
009 * with the License.  You may obtain a copy of the License at
010 *
011 *   http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing,
014 * software distributed under the License is distributed on an
015 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
016 * KIND, either express or implied.  See the License for the
017 * specific language governing permissions and limitations
018 * under the License.
019 */
020
021import org.apache.commons.lang.math.NumberUtils;
022import org.springframework.stereotype.Service;
023
024import javax.inject.Inject;
025import javax.inject.Named;
026import java.util.Date;
027import java.util.Properties;
028
029/**
030 * @author Olivier Lamy
031 * @since 1.4-M3
032 */
033@Service( "archivaRuntimeInfo" )
034public class ArchivaRuntimeInfo
035{
036
037    private String version;
038
039    private String buildNumber;
040
041    private long timestamp;
042
043    private boolean devMode;
044
045
046    @Inject
047    public ArchivaRuntimeInfo( @Named( value = "archivaRuntimeProperties" ) Properties archivaRuntimeProperties )
048    {
049        this.version = (String) archivaRuntimeProperties.get( "archiva.version" );
050        this.buildNumber = (String) archivaRuntimeProperties.get( "archiva.buildNumber" );
051        String archivaTimeStamp = (String) archivaRuntimeProperties.get( "archiva.timestamp" );
052        if ( NumberUtils.isNumber( archivaTimeStamp ) )
053        {
054            this.timestamp = NumberUtils.createLong( archivaTimeStamp );
055        }
056        else
057        {
058            this.timestamp = new Date().getTime();
059        }
060        this.devMode = Boolean.getBoolean( "archiva.devMode" );
061    }
062
063    public String getVersion()
064    {
065        return version;
066    }
067
068    public void setVersion( String version )
069    {
070        this.version = version;
071    }
072
073    public String getBuildNumber()
074    {
075        return buildNumber;
076    }
077
078    public void setBuildNumber( String buildNumber )
079    {
080        this.buildNumber = buildNumber;
081    }
082
083    public long getTimestamp()
084    {
085        return timestamp;
086    }
087
088    public void setTimestamp( long timestamp )
089    {
090        this.timestamp = timestamp;
091    }
092
093    public boolean isDevMode()
094    {
095        return devMode;
096    }
097
098    public void setDevMode( boolean devMode )
099    {
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}