建立ivr通道的模板

arg_unit.vm:

 

<Instance version="0.0.1" saveSerial="0" instanceName="" flowCode="pxz.demo.ivr02_in" instanceId="">
      <inArgs>
        <arg key="channelName" val="ch${chno}"/>
      </inArgs>
    </Instance>

 

channel.vm:

 

<ch${chno}>
      <channelName>ch${chno}</channelName>
      <board>board_pcm7</board>
      <chno>${chno_i}</chno>
      <signalling>Ss7Mix</signalling>
      <sleepLen>100</sleepLen>
      <poleReverseEnable>${enabled}</poleReverseEnable>
      <signalTone>450</signalTone>
    </ch${chno}>

产生:

    void testVelocity() {
        /*  first, get and initialize an engine  */

        VelocityEngine ve = new VelocityEngine();
        try {
            ve.init();
        } catch (Exception ex) {
            log.error("%s : %s", ex.getClass().getName(), ex.toString());
            return;
        }

        /*  next, get the Template  */

        Template t = null;
        try {
            t = ve.getTemplate("./templ/hello.vm");
        } catch (Exception ex) {
            log.error("%s : %s", ex.getClass().getName(), ex.toString());
            return;
        }

        /*  create a context and add data */

        VelocityContext context = new VelocityContext();
//
//        //    select $colnames from $table where $criteria order by $order
//
        context.put("clearBeforeLoad", true);
        context.put("transactionEnable", true);
        context.put("alias", "(file)");

        /* now render the template into a StringWriter */

        StringWriter writer = new StringWriter();

    try {
            t.merge(context, writer);
        } catch (Exception ex) {
            log.error("%s : %s", ex.getClass().getName(), ex.toString());
            return;
        }
        log.info("velocity out:\n%s", writer.toString());
    }

你可能感兴趣的:(velocity)