log a jira please.
On 3/6/2013 5:26 AM, Jean-François HEROUARD wrote:
> While playing with SerializableProvider in RestEASY beta 3 I got errors
> due to a MediaType being changed to
> "application/x-java-serialized-object;charset=UTF-8" by a global servlet
> Spring filter. Charset is useless but I think the @Provider should use
> MediaType.isCompatible instead of String equels.
>
> Here is the modification I made :
>
> @Provider
> @Produces(SerializableProvider.MIMETYPE)
> @Consumes(SerializableProvider.MIMETYPE)
> public class SerializableProvider implements
> MessageBodyReader<Serializable>, MessageBodyWriter<Serializable> {
> /** Marshaller for Java serialized objects */
> public final static String MIMETYPE =
> "application/x-java-serialized-object";
> /** Corresponding MediaType */
> public final static MediaType MEDIATYPE = new
> MediaType("application", "x-java-serialized-object");
>
> @Override
> public boolean isWriteable(Class<?> type, Type genericType,
> Annotation[] annotations, MediaType mediaType) {
> return Serializable.class.isAssignableFrom(type) &&
> MEDIATYPE.isCompatible(mediaType);
> }
>
> @Override
> public long getSize(Serializable t, Class<?> type, Type
> genericType, Annotation[] annotations, MediaType mediaType) {
> return -1;
> }
>
> @Override
> public void writeTo(Serializable t, Class<?> type, Type
> genericType, Annotation[] annotations, MediaType mediaType,
> MultivaluedMap<String, Object> httpHeaders, OutputStream
> entityStream) throws IOException,
> WebApplicationException {
> BufferedOutputStream bos = new BufferedOutputStream(entityStream);
> ObjectOutputStream oos = new ObjectOutputStream(bos);
> oos.writeObject(t);
> oos.close();
> }
>
> @Override
> public boolean isReadable(Class<?> type, Type genericType,
> Annotation[] annotations, MediaType mediaType) {
> return Serializable.class.isAssignableFrom(type)
> && MEDIATYPE.isCompatible(mediaType);
> }
>
> @Override
> public Serializable readFrom(Class<Serializable> type, Type
> genericType, Annotation[] annotations,
> MediaType mediaType, MultivaluedMap<String, String>
> httpHeaders, InputStream entityStream)
> throws IOException, WebApplicationException {
> BufferedInputStream bis = new BufferedInputStream(entityStream);
> ObjectInputStream ois = new ObjectInputStream(bis);
> try {
> return Serializable.class.cast(ois.readObject());
> } catch (ClassNotFoundException e) {
> throw new WebApplicationException(e);
> }
> }
> }
>
>
> ------------------------------------------------------------------------------
> Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
> Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
> endpoint security space. For insight on selecting the right partner to
> tackle endpoint security challenges, access the full report.
> http://p.sf.net/sfu/symantec-dev2dev
>
>
>
> _______________________________________________
> Resteasy-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/resteasy-users
>
--
Bill Burke
JBoss, a division of Red Hat
http://bill.burkecentral.com
------------------------------------------------------------------------------
Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester
Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the
endpoint security space. For insight on selecting the right partner to
tackle endpoint security challenges, access the full report.
http://p.sf.net/sfu/symantec-dev2dev
_______________________________________________
Resteasy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/resteasy-users