org.norther.tammi.spray.filter
Class DefaultExceptionFilter

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
All Implemented Interfaces:
Serializable, Filter, Manageable, ExceptionFilter, TerminationFilter
Direct Known Subclasses:
DefaultTemplateExceptionFilter

public class DefaultExceptionFilter
extends LogException
implements ExceptionFilter, Manageable

A default implementation of ExceptionFilter.

Note that negative status code prevents logging.

Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.norther.tammi.core.base.LogException
DEFAULT, ERROR, FATAL, INFO, NONE, WARN, WARNING
 
Constructor Summary
DefaultExceptionFilter(int code)
          Constructs an exception with a code.
DefaultExceptionFilter(int code, String argument)
          Constructs an exception with a code and argument.
DefaultExceptionFilter(int code, String argument, Throwable cause)
          Constructs an exception with a code, argument and cause.
DefaultExceptionFilter(int code, Throwable cause)
          Constructs an exception with a code and cause.
 
Method Summary
 void destroy()
           
 void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
           
 MBeanServer getMBeanServer()
          Gets the MBean server.
protected  CharSequence getMessage(ServletRequest request, ServletResponse response, FilterChain chain)
          Returns the message to produce.
 ObjectName getObjectName()
          Gets the object name.
 int getStatusCode()
          Gets the status code.
 void init(FilterConfig config)
           
 boolean isRegistered()
          Checks whether registered.
 void postmanaged()
          This method is called when the implementing adaptee has been managed either during post-registration of the corresponding adapter MBean or just after it is explicitly added to the adapter MBean during run-time.
 void premanaged(MBeanDelegate adapter)
          This method is called when the implementing adaptee is trying to be managed either during pre-registration of the corresponding adapter MBean or just before it is explicitly added to the adapter MBean during run-time.
protected  void prepareCommit(ServletRequest request, ServletResponse response, FilterChain chain)
          A callback for subclasses to modify the response before committing.
 void unmanaged()
          This method is called when the implementing adaptee is unmanaged either during pre-deregistration of the corresponding adapter MBean or just before it is explicitly removed from the adapter MBean during run-time.
 
Methods inherited from class org.norther.tammi.core.base.LogException
getArgument, getLevel, getLocalizedMessage, getLocalizedMessage, getLocalizedMessage, getMessageLog, getTime, 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, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.norther.tammi.spray.filter.ExceptionFilter
getLocalizedMessage, getMessage
 

Constructor Detail

DefaultExceptionFilter

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

Parameters:
code - the status code.

DefaultExceptionFilter

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

Parameters:
code - the status code.
argument - the argument string.

DefaultExceptionFilter

public DefaultExceptionFilter(int code,
                              Throwable cause)
Constructs an exception with a code and cause.

Parameters:
code - the status code.
cause - the cause throwable.

DefaultExceptionFilter

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

Parameters:
code - the status code.
argument - the argument string.
cause - the cause throwable.
Method Detail

premanaged

public void premanaged(MBeanDelegate adapter)
                throws Exception
Description copied from interface: Manageable
This method is called when the implementing adaptee is trying to be managed either during pre-registration of the corresponding adapter MBean or just before it is explicitly added to the adapter MBean during run-time.

Specified by:
premanaged in interface Manageable
Parameters:
adapter - the managing adapter.
Throws:
Exception - if the adaptee refused to be managed.

postmanaged

public void postmanaged()
Description copied from interface: Manageable
This method is called when the implementing adaptee has been managed either during post-registration of the corresponding adapter MBean or just after it is explicitly added to the adapter MBean during run-time.

Specified by:
postmanaged in interface Manageable

unmanaged

public void unmanaged()
               throws Exception
Description copied from interface: Manageable
This method is called when the implementing adaptee is unmanaged either during pre-deregistration of the corresponding adapter MBean or just before it is explicitly removed from the adapter MBean during run-time.

Specified by:
unmanaged in interface Manageable
Throws:
Exception - if the adaptee refused to be unmanaged.

getStatusCode

public int getStatusCode()
Description copied from interface: ExceptionFilter
Gets the status code.

Specified by:
getStatusCode in interface ExceptionFilter
Returns:
the status code.

init

public void init(FilterConfig config)
          throws ServletException
Specified by:
init in interface Filter
Throws:
ServletException

destroy

public void destroy()
Specified by:
destroy in interface Filter

doFilter

public void doFilter(ServletRequest request,
                     ServletResponse response,
                     FilterChain chain)
              throws ServletException,
                     IOException
Specified by:
doFilter in interface Filter
Throws:
ServletException
IOException

getObjectName

public ObjectName getObjectName()
Gets the object name.

Returns:
the object name or null.

isRegistered

public boolean isRegistered()
Checks whether registered.

Returns:
true if registered, false otherwise.

getMBeanServer

public MBeanServer getMBeanServer()
Gets the MBean server.

Returns:
the MBean server or null.

getMessage

protected CharSequence getMessage(ServletRequest request,
                                  ServletResponse response,
                                  FilterChain chain)
Returns the message to produce.

Parameters:
request - the request.
response - the response.
chain - the filter chain.
Returns:
the message.

prepareCommit

protected void prepareCommit(ServletRequest request,
                             ServletResponse response,
                             FilterChain chain)
A callback for subclasses to modify the response before committing.

Parameters:
request - the request.
response - the response.
chain - the filter chain.


Copyright © 2004 The Norther Organization. All rights reserved.