org.norther.tammi.spray.engine
Class DefaultTemplateExceptionFilter

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.io.IOException
              extended by org.norther.tammi.core.base.LogException
                  extended by org.norther.tammi.spray.filter.DefaultExceptionFilter
                      extended by org.norther.tammi.spray.terminal.TerminalExceptionFilter
                          extended by org.norther.tammi.spray.engine.DefaultTemplateExceptionFilter
All Implemented Interfaces:
Serializable, Filter, Manageable, TemplateExceptionFilter, ExceptionFilter, TerminationFilter
Direct Known Subclasses:
AuthorizationExceptionFilter, RedirectionExceptionFilter

public class DefaultTemplateExceptionFilter
extends TerminalExceptionFilter
implements TemplateExceptionFilter

A default implementation of TemplateExceptionFilter.

Note that negative status code prevents logging.

Version:
$Id: DefaultTemplateExceptionFilter.java,v 1.16 2010-03-30 16:01:29 cvsimp Exp $
Author:
Ilkka Priha
See Also:
Serialized Form

Constructor Summary
DefaultTemplateExceptionFilter(int code)
          Constructs an exception with a code.
DefaultTemplateExceptionFilter(int code, String argument)
          Constructs an exception with a code and argument.
DefaultTemplateExceptionFilter(int code, String argument, Throwable reason)
          Constructs an exception with a code, argument and reason.
DefaultTemplateExceptionFilter(int code, Throwable reason)
          Constructs an exception with a code and reason.
DefaultTemplateExceptionFilter(String template, int code)
          Constructs an exception with a template and code.
DefaultTemplateExceptionFilter(String template, int code, String argument)
          Constructs an exception with a template, code and argument.
DefaultTemplateExceptionFilter(String template, int code, String argument, Throwable reason)
          Constructs an exception with a template, code, argument and reason.
DefaultTemplateExceptionFilter(String template, int code, Throwable reason)
          Constructs an exception with a template, code and reason.
 
Method Summary
protected static void addDefaultTemplate(Class<? extends Throwable> clazz, String template)
          Adds a default template for the specified exception class if not present.
protected  void commitMessage(ServletRequest request, ServletResponse response, FilterChain chain)
          Commits a message.
 String getDefaultTemplate()
          Gets the default template for this exception class.
 String getDefaultTemplate(String className)
          Gets the default template for the named exception class.
 String getErrorTemplate()
          Gets the error template.
 void setDefaultTemplate(String className, String template)
          Sets the default template for the names exception class.
 void setErrorTemplate(String template)
          Sets the error template.
 
Methods inherited from class org.norther.tammi.spray.filter.DefaultExceptionFilter
commitMessage, destroy, doFilter, getMBeanServer, getObjectName, getStatusCode, init, isRegistered, postmanaged, premanaged, unmanaged
 
Methods inherited from class org.norther.tammi.core.base.LogException
equals, getArgument, getLevel, getLocalizedMessage, getLocalizedMessage, getMessageLog, getTime, hashCode, setLevel
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.norther.tammi.spray.filter.ExceptionFilter
getLocalizedMessage, getMessage, getStatusCode
 
Methods inherited from interface javax.servlet.Filter
destroy, doFilter, init
 

Constructor Detail

DefaultTemplateExceptionFilter

public DefaultTemplateExceptionFilter(int code)
Constructs an exception with a code.

Parameters:
code - a status code.

DefaultTemplateExceptionFilter

public DefaultTemplateExceptionFilter(int code,
                                      String argument)
Constructs an exception with a code and argument.

Parameters:
code - a status code.
argument - an argument string.

DefaultTemplateExceptionFilter

public DefaultTemplateExceptionFilter(int code,
                                      Throwable reason)
Constructs an exception with a code and reason.

Parameters:
code - a status code.
reason - a reason throwable.

DefaultTemplateExceptionFilter

public DefaultTemplateExceptionFilter(int code,
                                      String argument,
                                      Throwable reason)
Constructs an exception with a code, argument and reason.

Parameters:
code - a status code.
argument - an argument string.
reason - a reason throwable.

DefaultTemplateExceptionFilter

public DefaultTemplateExceptionFilter(String template,
                                      int code)
Constructs an exception with a template and code.

Parameters:
template - the actual template.
code - a status code.

DefaultTemplateExceptionFilter

public DefaultTemplateExceptionFilter(String template,
                                      int code,
                                      String argument)
Constructs an exception with a template, code and argument.

Parameters:
template - the actual template.
code - a status code.
argument - an argument string.

DefaultTemplateExceptionFilter

public DefaultTemplateExceptionFilter(String template,
                                      int code,
                                      Throwable reason)
Constructs an exception with a template, code and reason.

Parameters:
template - the actual template.
code - a status code.
reason - a reason throwable.

DefaultTemplateExceptionFilter

public DefaultTemplateExceptionFilter(String template,
                                      int code,
                                      String argument,
                                      Throwable reason)
Constructs an exception with a template, code, argument and reason.

Parameters:
template - the actual template.
code - a status code.
argument - an argument string.
reason - a reason throwable.
Method Detail

addDefaultTemplate

protected static void addDefaultTemplate(Class<? extends Throwable> clazz,
                                         String template)
Adds a default template for the specified exception class if not present.

Parameters:
clazz - the exception class.
template - the default template.

getErrorTemplate

public String getErrorTemplate()
Description copied from interface: TemplateExceptionFilter
Gets the error template.

Specified by:
getErrorTemplate in interface TemplateExceptionFilter
Returns:
the error template or null.

setErrorTemplate

public void setErrorTemplate(String template)
Description copied from interface: TemplateExceptionFilter
Sets the error template.

Specified by:
setErrorTemplate in interface TemplateExceptionFilter
Parameters:
template - the error template.

getDefaultTemplate

public String getDefaultTemplate()
Description copied from interface: TemplateExceptionFilter
Gets the default template for this exception class.

Specified by:
getDefaultTemplate in interface TemplateExceptionFilter
Returns:
the default template or null.

getDefaultTemplate

public String getDefaultTemplate(String className)
Description copied from interface: TemplateExceptionFilter
Gets the default template for the named exception class.

Specified by:
getDefaultTemplate in interface TemplateExceptionFilter
Parameters:
className - the exception class name.
Returns:
the default template or null.

setDefaultTemplate

public void setDefaultTemplate(String className,
                               String template)
Description copied from interface: TemplateExceptionFilter
Sets the default template for the names exception class.

Specified by:
setDefaultTemplate in interface TemplateExceptionFilter
Parameters:
className - the exception class name.
template - the default template.

commitMessage

protected void commitMessage(ServletRequest request,
                             ServletResponse response,
                             FilterChain chain)
                      throws IOException
Description copied from class: DefaultExceptionFilter
Commits a message.

Overrides:
commitMessage in class TerminalExceptionFilter
Parameters:
request - the request.
response - the response.
chain - the filter chain.
Throws:
IOException - on I/O errors.


Copyright © 2004 The Norther Organization. All rights reserved.