tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Romain Manni-Bucau <rmannibu...@gmail.com>
Subject Re: JsonbJaxrsProvider
Date Wed, 11 May 2016 15:15:26 GMT
Hi

you can add cxf.jaxrs.skip-provider-scanning = true (otherwise no need of
openejb-jar.xml since your provider will get scanned by default)

then it shouldn't be an issue johnzon providers are there since yours
should be taken first since these providers are on the CXf bus so they are
less prioritized.


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com> | JavaEE Factory
<https://javaeefactory-rmannibucau.rhcloud.com>

2016-05-11 17:12 GMT+02:00 ravi sankar <sankar_ravi_c@yahoo.co.in.invalid>:

> Since the default org.apache.johnzon.jaxrs.jsonb.jaxrs.JsonbJaxrsProvider
> doesn't support application/*+json
>
> I have created a simple provider extending JsonbJaxrsProvider
>
> @Provider
> @Produces({ "application/json", "application/*+json" })
> @Consumes({ "application/json", "application/*+json" })
> public class MyJsonbJaxRsProvider<T> extends JsonbJaxrsProvider<T> {
>     @Override
>     public boolean isWriteable(final Class<?> rawType, final Type
> genericType, final Annotation[] annotations,
>             final MediaType mediaType) {
>         return super.isWriteable(rawType, genericType, annotations,
> mediaType)
>                 && !OutputStream.class.isAssignableFrom(rawType) &&
> !StreamingOutput.class.isAssignableFrom(rawType)
>                 && !Writer.class.isAssignableFrom(rawType) &&
> !Response.class.isAssignableFrom(rawType)
>                 && !JsonStructure.class.isAssignableFrom(rawType);
>     }
> }
>
> Then added openejb-jar.xml in WEB-INF
> <openejb-jar xmlns="http://www.openejb.org/openejb-jar/1.1"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.openejb.org/openejb-jar/1.1">
>     <pojo-deployment  class-name="jaxrs-application">
>         <properties>
>             cxf.jaxrs.providers = com.example.MyJsonbJaxRsProvider
>         </properties>
>     </pojo-deployment>
> </openejb-jar>
>
> Application is working fine but
> I am seeing three MyJsonbJaxRsProvider registered in readers and writers,
> the default TomEEJohnzonProvider is also resgistered
> Am I doing something wrong
> I am using Tomee 7.0.0-M3 and Johnzon 0.9.3
>
> INFO - Using readers:
> INFO -      org.apache.cxf.jaxrs.provider.PrimitiveTextProvider@1aae0dc
> INFO -      org.apache.cxf.jaxrs.provider.FormEncodingProvider@17cf664
> INFO -      org.apache.cxf.jaxrs.provider.MultipartProvider@1f91b
> INFO -      org.apache.cxf.jaxrs.provider.SourceProvider@216e3d
> INFO -      org.apache.cxf.jaxrs.provider.JAXBElementProvider@a7c9e5
> INFO -      com.example.MyJsonbJaxRsProvider@3ede03
> INFO -      com.example.MyJsonbJaxRsProvider@1c432be
> INFO -      com.example.MyJsonbJaxRsProvider@c7e6fd
> INFO -
> org.apache.openejb.server.cxf.rs.CxfRSService$TomEEJohnzonProvider@11929da
> INFO -
> org.apache.openejb.server.cxf.rs.CxfRSService$TomEEJsonpProvider@17dab5b
> INFO -      org.apache.cxf.jaxrs.provider.StringTextProvider@63e761
> INFO -      org.apache.cxf.jaxrs.provider.BinaryDataProvider@7feea8
> INFO -      org.apache.cxf.jaxrs.provider.DataSourceProvider@18669b
> INFO - Using writers:
> INFO -      org.apache.johnzon.jaxrs.WadlDocumentMessageBodyWriter@19385eb
> INFO -      org.apache.cxf.jaxrs.provider.StringTextProvider@63e761
> INFO -      org.apache.cxf.jaxrs.provider.PrimitiveTextProvider@1aae0dc
> INFO -      org.apache.cxf.jaxrs.provider.FormEncodingProvider@17cf664
> INFO -      org.apache.cxf.jaxrs.provider.MultipartProvider@1f91b
> INFO -      org.apache.cxf.jaxrs.provider.SourceProvider@216e3d
> INFO -      org.apache.cxf.jaxrs.provider.JAXBElementProvider@a7c9e5
> INFO -      com.example.MyJsonbJaxRsProvider@3ede03
> INFO -      com.example.MyJsonbJaxRsProvider@1c432be
> INFO -      com.example.MyJsonbJaxRsProvider@c7e6fd
> INFO -
> org.apache.openejb.server.cxf.rs.CxfRSService$TomEEJohnzonProvider@11929da
> INFO -
> org.apache.openejb.server.cxf.rs.CxfRSService$TomEEJsonpProvider@17dab5b
> INFO -      org.apache.cxf.jaxrs.provider.BinaryDataProvider@7feea8
> INFO -      org.apache.cxf.jaxrs.provider.DataSourceProvider@18669b
> INFO - Using exception mappers:
> INFO -      org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper@dc2097
> INFO -      org.apache.openejb.server.cxf.rs.EJBExceptionMapper@1f3948a
> INFO -
> org.apache.cxf.jaxrs.validation.ValidationExceptionMapper@f01211
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message