From da40ada2d294cb29757c285b7bb961ed161122ba Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Mon, 21 May 2007 21:04:20 +0000 Subject: [PATCH] [MRM-347]: Undefined ${appserver.home} and ${appserver.base} git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@540296 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva/web/repository/AuditLog.java | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/AuditLog.java b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/AuditLog.java index 6ae6b8a49..a6a50b49f 100644 --- a/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/AuditLog.java +++ b/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/repository/AuditLog.java @@ -20,6 +20,9 @@ package org.apache.maven.archiva.web.repository; */ import org.apache.commons.lang.StringUtils; +import org.codehaus.plexus.evaluator.EvaluatorException; +import org.codehaus.plexus.evaluator.ExpressionEvaluator; +import org.codehaus.plexus.evaluator.ExpressionSource; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; import org.codehaus.plexus.webdav.DavServerComponent; @@ -48,13 +51,25 @@ public class AuditLog /** * @plexus.configuration default-value="${appserver.base}/logs/audit.log" */ - private File logFile; + private String logFilename; /** * @plexus.configuration default-value="yyyy-MM-dd HH:mm:ss" */ private String timestampFormat; + /** + * @plexus.requirement role-hint="default" + */ + private ExpressionEvaluator expressionEvaluator; + + /** + * @plexus.requirement role-hint="sysprops" + */ + private ExpressionSource syspropExprSource; + + private File logFile; + private PrintWriter writer; private SimpleDateFormat timestamp; @@ -108,6 +123,19 @@ public class AuditLog public void initialize() throws InitializationException { + String actualFilename; + try + { + expressionEvaluator.addExpressionSource( syspropExprSource ); + actualFilename = expressionEvaluator.expand( this.logFilename ); + } + catch ( EvaluatorException e1 ) + { + actualFilename = this.logFilename; + } + + this.logFile = new File( actualFilename ); + File parentDir = logFile.getParentFile(); if ( parentDir != null ) {