Access to MVEL interpreter

53 views
Skip to first unread message

Jesús Gabriel y Galán

unread,
Apr 7, 2015, 6:41:08 AM4/7/15
to squirrel-st...@googlegroups.com
Hi,

I am adding some mvel conditions to my transitions, and to simplify
the definition of the conditions I would like to inject some static
methods to the mvel compiler.

Is there a way to get access to the compiler used in the
MvelConditionImpl from the outside?

In fact, I think that would not be enough, I would need to be able to
either pass a ParserContext, or to handle the call to compile myself.
Maybe too much hassle for what it is.

Thoughts?

Thanks,

Jesus.

He Henry

unread,
Apr 9, 2015, 11:50:17 PM4/9/15
to squirrel-st...@googlegroups.com
Hi,

You can register your own MvelCondition implementation class instead of default one(MvelConditionImpl), e.g. SquirrelProvider.getInstance().register(MvelConditionImpl.class, MyMvelConditionImpl.class).
class MyMvelConditionImpl<C> extends Conditon<C> {
...
}

If you want initialize the MyMvelConditionImpl after it created, you can also register a post processor for your MyMvelConditionImpl, e.g. SquirrelPostProcessorProvider.getInstance().register(MvelConditionImpl.class, MyMvelConditionImplPostProcessor.class)
class MyMvelConditionImplPostProcessor implement SquirrelPostProcessor<MyMvelConditionImpl> {
    void postProcess(MyMvelConditionImpl c) {
          c.setYouResource(...);
    }
}

I hope this can solve your problem.

Thanks,
Henry


在 2015年4月7日星期二 UTC+8下午6:41:08,Jesús Gabriel y Galán写道:
Reply all
Reply to author
Forward
0 new messages