Package org.jostraca

Examples of org.jostraca.Template


    // do nothing
  }


  public void process( Template pTemplate ) {
    Template    template   = pTemplate;
    PropertySet tmps       = template.getMergedPropertySet();

    // FIX: need to elaborate on this!
    boolean     execute    = !tmps.isNo( Property.main_ExecuteCodeWriter );

    if( execute ) {
View Full Code Here


    }
  }


  protected void processImpl( Template pTemplate ) {
    Template    template   = pTemplate;
    PropertySet tmps       = template.getMergedPropertySet();

    File   codeWriterPath   = template.getCodeWriterPath();
    String codeWriterSource = template.getCodeWriterSource();

    try {
      String externalController        = makeExternalController( tmps );
      String externalControllerOptions = tmps.get( Property.main_ExternalControllerOptions );
      String absoluteCodeWriterPath    = TextUtil.quote(getCodeWriterPath( tmps ));

      String codeWriterOptions = makeCodeWriterOptions( tmps, template );

      // FIX: why use absolute controller path since compile does not?

      String cmd = Standard.EMPTY;
      boolean cwic = tmps.isYes( Property.main_CodeWriterIsController );

      cmd += ( externalController + Standard.SPACE + externalControllerOptions + Standard.SPACE );
    
      if( !cwic ) {
        cmd += absoluteCodeWriterPath;
      }

      cmd += Standard.SPACE + codeWriterOptions;

     
      boolean successful = executeGeneratingCmd( cmd, template );
      WayPointRecorder.add( BasicWayPoint.ExecutingCodeWriter.make( template.getCodeWriterPath().getAbsolutePath() ) );
    }
    catch( StandardException se ) {
      throw se;
    }
    catch( Exception e ) {
View Full Code Here

  // test methods

  public void testSaver() throws Exception {
    CommandLineUserMessageHandler cm = new CommandLineUserMessageHandler();

    Template tm01 = PackageTest.makeTemplate("tm01");
    Template tm02 = PackageTest.makeTemplate("tm02");
    ArrayList tmlist = ListUtil.make( tm01, tm02 );

    for( Iterator tmT = tmlist.iterator(); tmT.hasNext(); ) {
      Template tm = (Template) tmT.next();
      tm.getPropertySet( Service.CONF_template )
        .set( TemplateHandlerManager.PROPERTY_PREFIX+"Preparer", "org.jostraca.process.GenericPreparer" );
      tm.getPropertySet(Service.CONF_template)
        .set( TemplateHandlerManager.PROPERTY_PREFIX+"Parser", "org.jostraca.process.GenericParser" );
      tm.getPropertySet(Service.CONF_template)
        .set( TemplateHandlerManager.PROPERTY_PREFIX+"Merger", "org.jostraca.process.GenericMerger" );
      tm.getPropertySet(Service.CONF_template)
        .set( TemplateHandlerManager.PROPERTY_PREFIX+"Saver""org.jostraca.process.GenericSaver" );
    }

    PreparerProcessStage prps = new PreparerProcessStage();
    prps.setUserMessageHandler( cm );
View Full Code Here

    // do nothing
  }


  protected void processImpl( Template pTemplate ) {
    Template    template   = pTemplate;
    PropertySet tmps       = template.getMergedPropertySet();

    boolean     successful = false;
    PrintStream sysOut     = null;
    PrintStream sysErr     = null;
    RecordingUserMessageHandler rumh = new RecordingUserMessageHandler();

    try {
      String   cw   = tmps.get( Property.main_CodeWriter );
      String   cwo  = makeCodeWriterOptions( tmps, template );
      String[] args = ArgUtil.splitQuoted( cwo );
      String   cwp  = getCodeWriterPath( tmps );

      Properties jythonProps = new Properties();
      jythonProps.put( "python.home", tmps.get("jython.home") );
      PythonInterpreter.initialize( System.getProperties(), jythonProps, args );

      PyStringMap       dict  = new PyStringMap();
      PySystemState     pysys = new PySystemState();
      PythonInterpreter pi    = new PythonInterpreter( dict, pysys );


      // DO NOT use CommandLineUserMessageHandler here - causes infinite recursion
      MessageHandlerOutputStream  out  = new MessageHandlerOutputStream( UserMessageHandler.INFO,  rumh );
      MessageHandlerOutputStream  err  = new MessageHandlerOutputStream( UserMessageHandler.ERROR, rumh );

      // space out dots to avoid accidental replace on System DOT out search
      sysOut = System . out;
      sysErr = System . err;
   
      // set context if not null
      Object context = template.getContext();
      if( null != context ) {
        pi.set( "context", context );
      }

      System.setOut( new PrintStream( out ) );
      System.setErr( new PrintStream( err ) );

      pi.execfile( cwp );
     
      String jythonexec
        = "cw = "+cw+"()\n"
        + (null!=context?"cw._setContext( context )\n":"")
        + "cw.main( sys.argv )\n"
        + "result = cw._getResult()\n"
        ;
      pi.exec( jythonexec );
      WayPointRecorder.add( BasicWayPoint.ExecutingCodeWriter.make( template.getCodeWriterPath().getAbsolutePath() ) );

      Object result = pi.get("result");

      if( result instanceof Integer ) {
        successful = ( 0 == ((Integer)result).intValue() );
      }
      else {
        successful = true;
      }

      template.setResult( result );
    }

    // FIX: need a util to handle general exceptions and just rethrow StandardExceptions
    catch( StandardException se ) {
      throw se;
View Full Code Here

    CommandLineUserMessageHandler cm = new CommandLineUserMessageHandler();

    List tmlist = makeTMList();

    for( Iterator tmT = tmlist.iterator(); tmT.hasNext(); ) {
      Template tm = (Template) tmT.next();
      tm.getPropertySet(Service.CONF_template)
        .set( TemplateHandlerManager.PROPERTY_PREFIX+"Compiler", "org.jostraca.process.GenericCompiler" );
    }

    preprocess( cm, tmlist );
View Full Code Here

    CommandLineUserMessageHandler cm = new CommandLineUserMessageHandler();

    List tmlist = makeTMList();

    for( Iterator tmT = tmlist.iterator(); tmT.hasNext(); ) {
      Template tm = (Template) tmT.next();
      tm.getPropertySet(Service.CONF_template)
        .set( TemplateHandlerManager.PROPERTY_PREFIX+"Compiler", "org.jostraca.process.JavaCompiler" );
    }

    preprocess( cm, tmlist );
    CompilerProcessStage cps = new CompilerProcessStage();
View Full Code Here

    CommandLineUserMessageHandler cm = new CommandLineUserMessageHandler();

    List tmlist = makeTMList();

    for( Iterator tmT = tmlist.iterator(); tmT.hasNext(); ) {
      Template tm = (Template) tmT.next();
      tm.getPropertySet(Service.CONF_template)
        .set( TemplateHandlerManager.PROPERTY_PREFIX+"Compiler", "org.jostraca.process.InternalJavaCompiler" );
    }

    preprocess( cm, tmlist );
View Full Code Here

    CommandLineUserMessageHandler cm = new CommandLineUserMessageHandler();

    List tmlist = makeTMList();

    for( Iterator tmT = tmlist.iterator(); tmT.hasNext(); ) {
      Template tm = (Template) tmT.next();
      tm.getPropertySet(Service.CONF_template)
        .set( TemplateHandlerManager.PROPERTY_PREFIX+"Compiler", "org.jostraca.process.ExternalJavaCompiler" );
    }

    preprocess( cm, tmlist );
View Full Code Here

    cps.process( tmlist );
  }


  public List makeTMList() throws Exception {
    Template tm01 = PackageTest.makeTemplate("tm01");
    Template tm02 = PackageTest.makeTemplate("tm02");
    ArrayList tmlist = ListUtil.make( tm01, tm02 );
    return tmlist;
  }
View Full Code Here

  }


  public void preprocess( UserMessageHandler pCM, List pTmList ) {
    for( Iterator tmT = pTmList.iterator(); tmT.hasNext(); ) {
      Template tm = (Template) tmT.next();
      tm.getPropertySet( Service.CONF_template )
        .set( TemplateHandlerManager.PROPERTY_PREFIX+"Preparer", "org.jostraca.process.GenericPreparer" );
      tm.getPropertySet(Service.CONF_template)
        .set( TemplateHandlerManager.PROPERTY_PREFIX+"Parser", "org.jostraca.process.GenericParser" );
      tm.getPropertySet(Service.CONF_template)
        .set( TemplateHandlerManager.PROPERTY_PREFIX+"Merger", "org.jostraca.process.GenericMerger" );
      tm.getPropertySet(Service.CONF_template)
        .set( TemplateHandlerManager.PROPERTY_PREFIX+"Saver", "org.jostraca.process.GenericSaver" );
    }

    PreparerProcessStage prps = new PreparerProcessStage();
    prps.setUserMessageHandler( pCM );
View Full Code Here

TOP

Related Classes of org.jostraca.Template

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.