org.jboss.seam.rest.templating
Class TemplatingMessageBodyWriter

java.lang.Object
  extended by org.jboss.seam.rest.templating.TemplatingMessageBodyWriter
All Implemented Interfaces:
javax.ws.rs.ext.MessageBodyWriter<Object>

@Provider
@ApplicationScoped
public class TemplatingMessageBodyWriter
extends Object
implements javax.ws.rs.ext.MessageBodyWriter<Object>

TemplatingMessageBodyWriter is enabled for every JAX-RS method annotated with @ResponseTemplate annotation and delegates response production to the TemplatingProvider.

Author:
Jozef Hartinger

Constructor Summary
TemplatingMessageBodyWriter()
           
 
Method Summary
 org.jboss.seam.rest.templating.TemplatingProvider getProvider()
           
 long getSize(Object t, Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
           
 void init(javax.enterprise.inject.Instance<org.jboss.seam.rest.templating.TemplatingProvider> providerInstance, javax.enterprise.inject.Instance<org.jboss.seam.rest.SeamRestConfiguration> configuration)
          Initializes TemplatingMessageBodyWriter.
 void init(javax.servlet.ServletContext context)
          Initializes the TemplatingProvider if available.
 boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType)
          Returns true if and only if the templating extension is enabled and the method contains the @ResponseTemplate annotation.
 void writeTo(Object t, Class<?> type, Type genericType, Annotation[] annotations, javax.ws.rs.core.MediaType mediaType, javax.ws.rs.core.MultivaluedMap<String,Object> httpHeaders, OutputStream entityStream)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TemplatingMessageBodyWriter

public TemplatingMessageBodyWriter()
Method Detail

init

@Inject
public void init(javax.enterprise.inject.Instance<org.jboss.seam.rest.templating.TemplatingProvider> providerInstance,
                        javax.enterprise.inject.Instance<org.jboss.seam.rest.SeamRestConfiguration> configuration)
Initializes TemplatingMessageBodyWriter. TemplatingProvider is selected.

Throws:
javax.enterprise.inject.UnsatisfiedResolutionException - if the preferred TemplatingProvider is selected but is not available for injection.
javax.enterprise.inject.AmbiguousResolutionException - if there are multiple TemplatingProviders available.

init

public void init(@Observes@RestResource
                 javax.servlet.ServletContext context)
Initializes the TemplatingProvider if available.


isWriteable

public boolean isWriteable(Class<?> type,
                           Type genericType,
                           Annotation[] annotations,
                           javax.ws.rs.core.MediaType mediaType)
Returns true if and only if the templating extension is enabled and the method contains the @ResponseTemplate annotation.

Specified by:
isWriteable in interface javax.ws.rs.ext.MessageBodyWriter<Object>

getSize

public long getSize(Object t,
                    Class<?> type,
                    Type genericType,
                    Annotation[] annotations,
                    javax.ws.rs.core.MediaType mediaType)
Specified by:
getSize in interface javax.ws.rs.ext.MessageBodyWriter<Object>

writeTo

public void writeTo(Object t,
                    Class<?> type,
                    Type genericType,
                    Annotation[] annotations,
                    javax.ws.rs.core.MediaType mediaType,
                    javax.ws.rs.core.MultivaluedMap<String,Object> httpHeaders,
                    OutputStream entityStream)
             throws IOException,
                    javax.ws.rs.WebApplicationException
Specified by:
writeTo in interface javax.ws.rs.ext.MessageBodyWriter<Object>
Throws:
IOException
javax.ws.rs.WebApplicationException

getProvider

public org.jboss.seam.rest.templating.TemplatingProvider getProvider()


Copyright © 2011 Seam Framework. All Rights Reserved.