[jackson-jaxrs-providers] 18/162: More refactoring
Timo Aaltonen
tjaalton at moszumanska.debian.org
Mon Sep 8 22:16:24 UTC 2014
This is an automated email from the git hooks/post-receive script.
tjaalton pushed a commit to branch master
in repository jackson-jaxrs-providers.
commit f693036da107f5f3ecf0bfe5be902a9b6791dd07
Author: Tatu Saloranta <tsaloranta at gmail.com>
Date: Fri Mar 15 20:33:20 2013 -0700
More refactoring
---
.../jaxrs/base/cfg/MapperConfiguratorBase.java | 37 ++++++++++++++++++--
.../jackson/jaxrs/json/JacksonJsonProvider.java | 2 +-
.../jackson/jaxrs/json/cfg/MapperConfigurator.java | 40 ++--------------------
.../jackson/jaxrs/json/TestJsonpWrapping.java | 1 +
.../jaxrs/smile/cfg/MapperConfigurator.java | 40 ++--------------------
.../jackson/jaxrs/xml/cfg/MapperConfigurator.java | 40 ++--------------------
6 files changed, 44 insertions(+), 116 deletions(-)
diff --git a/base/src/main/java/com/fasterxml/jackson/jaxrs/base/cfg/MapperConfiguratorBase.java b/base/src/main/java/com/fasterxml/jackson/jaxrs/base/cfg/MapperConfiguratorBase.java
index 976074c..91bdb18 100644
--- a/base/src/main/java/com/fasterxml/jackson/jaxrs/base/cfg/MapperConfiguratorBase.java
+++ b/base/src/main/java/com/fasterxml/jackson/jaxrs/base/cfg/MapperConfiguratorBase.java
@@ -9,8 +9,9 @@ import com.fasterxml.jackson.databind.*;
* {@link ObjectMapper} instance to be used for data binding, as
* well as accessing it.
*/
-public abstract class MapperConfiguratorBase<IMPL extends MapperConfiguratorBase<IMPL,MAPPER>,
- MAPPER extends ObjectMapper>
+public abstract class MapperConfiguratorBase<IMPL extends MapperConfiguratorBase<IMPL,MAPPER,ANN>,
+ MAPPER extends ObjectMapper,
+ ANN extends Enum<ANN>>
{
/**
* Mapper provider was constructed with if any, or that was constructed
@@ -27,6 +28,12 @@ public abstract class MapperConfiguratorBase<IMPL extends MapperConfiguratorBase
* is only used if no mapper is found via provider lookup.
*/
protected MAPPER _defaultMapper;
+
+ /**
+ * Annotations set to use by default; overridden by explicit call
+ * to {@link #setAnnotationsToUse}
+ */
+ protected ANN[] _defaultAnnotationsToUse;
/**
* To support optional dependency to Jackson JAXB annotations module
@@ -40,9 +47,10 @@ public abstract class MapperConfiguratorBase<IMPL extends MapperConfiguratorBase
/**********************************************************
*/
- public MapperConfiguratorBase(MAPPER mapper)
+ public MapperConfiguratorBase(MAPPER mapper, ANN[] defaultAnnotations)
{
_mapper = mapper;
+ _defaultAnnotationsToUse = defaultAnnotations;
}
/*
@@ -64,6 +72,8 @@ public abstract class MapperConfiguratorBase<IMPL extends MapperConfiguratorBase
* that mapper.
*/
protected abstract MAPPER mapper();
+
+ protected abstract AnnotationIntrospector _resolveIntrospectors(ANN[] annotationsToUse);
/*
/***********************************************************
@@ -75,6 +85,10 @@ public abstract class MapperConfiguratorBase<IMPL extends MapperConfiguratorBase
_mapper = m;
}
+ public synchronized final void setAnnotationsToUse(ANN[] annotationsToUse) {
+ _setAnnotations(mapper(), annotationsToUse);
+ }
+
public synchronized final void configure(DeserializationFeature f, boolean state) {
mapper().configure(f, state);
}
@@ -90,4 +104,21 @@ public abstract class MapperConfiguratorBase<IMPL extends MapperConfiguratorBase
public synchronized final void configure(JsonGenerator.Feature f, boolean state) {
mapper().configure(f, state);
}
+
+ /*
+ /***********************************************************
+ /* Helper methods for sub-classes
+ /***********************************************************
+ */
+
+ protected final void _setAnnotations(ObjectMapper mapper, ANN[] annotationsToUse)
+ {
+ AnnotationIntrospector intr;
+ if (annotationsToUse == null || annotationsToUse.length == 0) {
+ intr = AnnotationIntrospector.nopInstance();
+ } else {
+ intr = _resolveIntrospectors(annotationsToUse);
+ }
+ mapper.setAnnotationIntrospector(intr);
+ }
}
diff --git a/json/src/main/java/com/fasterxml/jackson/jaxrs/json/JacksonJsonProvider.java b/json/src/main/java/com/fasterxml/jackson/jaxrs/json/JacksonJsonProvider.java
index 0909d55..65ec884 100644
--- a/json/src/main/java/com/fasterxml/jackson/jaxrs/json/JacksonJsonProvider.java
+++ b/json/src/main/java/com/fasterxml/jackson/jaxrs/json/JacksonJsonProvider.java
@@ -367,7 +367,7 @@ public class JacksonJsonProvider
}
public void setJSONPFunctionName(String fname) {
- this._jsonpFunctionName = fname;
+ _jsonpFunctionName = fname;
}
/*
diff --git a/json/src/main/java/com/fasterxml/jackson/jaxrs/json/cfg/MapperConfigurator.java b/json/src/main/java/com/fasterxml/jackson/jaxrs/json/cfg/MapperConfigurator.java
index e30614c..e9c1621 100644
--- a/json/src/main/java/com/fasterxml/jackson/jaxrs/json/cfg/MapperConfigurator.java
+++ b/json/src/main/java/com/fasterxml/jackson/jaxrs/json/cfg/MapperConfigurator.java
@@ -14,21 +14,8 @@ import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;
* well as accessing it.
*/
public class MapperConfigurator
- extends MapperConfiguratorBase<MapperConfigurator, ObjectMapper>
+ extends MapperConfiguratorBase<MapperConfigurator, ObjectMapper, Annotations>
{
-
- /**
- * Annotations set to use by default; overridden by explicit call
- * to {@link #setAnnotationsToUse}
- */
- protected Annotations[] _defaultAnnotationsToUse;
-
- /**
- * To support optional dependency to Jackson JAXB annotations module
- * (needed iff JAXB annotations are used for configuration)
- */
- protected Class<? extends AnnotationIntrospector> _jaxbIntrospectorClass;
-
/*
/**********************************************************
/* Construction
@@ -37,8 +24,7 @@ public class MapperConfigurator
public MapperConfigurator(ObjectMapper mapper, Annotations[] defAnnotations)
{
- super(mapper);
- _defaultAnnotationsToUse = defAnnotations;
+ super(mapper, defAnnotations);
}
/**
@@ -63,16 +49,6 @@ public class MapperConfigurator
/*
/**********************************************************
- /* Configuration methods
- /**********************************************************
- */
-
- public synchronized void setAnnotationsToUse(Annotations[] annotationsToUse) {
- _setAnnotations(mapper(), annotationsToUse);
- }
-
- /*
- /**********************************************************
/* Abstract method impl
/**********************************************************
*/
@@ -97,18 +73,6 @@ public class MapperConfigurator
/* Internal methods
/**********************************************************
*/
-
- protected void _setAnnotations(ObjectMapper mapper, Annotations[] annotationsToUse)
- {
- AnnotationIntrospector intr;
- if (annotationsToUse == null || annotationsToUse.length == 0) {
- intr = AnnotationIntrospector.nopInstance();
- } else {
- intr = _resolveIntrospectors(annotationsToUse);
- }
- mapper.setAnnotationIntrospector(intr);
- }
-
protected AnnotationIntrospector _resolveIntrospectors(Annotations[] annotationsToUse)
{
diff --git a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestJsonpWrapping.java b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestJsonpWrapping.java
index 121427c..e0ee96c 100644
--- a/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestJsonpWrapping.java
+++ b/json/src/test/java/com/fasterxml/jackson/jaxrs/json/TestJsonpWrapping.java
@@ -19,6 +19,7 @@ public class TestJsonpWrapping
assertEquals("[1,2,3]", out.toString("UTF-8"));
// then with wrapping:
+ prov = new JacksonJsonProvider();
prov.setJSONPFunctionName("addAll");
out = new ByteArrayOutputStream();
prov.writeTo(bean, bean.getClass(), bean.getClass(), new Annotation[0], MediaType.APPLICATION_JSON_TYPE, null, out);
diff --git a/smile/src/main/java/com/fasterxml/jackson/jaxrs/smile/cfg/MapperConfigurator.java b/smile/src/main/java/com/fasterxml/jackson/jaxrs/smile/cfg/MapperConfigurator.java
index ad00d2d..352f040 100644
--- a/smile/src/main/java/com/fasterxml/jackson/jaxrs/smile/cfg/MapperConfigurator.java
+++ b/smile/src/main/java/com/fasterxml/jackson/jaxrs/smile/cfg/MapperConfigurator.java
@@ -17,20 +17,8 @@ import com.fasterxml.jackson.jaxrs.smile.Annotations;
* well as accessing it.
*/
public class MapperConfigurator
- extends MapperConfiguratorBase<MapperConfigurator, ObjectMapper>
+ extends MapperConfiguratorBase<MapperConfigurator, ObjectMapper, Annotations>
{
- /**
- * Annotations set to use by default; overridden by explicit call
- * to {@link #setAnnotationsToUse}
- */
- protected Annotations[] _defaultAnnotationsToUse;
-
- /**
- * To support optional dependency to Jackson JAXB annotations module
- * (needed iff JAXB annotations are used for configuration)
- */
- protected Class<? extends AnnotationIntrospector> _jaxbIntrospectorClass;
-
/*
/**********************************************************
/* Construction
@@ -39,8 +27,7 @@ public class MapperConfigurator
public MapperConfigurator(ObjectMapper mapper, Annotations[] defAnnotations)
{
- super(mapper);
- _defaultAnnotationsToUse = defAnnotations;
+ super(mapper, defAnnotations);
}
/**
@@ -63,16 +50,6 @@ public class MapperConfigurator
/*
/***********************************************************
- /* Configuration methods
- /***********************************************************
- */
-
- public synchronized void setAnnotationsToUse(Annotations[] annotationsToUse) {
- _setAnnotations(mapper(), annotationsToUse);
- }
-
- /*
- /***********************************************************
/* Internal methods
/***********************************************************
*/
@@ -92,18 +69,7 @@ public class MapperConfigurator
return _mapper;
}
- protected void _setAnnotations(ObjectMapper mapper, Annotations[] annotationsToUse)
- {
- AnnotationIntrospector intr;
- if (annotationsToUse == null || annotationsToUse.length == 0) {
- intr = AnnotationIntrospector.nopInstance();
- } else {
- intr = _resolveIntrospectors(annotationsToUse);
- }
- mapper.setAnnotationIntrospector(intr);
- }
-
-
+ @Override
protected AnnotationIntrospector _resolveIntrospectors(Annotations[] annotationsToUse)
{
// Let's ensure there are no dups there first, filter out nulls
diff --git a/xml/src/main/java/com/fasterxml/jackson/jaxrs/xml/cfg/MapperConfigurator.java b/xml/src/main/java/com/fasterxml/jackson/jaxrs/xml/cfg/MapperConfigurator.java
index 8437c82..3b3b05e 100644
--- a/xml/src/main/java/com/fasterxml/jackson/jaxrs/xml/cfg/MapperConfigurator.java
+++ b/xml/src/main/java/com/fasterxml/jackson/jaxrs/xml/cfg/MapperConfigurator.java
@@ -19,20 +19,8 @@ import com.fasterxml.jackson.jaxrs.xml.Annotations;
* well as accessing it.
*/
public class MapperConfigurator
- extends MapperConfiguratorBase<MapperConfigurator, XmlMapper>
+ extends MapperConfiguratorBase<MapperConfigurator, XmlMapper, Annotations>
{
- /**
- * Annotations set to use by default; overridden by explicit call
- * to {@link #setAnnotationsToUse}
- */
- protected Annotations[] _defaultAnnotationsToUse;
-
- /**
- * To support optional dependency to Jackson JAXB annotations module
- * (needed iff JAXB annotations are used for configuration)
- */
- protected Class<? extends AnnotationIntrospector> _jaxbIntrospectorClass;
-
/*
/**********************************************************
/* Construction
@@ -41,8 +29,7 @@ public class MapperConfigurator
public MapperConfigurator(XmlMapper mapper, Annotations[] defAnnotations)
{
- super(mapper);
- _defaultAnnotationsToUse = defAnnotations;
+ super(mapper, defAnnotations);
}
/**
@@ -70,16 +57,6 @@ public class MapperConfigurator
{
return new JacksonXmlModule();
}
-
- /*
- /***********************************************************
- /* Configuration methods
- /***********************************************************
- */
-
- public synchronized void setAnnotationsToUse(Annotations[] annotationsToUse) {
- _setAnnotations(mapper(), annotationsToUse);
- }
/*
/***********************************************************
@@ -102,18 +79,7 @@ public class MapperConfigurator
return _mapper;
}
- protected void _setAnnotations(XmlMapper mapper, Annotations[] annotationsToUse)
- {
- AnnotationIntrospector intr;
- if (annotationsToUse == null || annotationsToUse.length == 0) {
- intr = AnnotationIntrospector.nopInstance();
- } else {
- intr = _resolveIntrospectors(annotationsToUse);
- }
- mapper.setAnnotationIntrospector(intr);
- }
-
-
+ @Override
protected AnnotationIntrospector _resolveIntrospectors(Annotations[] annotationsToUse)
{
// Let's ensure there are no dups there first, filter out nulls
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/jackson-jaxrs-providers.git
More information about the pkg-java-commits
mailing list