org.apache.cocoon.selection
Class XPathExceptionSelector

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.cocoon.selection.AbstractSwitchSelector
          extended byorg.apache.cocoon.selection.ExceptionSelector
              extended byorg.apache.cocoon.selection.XPathExceptionSelector
All Implemented Interfaces:
Configurable, LogEnabled, Selector, SwitchSelector, ThreadSafe

public class XPathExceptionSelector
extends ExceptionSelector
implements Configurable

Additional to the inherited functionality from its superclass ExceptionSelector, this selector allows to define xpath expressions to evaluate supplemental information given in the thrown exception. The configuration of this selector allows to map not only exceptions but also xpath expressions to symbolic names that are used in the <map:when> alternatives.

Example configuration :

   <map:selector type="error" src="....XPathExceptionSelector">
     <exception name="denied" class="my.comp.auth.AuthenticationFailure">
       <xpath name="PasswordWrong" test="authCode=10"/>
       <xpath name="PasswordExpired" test="errorCode=11"/>
       <xpath name="AccessForbidden" test="errorCode>11"/>
     </exception>
   </map:selector>
 
This example shows several features :
  • the test is the xpath expression that will be evaluated against the exception ,
  • an xpath expression can be given a name, which is used in the <map:when> tests,
  • Since:
    2.1
    Version:
    CVS $Id: XPathExceptionSelector.java 30941 2004-07-29 19:56:58Z vgritsenko $
    Author:
    Jürgen Seitz, Björn Lütkemeier

    Field Summary
     
    Fields inherited from interface org.apache.cocoon.selection.SwitchSelector
    ROLE
     
    Constructor Summary
    XPathExceptionSelector()
               
     
    Method Summary
     void configure(Configuration conf)
               
     Object getSelectorContext(Map objectModel, Parameters parameters)
              Compute the exception type, given the configuration and the exception stored in the object model.
     
    Methods inherited from class org.apache.cocoon.selection.ExceptionSelector
    select
     
    Methods inherited from class org.apache.cocoon.selection.AbstractSwitchSelector
    select
     
    Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
    enableLogging, getLogger, setupLogger, setupLogger, setupLogger
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    XPathExceptionSelector

    public XPathExceptionSelector()
    Method Detail

    configure

    public void configure(Configuration conf)
                   throws ConfigurationException
    Specified by:
    configure in interface Configurable
    Overrides:
    configure in class ExceptionSelector
    Throws:
    ConfigurationException

    getSelectorContext

    public Object getSelectorContext(Map objectModel,
                                     Parameters parameters)
    Compute the exception type, given the configuration and the exception stored in the object model.

    Specified by:
    getSelectorContext in interface SwitchSelector
    Overrides:
    getSelectorContext in class ExceptionSelector
    See Also:
    ObjectModelHelper.getThrowable(java.util.Map)


    Copyright ? 1999-2005 The Apache Software Foundation. All Rights Reserved.