Package org.codehaus.mojo.appassembler.daemon

Examples of org.codehaus.mojo.appassembler.daemon.DaemonGeneratorException


        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);
        }
    }
View Full Code Here


                }
            }
        }
        catch ( ArtifactNotFoundException ex )
        {
           throw new DaemonGeneratorException( "could not find artifact for jsw", ex );
        }
        catch ( ArtifactResolutionException ex )
        {
           throw new DaemonGeneratorException( "could not resolve artifact for jsw", ex );
        }
        catch ( NoSuchArchiverException ex )
        {
           throw new DaemonGeneratorException( "could not find UnArchiver for ".concat( JSW_TYPE ), ex );
        }
        catch ( ArchiverException ex )
        {
           throw new DaemonGeneratorException( "could not unpack jsw archive", ex );
        }

        return jswDirectory;
    }
View Full Code Here

        throws DaemonGeneratorException
    {
        File wrapperConfTemplate = new File( jswDirectory, "src" + File.separator + "conf" + File.separator + "wrapper.conf.in" );
        if ( ! wrapperConfTemplate.exists() )
        {
            throw new DaemonGeneratorException( "Could not load template." );
        }

        FormattedProperties confFile = new FormattedProperties();

        InputStream in = null;

        try
        {
            in = new FileInputStream( wrapperConfTemplate );
            confFile.read( in );
        }
        catch ( IOException e )
        {
            throw new DaemonGeneratorException( "Error reading template: " + e.getMessage(), e );
        }
        finally
        {
            IOUtil.close( in );
        }
View Full Code Here

            IOUtil.copy( reader, out );
        }
        catch ( IOException e )
        {
            throw new DaemonGeneratorException( "Error writing output file: " + outputFile.getAbsolutePath(), e );
        }
        finally
        {
            IOUtil.close( reader );
            IOUtil.close( out );
View Full Code Here

            IOUtil.copy( inputStream, out );
        }
        catch ( IOException e )
        {           
            throw new DaemonGeneratorException( "Error writing output file: " + outputFile.getAbsolutePath(), e );
        }
        finally
        {
            IOUtil.close( inputStream );
            IOUtil.close( out );
View Full Code Here

                libexecPath = "../".concat( libexec ).concat( "/wrapper"  );
            }
            File shellScriptTemplate = new File( jswDirectory, "src" + File.separator + "bin" + File.separator + "sh.script.in" );
            if ( ! shellScriptTemplate.exists() )
            {
                throw new DaemonGeneratorException( "Could not load shell script template." );
            }

            Reader reader = new FileReader( shellScriptTemplate );
            if ( libexecPath != null )
            {
                reader = new TokenFilterReader( reader, new SimpleRegexTokenResolver( "^WRAPPER_CMD=.*$", "WRAPPER_CMD=\"" + libexecPath + "\"") );
            }

            writeFilteredFile( request, daemon, reader, new File( outputDirectory, "bin" + File.separator + daemon.getId() ), context );

            File batchScriptTemplate = new File( jswDirectory, "src" + File.separator + "bin" + File.separator + "AppCommand.bat.in" );
            if ( ! batchScriptTemplate.exists() )
            {
                throw new DaemonGeneratorException( "Could not load shell script template." );
            }

            if ( libexec != null )
            {
                SimpleRegexTokenResolver resolver = new SimpleRegexTokenResolver( "^set\\ _WRAPPER_BASE=.*?\\r$", "set _WRAPPER_BASE=" + libexecPath);
                Reader batchReader = new TokenFilterReader( new FileReader( batchScriptTemplate ), resolver );
                writeFile( new File( outputDirectory, "bin" + File.separator + daemon.getId() + ".bat" ),
                       batchReader );
            }
            else
            {
                InputStream batchFileInputStream = new FileInputStream( batchScriptTemplate );

                writeFile( new File( outputDirectory, "bin" + File.separator + daemon.getId() + ".bat" ),
                           batchFileInputStream );
            }
        }
        catch ( IOException ex )
        {
            throw new DaemonGeneratorException( "could not write script files", ex);
        }
    }
View Full Code Here

TOP

Related Classes of org.codehaus.mojo.appassembler.daemon.DaemonGeneratorException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.