jakartaee / rest

Jakarta RESTful Web Services
Other
362 stars 117 forks source link

Add MultiPartEntity to spec api ? #1033

Open jimma opened 2 years ago

jimma commented 2 years ago

I saw we added javadoc to mention the GenericEntity for a List of EntityPart: the https://github.com/eclipse-ee4j/jaxrs-api/blob/master/jaxrs-api/src/main/java/jakarta/ws/rs/core/EntityPart.java#L45, and is it better we define a MultiPartEntity like for a strong type ? Then MsgBodyReader/Writer can clearly know it has a list of EntityPart instead of others.

public interface MultiPartEntity {

   List<EntityPart> getParts();

   void close();
}
jansupol commented 2 years ago

Not solely in a form of an interface, the users would need to implement it. From the message body provider perspective, I do not see much difference, maybe I miss something. From the user perspective, it might be better to use
MultiPartEntity multipartEntity = new MultiPartEntity(parts). than GenericEntity<List<EntityPart>> genericEntity = new GenericEntity<>(parts){};.

What is the close method doing?

jimma commented 2 years ago

Not solely in a form of an interface, the users would need to implement it. From the message body provider perspective, I do not see much difference, maybe I miss something.

I think the MessageBodyReader/Writer only needs to check this MultiPartEntity. If user put these EntityParts in a Map, the message body provider which check this List type doesn't work.

What is the close method doing?

It can dispose/close the underlying InputStream which isn't closed or delete any temporary files if there is any.