File outputDirectory = new File( request.getOutputDirectory(), daemon.getId() );
File jswDirectory = downloadAndUnpackJSW( request, outputDirectory );
if ( jswDirectory == null )
{
throw new DaemonGeneratorException( "could not find jsw directory" );
}
Properties configuration = createConfiguration( daemon );
String libexec = configuration.getProperty( "app.base.libexec");
// Don't want these in the wrapper.conf file
String appBaseEnvVar = configuration.getProperty( "app.base.envvar", "APP_BASE" );
configuration.remove( "app.base.envvar" );
String runAsUserEnvVar = configuration.getProperty( "run.as.user.envvar", "" );
if ( !runAsUserEnvVar.equals( "" ) )
{
runAsUserEnvVar = "RUN_AS_USER=" + runAsUserEnvVar;
configuration.remove( "run.as.user.envvar" );
}
Properties context = createContext( request, daemon );
context.setProperty( "app.base.envvar", appBaseEnvVar );
context.setProperty( "run.as.user.envvar", runAsUserEnvVar );
writeWrapperConfFile( request, daemon, outputDirectory, jswDirectory, context, configuration );
writeScriptFiles( request, daemon, outputDirectory, jswDirectory, context, libexec );
List jswPlatformIncludes = getJswPlatformIncludes( daemon );
writeLibraryFiles( outputDirectory, jswDirectory, jswPlatformIncludes );
if ( libexec == null ){
libexec = "bin";
}
writeExecutableFiles( new File( outputDirectory, libexec ), new File(jswDirectory, "bin"), jswPlatformIncludes );
// remove jsw temp files
try
{
FileUtils.deleteDirectory( jswDirectory );
}
catch ( IOException ex )
{
throw new DaemonGeneratorException( "could not delete jsw directory ".concat( jswDirectory.getPath()), ex);
}
}