Skip to content

Commit

Permalink
More refactoring, centralizing Annotations enumeration
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Mar 17, 2013
1 parent c0b0cf6 commit c200d91
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@
import com.fasterxml.jackson.databind.util.LRUMap;

import com.fasterxml.jackson.jaxrs.cfg.AnnotationBundleKey;
import com.fasterxml.jackson.jaxrs.cfg.Annotations;
import com.fasterxml.jackson.jaxrs.cfg.EndpointConfigBase;
import com.fasterxml.jackson.jaxrs.cfg.MapperConfiguratorBase;
import com.fasterxml.jackson.jaxrs.util.ClassKey;

public abstract class ProviderBase<
THIS extends ProviderBase<THIS, MAPPER, ANN, EP_CONFIG, MAPPER_CONFIG>,
THIS extends ProviderBase<THIS, MAPPER, EP_CONFIG, MAPPER_CONFIG>,
MAPPER extends ObjectMapper,
ANN extends Enum<ANN>,
EP_CONFIG extends EndpointConfigBase<EP_CONFIG>,
MAPPER_CONFIG extends MapperConfiguratorBase<MAPPER_CONFIG,MAPPER,ANN>
MAPPER_CONFIG extends MapperConfiguratorBase<MAPPER_CONFIG,MAPPER>
>
implements
MessageBodyReader<Object>,
Expand Down Expand Up @@ -199,7 +199,7 @@ public void addUntouchable(Class<?> type)
* @param annotationsToUse Ordered list of annotation sets to use; if null,
* default
*/
public void setAnnotationsToUse(ANN[] annotationsToUse) {
public void setAnnotationsToUse(Annotations[] annotationsToUse) {
_mapperConfig.setAnnotationsToUse(annotationsToUse);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.fasterxml.jackson.jaxrs.json;
package com.fasterxml.jackson.jaxrs.cfg;

/**
* Enumeration that defines standard annotation sets available for configuring
* data binding aspects.
*
* @since 2.2 (earlier located in actual datatype-specific modules)
*/
public enum Annotations {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* {@link ObjectMapper} instance to be used for data binding, as
* well as accessing it.
*/
public abstract class MapperConfiguratorBase<IMPL extends MapperConfiguratorBase<IMPL,MAPPER,ANN>,
MAPPER extends ObjectMapper,
ANN extends Enum<ANN>>
public abstract class MapperConfiguratorBase<IMPL extends MapperConfiguratorBase<IMPL,MAPPER>,
MAPPER extends ObjectMapper
>
{
/**
* Mapper provider was constructed with if any, or that was constructed
Expand All @@ -33,7 +33,7 @@ public abstract class MapperConfiguratorBase<IMPL extends MapperConfiguratorBase
* Annotations set to use by default; overridden by explicit call
* to {@link #setAnnotationsToUse}
*/
protected ANN[] _defaultAnnotationsToUse;
protected Annotations[] _defaultAnnotationsToUse;

/**
* To support optional dependency to Jackson JAXB annotations module
Expand All @@ -47,7 +47,7 @@ public abstract class MapperConfiguratorBase<IMPL extends MapperConfiguratorBase
/**********************************************************
*/

public MapperConfiguratorBase(MAPPER mapper, ANN[] defaultAnnotations)
public MapperConfiguratorBase(MAPPER mapper, Annotations[] defaultAnnotations)
{
_mapper = mapper;
_defaultAnnotationsToUse = defaultAnnotations;
Expand All @@ -73,7 +73,7 @@ public MapperConfiguratorBase(MAPPER mapper, ANN[] defaultAnnotations)
*/
protected abstract MAPPER mapper();

protected abstract AnnotationIntrospector _resolveIntrospectors(ANN[] annotationsToUse);
protected abstract AnnotationIntrospector _resolveIntrospectors(Annotations[] annotationsToUse);

/*
/***********************************************************
Expand All @@ -85,7 +85,7 @@ public synchronized final void setMapper(MAPPER m) {
_mapper = m;
}

public synchronized final void setAnnotationsToUse(ANN[] annotationsToUse) {
public synchronized final void setAnnotationsToUse(Annotations[] annotationsToUse) {
_setAnnotations(mapper(), annotationsToUse);
}

Expand All @@ -111,7 +111,7 @@ public synchronized final void configure(JsonGenerator.Feature f, boolean state)
/***********************************************************
*/

protected final void _setAnnotations(ObjectMapper mapper, ANN[] annotationsToUse)
protected final void _setAnnotations(ObjectMapper mapper, Annotations[] annotationsToUse)
{
AnnotationIntrospector intr;
if (annotationsToUse == null || annotationsToUse.length == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import javax.ws.rs.ext.Provider;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.jaxrs.cfg.Annotations;

/**
* JSON content type provider automatically configured to use both Jackson
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.fasterxml.jackson.databind.*;

import com.fasterxml.jackson.jaxrs.base.ProviderBase;
import com.fasterxml.jackson.jaxrs.cfg.Annotations;


/**
Expand Down Expand Up @@ -47,7 +48,7 @@
@Produces(MediaType.WILDCARD)
public class JacksonJsonProvider
extends ProviderBase<JacksonJsonProvider,
ObjectMapper, Annotations,
ObjectMapper,
JsonEndpointConfig, JsonMapperConfigurator>
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
import com.fasterxml.jackson.jaxrs.cfg.Annotations;
import com.fasterxml.jackson.jaxrs.cfg.MapperConfiguratorBase;
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;

Expand All @@ -13,7 +14,7 @@
* well as accessing it.
*/
public class JsonMapperConfigurator
extends MapperConfiguratorBase<JsonMapperConfigurator, ObjectMapper, Annotations>
extends MapperConfiguratorBase<JsonMapperConfigurator, ObjectMapper>
{
/*
/**********************************************************
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import javax.ws.rs.ext.Provider;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.jaxrs.cfg.Annotations;

/**
* JSON content type provider automatically configured to use both Jackson
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.jaxrs.base.ProviderBase;
import com.fasterxml.jackson.jaxrs.cfg.Annotations;

/**
* Basic implementation of JAX-RS abstractions ({@link MessageBodyReader},
Expand Down Expand Up @@ -45,7 +46,7 @@
@Produces(SmileMediaTypes.APPLICATION_JACKSON_SMILE)
public class JacksonSmileProvider
extends ProviderBase<JacksonSmileProvider,
ObjectMapper, Annotations,
ObjectMapper,
SmileEndpointConfig,
SmileMapperConfigurator
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@
import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
import com.fasterxml.jackson.dataformat.smile.SmileFactory;

import com.fasterxml.jackson.jaxrs.cfg.Annotations;
import com.fasterxml.jackson.jaxrs.cfg.MapperConfiguratorBase;
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector;


/**
* Helper class used to encapsulate details of configuring an
* {@link ObjectMapper} instance to be used for data binding, as
* well as accessing it.
*/
public class SmileMapperConfigurator
extends MapperConfiguratorBase<SmileMapperConfigurator, ObjectMapper, Annotations>
extends MapperConfiguratorBase<SmileMapperConfigurator, ObjectMapper>
{
/*
/**********************************************************
Expand Down
21 changes: 0 additions & 21 deletions xml/src/main/java/com/fasterxml/jackson/jaxrs/xml/Annotations.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import javax.ws.rs.ext.Provider;

import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.jaxrs.cfg.Annotations;

/**
* JSON content type provider automatically configured to use both Jackson
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.fasterxml.jackson.dataformat.xml.XmlMapper;

import com.fasterxml.jackson.jaxrs.base.ProviderBase;
import com.fasterxml.jackson.jaxrs.cfg.Annotations;

/**
* Basic implementation of JAX-RS abstractions ({@link MessageBodyReader},
Expand Down Expand Up @@ -49,7 +50,7 @@
@Produces({MediaType.TEXT_XML, MediaType.APPLICATION_XML})
public class JacksonXMLProvider
extends ProviderBase<JacksonXMLProvider,
XmlMapper, Annotations,
XmlMapper,
XMLEndpointConfig,
XMLMapperConfigurator
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.dataformat.xml.jaxb.XmlJaxbAnnotationIntrospector;

import com.fasterxml.jackson.jaxrs.cfg.Annotations;
import com.fasterxml.jackson.jaxrs.cfg.MapperConfiguratorBase;


/**
* Helper class used to encapsulate details of configuring an
* {@link XmlMapper} instance to be used for data binding, as
* well as accessing it.
*/
public class XMLMapperConfigurator
extends MapperConfiguratorBase<XMLMapperConfigurator, XmlMapper, Annotations>
extends MapperConfiguratorBase<XMLMapperConfigurator, XmlMapper>
{
/*
/**********************************************************
Expand Down

0 comments on commit c200d91

Please sign in to comment.