Author: olamy
Date: Mon Apr 30 08:54:45 2012
New Revision: 1332124

URL: http://svn.apache.org/viewvc?rev=1332124&view=rev
Log:
fix issues thanks Konstantin for review

Modified:
    
tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java
    
tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7Runner.java

Modified: 
tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java
URL: 
http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java?rev=1332124&r1=1332123&r2=1332124&view=diff
==============================================================================
--- 
tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java
 (original)
+++ 
tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/run/AbstractExecWarMojo.java
 Mon Apr 30 08:54:45 2012
@@ -294,7 +294,7 @@ public abstract class AbstractExecWarMoj
 
             Properties properties = new Properties();
 
-            properties.put( Tomcat7Runner.ARCHIVE_GENERATION_TIMESTAMP_KEY, 
Long.toString( new Date().getTime() ) );
+            properties.put( Tomcat7Runner.ARCHIVE_GENERATION_TIMESTAMP_KEY, 
Long.toString( System.currentTimeMillis() ) );
             properties.put( Tomcat7Runner.ENABLE_NAMING_KEY, Boolean.toString( 
enableNaming ) );
             properties.put( Tomcat7Runner.ACCESS_LOG_VALVE_FORMAT_KEY, 
accessLogValveFormat );
             properties.put( Tomcat7Runner.HTTP_PROTOCOL_KEY, 
connectorHttpProtocol );

Modified: 
tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7Runner.java
URL: 
http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7Runner.java?rev=1332124&r1=1332123&r2=1332124&view=diff
==============================================================================
--- 
tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7Runner.java
 (original)
+++ 
tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7Runner.java
 Mon Apr 30 08:54:45 2012
@@ -31,10 +31,9 @@ import org.apache.tomcat.util.http.fileu
 
 import java.io.BufferedOutputStream;
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
 import java.io.IOException;
 import java.io.InputStream;
 import java.lang.reflect.InvocationTargetException;
@@ -134,11 +133,10 @@ public class Tomcat7Runner
         // compare timestamp stored during previous run if exists
         File timestampFile = new File( extractDirectoryFile, 
".tomcat_executable_archive.timestamp" );
 
-        Properties timestampProps = new Properties();
+        Properties timestampProps = loadProperties( timestampFile );
 
         if ( timestampFile.exists() )
         {
-            timestampProps.load( new FileReader( timestampFile ) );
             String timestampValue = timestampProps.getProperty( 
Tomcat7Runner.ARCHIVE_GENERATION_TIMESTAMP_KEY );
             if ( timestampValue != null )
             {
@@ -158,12 +156,12 @@ public class Tomcat7Runner
             if ( !extractDirectoryFile.exists() || resetExtract || 
archiveTimestampChanged )
             {
                 extract();
-                // first run so create timestamp file
-                if ( !timestampFile.exists() )
+                //if archiveTimestampChanged or timestamp file not exists 
store the last timestamp from the archive
+                if ( archiveTimestampChanged || !timestampFile.exists() )
                 {
                     timestampProps.put( 
Tomcat7Runner.ARCHIVE_GENERATION_TIMESTAMP_KEY, runtimeProperties.getProperty(
                         Tomcat7Runner.ARCHIVE_GENERATION_TIMESTAMP_KEY ) );
-                    timestampProps.store( new FileWriter( timestampFile ), 
"Timestamp file for executable war/jar" );
+                    saveProperties( timestampProps, timestampFile );
                 }
             }
             else
@@ -644,4 +642,39 @@ public class Tomcat7Runner
             System.out.println( "WARNING: loggerName " + loggerName + " not 
supported, skip it" );
         }
     }
+
+    private Properties loadProperties( File file )
+        throws FileNotFoundException, IOException
+    {
+        Properties properties = new Properties();
+        if ( file.exists() )
+        {
+
+            FileInputStream fileInputStream = new FileInputStream( file );
+            try
+            {
+                properties.load( fileInputStream );
+            }
+            finally
+            {
+                fileInputStream.close();
+            }
+
+        }
+        return properties;
+    }
+
+    private void saveProperties( Properties properties, File file )
+        throws FileNotFoundException, IOException
+    {
+        FileOutputStream fileOutputStream = new FileOutputStream( file );
+        try
+        {
+            properties.store( fileOutputStream, "Timestamp file for executable 
war/jar" );
+        }
+        finally
+        {
+            fileOutputStream.close();
+        }
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to