ANY23-321 Add openie toggle functionality to service
authorLewis John McGibbney <lewis.mcgibbney@gmail.com>
Fri, 23 Feb 2018 17:58:54 +0000 (09:58 -0800)
committerLewis John McGibbney <lewis.mcgibbney@gmail.com>
Fri, 23 Feb 2018 17:58:54 +0000 (09:58 -0800)
service/src/main/java/org/apache/any23/servlet/Servlet.java

index 1ab542c..154f41d 100644 (file)
@@ -19,6 +19,8 @@ package org.apache.any23.servlet;
 
 import org.apache.any23.configuration.DefaultConfiguration;
 import org.apache.any23.extractor.ExtractionParameters;
+import org.apache.any23.extractor.ExtractorRegistry;
+import org.apache.any23.extractor.ExtractorRegistryImpl;
 import org.apache.any23.http.HTTPClient;
 import org.apache.any23.plugin.Any23PluginManager;
 import org.apache.any23.servlet.conneg.Any23Negotiator;
@@ -100,7 +102,13 @@ public class Servlet extends HttpServlet {
             File openIEJarPath = new File(webappClasspath.getParentFile().getPath() + "/lib/apache-any23-openie");
             boolean loadedJars = pManager.loadJARDir(openIEJarPath);
             if (loadedJars) {
-                LOG.info("Successful dynamic classloading of apache-any23-openie directory from webapp lib.");
+                ExtractorRegistry r = ExtractorRegistryImpl.getInstance();
+                try {
+                    pManager.getExtractors().forEachRemaining(r::register);
+                } catch (IOException e) {
+                    LOG.error("Error during dynamic classloading of JARs from OpenIE runtime directory {}", openIEJarPath.toString(), e);
+                }
+                LOG.info("Successful dynamic classloading of JARs from OpenIE runtime directory {}", openIEJarPath.toString());
             }
         }
         final ExtractionParameters eps = getExtractionParameters(req);