cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-5990] Support for a custom parser class property, patch from Romain Castan applied
Date Thu, 11 Sep 2014 15:53:05 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 7268b3c5d -> a8c28e3f6


[CXF-5990] Support for a custom parser class property, patch from Romain Castan applied


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/a8c28e3f
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/a8c28e3f
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/a8c28e3f

Branch: refs/heads/master
Commit: a8c28e3f65524f93f58f38a0112b19d9bb8336b0
Parents: 7268b3c
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Thu Sep 11 16:52:47 2014 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Thu Sep 11 16:52:47 2014 +0100

----------------------------------------------------------------------
 .../cxf/jaxrs/ext/search/SearchContextImpl.java     | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/a8c28e3f/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
----------------------------------------------------------------------
diff --git a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
index 0aaed79..0380b00 100644
--- a/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
+++ b/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.jaxrs.ext.search;
 
+import java.lang.reflect.Constructor;
 import java.util.ArrayList;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -27,6 +28,7 @@ import java.util.logging.Logger;
 
 import javax.ws.rs.core.MultivaluedMap;
 
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.PropertyUtils;
 import org.apache.cxf.helpers.CastUtils;
@@ -43,6 +45,7 @@ public class SearchContextImpl implements SearchContext {
     public static final String SEARCH_QUERY = "_search";
     public static final String SHORT_SEARCH_QUERY = "_s";
     public static final String CUSTOM_SEARCH_PARSER_PROPERTY = "search.parser";
+    public static final String CUSTOM_SEARCH_PARSER_CLASS_PROPERTY = "search.parser.class";
     public static final String CUSTOM_SEARCH_QUERY_PARAM_NAME = "search.query.parameter.name";
     private static final String USE_PLAIN_QUERY_PARAMETERS = "search.use.plain.queries";
     private static final String USE_ALL_QUERY_COMPONENT = "search.use.all.query.component";
@@ -210,6 +213,19 @@ public class SearchContextImpl implements SearchContext {
             beanProps = beanProperties;
         }
         
+        String parserClassProp = (String) message.getContextualProperty(CUSTOM_SEARCH_PARSER_CLASS_PROPERTY);
+        if (parserClassProp != null) {
+            try {
+                final Class<?> parserClass = ClassLoaderUtils.loadClass(parserClassProp,
SearchContextImpl.class);
+                final Constructor<?> constructor = parserClass.getConstructor(Class.class,
Map.class, Map.class);
+                @SuppressWarnings("unchecked")
+                SearchConditionParser<T> customParser = 
+                    (SearchConditionParser<T>)constructor.newInstance(cls, props, beanProps);
+                return customParser;
+            } catch (Exception ex) {
+                throw new SearchParseException(ex);
+            }
+        }
         return new FiqlParser<T>(cls, props, beanProps); 
     }
     


Mime
View raw message