Examples of DaemonGeneratorException


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

    {
        Platform platform = (Platform) ALL_PLATFORMS.get( platformName );

        if ( platform == null )
        {
            throw new DaemonGeneratorException( "Unknown platform name '" + platformName + "'" );
        }

        return platform;
    }
View Full Code Here

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

            if ( "all".equals( first ) )
            {
                return allSet;
            }

            throw new DaemonGeneratorException(
                "The special platform 'all' can only be used if it is the only element in the platform list." );
        }

        Set platformSet = new HashSet();

        for ( Iterator it = platformList.iterator(); it.hasNext(); )
        {
            String platformName = (String) it.next();

            if ( platformName.equals( "all" ) )
            {
                throw new DaemonGeneratorException(
                    "The special platform 'all' can only be used if it is the only element in a platform list." );
            }

            platformSet.add( getInstance( platformName ) );
        }
View Full Code Here

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

            {
                classpathBuffer.append( getRepo() ).append( getSeparator() );
            }
            else
            {
                throw new DaemonGeneratorException( "Unknown classpath element type: " + object.getClass().getName() );
            }

            classpathBuffer.append( StringUtils.replace( ( (ClasspathElement) object ).getRelativePath(),
                                                         "/", getSeparator() ) );
        }
View Full Code Here

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

        {
            in = getClass().getResourceAsStream( resourcePrefix + platformName + "BinTemplate" );

            if ( in == null )
            {
                throw new DaemonGeneratorException(
                    "Internal error: could not find template for platform '" + platformName + "'." );
            }

            InputStreamReader reader = new InputStreamReader( in );

            Map context = new HashMap( extraVars );
            context.put( "MAINCLASS", daemon.getMainClass() );
            context.put( "CLASSPATH", platform.getClassPath( daemon ) );
            context.put( "EXTRA_JVM_ARGUMENTS", platform.getExtraJvmArguments( daemon.getJvmSettings() ) );
            context.put( "APP_NAME", daemon.getId() );
            context.put( "ENV_SETUP", platform.getEnvSetup( daemon ) );
            context.put( "REPO", daemon.getRepositoryName() );
            if ( platform.isShowConsoleWindow( daemon ) )
            {
                context.put( "JAVA_BINARY", "java" );
            }
            else
            {
                context.put( "JAVA_BINARY", "start /min javaw" );
            }

            String appArguments = platform.getAppArguments( daemon );
            if ( appArguments != null )
            {
                context.put( "APP_ARGUMENTS", appArguments + " " );
            }
            else
            {
                context.put( "APP_ARGUMENTS", "" );
            }

            String interpolationToken = platform.getInterpolationToken();
            InterpolationFilterReader interpolationFilterReader =
                new InterpolationFilterReader( reader, context, interpolationToken, interpolationToken );

            // Set the name of the bin file
            String programName = "";

            if ( daemon.getId() == null || daemon.getId().trim().equals( "" ) )
            {
                // Get class name and use it as the filename
                StringTokenizer tokenizer = new StringTokenizer( daemon.getMainClass(), "." );
                while ( tokenizer.hasMoreElements() )
                {
                    programName = tokenizer.nextToken();
                }

                programName = programName.toLowerCase();
            }
            else
            {
                programName = daemon.getId();
            }

            File binDir = new File( outputDirectory, "bin" );
            FileUtils.forceMkdir( binDir );
            File binFile = new File( binDir, programName + platform.getBinFileExtension() );

            out = new FileWriter( binFile );
            getLogger().debug( "Writing shell file for platform '" + platform.getName() + "' to '"
                + binFile.getAbsolutePath() + "'." );

            IOUtil.copy( interpolationFilterReader, out );

            binFile.setExecutable(true);
        }
        catch ( FileNotFoundException e )
        {
            throw new DaemonGeneratorException( "Failed to get template for bin file.", e );
        }
        catch ( IOException e )
        {
            throw new DaemonGeneratorException( "Failed to write bin file.", e );
        }
        finally
        {
            IOUtil.close( out );
            IOUtil.close( in );
View Full Code Here

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

    {
        Artifact artifact = (Artifact) project.getArtifactMap().get( id );

        if ( artifact == null )
        {
            throw new DaemonGeneratorException( "The project has to have a dependency on '" + id + "'." );
        }

        Dependency dependency = new Dependency();

        dependency.setRelativePath( artifactRepositoryLayout.pathOf( artifact ) );
View Full Code Here

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

    File outputDirectory = new File(request.getOutputDirectory(),
                             daemon.getId());

    if (!outputDirectory.exists() &&!outputDirectory.mkdirs())
    {
      throw new DaemonGeneratorException(
        "could not create directory ".concat(outputDirectory.getPath()));
    }

    File nativeDirectory = downloadAndUnpackCommonsDaemon(request,
                             outputDirectory);

    if (nativeDirectory == null)
    {
      throw new DaemonGeneratorException("could not find native directory");
    }

    File libexecDirectory = new File(outputDirectory, "libexec");

    if (!nativeDirectory.renameTo(libexecDirectory))
    {
      throw new DaemonGeneratorException("could not move native directory");
    }

    try
    {
      File varDirectory = new File(outputDirectory, "var");

      FileUtils.forceMkdir(varDirectory);

      File logDirectory = new File(varDirectory, "log");

      FileUtils.forceMkdir(logDirectory);
    }
    catch (IOException ex)
    {
      throw new DaemonGeneratorException("could not create directory", ex);
    }

    Iterator platformIt = Platform.getAllPlatformNames().iterator();

    while (platformIt.hasNext())
View Full Code Here

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

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

    return nativeDirectory;
  }
View Full Code Here

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

        {
            FileUtils.forceMkdir( request.getOutputDirectory() );
        }
        catch ( IOException e )
        {
            throw new DaemonGeneratorException( "Error creating output directory: " + request.getOutputDirectory(), e );
        }

        File envDir = new File( request.getOutputDirectory(), "env" );
        envDir.mkdir();

        copyEnvFile( "JAVA_HOME", envDir );
        copyEnvFile( "USER", envDir );

        File logDir = new File( request.getOutputDirectory(), "logs" );
        logDir.mkdir();

        File serviceDir = new File( request.getOutputDirectory(), "service" );
        serviceDir.mkdir();

        // -----------------------------------------------------------------------
        //
        // -----------------------------------------------------------------------

        InputStream in = this.getClass().getResourceAsStream( "run.sh.template" );

        if ( in == null )
        {
            throw new DaemonGeneratorException( "Could not load template." );
        }

        InputStreamReader reader = new InputStreamReader( in );

        Map context = new HashMap();
        context.put( "MAINCLASS", daemon.getMainClass() );
        context.put( "NAME", daemon.getId() );

        InterpolationFilterReader interpolationFilterReader = new InterpolationFilterReader( reader, context,
                                                                                             "@", "@" );

        File runFile = new File( request.getOutputDirectory(), "run" );
        FileWriter out = null;

        try
        {
            // -----------------------------------------------------------------------
            // Write the file
            // -----------------------------------------------------------------------

            out = new FileWriter( runFile );

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

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

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

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

            AppassemblerModelStaxWriter staxWriter = new AppassemblerModelStaxWriter();
            staxWriter.write( writer, mergedDaemon );
        }
        catch ( IOException e )
        {
            throw new DaemonGeneratorException( "Error while writing output file: " + request.getOutputDirectory(), e );
        }
        catch ( XMLStreamException e )
        {
            throw new DaemonGeneratorException( "Error while writing output file: " + request.getOutputDirectory(), e );
        }
        finally
        {
            IOUtil.close( writer );
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.