You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ol...@apache.org on 2011/12/21 14:34:54 UTC
svn commit: r1221719 - in
/tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner:
Tomcat7Runner.java Tomcat7RunnerCli.java
Author: olamy
Date: Wed Dec 21 13:34:54 2011
New Revision: 1221719
URL: http://svn.apache.org/viewvc?rev=1221719&view=rev
Log:
[MTOMCAT-111] Make extract directory configurable
Modified:
tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7Runner.java
tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7RunnerCli.java
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=1221719&r1=1221718&r2=1221719&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 Wed Dec 21 13:34:54 2011
@@ -77,13 +77,15 @@ public class Tomcat7Runner
public boolean debug = false;
- public boolean clientAuth = false;
-
- public String keyAlias = null;
+ public boolean clientAuth = false;
+
+ public String keyAlias = null;
public String httpProtocol;
- public File extractDirectory = new File( ".extract" );
+ public String extractDirectory = ".extract";
+
+ public File extractDirectoryFile;
Catalina container;
@@ -103,8 +105,21 @@ public class Tomcat7Runner
throws Exception
{
- PasswordUtil.deobfuscateSystemProps();
-
+ PasswordUtil.deobfuscateSystemProps();
+
+ this.extractDirectoryFile = new File( this.extractDirectory );
+ if ( !this.extractDirectoryFile.exists() )
+ {
+ boolean create = this.extractDirectoryFile.mkdirs();
+ if ( !create )
+ {
+ System.out.println( "FATAL: impossible to create directory:" + this.extractDirectoryFile.getPath() );
+ System.exit( 1 );
+ }
+ }
+
+ debugMessage( "use extractDirectory:" + extractDirectoryFile.getPath() );
+
// do we have to extract content
if ( !new File( ".extract" ).exists() || resetExtract )
{
@@ -126,8 +141,8 @@ public class Tomcat7Runner
System.setProperty( "java.io.tmpdir", tmpDir.getAbsolutePath() );
- System.setProperty( "catalina.base", extractDirectory.getAbsolutePath() );
- System.setProperty( "catalina.home", extractDirectory.getAbsolutePath() );
+ System.setProperty( "catalina.base", extractDirectoryFile.getAbsolutePath() );
+ System.setProperty( "catalina.home", extractDirectoryFile.getAbsolutePath() );
// start with a server.xml
if ( serverXmlPath != null || useServerXml() )
@@ -165,21 +180,21 @@ public class Tomcat7Runner
debugMessage( "use connectorHttpProtocol:" + connectorHttpProtocol );
- if (httpPort > 0)
- {
- Connector connector = new Connector( connectorHttpProtocol );
- connector.setPort( httpPort );
-
- if ( httpsPort > 0 )
- {
- connector.setRedirectPort( httpsPort );
- }
- // FIXME parameter for that def ? ISO-8859-1
- //connector.setURIEncoding(uriEncoding);
+ if ( httpPort > 0 )
+ {
+ Connector connector = new Connector( connectorHttpProtocol );
+ connector.setPort( httpPort );
- tomcat.getService().addConnector( connector );
+ if ( httpsPort > 0 )
+ {
+ connector.setRedirectPort( httpsPort );
+ }
+ // FIXME parameter for that def ? ISO-8859-1
+ //connector.setURIEncoding(uriEncoding);
+
+ tomcat.getService().addConnector( connector );
- tomcat.setConnector( connector );
+ tomcat.setConnector( connector );
}
// add a default acces log valve
@@ -193,43 +208,46 @@ public class Tomcat7Runner
{
Connector httpsConnector = new Connector( connectorHttpProtocol );
httpsConnector.setPort( httpsPort );
- httpsConnector.setSecure(true);
- httpsConnector.setProperty("SSLEnabled", "true");
- httpsConnector.setProperty("sslProtocol", "TLS");
-
- String keystoreFile = System.getProperty("javax.net.ssl.keyStore");
- String keystorePass = System.getProperty("javax.net.ssl.keyStorePassword");
- String keystoreType = System.getProperty("javax.net.ssl.keyStoreType", "jks");
-
+ httpsConnector.setSecure( true );
+ httpsConnector.setProperty( "SSLEnabled", "true" );
+ httpsConnector.setProperty( "sslProtocol", "TLS" );
+
+ String keystoreFile = System.getProperty( "javax.net.ssl.keyStore" );
+ String keystorePass = System.getProperty( "javax.net.ssl.keyStorePassword" );
+ String keystoreType = System.getProperty( "javax.net.ssl.keyStoreType", "jks" );
+
if ( keystoreFile != null )
{
- httpsConnector.setAttribute("keystoreFile", keystoreFile);
+ httpsConnector.setAttribute( "keystoreFile", keystoreFile );
}
if ( keystorePass != null )
{
- httpsConnector.setAttribute("keystorePass", keystorePass);
+ httpsConnector.setAttribute( "keystorePass", keystorePass );
}
- httpsConnector.setAttribute("keystoreType", keystoreType);
-
- String truststoreFile = System.getProperty("javax.net.ssl.trustStore");
- String truststorePass = System.getProperty("javax.net.ssl.trustStorePassword");
- String truststoreType = System.getProperty("javax.net.ssl.trustStoreType", "jks");
+ httpsConnector.setAttribute( "keystoreType", keystoreType );
+
+ String truststoreFile = System.getProperty( "javax.net.ssl.trustStore" );
+ String truststorePass = System.getProperty( "javax.net.ssl.trustStorePassword" );
+ String truststoreType = System.getProperty( "javax.net.ssl.trustStoreType", "jks" );
if ( truststoreFile != null )
{
- httpsConnector.setAttribute("truststoreFile", truststoreFile);
+ httpsConnector.setAttribute( "truststoreFile", truststoreFile );
}
if ( truststorePass != null )
{
- httpsConnector.setAttribute("truststorePass", truststorePass);
+ httpsConnector.setAttribute( "truststorePass", truststorePass );
}
- httpsConnector.setAttribute("truststoreType", truststoreType);
-
- httpsConnector.setAttribute("clientAuth", clientAuth);
- httpsConnector.setAttribute("keyAlias", keyAlias);
-
+ httpsConnector.setAttribute( "truststoreType", truststoreType );
+
+ httpsConnector.setAttribute( "clientAuth", clientAuth );
+ httpsConnector.setAttribute( "keyAlias", keyAlias );
+
tomcat.getService().addConnector( httpsConnector );
-
- if (httpPort <= 0) tomcat.setConnector( httpsConnector );
+
+ if ( httpPort <= 0 )
+ {
+ tomcat.setConnector( httpsConnector );
+ }
}
// create ajp connector
@@ -329,11 +347,10 @@ public class Tomcat7Runner
throws Exception
{
- if ( extractDirectory.exists() )
+ if ( extractDirectoryFile.exists() )
{
- FileUtils.deleteDirectory( extractDirectory );
+ FileUtils.deleteDirectory( extractDirectoryFile );
}
- extractDirectory.mkdirs();
// ensure webapp dir is here
new File( extractDirectory, "webapps" ).mkdirs();
@@ -374,13 +391,13 @@ public class Tomcat7Runner
}
// expand tomcat configuration files if there
- expandConfigurationFile( "catalina.properties", extractDirectory );
- expandConfigurationFile( "logging.properties", extractDirectory );
- expandConfigurationFile( "tomcat-users.xml", extractDirectory );
- expandConfigurationFile( "catalina.policy", extractDirectory );
- expandConfigurationFile( "context.xml", extractDirectory );
- expandConfigurationFile( "server.xml", extractDirectory );
- expandConfigurationFile( "web.xml", extractDirectory );
+ expandConfigurationFile( "catalina.properties", extractDirectoryFile );
+ expandConfigurationFile( "logging.properties", extractDirectoryFile );
+ expandConfigurationFile( "tomcat-users.xml", extractDirectoryFile );
+ expandConfigurationFile( "catalina.policy", extractDirectoryFile );
+ expandConfigurationFile( "context.xml", extractDirectoryFile );
+ expandConfigurationFile( "server.xml", extractDirectoryFile );
+ expandConfigurationFile( "web.xml", extractDirectoryFile );
}
@@ -496,6 +513,7 @@ public class Tomcat7Runner
}
}
+
public boolean enableNaming()
{
return Boolean.parseBoolean( runtimeProperties.getProperty( ENABLE_NAMING_KEY, Boolean.FALSE.toString() ) );
Modified: tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7RunnerCli.java
URL: http://svn.apache.org/viewvc/tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7RunnerCli.java?rev=1221719&r1=1221718&r2=1221719&view=diff
==============================================================================
--- tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7RunnerCli.java (original)
+++ tomcat/maven-plugin/trunk/tomcat7-war-runner/src/main/java/org/apache/tomcat/maven/runner/Tomcat7RunnerCli.java Wed Dec 21 13:34:54 2011
@@ -36,7 +36,7 @@ import java.util.Properties;
* @author Olivier Lamy
* @since 2.0
*/
-@SuppressWarnings("static-access")
+@SuppressWarnings( "static-access" )
public class Tomcat7RunnerCli
{
@@ -66,29 +66,33 @@ public class Tomcat7RunnerCli
static Option sysProps = OptionBuilder.withDescription( "use value for given property" ).hasArgs().withDescription(
"key=value" ).withValueSeparator().create( 'D' );
- static Option clientAuth =
- OptionBuilder.withArgName( "clientAuth" ).withDescription( "enable client authentication for https" ).create(
- "clientAuth" );
-
- static Option keyAlias =
- OptionBuilder.withArgName( "keyAlias" ).hasArgs().withDescription( "alias from keystore for ssl" ).create(
- "keyAlias" );
-
- static Option obfuscate =
- OptionBuilder.withArgName( "password" ).hasArgs().withDescription( "obfuscate the password and exit" ).create(
- "obfuscate" );
+ static Option clientAuth =
+ OptionBuilder.withArgName( "clientAuth" ).withDescription( "enable client authentication for https" ).create(
+ "clientAuth" );
+
+ static Option keyAlias =
+ OptionBuilder.withArgName( "keyAlias" ).hasArgs().withDescription( "alias from keystore for ssl" ).create(
+ "keyAlias" );
+
+ static Option obfuscate =
+ OptionBuilder.withArgName( "password" ).hasArgs().withDescription( "obfuscate the password and exit" ).create(
+ "obfuscate" );
static Option httpProtocol = OptionBuilder.withArgName( "httpProtocol" ).hasArg().withDescription(
"http protocol to use: HTTP/1.1 or org.apache.coyote.http11.Http11NioProtocol" ).create( "httpProtocol" );
+ static Option extractDirectory = OptionBuilder.withArgName( "extractDirectory" ).hasArg().withDescription(
+ "path to extract war content" ).create( "extractDirectory" );
+
static Options options = new Options();
static
{
options.addOption( httpPort ).addOption( httpsPort ).addOption( ajpPort ).addOption( serverXmlPath ).addOption(
- resetExtract ).addOption( help ).addOption( debug ).addOption( sysProps ).addOption( httpProtocol )
- .addOption(clientAuth).addOption(keyAlias).addOption(obfuscate);
+ resetExtract ).addOption( help ).addOption( debug ).addOption( sysProps ).addOption(
+ httpProtocol ).addOption( clientAuth ).addOption( keyAlias ).addOption( obfuscate ).addOption(
+ extractDirectory );
}
@@ -175,6 +179,12 @@ public class Tomcat7RunnerCli
{
tomcat7Runner.keyAlias = line.getOptionValue( keyAlias.getOpt() );
}
+
+ if ( line.hasOption( extractDirectory.getOpt() ) )
+ {
+ tomcat7Runner.extractDirectory = line.getOptionValue( extractDirectory.getOpt() );
+ }
+
// here we go
tomcat7Runner.run();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org