Author: olamy Date: Sat Dec 10 21:06:31 2011 New Revision: 1212874 URL: http://svn.apache.org/viewvc?rev=1212874&view=rev Log: use length of war file when we have it to avoid chunked transfer
Modified: tomcat/maven-plugin/trunk/common-tomcat-maven-plugin/src/main/java/org/apache/tomcat/maven/common/deployer/TomcatManager.java tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat6/AbstractDeployWarMojo.java tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/deploy/AbstractDeployWarMojo.java Modified: tomcat/maven-plugin/trunk/common-tomcat-maven-plugin/src/main/java/org/apache/tomcat/maven/common/deployer/TomcatManager.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/common-tomcat-maven-plugin/src/main/java/org/apache/tomcat/maven/common/deployer/TomcatManager.java?rev=1212874&r1=1212873&r2=1212874&view=diff ============================================================================== --- tomcat/maven-plugin/trunk/common-tomcat-maven-plugin/src/main/java/org/apache/tomcat/maven/common/deployer/TomcatManager.java (original) +++ tomcat/maven-plugin/trunk/common-tomcat-maven-plugin/src/main/java/org/apache/tomcat/maven/common/deployer/TomcatManager.java Sat Dec 10 21:06:31 2011 @@ -336,6 +336,24 @@ public class TomcatManager } /** + * + * @param path + * @param war + * @param update + * @param tag + * @param length + * @return + * @throws TomcatManagerException + * @throws IOException + * @since 2.0 + */ + public TomcatManagerResponse deploy( String path, InputStream war, boolean update, String tag, long length ) + throws TomcatManagerException, IOException + { + return deployImpl( path, null, null, war, update, tag, length ); + } + + /** * Deploys the specified context XML configuration to the specified context path. * * @param path the webapp context path to deploy to @@ -596,13 +614,20 @@ public class TomcatManager protected TomcatManagerResponse invoke( String path ) throws TomcatManagerException, IOException { - return invoke( path, null ); + return invoke( path, null, -1 ); } // ---------------------------------------------------------------------- // Private Methods // ---------------------------------------------------------------------- + private TomcatManagerResponse deployImpl( String path, URL config, URL war, InputStream data, boolean update, + String tag ) + throws TomcatManagerException, IOException + { + return deployImpl( path, config, war, data, update, tag, -1 ); + } + /** * Deploys the specified WAR. * @@ -616,7 +641,8 @@ public class TomcatManager * @throws TomcatManagerException if the Tomcat manager request fails * @throws IOException if an i/o error occurs */ - private TomcatManagerResponse deployImpl( String path, URL config, URL war, InputStream data, boolean update, String tag ) + private TomcatManagerResponse deployImpl( String path, URL config, URL war, InputStream data, boolean update, + String tag, long length ) throws TomcatManagerException, IOException { StringBuilder buffer = new StringBuilder( "/deploy" ); @@ -642,7 +668,7 @@ public class TomcatManager buffer.append( "&tag=" ).append( URLEncoder.encode( tag, charset ) ); } - return invoke( buffer.toString(), data ); + return invoke( buffer.toString(), data, length ); } @@ -655,7 +681,7 @@ public class TomcatManager * @throws TomcatManagerException if the Tomcat manager request fails * @throws IOException if an i/o error occurs */ - protected TomcatManagerResponse invoke( String path, InputStream data ) + protected TomcatManagerResponse invoke( String path, InputStream data, long length ) throws TomcatManagerException, IOException { @@ -668,7 +694,7 @@ public class TomcatManager { HttpPut httpPut = new HttpPut( url + path ); - httpPut.setEntity( new RequestEntityImplementation( data, -1 ) ); + httpPut.setEntity( new RequestEntityImplementation( data, length ) ); httpRequestBase = httpPut; Modified: tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat6/AbstractDeployWarMojo.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat6/AbstractDeployWarMojo.java?rev=1212874&r1=1212873&r2=1212874&view=diff ============================================================================== --- tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat6/AbstractDeployWarMojo.java (original) +++ tomcat/maven-plugin/trunk/tomcat6-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat6/AbstractDeployWarMojo.java Sat Dec 10 21:06:31 2011 @@ -84,7 +84,7 @@ public class AbstractDeployWarMojo getLog().info( messagesProvider.getMessage( "AbstractDeployMojo.deployingWar", getDeployedURL() ) ); - log( getManager().deploy( getPath(), new FileInputStream( warFile ), isUpdate(), - getTag() ).getHttpResponseBody() ); + log( getManager().deploy( getPath(), new FileInputStream( warFile ), isUpdate(), getTag(), + warFile.length() ).getHttpResponseBody() ); } } Modified: tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/deploy/AbstractDeployWarMojo.java URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/deploy/AbstractDeployWarMojo.java?rev=1212874&r1=1212873&r2=1212874&view=diff ============================================================================== --- tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/deploy/AbstractDeployWarMojo.java (original) +++ tomcat/maven-plugin/trunk/tomcat7-maven-plugin/src/main/java/org/apache/tomcat/maven/plugin/tomcat7/deploy/AbstractDeployWarMojo.java Sat Dec 10 21:06:31 2011 @@ -84,7 +84,7 @@ public class AbstractDeployWarMojo getLog().info( messagesProvider.getMessage( "AbstractDeployMojo.deployingWar", getDeployedURL() ) ); - log( getManager().deploy( getPath(), new FileInputStream( warFile ), isUpdate(), - getTag() ).getHttpResponseBody() ); + log( getManager().deploy( getPath(), new FileInputStream( warFile ), isUpdate(), getTag(), + warFile.length() ).getHttpResponseBody() ); } } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org