Examples of ParserContext


Examples of org.mvel2.ParserContext

                                "Action node '" + node.getName() + "' [" + node.getId() + "] has empty action."));
                        } else if( "mvel".equals( droolsAction.getDialect() ) ) {
                            try {
                                ExpressionCompiler compiler = new ExpressionCompiler(actionString);
                                compiler.setVerifying(true);
                                ParserContext parserContext = new ParserContext();
                                //parserContext.setStrictTypeEnforcement(true);
                                compiler.compile(parserContext);
                                List<ErrorDetail> mvelErrors = parserContext.getErrorList();
                                if (mvelErrors != null) {
                                    for (Iterator<ErrorDetail> iterator = mvelErrors.iterator(); iterator.hasNext(); ) {
                                        ErrorDetail error = iterator.next();
                                        errors.add(new ProcessValidationErrorImpl(process,
                                            "Action node '" + node.getName() + "' [" + node.getId() + "] has invalid action: " + error.getMessage() + "."));
View Full Code Here

Examples of org.mvel2.ParserContext

    Expression,
    Receiver {
    private Serializable expr;

    public MvelExpression(String text) {
        final ParserContext parserContext = new ParserContext();
        parserContext.setStrictTypeEnforcement( false );

        ExpressionCompiler compiler = new ExpressionCompiler( text );
        this.expr = compiler.compile( parserContext );
    }
View Full Code Here

Examples of org.mvel2.ParserContext

    public void lispFormHandler(LispForm lispForm) {
        StringBuilderAppendable appendable = new StringBuilderAppendable();
        FunctionHandlers.dump( lispForm,
                               appendable );

        ParserContext context = new ParserContext();
       

        String namespace = this.session.getAgenda().getFocusName();

        Package pkg = this.ruleBase.getPackage( namespace );
        if ( pkg == null ) {
            this.packageBuilder.addPackage( createPackageDescr( namespace ) );
            pkg = this.ruleBase.getPackage( namespace );
           
        }

        if ( pkg != null ) {
            // only time this will be null is if we have yet to do any packagedescr work

            try {
                for ( Iterator it = pkg.getImports().entrySet().iterator(); it.hasNext(); ) {
                    Entry entry = (Entry) it.next();
                    String importName = ((ImportDeclaration) entry.getValue()).getTarget();
                    if ( importName.endsWith( "*" )) {
                        context.addPackageImport( importName.substring( 0,
                                                                        importName.length() - 2 ) );
                    } else {
                     
                        Class cls = ((InternalRuleBase)ruleBase).getRootClassLoader().loadClass( importName );
                        context.addImport( cls.getSimpleName(),
                                           (Class) cls );
                    }
                }

            } catch ( Exception e ) {
View Full Code Here

Examples of org.mvel2.ParserContext

        String name = context.getRuleName();
        RuleInfo currentRule = getCurrentRule( drlInfo,
                                               name );
        String qName = drlInfo.getPackageName() + "." + name;
        MVELDialect dialect = (MVELDialect) drlInfo.getDialectRegistry().getDialect("mvel");
        ParserContext initialContext = createInitialContext( params,
                                                             qName,
                                                             dialect );
        MvelContext mCon = new MvelContext();
        mCon.setContext( initialContext );
View Full Code Here

Examples of org.mvel2.ParserContext

        //Lookup ParserConfiguration to retrieve imports and package imports
        PackageRegistry packageRegistry = dialect.getPackageRegistry();
        MVELDialectRuntimeData data = (MVELDialectRuntimeData) packageRegistry.getDialectRuntimeRegistry().getDialectData( dialect.getId() );
        ParserConfiguration pconf = data.getParserConfiguration();

        final ParserContext context = new ParserContext( pconf.getImports(),
                                                         null,
                                                         qualifiedName );

        if ( pconf.getPackageImports() != null ) {
            for (String packageImport : pconf.getPackageImports()) {
                context.addPackageImport( packageImport );
            }
        }
        context.setStrictTypeEnforcement( false );

        context.setInterceptors( dialect.getInterceptors() );
        context.setInputs( params );
        context.addInput("drools", KnowledgeHelper.class);
        context.addInput("kcontext", RuleContext.class);
        context.setCompiled( true );
        return context;
    }
View Full Code Here

Examples of org.mvel2.ParserContext

            vars.putAll( this.context );
            vars.put( "tuple",
                      ((LeftTuple)tuple).toFactHandles() );

            // compile MVEL expression
            ParserContext mvelctx = new ParserContext();
            Serializable compiled = MVEL.compileExpression( this.expr,
                                                            mvelctx );
            // execute the expression
            Boolean result = (Boolean) MVEL.executeExpression( compiled,
                                                               vars );
View Full Code Here

Examples of org.mvel2.ParserContext

                Class<?> variableType = getVariableType(variableName);
                if (variableType != null) {
                    return new VariableExpression(variableName, analyzeExpressionNode(accessorNode, node, variableType), variableType);
                } else {
                    if (node.getLiteralValue() instanceof ParserContext) {
                        ParserContext pCtx = (ParserContext)node.getLiteralValue();
                        // it's not a variable but a method invocation on this
                        Class<?> thisClass = pCtx.getInputs().get("this");
                        try {
                            return new EvaluatedExpression(new MethodInvocation(thisClass.getMethod(variableName)));
                        } catch (NoSuchMethodException e) {
                            if (node.getEgressType() == Class.class) {
                                // there's no method on this with the given name, check if it is a class literal
                                Class<?> classLiteral = pCtx.getParserConfiguration().getImport(variableName);
                                if (classLiteral != null) {
                                    return new FixedExpression(Class.class, classLiteral);
                                }
                            }
                            throw new RuntimeException(e);
View Full Code Here

Examples of org.mvel2.ParserContext

        MVELDialectRuntimeData data = (MVELDialectRuntimeData) context.getPkg().getDialectRuntimeRegistry().getDialectData( "mvel" );
        ParserConfiguration conf = data.getParserConfiguration();

        conf.setClassLoader( context.getPackageBuilder().getRootClassLoader() );

        final ParserContext pctx = new ParserContext( conf );
        pctx.setStrictTypeEnforcement( false );
        pctx.setStrongTyping( false );
        pctx.addInput( "this",
                       thisClass );
        pctx.addInput( "empty",
                       boolean.class ); // overrides the mvel empty label
        MVEL.COMPILER_OPT_ALLOW_NAKED_METH_CALL = true;
        MVEL.COMPILER_OPT_ALLOW_OVERRIDE_ALL_PROPHANDLING = true;
        MVEL.COMPILER_OPT_ALLOW_RESOLVE_INNERCLASSES_WITH_DOTNOTATION = true;
        MVEL.COMPILER_OPT_SUPPORT_JAVA_STYLE_CLASS_LITERALS = true;
        MVEL.analysisCompile( expr,
                              pctx );

        if ( !pctx.getInputs().isEmpty() ) {
            for ( String v : pctx.getInputs().keySet() ) {
                // in the following if, we need to check that the expr actually contains a reference
                // to an "empty" property, or the if will evaluate to true even if it doesn't
                if ( "this".equals( v ) || (PropertyTools.getFieldOrAccessor( thisClass,
                                                                               v ) != null && expr.matches( "(^|.*\\W)empty($|\\W.*)" )) ) {
                    descrBranch.getFieldAccessors().add( v );
View Full Code Here

Examples of org.springframework.beans.factory.xml.ParserContext

  public static ParserContext create(BeanDefinitionParserDelegate delegate) {
    DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
    XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
    XmlReaderContext readerContext = new XmlReaderContext(null, null, null, null, reader,
        null);
    return new ParserContext(readerContext, delegate);
  }
View Full Code Here

Examples of org.springframework.binding.expression.ParserContext

  }

  private Action parseRenderAction(RenderModel render) {
    String[] fragmentExpressionStrings = StringUtils.commaDelimitedListToStringArray(render.getFragments());
    fragmentExpressionStrings = StringUtils.trimArrayElements(fragmentExpressionStrings);
    ParserContext context = new FluentParserContext().template().evaluate(RequestContext.class).expectResult(
        String.class);
    Expression[] fragments = new Expression[fragmentExpressionStrings.length];
    for (int i = 0; i < fragmentExpressionStrings.length; i++) {
      String fragment = fragmentExpressionStrings[i];
      fragments[i] = getLocalContext().getExpressionParser().parseExpression(fragment, context);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.