You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by gk...@apache.org on 2014/03/28 10:38:21 UTC
svn commit: r1582652 - in /turbine/fulcrum/trunk/json:
api/src/java/org/apache/fulcrum/json/ dist/src/assembly/
jackson/src/java/org/apache/fulcrum/json/jackson/
jackson2/src/java/org/apache/fulcrum/json/jackson/
Author: gk
Date: Fri Mar 28 09:38:20 2014
New Revision: 1582652
URL: http://svn.apache.org/r1582652
Log:
Updating Javadoc; adding cache filter to Jackson component; exclude fix in src.xml.
Modified:
turbine/fulcrum/trunk/json/api/src/java/org/apache/fulcrum/json/JsonService.java
turbine/fulcrum/trunk/json/dist/src/assembly/src.xml
turbine/fulcrum/trunk/json/jackson/src/java/org/apache/fulcrum/json/jackson/JacksonMapperService.java
turbine/fulcrum/trunk/json/jackson2/src/java/org/apache/fulcrum/json/jackson/Jackson2MapperService.java
Modified: turbine/fulcrum/trunk/json/api/src/java/org/apache/fulcrum/json/JsonService.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/json/api/src/java/org/apache/fulcrum/json/JsonService.java?rev=1582652&r1=1582651&r2=1582652&view=diff
==============================================================================
--- turbine/fulcrum/trunk/json/api/src/java/org/apache/fulcrum/json/JsonService.java (original)
+++ turbine/fulcrum/trunk/json/api/src/java/org/apache/fulcrum/json/JsonService.java Fri Mar 28 09:38:20 2014
@@ -44,7 +44,7 @@ public interface JsonService {
* Serializes a Java object
*
* @param src
- * The java object to be serialized.
+ * the java object to be serialized, not null.
*
* @return JSON string
*
@@ -55,8 +55,8 @@ public interface JsonService {
/**
* @param src
- * The java object to be serialized.
- * @param refreshCache
+ * the java object to be serialized, not null.
+ * @param refreshCache a boolean value, not null.
* If <code>true</code>, try to refresh cache after serialization
*
*/
@@ -66,9 +66,9 @@ public interface JsonService {
* Serializes a Java object
*
* @param src
- * The java object to be serialized
+ * The Java object to be serialized
* @param type
- * Java Type, which should be used for the provided object .
+ * the Java Type, which should be used for the provided object .
*
* @return JSON string
*
@@ -92,11 +92,11 @@ public interface JsonService {
* Deserializing a JSON string
*
* @param src
- * Tthe JSON string to be deserialized
+ * the JSON string to be deserialized
* @param type
- * The Java Type to be used as a class
+ * the Java Type to be used as a class
*
- * @return an object
+ * @return the Java Object
*
* @throws Exception
* if JSON deserialization fails
@@ -114,7 +114,7 @@ public interface JsonService {
* Cft. implementation tests for more details (GSON).
* @param elementType
* The element type. This is need in any case to assure the generic checking.
- * @return
+ * @return the generated Java Collection.
* @throws Exception
*/
<T> Collection<T> deSerCollection(String json, Object collectionType, Class<T> elementType)
@@ -132,15 +132,15 @@ public interface JsonService {
* Serialize only object properties where filter attributes are provided
*
* @param src
- * The Java object to serialize
+ * the Java object to serialize
* @param filterClass
- * The class to which the filtering should be applied
+ * the class to which the filtering should be applied
*
* @param cleanFilter
- * clean filter (clean cache for this filterClass) if <code>true</code>, after serialization.
+ * the Boolean value, not null If it is <code>true</code>, cleans cache and the custom filter after serialization.
*
* @param filterAttr
- * The class bean attributes which should be serialized
+ * the class bean attributes which should be serialized
*
* @return JSON string
*
@@ -154,16 +154,16 @@ public interface JsonService {
* Serialize all object properties excluding provided filters attributes
*
* @param src
- * The Java object to serialize
+ * the Java object to serialize
* @param filterClass
- * The class to which the filtering should be applied. If its the
+ * the class to which the filtering should be applied. If its the
* same class, just the filterAttributes get applied. If not the
* class is filtered out, if found as a property type.
* @param cleanFilter
- * clean filter (clean cache for this filterClass) after serialization.
+ * clean filter (clean cache and custom filter for this filterClass) after serialization.
*
* @param filterAttr
- * The bean attributes which should not be serialized
+ * the bean attributes which should not be serialized
*
* @return JSON string
*
@@ -187,11 +187,11 @@ public interface JsonService {
* Cft. to {@link #addAdapter(String, Class, Object)}
*
* @param name
- * A name for the adapter
+ * the name of the adapter
* @param target
- * The target class for this adapter
+ * the target class for this adapter
* @param mixin
- * The adapter/mixin for the target class
+ * the adapter/mixin for the target class
*
* @return JsonService
*
@@ -208,11 +208,11 @@ public interface JsonService {
* implementation)
*
* @param name
- * A name for the adapter
+ * the name of the adapter
* @param target
- * The target class for this adapter
+ * the target class for this adapter
* @param mixin
- * The adapter/mixin for the target object
+ * the adapter/mixin for the target object
* (module/serializer/deserializer)
*
* @return JsonService
@@ -225,9 +225,9 @@ public interface JsonService {
/**
* @param df
- * The {@link DateFormat} to be used by the JsonService.
+ * the {@link DateFormat} to be used by the JsonService, not null.
*
- * It could be provided by component configuration too.
+ * It could be provided by component configuration too.
*
*/
public void setDateFormat(final DateFormat df);
Modified: turbine/fulcrum/trunk/json/dist/src/assembly/src.xml
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/json/dist/src/assembly/src.xml?rev=1582652&r1=1582651&r2=1582652&view=diff
==============================================================================
--- turbine/fulcrum/trunk/json/dist/src/assembly/src.xml (original)
+++ turbine/fulcrum/trunk/json/dist/src/assembly/src.xml Fri Mar 28 09:38:20 2014
@@ -36,6 +36,7 @@
<fileSets>
<fileSet>
<excludes>
+ <exclude>*.releaseBackup</exclude>
<exclude>target/**</exclude>
</excludes>
</fileSet>
Modified: turbine/fulcrum/trunk/json/jackson/src/java/org/apache/fulcrum/json/jackson/JacksonMapperService.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/json/jackson/src/java/org/apache/fulcrum/json/jackson/JacksonMapperService.java?rev=1582652&r1=1582651&r2=1582652&view=diff
==============================================================================
--- turbine/fulcrum/trunk/json/jackson/src/java/org/apache/fulcrum/json/jackson/JacksonMapperService.java (original)
+++ turbine/fulcrum/trunk/json/jackson/src/java/org/apache/fulcrum/json/jackson/JacksonMapperService.java Fri Mar 28 09:38:20 2014
@@ -46,6 +46,7 @@ import org.codehaus.jackson.map.Serializ
import org.codehaus.jackson.map.introspect.JacksonAnnotationIntrospector;
import org.codehaus.jackson.map.module.SimpleModule;
import org.codehaus.jackson.map.ser.FilterProvider;
+import org.codehaus.jackson.map.ser.StdSerializerProvider;
import org.codehaus.jackson.map.ser.impl.SimpleBeanPropertyFilter;
import org.codehaus.jackson.map.ser.impl.SimpleFilterProvider;
@@ -120,6 +121,9 @@ public class JacksonMapperService extend
// Exception("Found registered filter - could not use custom view and custom filter for class:"+
// src.getClass().getName());
}
+ if (!cacheFilters || cleanCache) {
+ cleanSerializerCache();
+ }
return mapper.writer().writeValueAsString(src);
}
@@ -135,6 +139,9 @@ public class JacksonMapperService extend
// Exception("Found registered filter - could not use custom view and custom filter for class:"+
// src.getClass().getName());
}
+ if (!cacheFilters || cleanCache) {
+ cleanSerializerCache();
+ }
return mapper.writerWithView(type).writeValueAsString(src);
}
@@ -181,8 +188,10 @@ public class JacksonMapperService extend
}
}
String serialized = ser(src, filter);
- if (!cacheFilters)
+ if (!cacheFilters || refreshFilter) {
removeFilterClass(filterClass);
+ cleanSerializerCache();
+ }
return serialized;
}
@@ -218,8 +227,10 @@ public class JacksonMapperService extend
}
String serialized = ser(src, filter);
getLogger().debug("serialized " + serialized);
- if (!cacheFilters || refreshFilter)
+ if (!cacheFilters || refreshFilter) {
removeFilterClass(filterClass);
+ cleanSerializerCache();
+ }
return serialized;
}
@@ -233,6 +244,20 @@ public class JacksonMapperService extend
+ filterClass.getName());
}
}
+
+ private void cleanSerializerCache() {
+ if (mapper.getSerializerProvider() instanceof StdSerializerProvider) {
+ int cachedSerProvs = ((StdSerializerProvider) mapper
+ .getSerializerProvider()).cachedSerializersCount();
+ if (cachedSerProvs > 0) {
+ getLogger()
+ .debug("flushing cachedSerializersCount:"
+ + cachedSerProvs);
+ ((StdSerializerProvider) mapper.getSerializerProvider())
+ .flushCachedSerializers();
+ }
+ }
+ }
private <T> void setCustomIntrospectorWithExternalFilterId(
Class<T> externalFilterId) {
Modified: turbine/fulcrum/trunk/json/jackson2/src/java/org/apache/fulcrum/json/jackson/Jackson2MapperService.java
URL: http://svn.apache.org/viewvc/turbine/fulcrum/trunk/json/jackson2/src/java/org/apache/fulcrum/json/jackson/Jackson2MapperService.java?rev=1582652&r1=1582651&r2=1582652&view=diff
==============================================================================
--- turbine/fulcrum/trunk/json/jackson2/src/java/org/apache/fulcrum/json/jackson/Jackson2MapperService.java (original)
+++ turbine/fulcrum/trunk/json/jackson2/src/java/org/apache/fulcrum/json/jackson/Jackson2MapperService.java Fri Mar 28 09:38:20 2014
@@ -265,7 +265,7 @@ public class Jackson2MapperService exten
return ser(src, filter);//mapper.writerWithView(src.getClass()).writeValueAsString(src);
}
String res = mapper.writerWithView(Object.class).writeValueAsString(src);
- if (cleanCache) {
+ if (cleanCache != null && cleanCache) {
cleanSerializerCache();
}
return res;