commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Hughes" <ahhug...@gmail.com>
Subject Re: JXPath and Custom Graphs
Date Tue, 18 Nov 2008 23:48:48 GMT
Thanks Carsten for the reply!
I must admit I am still a little unsure how I can resolve my problem. Most
of what I am dealing with exists in an event driven model. We start with a
root object and we then register listeners on child object creation. Then
its children, and its and so forth...

getRootObject().addChildCreationListener(new ChildCreationListener(){
onCreate(TheObject obj){..do something with the new leaf/node/child..});

Since this is all event driven I can't see how a JXPathBeanInfo would
'easily' be able to traverse 'children' as they aren't stored in the parent
object. What I was thinking is that as object's are created the listeners
take the newly created leaf/child objects and inject it into the context (or
maybe into a dynabean sitting in the context).

What I'm hoping, is that as objects are created and the creation listener is
invoked the creation listener can then inject the new node and create its
path in the JXPathContext (as below).
JXPathContext.createPathAndSetValue(parentPath+"/"+obj.getName(), obj);


There's a few things I don't quite know tho....

   1. Is this a good option?
   2. How can I remove a path and it's value when it disappears? Do I set
   the path to null???
   3. Is this going to get really bad performance?


Your advice is MUCH APPRECIATED, I'm very impressed with JXPath so far!


On Tue, Nov 18, 2008 at 2:20 AM, Carsten Schlipf <carsten.schlipf@yeap.de>wrote:

> If I understand you right, a JXPathBeanInfo implementation for you classes
> will solve this problem for you:
>
>
> http://commons.apache.org/jxpath/apidocs/org/apache/commons/jxpath/JXPathBeanInfo.html
>
> This allows to map property names to arbitrary functions in your pojo as
> well as hiding properties that shall not be exposed.
>
> Regards,
> Carsten
>
>
> Andrew Hughes wrote:
>
>> Hi All,
>> We've got an existing 'graph' of dynamic pojo's. This is effectively a
>> root
>> node, with sibling child node(S), and inturn they have child node(s) (so
>> your typical tree/graph). Ideally we would like to run xpath
>> expression/evalution on our dynamic graph. The objects we're storing do
>> not
>> meet the beans or dyna beans standard. I know there are a few options here
>> and to be quite honest I'm not sure which option is the best.
>>
>> I believe my options are to wrap/store the existing pojo's inside a
>> bean/dynabean standard wrapping pojo's. Alternatively, I can do some work
>> that will provide JXPath with the ability to traverse our current 'graph'
>> and hence evaluate XPath expressions. I would much prefer the second
>> option
>> (if possible).
>>
>> Finally there's the gotcha. As our 'graph' is dynamic and just as nodes
>> are
>> created at runtime they are also destroyed and it would be nice to have
>> JXPath as an observer (not maintainer) of the graph.
>>
>> Any advice/help would be much appreciated :)
>>
>> Thanks,
>> Andrew
>>
>>
>>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message