jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1422655 - /jmeter/trunk/src/components/org/apache/jmeter/extractor/JSoupExtractor.java
Date Sun, 16 Dec 2012 18:22:12 GMT
Author: pmouawad
Date: Sun Dec 16 18:22:12 2012
New Revision: 1422655

URL: http://svn.apache.org/viewvc?rev=1422655&view=rev
Log:
Bug 54259 - Introduce a CSS or jquery-like based Extractor
Introduce parse caching to improve performances
Bugzilla Id: 54259

Modified:
    jmeter/trunk/src/components/org/apache/jmeter/extractor/JSoupExtractor.java   (contents,
props changed)

Modified: jmeter/trunk/src/components/org/apache/jmeter/extractor/JSoupExtractor.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/components/org/apache/jmeter/extractor/JSoupExtractor.java?rev=1422655&r1=1422654&r2=1422655&view=diff
==============================================================================
--- jmeter/trunk/src/components/org/apache/jmeter/extractor/JSoupExtractor.java (original)
+++ jmeter/trunk/src/components/org/apache/jmeter/extractor/JSoupExtractor.java Sun Dec 16
18:22:12 2012
@@ -20,6 +20,7 @@ package org.apache.jmeter.extractor;
 
 import java.util.List;
 
+import org.apache.jmeter.threads.JMeterContextService;
 import org.apache.jorphan.util.JOrphanUtils;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
@@ -38,6 +39,7 @@ public class JSoupExtractor implements E
      */
     private static final long serialVersionUID = -6308012192067714191L;
 
+    private static final String CACHE_KEY_PREFIX = JSoupExtractor.class.getName()+"_PARSED_BODY";
 
     /**
      * 
@@ -47,13 +49,23 @@ public class JSoupExtractor implements E
     }
 
     /**
-     * @see org.apache.jmeter.extractor.Extractor#extract(java.lang.String, java.lang.String,
int, java.lang.String, java.util.List, int, boolean)
+     * @see org.apache.jmeter.extractor.Extractor#extract(java.lang.String, java.lang.String,
int, java.lang.String, java.util.List, int, String)
      */
     @Override
     public int extract(String expression, String attribute, int matchNumber,
             String inputString, List<String> result, int found,
-            boolean cacheIfPossible) {
-        Document document = Jsoup.parse(inputString);
+            String cacheKey) {
+        Document document = null;
+        if (cacheKey != null) {
+            document = (Document) 
+                    JMeterContextService.getContext().getSamplerContext().get(CACHE_KEY_PREFIX+cacheKey);
+            if(document==null) {
+                document = Jsoup.parse(inputString);
+                JMeterContextService.getContext().getSamplerContext().put(CACHE_KEY_PREFIX+cacheKey,
document);
+            }
+        } else {
+            document = Jsoup.parse(inputString);
+        }
         Elements elements = document.select(expression);
         int size = elements.size();
         for (int i = 0; i < size; i++) {

Propchange: jmeter/trunk/src/components/org/apache/jmeter/extractor/JSoupExtractor.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message