Package org.apache.velocity

Examples of org.apache.velocity.VelocityContext


    return writer.toString();
  }

  OutputFile compileInterface(Protocol protocol) {
    protocol = addStringType(protocol);           // annotate protocol as needed
    VelocityContext context = new VelocityContext();
    context.put("protocol", protocol);
    context.put("this", this);
    String out = renderTemplate(templateDir+"protocol.vm", context);

    OutputFile outputFile = new OutputFile();
    String mangledName = mangle(protocol.getName());
    outputFile.path = makePath(mangledName, protocol.getNamespace());
View Full Code Here


  }

  OutputFile compile(Schema schema) {
    schema = addStringType(schema);               // annotate schema as needed
    String output = "";
    VelocityContext context = new VelocityContext();
    context.put("this", this);
    context.put("schema", schema);

    switch (schema.getType()) {
    case RECORD:
      output = renderTemplate(templateDir+"record.vm", context);
      break;
View Full Code Here

        Velocity.setProperty(Velocity.RESOURCE_LOADER, "class");
        Velocity.setProperty("class.resource.loader.description", "Velocity Classpath Resource Loader");
        Velocity.setProperty("class.resource.loader.class", ClasspathResourceLoader.class.getName());
        Velocity.init();
        Template template = Velocity.getTemplate("/org/apache/tomee/configs/" + filename);
        VelocityContext context = new VelocityContext();
        context.put("tomcatHttpPort", Integer.toString(configuration.getHttpPort()));
        context.put("tomcatShutdownPort", Integer.toString(configuration.getStopPort()));
        Writer writer = new FileWriter(new File(targetDir, filename));
        template.merge(context, writer);
        writer.flush();
        writer.close();
    }
View Full Code Here

        String content;

        try
        {
            VelocityContext context = new VelocityContext();

            context.put( "includeTestSummary", includeTestSummary );

            context.put( "includeOutput", includeBuildOutput );

            if ( includeBuildOutput )
            {
                context.put( "buildOutput", getBuildOutput( project, build ) );
            }

            if ( includeBuildSummary )
            {
                context.put( "build", build );

                ReportTestResult reportTestResult =
                    reportTestSuiteGenerator.generateReportTestResult( build.getId(), project.getId() );

                context.put( "testResult", reportTestResult );

                context.put( "project", project );

                context.put( "changesSinceLastSuccess",
                             continuum.getChangesSinceLastSuccess( project.getId(), build.getId() ) );

                context.put( "previousBuild", previousBuild );

                // ----------------------------------------------------------------------
                // Tools
                // ----------------------------------------------------------------------

                context.put( "formatter", formatterTool );

                // TODO: Make the build host a part of the build

                context.put( "buildHost", buildHost );

                String osName = System.getProperty( "os.name" );

                String osPatchLevel = System.getProperty( "sun.os.patch.level" );

                if ( osPatchLevel != null )
                {
                    osName = osName + "(" + osPatchLevel + ")";
                }

                context.put( "osName", osName );

                context.put( "javaVersion",
                             System.getProperty( "java.version" ) + "(" + System.getProperty( "java.vendor" ) + ")" );

                // TODO only in case of a java project ?
                context.put( "javaHomeInformations", getJavaHomeInformations( buildDefinition ) );

                context.put( "builderVersions", getBuilderVersion( buildDefinition, project ) );
            }

            // ----------------------------------------------------------------------
            // Data objects
            // ----------------------------------------------------------------------

            context.put( "reportUrl", getReportUrl( project, build, configurationService ) );

            // TODO put other profile env var could be a security if they provide passwords ?

            // ----------------------------------------------------------------------
            // Generate
View Full Code Here

        String content;

        try
        {
            VelocityContext context = new VelocityContext();

            // ----------------------------------------------------------------------
            // Data objects
            // ----------------------------------------------------------------------

            context.put( "reportUrl",
                         getReportUrl( projectScmRoot.getProjectGroup(), projectScmRoot, configurationService ) );

            context.put( "projectGroup", projectScmRoot.getProjectGroup() );

            context.put( "projectScmRoot", projectScmRoot );

            // TODO put other profile env var could be a security if they provide passwords ?

            // ----------------------------------------------------------------------
            // Generate
View Full Code Here

    * @return VelocityContext
    */
   protected VelocityContext updateVelocityContext( VelocityContext    context,
                                                    ResourceDefinition resourceDef )
   {
      VelocityContext velocityContext = super.updateVelocityContext( context, resourceDef );
      if ( hasPropChange( resourceDef ) )
      {
         velocityContext.put( VCTY_CTX_PROP_CHANGE, "true" );
      }

      if ( hasResourceTermination( resourceDef ) )
      {
         velocityContext.put( VCTY_CTX_RESOURCE_TERMINATION, "true" );
      }

      if ( hasNotificationProducer( resourceDef ) )
      {
         velocityContext.put( VCTY_CTX_NOTIF_PRODUCER, "true" );
      }

      return velocityContext;
   }
View Full Code Here

    private String generateSubject( Project project, BuildResult build )
        throws Exception
    {
        String state = getState( project, build );

        VelocityContext context = new VelocityContext();
        context.put( "project", project );
        context.put( "build", build );
        context.put( "state", state );

        StringWriter writer = new StringWriter();

        boolean velocityRes = velocity.getEngine().evaluate( context, writer, "subjectPattern", buildSubjectFormat );
View Full Code Here

    private String generateSubject( ProjectScmRoot projectScmRoot )
        throws Exception
    {
        String state = getState( projectScmRoot );

        VelocityContext context = new VelocityContext();
        context.put( "projectScmRoot", projectScmRoot );
        context.put( "state", state );

        StringWriter writer = new StringWriter();

        boolean velocityResults =
            velocity.getEngine().evaluate( context, writer, "subjectPattern", prepareBuildSubjectFormat );
View Full Code Here

            /*
             * now, make a Context object and populate it.
             */

            VelocityContext context = new VelocityContext();
            context.put("root", root);

            /*
             *  make a writer, and merge the template 'against' the context
             */
View Full Code Here

     * @parameter
     */
    private UseMavenDependencies useMavenDependencies;

    private VelocityContext createContext() {
        VelocityContext context = new VelocityContext();

        // Load properties, It inherits them all!
        Properties props = project.getProperties();
        for (Object o : props.keySet()) {
            String key = (String) o;
            String value = props.getProperty(key);

            log.debug("Setting " + key + "=" + value);
            context.put(key, value);
        }

        context.put("pom", project);

        return context;
    }
View Full Code Here

TOP

Related Classes of org.apache.velocity.VelocityContext

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.