commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Carman" <ja...@carmanconsulting.com>
Subject [DISCUSS] New Expressions Sandbox Project...
Date Wed, 09 Apr 2008 14:07:04 GMT
I wanted to start up a discussion about maybe starting a new sandbox
project for expression abstraction.  It could be named
commons-expresso.  I realize that there's a J2EE framework out there
called "Expresso", but its site hasn't been updated since 2005, so I
don't know how active it is or if this would even be a conflict
anyway.  I don't really care what it's called.  I just care about the
content.

For those who have not been reading the other threads, I would like to
create a project which allows us to abstract the idea of an
"expression" in Java.  Here's the main interface:

public interface Expression
{
  public Object getValue(Object root);
  public void setValue(Object root, Object value);
}

This could be generified to perhaps:

public interface Expression<R,V>
{
  public V getValue(R root);
  public void setValue(R root, V value);
}

Anyway, the "guts" of the project would be the implementations of this
interface.  I have plans to implement it using the following
technologies for now (please add suggestions if you have them):

Javassist
MVEL
OGNL
JSTL-EL
JXPath

That's just a preliminary list, but you get the idea of the sort of
thing I'm looking for.  Matt Benson has suggested that this sort of
thing might be best suited to go into his "Morph" project currently
located at Sourceforge.  Currently, it doesn't have anything like
this.  The project would also contain expression "builder"
implementations which would allow you to use Java to build up the
expression:

public interface ExpressionBuilder<R>
{
  public R recorder();
  public <V> Expresion<R,V> buildExpression(V value);
}

Example usage:

ExpressionBuilder builder = new JavassistExpressionBuilder<Person>();
Expression<Person,String> expr =
builder.buildExpression(builder.recorder().getAddress().getCity());
Person p = ...;
String city = expr.getValue(p);

The cool thing about this is that you can switch the expression
implementation without changing how you build up the expression!
Thoughts anyone?

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message