Skip to content

Commit

Permalink
Merge branch 'release/0.1.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
codahale committed Sep 14, 2011
2 parents 7670373 + e10eaf1 commit bb13ef5
Show file tree
Hide file tree
Showing 17 changed files with 417 additions and 159 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
v0.1.9: Sep 13 2011
===================

* Upgraded to Jersey 1.9.
* Upgraded to Jerkson 0.4.1.
* Upgraded to Slf4j 1.6.2.
* Added support for Scala 2.9.1.
* Fixed issues with parameterized media types and deserializing JSON entities.

v0.1.8: Aug 11 2011
===================

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ Jersey-Scala is a set of classes which add Scala interoperation to Jersey.
Requirements
------------

* Scala 2.8.1 or 2.9.0-1
* Jerkson 0.4.0
* Jersey 1.8
* Slf4j API 1.6.1
* Scala 2.8.1 or 2.9.0-1 or 2.9.1
* Jerkson 0.4.1
* Jersey 1.9
* Slf4j API 1.6.2


How To Use
Expand All @@ -24,7 +24,7 @@ How To Use
<dependency>
<groupId>com.codahale</groupId>
<artifactId>jersey-scala_${scala.version}</artifactId>
<version>0.1.8</version>
<version>0.1.9</version>
</dependency>
```

Expand Down
16 changes: 8 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<modelVersion>4.0.0</modelVersion>

<groupId>com.codahale</groupId>
<artifactId>jersey-scala_2.9.0-1</artifactId>
<version>0.1.8</version>
<artifactId>jersey-scala_2.9.1</artifactId>
<version>0.1.9</version>
<name>Jersey Support for Scala ${scala.version}</name>

<properties>
<scala.version>2.9.0-1</scala.version>
<scala.version>2.9.1</scala.version>
</properties>

<developers>
Expand Down Expand Up @@ -78,28 +78,28 @@
<dependency>
<groupId>com.codahale</groupId>
<artifactId>jerkson_${scala.version}</artifactId>
<version>0.4.0</version>
<version>0.4.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.8</version>
<version>1.9</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>com.codahale</groupId>
<artifactId>simplespec_${scala.version}</artifactId>
<version>0.4.0</version>
<version>0.5.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.6.1</version>
<version>1.6.2</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
12 changes: 6 additions & 6 deletions pom_2.8.1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.codahale</groupId>
<artifactId>jersey-scala_2.8.1</artifactId>
<version>0.1.8</version>
<version>0.1.9</version>
<name>Jersey Support for Scala ${scala.version}</name>

<properties>
Expand Down Expand Up @@ -78,28 +78,28 @@
<dependency>
<groupId>com.codahale</groupId>
<artifactId>jerkson_${scala.version}</artifactId>
<version>0.4.0</version>
<version>0.4.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.8</version>
<version>1.9</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>com.codahale</groupId>
<artifactId>simplespec_${scala.version}</artifactId>
<version>0.4.0</version>
<version>0.5.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.6.1</version>
<version>1.6.2</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
209 changes: 209 additions & 0 deletions pom_2.9.0-1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.codahale</groupId>
<artifactId>jersey-scala_2.9.0-1</artifactId>
<version>0.1.9</version>
<name>Jersey Support for Scala ${scala.version}</name>

<properties>
<scala.version>2.9.0-1</scala.version>
</properties>

<developers>
<developer>
<name>Coda Hale</name>
<email>[email protected]</email>
<timezone>-8</timezone>
</developer>
</developers>

<licenses>
<license>
<url>http://codahale.com/mit.txt</url>
<name>The MIT License</name>
<distribution>repo</distribution>
</license>
</licenses>

<scm>
<connection>scm:git:git://github.com/codahale/jersey-scala.git</connection>
<developerConnection>scm:git:[email protected]:codahale/jersey-scala.git</developerConnection>
<url>http://github.com/codahale/jersey-scala/</url>
</scm>

<issueManagement>
<system>github</system>
<url>http://github.com/codahale/jersey-scala/issues#issue/</url>
</issueManagement>

<repositories>
<repository>
<id>scala-tools-releases</id>
<url>http://scala-tools.org/repo-releases/</url>
</repository>
<repository>
<id>repo.codahale.com</id>
<url>http://repo.codahale.com</url>
</repository>
<repository>
<id>java.net.m2</id>
<url>http://download.java.net/maven/2/</url>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>scala-tools-releases</id>
<url>http://scala-tools.org/repo-releases/</url>
</pluginRepository>
</pluginRepositories>

<distributionManagement>
<repository>
<id>repo.codahale.com</id>
<url>scp://codahale.com/home/codahale/repo.codahale.com</url>
</repository>
</distributionManagement>

<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>com.codahale</groupId>
<artifactId>jerkson_${scala.version}</artifactId>
<version>0.4.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>com.codahale</groupId>
<artifactId>simplespec_${scala.version}</artifactId>
<version>0.5.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-nop</artifactId>
<version>1.6.2</version>
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
<profile>
<id>sign</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<build>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.2</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<args>
<arg>-optimise</arg>
<arg>-unchecked</arg>
<arg>-deprecation</arg>
</args>
<charset>UTF-8</charset>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.8.1</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
<argLine>-Xmx1024m</argLine>
<includes>
<include>**/*Spec.java</include>
</includes>
<excludes>
<exclude>**/*Test.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>1.0-beta-7</version>
</extension>
</extensions>
</build>
</project>
33 changes: 24 additions & 9 deletions src/main/scala/com/codahale/jersey/providers/JValueProvider.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@ import com.sun.jersey.core.provider.AbstractMessageReaderWriterProvider
import com.codahale.jerkson.AST.JValue
import com.codahale.jerkson.{Json, ParsingException}
import org.slf4j.LoggerFactory
import java.io.{IOException, EOFException, InputStream, OutputStream}
import java.io.{IOException, InputStream, OutputStream}

@Provider
@Consumes(Array(MediaType.APPLICATION_JSON))
class JValueProvider extends AbstractMessageReaderWriterProvider[JValue] {
private val logger = LoggerFactory.getLogger(classOf[JValueProvider])

def writeTo(json: JValue, t: Class[_], genericType: Type, annotations: Array[Annotation],
mediaType: MediaType, httpHeaders: MultivaluedMap[String, AnyRef],
def writeTo(json: JValue,
t: Class[_],
genericType: Type,
annotations: Array[Annotation],
mediaType: MediaType,
httpHeaders: MultivaluedMap[String, AnyRef],
entityStream: OutputStream) {
try {
Json.generate(json, entityStream)
Expand All @@ -28,11 +32,18 @@ class JValueProvider extends AbstractMessageReaderWriterProvider[JValue] {
}
}

def isWriteable(t: Class[_], genericType: Type, annotations: Array[Annotation],
mediaType: MediaType) = classOf[JValue].isAssignableFrom(t)
def isWriteable(t: Class[_],
genericType: Type,
annotations: Array[Annotation],
mediaType: MediaType) =
MediaType.APPLICATION_JSON_TYPE.isCompatible(mediaType) &&
classOf[JValue].isAssignableFrom(t)

def readFrom(t: Class[JValue], genericType: Type, annotations: Array[Annotation],
mediaType: MediaType, httpHeaders: MultivaluedMap[String, String],
def readFrom(t: Class[JValue],
genericType: Type,
annotations: Array[Annotation],
mediaType: MediaType,
httpHeaders: MultivaluedMap[String, String],
entityStream: InputStream): JValue = {
try {
Json.parse[JValue](entityStream)
Expand All @@ -52,6 +63,10 @@ class JValueProvider extends AbstractMessageReaderWriterProvider[JValue] {
}
}

def isReadable(t: Class[_], genericType: Type, annotations: Array[Annotation],
mediaType: MediaType) = classOf[JValue].isAssignableFrom(t)
def isReadable(t: Class[_],
genericType: Type,
annotations: Array[Annotation],
mediaType: MediaType) =
MediaType.APPLICATION_JSON_TYPE.isCompatible(mediaType) &&
classOf[JValue].isAssignableFrom(t)
}
Loading

0 comments on commit bb13ef5

Please sign in to comment.