All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.cosenonjaviste.security.jwt.catalinawriters.ResponseWriter Maven / Gradle / Ivy

package it.cosenonjaviste.security.jwt.catalinawriters;

import java.io.IOException;

import org.apache.catalina.connector.Response;

/**
 * Abstract class for catalina response writing. 
 * Supported media type are json and xml. Html is default
 * 
 * @author acomo
 *
 */
public abstract class ResponseWriter {

	static final String APPLICATION_XML = "application/xml";
	
	static final String APPLICATION_JSON = "application/json";
	
	/**
	 * Create a new {@link ResponseWriter} instance based on provided mimetype.
	 * 
	 * Supported mimetype are:
	 * 
    *
  • application/json
  • *
  • application/xml
  • *
  • text/html is default
  • *
* * @param mimeType * @return */ public static ResponseWriter get(String mimeType) { switch (mimeType != null ? mimeType : "") { case APPLICATION_JSON: return new JsonResponseWriter(); case APPLICATION_XML: return new XmlResponseWriter(); default: return new HtmlResponseWriter(); } } /** * Write body values to response with provided status code. Body serialization depends on concrete class * * @param response * @param statusCode * @param body * @throws IOException */ public abstract void write(Response response, int statusCode, Object body) throws IOException; }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy