cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1419014 - in /cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search: SearchContext.java SearchContextImpl.java
Date Sun, 09 Dec 2012 16:21:20 GMT
Author: sergeyb
Date: Sun Dec  9 16:21:19 2012
New Revision: 1419014

URL: http://svn.apache.org/viewvc?rev=1419014&view=rev
Log:
Making it easier to pass parser/contextual properties by adding a couple of more methods to
SearchContext

Modified:
    cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContext.java
    cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java

Modified: cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContext.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContext.java?rev=1419014&r1=1419013&r2=1419014&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContext.java
(original)
+++ cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContext.java
Sun Dec  9 16:21:19 2012
@@ -48,6 +48,21 @@ public interface SearchContext {
      */
     <T> SearchCondition<T> getCondition(Class<T> cls, Map<String, String>
beanProperties);
     
+    /**
+     * Returns the typed search condition representing 
+     * the search expression which is extracted from 
+     * the request URI
+     * 
+     * @param cls the type of the bean(s) the new search condition will 
+     *        attempt to match
+     * @param beanProperties mapping between search and bean properties
+     * @param parserProperties parser properties       
+     * @return the search condition
+     */
+    <T> SearchCondition<T> getCondition(Class<T> cls, 
+                                        Map<String, String> beanProperties, 
+                                        Map<String, String> parserProperties);
+    
     
     /**
      * Returns the typed search condition representing 
@@ -72,6 +87,21 @@ public interface SearchContext {
      */
     <T> SearchCondition<T> getCondition(String expression, Class<T> cls,
Map<String, String> beanProperties);
     
+    /**
+     * Returns the typed search condition representing 
+     * the provided search expression
+     * 
+     * @param expression the search expression
+     * @param cls the type of the bean(s) the new search condition will 
+     *        attempt to match
+     * @param beanProperties mapping between search and bean properties
+     * @param parserProperties parser properties       
+     * @return the search condition
+     */
+    <T> SearchCondition<T> getCondition(String expression, Class<T> cls,

+                                        Map<String, String> beanProperties,
+                                        Map<String, String> parserProperties);
+    
     
     /**
      * Returns the search expression

Modified: cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java?rev=1419014&r1=1419013&r2=1419014&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
(original)
+++ cxf/trunk/rt/rs/extensions/search/src/main/java/org/apache/cxf/jaxrs/ext/search/SearchContextImpl.java
Sun Dec  9 16:21:19 2012
@@ -51,20 +51,33 @@ public class SearchContextImpl implement
         return getCondition(null, cls, beanProperties);
     }
     
+    public <T> SearchCondition<T> getCondition(Class<T> cls, 
+                                               Map<String, String> beanProperties,
+                                               Map<String, String> parserProperties)
{
+        return getCondition(null, cls, beanProperties, parserProperties);
+    }
+    
     public <T> SearchCondition<T> getCondition(String expression, Class<T>
cls) {
         return getCondition(expression, cls, null);
     }
     
     public <T> SearchCondition<T> getCondition(String expression, 
                                                Class<T> cls, 
-                                               Map<String, String> beanProperties)
{    
+                                               Map<String, String> beanProperties)
{
+        return getCondition(expression, cls, beanProperties, null);
+    }
+    
+    public <T> SearchCondition<T> getCondition(String expression, 
+                                               Class<T> cls, 
+                                               Map<String, String> beanProperties,
+                                               Map<String, String> parserProperties)
{    
         if (InjectionUtils.isPrimitive(cls)) {
             String errorMessage = "Primitive condition types are not supported"; 
             LOG.warning(errorMessage);
             throw new IllegalArgumentException(errorMessage);
         }
         
-        SearchConditionParser<T> parser = getParser(cls, beanProperties);
+        SearchConditionParser<T> parser = getParser(cls, beanProperties, parserProperties);
         
         String theExpression = expression == null 
             ? getSearchExpression() : expression;
@@ -97,17 +110,24 @@ public class SearchContextImpl implement
         }
     }
     
-    private <T> SearchConditionParser<T> getParser(Class<T> cls, Map<String,
String> beanProperties) {
+    private <T> SearchConditionParser<T> getParser(Class<T> cls, 
+                                                   Map<String, String> beanProperties,
+                                                   Map<String, String> parserProperties)
{
         // we can use this method as a parser factory, ex
         // we can get parsers capable of parsing XQuery and other languages
         // depending on the properties set by a user
-        Map<String, String> props = new LinkedHashMap<String, String>(4);
-        props.put(SearchUtils.DATE_FORMAT_PROPERTY, 
-                  (String)message.getContextualProperty(SearchUtils.DATE_FORMAT_PROPERTY));
-        props.put(SearchUtils.TIMEZONE_SUPPORT_PROPERTY, 
-                  (String)message.getContextualProperty(SearchUtils.TIMEZONE_SUPPORT_PROPERTY));
-        props.put(SearchUtils.LAX_PROPERTY_MATCH, 
-                  (String)message.getContextualProperty(SearchUtils.LAX_PROPERTY_MATCH));
+        Map<String, String> props = null;
+        if (parserProperties == null) {
+            props = new LinkedHashMap<String, String>(4);
+            props.put(SearchUtils.DATE_FORMAT_PROPERTY, 
+                      (String)message.getContextualProperty(SearchUtils.DATE_FORMAT_PROPERTY));
+            props.put(SearchUtils.TIMEZONE_SUPPORT_PROPERTY, 
+                      (String)message.getContextualProperty(SearchUtils.TIMEZONE_SUPPORT_PROPERTY));
+            props.put(SearchUtils.LAX_PROPERTY_MATCH, 
+                      (String)message.getContextualProperty(SearchUtils.LAX_PROPERTY_MATCH));
+        } else {
+            props = parserProperties;
+        }
         
         Map<String, String> beanProps = null;
             



Mime
View raw message