Skip to content

Commit

Permalink
Replace specialized providers with JerksonProvider.
Browse files Browse the repository at this point in the history
  • Loading branch information
codahale committed Sep 21, 2011
1 parent edba5a1 commit 4745cd5
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 296 deletions.
72 changes: 0 additions & 72 deletions src/main/scala/com/codahale/jersey/providers/JValueProvider.scala

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import scala.reflect.Manifest
@Provider
@Produces(Array(MediaType.APPLICATION_JSON))
@Consumes(Array(MediaType.APPLICATION_JSON))
class ArrayProvider[A] extends AbstractMessageReaderWriterProvider[Array[A]] {
private val logger = LoggerFactory.getLogger(classOf[ArrayProvider[A]])
class JerksonProvider[A] extends AbstractMessageReaderWriterProvider[A] {
private val logger = LoggerFactory.getLogger(classOf[JerksonProvider[_]])

def readFrom(klass: Class[Array[A]],
def readFrom(klass: Class[A],
genericType: Type,
annotations: Array[Annotation],
mediaType: MediaType,
Expand All @@ -38,9 +38,9 @@ class ArrayProvider[A] extends AbstractMessageReaderWriterProvider[Array[A]] {
def isReadable(klass: Class[_],
genericType: Type,
annotations: Array[Annotation],
mediaType: MediaType) = klass.isArray
mediaType: MediaType) = mediaType.isCompatible(MediaType.APPLICATION_JSON_TYPE)

def writeTo(t: Array[A],
def writeTo(t: A,
klass: Class[_],
genericType: Type,
annotations: Array[Annotation],
Expand All @@ -51,12 +51,12 @@ class ArrayProvider[A] extends AbstractMessageReaderWriterProvider[Array[A]] {
Json.generate(t, entityStream)
} catch {
case e: IOException => logger.debug("Error writing to stream", e)
case e => logger.error("Error encoding %s as JSON".format(t.mkString("Array(", ",", ")")), e)
case e => logger.error("Error encoding %s as JSON".format(t, e))
}
}

def isWriteable(klass: Class[_],
genericType: Type,
annotations: Array[Annotation],
mediaType: MediaType) = klass.isArray
mediaType: MediaType) = mediaType.isCompatible(MediaType.APPLICATION_JSON_TYPE)
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package com.codahale.jersey.providers.specs
import com.codahale.simplespec.Spec
import org.junit.Test
import javax.ws.rs.core.MediaType
import com.codahale.jersey.providers.ArrayProvider
import com.codahale.jersey.providers.JerksonProvider
import javax.ws.rs.WebApplicationException
import java.io.{ByteArrayOutputStream, ByteArrayInputStream}

class ArrayProviderSpec extends Spec {
private val provider = new ArrayProvider[Int]
class JerksonProviderSpec extends Spec {
private val provider = new JerksonProvider[Array[Int]]

class `An array of ints` {
@Test def `is writable` = {
Expand Down

This file was deleted.

0 comments on commit 4745cd5

Please sign in to comment.