[ 
https://issues.apache.org/jira/browse/STANBOL-1237?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13848859#comment-13848859
 ] 

Rupert Westenthaler edited comment on STANBOL-1237 at 12/16/13 6:35 AM:
------------------------------------------------------------------------

ModelWriter interface
-----------------------

The ModelWriter Interface defines the following constants and methos

{code:title=ModelWriter.java|borderStyle=solid}
    /** The default charset is UTF-8 **/
    String DEFAULT_CHARSET = "UTF-8";

    /** The default MediaType is 'application/json; charset=UTF-8' **/
    MediaType DEFAULT_MEDIA_TYPE = 
        MediaType.APPLICATION_JSON_TYPE
        .withCharset(DEFAULT_CHARSET);

    /** The natively supported Represntation or null if none **/
    Class<? extends Representation> getNativeType();

    /** List of supported mediaTypes. Most preferred type first **/
    List<MediaType> supportedMediaTypes()

    /**
     * Getter for the best fitting {@link MediaType} for the parsed one. This
     * Method is intended to let the ModelWriter choose the best fitting type
     * in case the parsed {@link MediaType} uses a wildcard type or sub-type. 
     * @param mediaType a wildcard mediaType
     * @return the selected mediaType or <code>null<code> if none was found.
     */
    public MediaType getBestMediaType(MediaType mediaType);

    /** writes a Representation **/
    public void write(Representation rep, OutputStream out, MediaType medType) 
        throws WebApplicationException, IOException;

    /** writes an Entity **/
    public void write(Entity entity, OutputStream out, MediaType medType)
        throws WebApplicationException, IOException;

    /** writes a query result list. Needs to support String, Representation and 
Entity **/
    public void write(QueryResultList<?> result, OutputStream out, MediaType 
medType) 
        throws WebApplicationException, IOException;

{code}

This extension point will be defined by the Entityhub Jersey module and not by 
the Entityhub Servicesapi. This is because this interface has a dependency to 
JAX-RS.


was (Author: rwesten):
ModelWriter interface
-----------------------

The ModelWriter Interface defines the following constants and methos

{code:title=ModelWriter.java|borderStyle=solid}
    /** The default charset is UTF-8 **/
    String DEFAULT_CHARSET = "UTF-8";
    /** The default MediaType is 'application/json; charset=UTF-8' **/
    MediaType DEFAULT_MEDIA_TYPE = 
        MediaType.APPLICATION_JSON_TYPE
        .withCharset(DEFAULT_CHARSET);
    /** The natively supported Represntation or null if none **/
    Class<? extends Representation> getNativeType();
    /** List of supported mediaTypes. Most preferred type first **/
    List<MediaType> supportedMediaTypes()
    /**
     * Getter for the best fitting {@link MediaType} for the parsed one. This
     * Method is intended to let the ModelWriter choose the best fitting type
     * in case the parsed {@link MediaType} uses a wildcard type or sub-type. 
     * @param mediaType a wildcard mediaType
     * @return the selected mediaType or <code>null<code> if none was found.
     */
    public MediaType getBestMediaType(MediaType mediaType);
    /** writes a Representation **/
    public void write(Representation rep, OutputStream out, MediaType medType) 
        throws WebApplicationException, IOException;
    /** writes an Entity **/
    public void write(Entity entity, OutputStream out, MediaType medType)
        throws WebApplicationException, IOException;
    /** writes a query result list. Needs to support String, Representation and 
Entity **/
    public void write(QueryResultList<?> result, OutputStream out, MediaType 
medType) 
        throws WebApplicationException, IOException;

{code}

This extension point will be defined by the Entityhub Jersey module and not by 
the Entityhub Servicesapi. This is because this interface has a dependency to 
JAX-RS.

> Make Entityhub Serializer extendable
> ------------------------------------
>
>                 Key: STANBOL-1237
>                 URL: https://issues.apache.org/jira/browse/STANBOL-1237
>             Project: Stanbol
>          Issue Type: Improvement
>          Components: Entityhub
>            Reporter: Rupert Westenthaler
>            Assignee: Rupert Westenthaler
>
> The Serialization of the Entityhub models is implemented as JAX-RS 
> MessageBodyWriter. Model classes to be serialized include Representation, 
> Entity and QueryResultList. Where an Entity is constructed of two 
> Representations (data and metadata) and QueryResultLists can include Strings 
> (ids only), Representations or Entities.
> Currently there are two implementations of model serializer: (1) an 
> Implementation for the Entityhub specific JSON format and (2) an 
> implementation based on Clerezza that supports the various RDF formats. Those 
> implementations are registered to JAX-RS via the supported interfaces and the 
> supported media types.
> WIth STANBOL-1165 support for Sesame was added to the Stanbol Entityhub, but 
> serialization of Sesame backed Representation to RDF based media formats is 
> still done by the Clerezza serializers what is extremely inefficient as (1) 
> the Sesame Model needs to be converted to a Clerezza backed model requiring 
> to copy all the data field by field (2) Clerezza internally will use the Jena 
> serializer via a Clerzza/Jena adapter.
> To avoid this the Entityhub requires an extendable serializer framework that 
> allows to register ModelWriter for specific Entityhub Model implementation. 
> For Sesame this will be done within STANBOL-1234.
> The MessageBodyWirter extension point provided by JAX-RS can not be used for 
> this as there are no native implementations for Entity and QueryResultList. 
> Also the use of generic types is not an option as the Entity interface does  
> not use the same.
> Because of that this issue will introduce an new extension point called 
> "ModelWriter" that can be implemented by modules that need to provide native 
> serialization support for Representation implementations. ModelWriter will be 
> registered as OSGI services. A ModelWriterRegistry will be responsible for 
> tracking those. Three MessageBodyWriter implementation for Representation, 
> Entity and QueryResultList will use this registry to forward the calls of 
> JAX-RS to the best fitting ModelWriter service.
> In addition this will provide two ModelWriter implementations (1) for 
> 'application/json' with no specific native type and (2) for the various RDF 
> formats with native Support for the Clerezza Model implementation.
> STANBOL-1234 will provide a third implementation of a ModelWriter for the 
> Sesame model implementation.



--
This message was sent by Atlassian JIRA
(v6.1.4#6159)

Reply via email to