Return-Path: Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 92520 invoked from network); 20 Jun 2003 15:37:01 -0000 Received: from smtp.orcom.com (HELO tamarisk.orcom.com) (208.5.48.3) by daedalus.apache.org with SMTP; 20 Jun 2003 15:37:01 -0000 Received: from Unknown [172.17.31.30] by tamarisk.orcom.com - SurfControl E-mail Filter (4.5); Friday, 20 June 2003, 08:26:43 Received: by fig.orcom.com with Internet Mail Service (5.5.2656.59) id ; Fri, 20 Jun 2003 09:36:04 -0600 Message-ID: From: Dmitry Sklyut To: "Jakarta Commons User List (E-mail)" Date: Fri, 20 Jun 2003 09:37:06 -0600 Subject: [JXPath] Serializing JXpath object - Long MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="--=_NextPart_ST_08_26_46_Friday_June_20_2003_12883" X-Mailer: Internet Mail Service (5.5.2656.59) X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N ----=_NextPart_ST_08_26_46_Friday_June_20_2003_12883 Content-Type: text/plain; charset="iso-8859-1" Hi All, I am looking for the best approach in using JXpath in the following situation. Here is the explanation of the requirements : I must have all of the data encapsulated in the java beans. Those beans must expose the following 3 APIs that accept Xpath expression to set, get and find data: 1) set(path, object):void -> maps to createPathAndSetValue of JXpathContext 2) get(path):Object -> maps to getValue() 3) find(path):Iterator -> maps to iterate() I am also must decouple the actual Xpath implementation from the core system, so it can be switched on the fly. These APIs are used by the custom tags on the JSPs to get the data from the beans by building XPath expressions. Here is an example:
the above would render as:
User actions can span multiple page invocations (request) so HttpSession is used to save the conversational state. Custom Tags get the beans from the HttpSession and render the page with the data from the beans, and ControllerServlet reads the Xpath from the HttpServletRequest parameters and constructs/populates beans upon submission of the request. To achieve all of these requirements I must access JXpathContext through a interface exposed by my data beans (get/set/find). These beans also must be Serializable to be added to the HttpSession. So by wrapping JXpathContext in the my bean I can have the pathing API working. The problem is that none of the JXpath classes (except for the Pointers) are Serializable. This presents a problem when Serializing the bean. I see three solutions: 1) Make wrapped JXpathContext transient and provide lazy initialization of the JXpathContext. 2) Modify the code to add "implements Serializable" to most of the JXpath classes 3) Create new JXpathContext object with each get/set/find API invocation. So far only option 1 (one) looks appealing. Option 2 - I don't want to change the JXpath code (lazy and not sure of the impact, plus I want to be able to grab the jar of the web when in a jam without too much copy/paste/compile). Option 3 - Just not something I am willing to do. Are there any other approaches that anyone can suggest? Maybe there is a way to use Pointers or have only CompiledPaths? But in any case that I seen so far - there is always a need for JXpathContext object. Thanks for reading this far :) Dmitry ----=_NextPart_ST_08_26_46_Friday_June_20_2003_12883--