-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Resource Class reflection registration when custom Writer is used
Originally reported at: https://quarkusio.zulipchat.com/#narrow/stream/306418-resteasy-reactive/topic/CloudEvents.20lib.20doesn't.20work.20in.20native.20mode/near/357052399
- Loading branch information
Showing
6 changed files
with
137 additions
and
12 deletions.
There are no files selected for viewing
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
21 changes: 21 additions & 0 deletions
21
integration-tests/hibernate-orm-envers/src/main/java/io/quarkus/it/envers/Message2.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,21 @@ | ||
package io.quarkus.it.envers; | ||
|
||
public class Message2 { | ||
|
||
private String data; | ||
|
||
public Message2() { | ||
} | ||
|
||
public Message2(String data) { | ||
this.data = data; | ||
} | ||
|
||
public String getData() { | ||
return data; | ||
} | ||
|
||
public void setData(String data) { | ||
this.data = data; | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...ation-tests/hibernate-orm-envers/src/main/java/io/quarkus/it/envers/Message2Provider.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,54 @@ | ||
package io.quarkus.it.envers; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
import java.lang.annotation.Annotation; | ||
import java.lang.reflect.Type; | ||
import java.nio.charset.StandardCharsets; | ||
|
||
import jakarta.ws.rs.Consumes; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.WebApplicationException; | ||
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.core.MultivaluedMap; | ||
import jakarta.ws.rs.ext.MessageBodyReader; | ||
import jakarta.ws.rs.ext.MessageBodyWriter; | ||
import jakarta.ws.rs.ext.Provider; | ||
|
||
@Provider | ||
@Consumes(MediaType.WILDCARD) | ||
@Produces(MediaType.WILDCARD) | ||
public class Message2Provider implements MessageBodyReader<Message2>, MessageBodyWriter<Message2> { | ||
|
||
@Override | ||
public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { | ||
return Message2.class.isAssignableFrom(type); | ||
} | ||
|
||
@Override | ||
public Message2 readFrom(Class<Message2> type, Type genericType, Annotation[] annotations, MediaType mediaType, | ||
MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException, WebApplicationException { | ||
return new Message2("in"); | ||
} | ||
|
||
@Override | ||
public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType) { | ||
return Message2.class.isAssignableFrom(type); | ||
} | ||
|
||
@Override | ||
public void writeTo(Message2 event, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, | ||
MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException { | ||
String data = "out"; | ||
if (annotations != null) { | ||
for (Annotation annotation : annotations) { | ||
if (annotation.annotationType().equals(CustomOutput.class)) { | ||
data = ((CustomOutput) annotation).value(); | ||
break; | ||
} | ||
} | ||
} | ||
entityStream.write(String.format("{\"data\": \"%s\"}", data).getBytes(StandardCharsets.UTF_8)); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...ration-tests/hibernate-orm-envers/src/main/java/io/quarkus/it/envers/Output2Resource.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 io.quarkus.it.envers; | ||
|
||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.MediaType; | ||
|
||
@Path("output2") | ||
public class Output2Resource { | ||
|
||
@GET | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public Message2 out() { | ||
return new Message2("test"); | ||
} | ||
} |
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
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