Re: [jexl] custom expressions / registering functions

2010-05-26 Thread henrib

Hi,
JEXL should be appropriate feature-wise; adding EL capabilities to a
framework is one of its intents.

JEXL 2.0 allows to invoke any method on an object accessible through the
evaluation context.
It also allows to register functions in namespaces achieved by mapping the
namespace name to an instance or a class - if all methods are static.

code
public static MyMath {
public double cos(double x) {
return Math.cos(x);
}
}
MapString, Object funcs = new HashMapString, Object();
funcs.put(math, new MyMath());
JexlEngine jexl = new JexlEngine();
jexl.setFunctions(funcs);

JexlContext jc = new MapContext();
jc.set(pi, Math.PI);

e = JEXL.createExpression(math:cos(pi));
o = e.evaluate(jc);
assertEquals(Double.valueOf(-1),o);
/code

Useful links on the topic:
http://commons.apache.org/jexl/index.html
http://commons.apache.org/jexl/reference/syntax.html  (method calls,
functions)
http://commons.apache.org/jexl/apidocs/index.html

Follow-up if things aren't clear enough;
Regards
Henrib

-- 
View this message in context: 
http://apache-commons.680414.n4.nabble.com/jexl-custom-expressions-registering-functions-tp2228958p2231466.html
Sent from the Commons - User mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [jexl] custom expressions / registering functions

2010-05-25 Thread Paul Libbrecht


Le 25-mai-10 à 06:40, Adrian Herscu a écrit :

On 24/05/2010 22:52, Paul Libbrecht wrote:

Jexl containers allow you to add objects.


Can you, please, send a link for more info?


At least jelly does.


Jelly is at... commons-jelly:
http://commons.apache.org/jelly/
some other projects use jexl, especially newer version of it,  
including scxml.


paul



smime.p7s
Description: S/MIME cryptographic signature


Re: [jexl] custom expressions / registering functions

2010-05-25 Thread Jörg Schaible
Adrian Herscu wrote:

 Hi all,
 
 I am looking for an expression language to using in a testing framework
 that I am designing.
 
 The requirement is that the users of the framework are allowed to define
 their own functions. I could not find it possible to add a function to a
 JEXL context. Is there any other mechanism?

Why don't you simply use the JavaScript engine (JSR 223)? It comes out of 
the box with Java 6 (including Rhino) and for earlier JDKs you can use 
Apache BSF (http://jakarta.apache.org/bsf/) that implements also JSR 223 and 
provides therefore a smooth upgrade path. With the embedded JavaScript of 
Rhino you can access easily also all Java stuff.

- Jörg


-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



[jexl] custom expressions / registering functions

2010-05-24 Thread Adrian Herscu

Hi all,

I am looking for an expression language to using in a testing framework 
that I am designing.


The requirement is that the users of the framework are allowed to define 
their own functions. I could not find it possible to add a function to a 
JEXL context. Is there any other mechanism?


Please help,
Adrian.


-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [jexl] custom expressions / registering functions

2010-05-24 Thread Paul Libbrecht

Jexl containers allow you to add objects.
At least jelly does.

And invoking methods on these functions sounds like an easy thing.

paul


Le 23-mai-10 à 15:39, Adrian Herscu a écrit :


Hi all,

I am looking for an expression language to using in a testing  
framework that I am designing.


The requirement is that the users of the framework are allowed to  
define their own functions. I could not find it possible to add a  
function to a JEXL context. Is there any other mechanism?


Please help,
Adrian.


-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org





smime.p7s
Description: S/MIME cryptographic signature


Re: [jexl] custom expressions / registering functions

2010-05-24 Thread Adrian Crum
You could also take a look at JUEL.

-Adrian

--- On Mon, 5/24/10, Paul Libbrecht p...@activemath.org wrote:

 From: Paul Libbrecht p...@activemath.org
 Subject: Re: [jexl] custom expressions / registering functions
 To: Commons Users List user@commons.apache.org
 Date: Monday, May 24, 2010, 12:52 PM
 Jexl containers allow you to add
 objects.
 At least jelly does.
 
 And invoking methods on these functions sounds like an easy
 thing.
 
 paul
 
 
 Le 23-mai-10 à 15:39, Adrian Herscu a écrit :
 
  Hi all,
  
  I am looking for an expression language to using in a
 testing framework that I am designing.
  
  The requirement is that the users of the framework are
 allowed to define their own functions. I could not find it
 possible to add a function to a JEXL context. Is there any
 other mechanism?
  
  Please help,
  Adrian.
  
  
 
 -
  To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
  For additional commands, e-mail: user-h...@commons.apache.org
  
 
 




-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org



Re: [jexl] custom expressions / registering functions

2010-05-24 Thread Adrian Herscu



On 24/05/2010 22:52, Paul Libbrecht wrote:

Jexl containers allow you to add objects.


Can you, please, send a link for more info?


At least jelly does.

And invoking methods on these functions sounds like an easy thing.

paul


Le 23-mai-10 à 15:39, Adrian Herscu a écrit :


Hi all,

I am looking for an expression language to using in a testing
framework that I am designing.

The requirement is that the users of the framework are allowed to
define their own functions. I could not find it possible to add a
function to a JEXL context. Is there any other mechanism?

Please help,
Adrian.


-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org






-
To unsubscribe, e-mail: user-unsubscr...@commons.apache.org
For additional commands, e-mail: user-h...@commons.apache.org