From 8d497e85550282d2255f5a7596c02fe21ce4d031 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Fri, 10 Jun 2011 16:38:49 +0000 Subject: [PATCH] move audit plugin to spring annotations : it looks now mvn tomcat:run -Pdev works !! git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1134378 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/webapp/WEB-INF/applicationContext.xml | 7 +++++-- .../org/apache/archiva/audit/AuditEventFactory.java | 4 +++- .../java/org/apache/archiva/audit/AuditListener.java | 2 +- .../main/java/org/apache/archiva/audit/AuditLog.java | 4 +++- .../java/org/apache/archiva/audit/Auditable.java | 6 +++--- .../apache/archiva/audit/DefaultAuditManager.java | 2 ++ .../apache/archiva/audit/MetadataAuditListener.java | 12 +++++++++--- .../file/FileRepositorySessionFactory.java | 2 +- 8 files changed, 27 insertions(+), 12 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml index d65c5fbd7..ad1853073 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml @@ -50,12 +50,15 @@ + + + - + @@ -64,7 +67,7 @@ - + diff --git a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditEventFactory.java b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditEventFactory.java index f2572054f..f45db77f5 100644 --- a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditEventFactory.java +++ b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditEventFactory.java @@ -21,10 +21,12 @@ package org.apache.archiva.audit; import org.apache.archiva.metadata.model.MetadataFacet; import org.apache.archiva.metadata.model.MetadataFacetFactory; +import org.springframework.stereotype.Service; /** - * @plexus.component role="org.apache.archiva.metadata.model.MetadataFacetFactory" role-hint="org.apache.archiva.audit" + * plexus.component role="org.apache.archiva.metadata.model.MetadataFacetFactory" role-hint="org.apache.archiva.audit" */ +@Service("metadataFacetFactory#org.apache.archiva.audit") public class AuditEventFactory implements MetadataFacetFactory { diff --git a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditListener.java b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditListener.java index 204f7ae5c..81d596fa9 100644 --- a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditListener.java +++ b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditListener.java @@ -31,5 +31,5 @@ public interface AuditListener * * @param event the event details. */ - public void auditEvent( AuditEvent event ); + void auditEvent( AuditEvent event ); } diff --git a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditLog.java b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditLog.java index f1b8c7fba..00d779c78 100644 --- a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditLog.java +++ b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/AuditLog.java @@ -21,6 +21,7 @@ package org.apache.archiva.audit; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; /** * AuditLog - Audit Log. @@ -28,6 +29,7 @@ import org.slf4j.LoggerFactory; * @version $Id$ * @plexus.component role="org.apache.archiva.audit.AuditListener" role-hint="logging" */ +@Service("auditListener#logging") public class AuditLog implements AuditListener { @@ -43,7 +45,7 @@ public class AuditLog */ public void auditEvent( AuditEvent event ) { - StringBuffer msg = new StringBuffer(); + StringBuilder msg = new StringBuilder(); msg.append( checkNull( event.getRepositoryId() ) ).append( DELIM ); msg.append( event.getUserId() ).append( DELIM ); msg.append( checkNull( event.getRemoteIP() ) ).append( DELIM ); diff --git a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/Auditable.java b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/Auditable.java index b2655240c..0f2f47958 100644 --- a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/Auditable.java +++ b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/Auditable.java @@ -31,17 +31,17 @@ public interface Auditable * * @param the listener to add. */ - public void addAuditListener( AuditListener auditListener ); + void addAuditListener( AuditListener auditListener ); /** * Remove an AuditListener. * * @param the listener to remove. */ - public void removeAuditListener( AuditListener auditListener ); + void removeAuditListener( AuditListener auditListener ); /** * Remove all registered {@link AuditListener} objects. */ - public void clearAuditListeners(); + void clearAuditListeners(); } diff --git a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/DefaultAuditManager.java b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/DefaultAuditManager.java index 187357429..d199b725d 100644 --- a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/DefaultAuditManager.java +++ b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/DefaultAuditManager.java @@ -23,6 +23,7 @@ import org.apache.archiva.metadata.repository.MetadataRepository; import org.apache.archiva.metadata.repository.MetadataRepositoryException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -37,6 +38,7 @@ import java.util.TimeZone; /** * @plexus.component role="org.apache.archiva.audit.AuditManager" */ +@Service("auditManager#default") public class DefaultAuditManager implements AuditManager { diff --git a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/MetadataAuditListener.java b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/MetadataAuditListener.java index 6c38d93a8..181a58ba9 100644 --- a/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/MetadataAuditListener.java +++ b/archiva-modules/plugins/audit/src/main/java/org/apache/archiva/audit/MetadataAuditListener.java @@ -24,26 +24,32 @@ import org.apache.archiva.metadata.repository.RepositorySession; import org.apache.archiva.metadata.repository.RepositorySessionFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import javax.inject.Inject; /** - * @plexus.component role="org.apache.archiva.audit.AuditListener" role-hint="metadata" + * plexus.component role="org.apache.archiva.audit.AuditListener" role-hint="metadata" */ +@Service("uuditListener#metadata") public class MetadataAuditListener implements AuditListener { private static final Logger log = LoggerFactory.getLogger( MetadataAuditListener.class ); /** - * @plexus.requirement + * plexus.requirement */ + @Inject private AuditManager auditManager; /** * FIXME: this could be multiple implementations and needs to be configured. It also starts a separate session to * the originator of the audit event that we may rather want to pass through. * - * @plexus.requirement + * plexus.requirement */ + @Inject private RepositorySessionFactory repositorySessionFactory; public void auditEvent( AuditEvent event ) diff --git a/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileRepositorySessionFactory.java b/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileRepositorySessionFactory.java index 9b3ea500e..3b2f02750 100644 --- a/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileRepositorySessionFactory.java +++ b/archiva-modules/plugins/metadata-store-file/src/main/java/org/apache/archiva/metadata/repository/file/FileRepositorySessionFactory.java @@ -43,7 +43,7 @@ public class FileRepositorySessionFactory implements RepositorySessionFactory { /** - * @plexus.requirement role="org.apache.archiva.metadata.model.MetadataFacetFactory" + * plexus.requirement role="org.apache.archiva.metadata.model.MetadataFacetFactory" */ private Map metadataFacetFactories;