Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 323854

Summary: Implementing a cache for returned objects from XPath
Product: z_Archived Reporter: Jean Neveux <j.neveux>
Component: JetAssignee: Project Inbox <m2t.jet-inbox>
Status: NEW --- QA Contact:
Severity: enhancement    
Priority: P3 CC: pelder.eclipse
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Jean Neveux CLA 2010-08-27 12:33:54 EDT
Hi,

Some XPath functions always returns the same result, especially if you start from the root element or if you have a generic functions such as "//".

For example I consider the following function "//Interface" beeing static. Meaning it will always return the same result for a given model. Putting a cache on this fonction will only consume process the first time it's executed.

This cache would be place before the XPath function eval inside "XPathExpressionImpl".

In this example the XPath expression is passed to the XPathExpressionImpl constructor :

  public Object evaluate(Object contextObject)
  {

    if (this.expression != null && isStaticExpr(this.expression))
    {
      // Look up cache.
      if (Cache.getXPathCache(expression) == null)
      {
        Cache.getXpathCache().put(
          expression,
          node.evalAsObject(new Context(contextObject, variableResolver, annotationManager, functionResolver)));
      }
      return Cache.getXPathCache(expression);
    }
    else
    {
      return node.evalAsObject(new Context(contextObject, variableResolver, annotationManager, functionResolver));
    }
  }

Best regards,

Jean