Package org.mvel2.integration.impl

Examples of org.mvel2.integration.impl.ClassImportResolverFactory


    return getDirectValue(staticContext, factory);
  }

  public Object getDirectValue(Object staticContext, VariableResolverFactory factory) {
    return execute(false, this, staticContext,
        importInjectionRequired ? new ClassImportResolverFactory(parserConfiguration, factory, true) : new StackResetResolverFactory(factory));
  }
View Full Code Here


//    }


  public void testCheeseConstructor() {
    MapVariableResolverFactory mvf = new MapVariableResolverFactory(createTestMap());
    ClassImportResolverFactory classes = new ClassImportResolverFactory(null, null, false);
    classes.addClass(Cheese.class);

    ResolverTools.appendFactory(mvf,
        classes);
    assertTrue(executeExpression(compileExpression("cheese = new Cheese(\"cheddar\", 15);",
        classes.getImportedClasses()),
        mvf) instanceof Cheese);
  }
View Full Code Here

      finally {
        OptimizerFactory.clearThreadAccessorOptimizer();
      }
    }
    if (importInjectionRequired) {
      return execute(false, this, staticContext, new ClassImportResolverFactory(parserContext.getParserConfiguration(), factory, true));
    }
    else {
      return execute(false, this, staticContext, factory);
    }
  }
View Full Code Here

    }
  }

  public Object getDirectValue(Object staticContext, VariableResolverFactory factory) {
    if (importInjectionRequired) {
      return execute(false, this, staticContext, new ClassImportResolverFactory(parserContext.getParserConfiguration(), factory, true));
    }
    else {
      return execute(false, this, staticContext, factory);
    }
  }
View Full Code Here

    if (factory == null) {
      throw new OptimizationFailure("unable to import classes.  no variable resolver factory available.");
    }
    else {
      return insertFactory(factory, new ClassImportResolverFactory());
    }
  }
View Full Code Here

//    }


  public void testCheeseConstructor() {
    MapVariableResolverFactory mvf = new MapVariableResolverFactory(createTestMap());
    ClassImportResolverFactory classes = new ClassImportResolverFactory();
    classes.addClass(Cheese.class);

    ResolverTools.appendFactory(mvf,
            classes);
    assertTrue(executeExpression(compileExpression("cheese = new Cheese(\"cheddar\", 15);",
            classes.getImportedClasses()),
            mvf) instanceof Cheese);
  }
View Full Code Here

  }

  public void testSataticClassImportViaFactoryAndWithModification() {
    OptimizerFactory.setDefaultOptimizer("ASM");
    MapVariableResolverFactory mvf = new MapVariableResolverFactory(createTestMap());
    ClassImportResolverFactory classes = new ClassImportResolverFactory();
    classes.addClass(Person.class);

    ResolverTools.appendFactory(mvf,
        classes);

    assertEquals(21,
        executeExpression(
            compileExpression("p = new Person('tom'); p.age = 20; " +
                "with( p ) { age = p.age + 1 }; return p.age;",
                classes.getImportedClasses()),
            mvf));
  }
View Full Code Here

                                 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

    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 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,
                                             invokerLookup );
        context.getDescrLookups().put( invokerClassName,
View Full Code Here

TOP

Related Classes of org.mvel2.integration.impl.ClassImportResolverFactory

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.