You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ol...@apache.org on 2012/01/09 13:44:45 UTC

svn commit: r1229120 - in /archiva/trunk/archiva-modules/archiva-web: archiva-webapp-common/ archiva-webapp-common/src/main/java/org/apache/archiva/web/runtime/ archiva-webapp-common/src/main/resources/META-INF/ archiva-webapp/src/main/java/org/apache/...

Author: olamy
Date: Mon Jan  9 12:44:45 2012
New Revision: 1229120

URL: http://svn.apache.org/viewvc?rev=1229120&view=rev
Log:
add a bean with archiva runtime information

Added:
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-common/src/main/java/org/apache/archiva/web/runtime/
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-common/src/main/java/org/apache/archiva/web/runtime/ArchivaRuntimeInfo.java   (with props)
Modified:
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-common/pom.xml
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-common/src/main/resources/META-INF/spring-context.xml
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/AbstractActionSupport.java
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/resources/META-INF/spring-context.xml

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-common/pom.xml
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-common/pom.xml?rev=1229120&r1=1229119&r2=1229120&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-common/pom.xml (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-common/pom.xml Mon Jan  9 12:44:45 2012
@@ -142,6 +142,15 @@
   </dependencies>
 
   <build>
+    <resources>
+      <resource>
+        <directory>src/main/resources</directory>
+      </resource>
+      <resource>
+        <directory>src/main/filtered-resources</directory>
+        <filtering>true</filtering>
+      </resource>
+    </resources>
     <plugins>
       <plugin>
         <groupId>org.apache.felix</groupId>

Added: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-common/src/main/java/org/apache/archiva/web/runtime/ArchivaRuntimeInfo.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-common/src/main/java/org/apache/archiva/web/runtime/ArchivaRuntimeInfo.java?rev=1229120&view=auto
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-common/src/main/java/org/apache/archiva/web/runtime/ArchivaRuntimeInfo.java (added)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-common/src/main/java/org/apache/archiva/web/runtime/ArchivaRuntimeInfo.java Mon Jan  9 12:44:45 2012
@@ -0,0 +1,92 @@
+package org.apache.archiva.web.runtime;
+/*
+ * 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 org.apache.commons.lang.math.NumberUtils;
+import org.springframework.stereotype.Service;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import java.util.Properties;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4-M3
+ */
+@Service( "archivaRuntimeInfo" )
+public class ArchivaRuntimeInfo
+{
+
+    private String version;
+
+    private String buildNumber;
+
+    private long timestamp;
+
+
+    @Inject
+    public ArchivaRuntimeInfo( @Named( value = "archivaRuntimeProperties" ) Properties archivaRuntimeProperties )
+    {
+        this.version = (String) archivaRuntimeProperties.get( "archiva.version" );
+        this.buildNumber = (String) archivaRuntimeProperties.get( "archiva.buildNumber" );
+        this.timestamp = NumberUtils.createLong( (String) archivaRuntimeProperties.get( "archiva.timestamp" ) );
+    }
+
+    public String getVersion()
+    {
+        return version;
+    }
+
+    public void setVersion( String version )
+    {
+        this.version = version;
+    }
+
+    public String getBuildNumber()
+    {
+        return buildNumber;
+    }
+
+    public void setBuildNumber( String buildNumber )
+    {
+        this.buildNumber = buildNumber;
+    }
+
+    public long getTimestamp()
+    {
+        return timestamp;
+    }
+
+    public void setTimestamp( long timestamp )
+    {
+        this.timestamp = timestamp;
+    }
+
+    @Override
+    public String toString()
+    {
+        final StringBuilder sb = new StringBuilder();
+        sb.append( "ArchivaRuntimeInfo" );
+        sb.append( "{version='" ).append( version ).append( '\'' );
+        sb.append( ", buildNumber='" ).append( buildNumber ).append( '\'' );
+        sb.append( ", timestamp=" ).append( timestamp );
+        sb.append( '}' );
+        return sb.toString();
+    }
+}

Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-common/src/main/java/org/apache/archiva/web/runtime/ArchivaRuntimeInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-common/src/main/java/org/apache/archiva/web/runtime/ArchivaRuntimeInfo.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-common/src/main/resources/META-INF/spring-context.xml
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-common/src/main/resources/META-INF/spring-context.xml?rev=1229120&r1=1229119&r2=1229120&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-common/src/main/resources/META-INF/spring-context.xml (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-common/src/main/resources/META-INF/spring-context.xml Mon Jan  9 12:44:45 2012
@@ -31,6 +31,8 @@
        default-lazy-init="true">
 
   <context:annotation-config/>
-  <context:component-scan base-package="org.apache.archiva.web.spring, org.apache.archiva.web.startup"/>
+  <context:component-scan base-package="org.apache.archiva.web.spring, org.apache.archiva.web.startup, org.apache.archiva.web.runtime"/>
+
+  <util:properties id="archivaRuntimeProperties" location="classpath:application.properties" />
 
 </beans>
\ No newline at end of file

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/AbstractActionSupport.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/AbstractActionSupport.java?rev=1229120&r1=1229119&r2=1229120&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/AbstractActionSupport.java (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/AbstractActionSupport.java Mon Jan  9 12:44:45 2012
@@ -27,8 +27,8 @@ import org.apache.archiva.audit.AuditLis
 import org.apache.archiva.audit.Auditable;
 import org.apache.archiva.metadata.repository.RepositorySessionFactory;
 import org.apache.archiva.security.ArchivaXworkUser;
+import org.apache.archiva.web.runtime.ArchivaRuntimeInfo;
 import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.math.NumberUtils;
 import org.apache.struts2.ServletActionContext;
 import org.apache.struts2.interceptor.SessionAware;
 import org.codehaus.plexus.redback.users.User;
@@ -47,7 +47,6 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Properties;
 
 /**
  * LogEnabled and SessionAware ActionSupport
@@ -73,9 +72,12 @@ public abstract class AbstractActionSupp
 
     private String principal;
 
+    //@Inject
+    //@Named( value = "archivaRuntimeProperties" )
+    //private Properties archivaRuntimeProperties;
+
     @Inject
-    @Named( value = "archivaRuntimeProperties" )
-    private Properties archivaRuntimeProperties;
+    private ArchivaRuntimeInfo archivaRuntimeInfo;
 
     @PostConstruct
     public void initialize()
@@ -200,24 +202,25 @@ public abstract class AbstractActionSupp
 
     public String getArchivaVersion()
     {
-        return (String) archivaRuntimeProperties.get( "archiva.version" );
+        return archivaRuntimeInfo.getVersion(); //(String) archivaRuntimeProperties.get( "archiva.version" );
     }
 
     public String getArchivaBuildNumber()
     {
-        return (String) archivaRuntimeProperties.get( "archiva.buildNumber" );
+        return archivaRuntimeInfo.getBuildNumber();// (String) archivaRuntimeProperties.get( "archiva.buildNumber" );
     }
 
     public String getArchivaBuildTimestamp()
     {
-        return (String) archivaRuntimeProperties.get( "archiva.timestamp" );
+        return Long.toString(
+            archivaRuntimeInfo.getTimestamp() ); //(String) archivaRuntimeProperties.get( "archiva.timestamp" );
     }
 
     public String getArchivaBuildTimestampDateStr()
     {
         SimpleDateFormat sfd = new SimpleDateFormat( "yyyy-MM-dd'T'HH:mm:ssz", getLocale() );
-        return sfd.format(
-            new Date( NumberUtils.createLong( (String) archivaRuntimeProperties.get( "archiva.timestamp" ) ) ) );
+        return sfd.format( new Date( archivaRuntimeInfo.getTimestamp() ) );
+        //new Date( NumberUtils.createLong( (String) archivaRuntimeProperties.get( "archiva.timestamp" ) ) ) );
     }
 
     /**

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/resources/META-INF/spring-context.xml
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/resources/META-INF/spring-context.xml?rev=1229120&r1=1229119&r2=1229120&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/resources/META-INF/spring-context.xml (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp/src/main/resources/META-INF/spring-context.xml Mon Jan  9 12:44:45 2012
@@ -33,8 +33,6 @@
   <context:annotation-config/>
   <context:component-scan base-package="org.apache.archiva.web"/>
 
-  <util:properties id="archivaRuntimeProperties" location="classpath:application.properties" />
-
   <bean id="jcr-repository" class="org.apache.jackrabbit.core.RepositoryImpl" destroy-method="shutdown" lazy-init="true">
     <constructor-arg ref="jcr-config"/>
   </bean>