Package org.mvel2.templates

Examples of org.mvel2.templates.TemplateError


      return appender.toString();

    }
    catch (FileNotFoundException e) {
      throw new TemplateError("cannot include template '" + file.getPath() + "': file not found.");
    }
    catch (IOException e) {
      throw new TemplateError("unknown I/O exception while including '" + file.getPath() + "' (stacktrace nested)", e);
    }
  }
View Full Code Here


      fc.close();

      return appender.toString();
    }
    catch (FileNotFoundException e) {
      throw new TemplateError("cannot include template '" + file.getName() + "': file not found.");
    }
    catch (IOException e) {
      throw new TemplateError("unknown I/O exception while including '" + file.getName() + "' (stacktrace nested)", e);
    }
  }
View Full Code Here

      return appender.toString();
    }
    catch (NullPointerException e) {
      if (instream == null) {
        throw new TemplateError("null input stream", e);
      }
      else {
        throw e;
      }
    }
    catch (IOException e) {
      throw new TemplateError("unknown I/O exception while including (stacktrace nested)", e);
    }
  }
View Full Code Here

    if (next != null) {
      String namedTemplate = MVEL.executeExpression(cIncludeExpression, ctx, factory, String.class);
      CompiledTemplate ct = runtime.getNamedTemplateRegistry().getNamedTemplate(namedTemplate);

      if (ct == null)
        throw new TemplateError("named template does not exist: " + namedTemplate);

      return next.eval(runtime, appender.append(String.valueOf(TemplateRuntime.execute(ct, ctx, factory, runtime.getNamedTemplateRegistry()))), ctx, factory);

//            return next.eval(runtime,
//                    appender.append(String.valueOf(TemplateRuntime.execute(runtime.getNamedTemplateRegistry().getNamedTemplate(MVEL.executeExpression(cIncludeExpression, ctx, factory, String.class)), ctx, factory))), ctx, factory);
View Full Code Here

      return appender.toString();

    }
    catch (FileNotFoundException e) {
      throw new TemplateError("cannot include template '" + fileName + "': file not found.");
    }
    catch (IOException e) {
      throw new TemplateError("unknown I/O exception while including '" + fileName + "' (stacktrace nested)", e);
    }
  }
View Full Code Here

    if (next != null) {
      String namedTemplate = MVEL.executeExpression(cIncludeExpression, ctx, factory, String.class);
      CompiledTemplate ct = runtime.getNamedTemplateRegistry().getNamedTemplate(namedTemplate);

      if (ct == null)
        throw new TemplateError("named template does not exist: " + namedTemplate);

      return next.eval(runtime, appender.append(String.valueOf(TemplateRuntime.execute(ct, ctx, factory, runtime.getNamedTemplateRegistry()))), ctx, factory);

//            return next.eval(runtime,
//                    appender.append(String.valueOf(TemplateRuntime.execute(runtime.getNamedTemplateRegistry().getNamedTemplate(MVEL.executeExpression(cIncludeExpression, ctx, factory, String.class)), ctx, factory))), ctx, factory);
View Full Code Here

                                 final ProcessBuildContext context,
                                 final String className,
                                 final Map vars,
                                 final Object invokerLookup,
                                 final BaseDescr descrLookup) {
        TemplateRegistry registry = getRuleTemplateRegistry();

        context.getMethods().add(
                TemplateRuntime.execute(registry.getNamedTemplate(ruleTemplate), null, new MapVariableResolverFactory(vars), registry)
        );

        registry = getInvokerTemplateRegistry();
        final String invokerClassName = context.getPkg().getName() + "." + context.getProcessDescr().getClassName() + StringUtils.ucFirst(className) + "Invoker";

        context.getInvokers().put(invokerClassName,
                TemplateRuntime.execute(registry.getNamedTemplate(invokerTemplate), null, new MapVariableResolverFactory(vars), registry)
        );

        context.getInvokerLookups().put(invokerClassName,
                invokerLookup);
        context.getDescrLookups().put(invokerClassName,
View Full Code Here

        generateMethodTemplate(ruleTemplate, context, vars);
        generateInvokerTemplate(invokerTemplate, context, className, vars, invokerLookup, descrLookup);
    }

    public static void generateMethodTemplate(final String ruleTemplate, final RuleBuildContext context, final Map vars) {
        TemplateRegistry registry = getRuleTemplateRegistry(context.getPackageBuilder().getRootClassLoader());

        context.addMethod((String) TemplateRuntime.execute( registry.getNamedTemplate(ruleTemplate),
                                                            null,
                                                            new MapVariableResolverFactory(vars),
                                                            registry) );
    }
View Full Code Here

                                               final RuleBuildContext context,
                                               final String className,
                                               final Map vars,
                                               final Object invokerLookup,
                                               final BaseDescr descrLookup) {
        TemplateRegistry registry = getInvokerTemplateRegistry(context.getPackageBuilder().getRootClassLoader());
        final String invokerClassName = context.getPkg().getName() + "." + context.getRuleDescr().getClassName() + StringUtils.ucFirst( className ) + "Invoker";

        context.getInvokers().put( invokerClassName,
                                   (String) TemplateRuntime.execute( registry.getNamedTemplate( invokerTemplate ),
                                                                     null,
                                                                     new MapVariableResolverFactory( vars ),
                                                                     registry ) );

        context.getInvokerLookups().put( invokerClassName,
View Full Code Here

        String[] allVars = new String[varNames.length + locals.length];

        System.arraycopy(varNames, 0, allVars, 0, varNames.length);
        System.arraycopy(locals, 0, allVars, varNames.length, locals.length);       
       
        this.varModel = new SimpleVariableSpaceModel(allVars);
        this.allVarsLength = allVars.length;
       
        return stmt;
    }
View Full Code Here

TOP

Related Classes of org.mvel2.templates.TemplateError

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.