-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from Spikhalskiy/jaxrs1-compatibility
Implemented dynamic selection of NoContentException provider to back support of JaxRS 1.x
- Loading branch information
Showing
4 changed files
with
75 additions
and
3 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
base/src/main/java/com/fasterxml/jackson/jaxrs/base/NoContentExceptionSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.fasterxml.jackson.jaxrs.base; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Implementors of this class contains strategies for NoContentException creation | ||
*/ | ||
public interface NoContentExceptionSupplier | ||
{ | ||
String NO_CONTENT_MESSAGE = "No content (empty input stream)"; | ||
|
||
IOException createNoContentException(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...ain/java/com/fasterxml/jackson/jaxrs/base/nocontent/JaxRS1NoContentExceptionSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.fasterxml.jackson.jaxrs.base.nocontent; | ||
|
||
import com.fasterxml.jackson.jaxrs.base.NoContentExceptionSupplier; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Create plain IOException for JaxRS 1.x because {@link javax.ws.rs.core.NoContentException} | ||
* has been introduced in JaxRS 2.x | ||
*/ | ||
public class JaxRS1NoContentExceptionSupplier implements NoContentExceptionSupplier | ||
{ | ||
@Override | ||
public IOException createNoContentException() | ||
{ | ||
return new IOException(NO_CONTENT_MESSAGE); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...ain/java/com/fasterxml/jackson/jaxrs/base/nocontent/JaxRS2NoContentExceptionSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.fasterxml.jackson.jaxrs.base.nocontent; | ||
|
||
import com.fasterxml.jackson.jaxrs.base.NoContentExceptionSupplier; | ||
|
||
import javax.ws.rs.core.NoContentException; | ||
import java.io.IOException; | ||
|
||
/** | ||
* This supplier creates fair NoContentException from JaxRS 2.x | ||
*/ | ||
public class JaxRS2NoContentExceptionSupplier implements NoContentExceptionSupplier { | ||
@Override | ||
public IOException createNoContentException() { | ||
return new NoContentException(NoContentExceptionSupplier.NO_CONTENT_MESSAGE); | ||
} | ||
} |