commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Benson <gudnabr...@yahoo.com>
Subject Re: [DISCUSS] New Expressions Sandbox Project...
Date Wed, 09 Apr 2008 19:01:14 GMT
Excuse the top post, but there isn't much context to
what I want to say.

Beyond what I've already said wrt Morph, its Language
concept does allow for setting and getting from
expressions, as do those various libraries to which
James plans to interface.  But Morph also contains a
Reflector abstraction, which I have suggested is
suited to be a discrete Commons component.  Morph
implements a Language with a Reflector.  The only
difference between the two is that a Reflector is
intended to set/get a property exactly one level
removed from the source object.  Perhaps that is an
unnecessary distinction and the [expression] idea is
really another way of expressing the need for generic
reflectors that can get/set a -possibly nested-
property given a root object (BeanUtils and Spring
have also implemented this basic requirement as well).
 I don't think this POV invalidates Morph's existing
single-level Reflectors, nor do I see any real
conflict with "complex" Reflectors being dependent on
"simple" Reflectors.

To address the other part of your proposal, James, the
record/playback  mechanism:  wouldn't the resulting
object be a functor a la [functor]?  A get would be a
function, a set a procedure.

-Matt

--- James Carman <james@carmanconsulting.com> wrote:

> 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
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Mime
View raw message