mirror of
https://github.com/apache/archiva.git
synced 2025-02-24 11:35:02 +00:00
more easy version display using bean properties
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1177720 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0ad390f082
commit
c7bd423375
@ -17,3 +17,4 @@
|
||||
# under the License.
|
||||
#
|
||||
user.agent=Apache Archiva/${project.version}
|
||||
archiva.version=${project.version}
|
||||
|
@ -44,6 +44,7 @@
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* LogEnabled and SessionAware ActionSupport
|
||||
@ -69,6 +70,10 @@ public abstract class AbstractActionSupport
|
||||
|
||||
private String principal;
|
||||
|
||||
@Inject
|
||||
@Named(value = "archivaRuntimeProperties")
|
||||
private Properties archivaRuntimeProperties;
|
||||
|
||||
@PostConstruct
|
||||
public void initialize()
|
||||
{
|
||||
@ -185,6 +190,11 @@ protected AuditInformation getAuditInformation()
|
||||
return auditInformation;
|
||||
}
|
||||
|
||||
public String getArchivaVersion()
|
||||
{
|
||||
return (String) archivaRuntimeProperties.get( "archiva.version" );
|
||||
}
|
||||
|
||||
/**
|
||||
* dummy information for audit events
|
||||
* @since 1.4
|
||||
|
@ -19,10 +19,10 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.archiva.common.ArchivaException;
|
||||
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
|
||||
import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
|
||||
import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
|
||||
import org.apache.archiva.common.ArchivaException;
|
||||
import org.apache.maven.index.NexusIndexer;
|
||||
import org.apache.maven.index.context.IndexingContext;
|
||||
import org.codehaus.plexus.taskqueue.Task;
|
||||
@ -35,6 +35,7 @@
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Properties;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
/**
|
||||
@ -67,6 +68,8 @@ public void contextInitialized( ServletContextEvent contextEvent )
|
||||
repositoryTaskScheduler =
|
||||
wac.getBean( "archivaTaskScheduler#repository", RepositoryArchivaTaskScheduler.class );
|
||||
|
||||
Properties archivaRuntimeProperties = wac.getBean( "archivaRuntimeProperties", Properties.class );
|
||||
|
||||
tqeRepoScanning = wac.getBean( "taskQueueExecutor#repository-scanning", ThreadedTaskQueueExecutor.class );
|
||||
|
||||
tqeIndexing = wac.getBean( "taskQueueExecutor#indexing", ThreadedTaskQueueExecutor.class );
|
||||
@ -85,7 +88,7 @@ public void contextInitialized( ServletContextEvent contextEvent )
|
||||
{
|
||||
securitySync.startup();
|
||||
repositoryTaskScheduler.startup();
|
||||
Banner.display();
|
||||
Banner.display( (String) archivaRuntimeProperties.get( "archiva.version" ) );
|
||||
}
|
||||
catch ( ArchivaException e )
|
||||
{
|
||||
@ -147,12 +150,13 @@ public void contextDestroyed( ServletContextEvent contextEvent )
|
||||
}
|
||||
|
||||
// closing correctly indexer to close correctly lock and file
|
||||
for( IndexingContext indexingContext : nexusIndexer.getIndexingContexts().values() )
|
||||
for ( IndexingContext indexingContext : nexusIndexer.getIndexingContexts().values() )
|
||||
{
|
||||
try
|
||||
{
|
||||
indexingContext.close( false );
|
||||
} catch ( Exception e )
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
contextEvent.getServletContext().log( "skip error closing indexingContext " + e.getMessage() );
|
||||
}
|
||||
|
@ -1,83 +0,0 @@
|
||||
package org.apache.archiva.web.startup;
|
||||
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.archiva.configuration.ArchivaConfiguration;
|
||||
|
||||
/**
|
||||
* ArchivaVersion
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ArchivaVersion
|
||||
{
|
||||
private static String version = null;
|
||||
|
||||
private ArchivaVersion()
|
||||
{
|
||||
}
|
||||
|
||||
public static String determineVersion( )
|
||||
{
|
||||
if ( version != null )
|
||||
{
|
||||
return version;
|
||||
}
|
||||
|
||||
InputStream is = ArchivaConfiguration.class.getResourceAsStream( "/META-INF/maven/org.apache.archiva/archiva-configuration/pom.properties" );
|
||||
|
||||
if ( is != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
Properties props = new Properties();
|
||||
props.load( is );
|
||||
String version = props.getProperty( "version" );
|
||||
if ( StringUtils.isNotBlank( version ) )
|
||||
{
|
||||
ArchivaVersion.version = version;
|
||||
return version;
|
||||
}
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly( is );
|
||||
}
|
||||
}
|
||||
|
||||
ArchivaVersion.version = "";
|
||||
return version;
|
||||
}
|
||||
|
||||
public static String getVersion()
|
||||
{
|
||||
return version;
|
||||
}
|
||||
}
|
@ -221,9 +221,9 @@ public static String getBanner( String version )
|
||||
return injectVersion( decode( encodedBanner ), version );
|
||||
}
|
||||
|
||||
public static void display()
|
||||
public static void display( String version )
|
||||
{
|
||||
String banner = getBanner( ArchivaVersion.determineVersion() );
|
||||
String banner = getBanner( version );
|
||||
LoggerFactory.getLogger( Banner.class ).info( StringUtils.repeat( "_", 25 ) + eol + banner );
|
||||
}
|
||||
}
|
||||
|
@ -21,14 +21,18 @@
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xmlns:util="http://www.springframework.org/schema/util"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
|
||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd
|
||||
http://www.springframework.org/schema/util
|
||||
http://www.springframework.org/schema/util/spring-util-3.0.xsd"
|
||||
default-lazy-init="true">
|
||||
|
||||
<context:annotation-config/>
|
||||
<context:component-scan base-package="org.apache.archiva.web"/>
|
||||
|
||||
<util:properties id="archivaRuntimeProperties" location="classpath:application.properties" />
|
||||
|
||||
</beans>
|
@ -25,8 +25,7 @@
|
||||
http://www.springframework.org/schema/context
|
||||
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
|
||||
|
||||
<context:property-placeholder location="classpath:application.properties" />
|
||||
|
||||
<context:property-placeholder location="classpath:application.properties"/>
|
||||
|
||||
<bean id="loggerManager" class="org.codehaus.plexus.logging.slf4j.Slf4jLoggerManager"
|
||||
init-method="initialize"/>
|
||||
|
@ -26,7 +26,6 @@
|
||||
<%@ taglib prefix="my" tagdir="/WEB-INF/tags" %>
|
||||
<%@ taglib prefix="redback" uri="http://plexus.codehaus.org/redback/taglib-1.0" %>
|
||||
<%@ page import="java.util.Calendar" %>
|
||||
<%@ page import="org.apache.archiva.web.startup.ArchivaVersion" %>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
@ -196,7 +195,7 @@
|
||||
|
||||
<div id="footer">
|
||||
<div class="xleft">
|
||||
<a target="_blank" href="http://archiva.apache.org/">Apache Ar<c:if test="${is19Sep}">rr</c:if>chiva <%= ArchivaVersion.getVersion()%></a>
|
||||
<a target="_blank" href="http://archiva.apache.org/">Apache Ar<c:if test="${is19Sep}">rr</c:if>chiva - <s:property value="archivaVersion"/></a>
|
||||
</div>
|
||||
<div class="xright">
|
||||
Copyright © <%= copyrightRange%> <a target="_blank" href="http://www.apache.org/">The Apache Software Foundation</a>
|
||||
|
Loading…
x
Reference in New Issue
Block a user