org.apache.cocoon.selection
Class ExceptionSelector
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.cocoon.selection.AbstractSwitchSelector
org.apache.cocoon.selection.ExceptionSelector
- All Implemented Interfaces:
- Configurable, LogEnabled, Selector, SwitchSelector, ThreadSafe
- Direct Known Subclasses:
- XPathExceptionSelector
- public class ExceptionSelector
- extends AbstractSwitchSelector
- implements Configurable
In a <map:handle-errors>, selects depending on the exception that caused the error.
The configuration of this selector allows to map exception class names to symbolic names
that are used in the <map:when> alternatives.
Example configuration :
<map:selector type="error" src="....ExceptionSelector">
<exception class="org.xml.sax.SAXException" name="sax" unroll="true"/>
<exception name="not-found" class="org.apache.cocoon.ResourceNotFoundException"/>
<exception class="org.apache.cocoon.ProcessingException" unroll="true"/>
<exception name="denied" class="java.security.SecurityException"/>
<exception name="denied" class="my.comp.auth.AuthenticationFailure"/>
</map:selector>
This example shows several features :
the "class" is the class name of the exception (which can be any Throwable
),
an exception can be given a name, which is used in the <map:when> tests,
an exception can be unrolled, meaning we try to get its cause and then consider this cause for
the exception name
Note that both "name" and "unroll" can be specified. In that case, we first try to unroll the exception,
and if none of the causes has a name, then the "name" attribute is considered.
- Since:
- 2.1
- Version:
- CVS $Id: ExceptionSelector.java 280632 2005-09-13 19:35:46Z sylvain $
- Author:
- Jürgen Seitz, Björn Lütkemeier, Sylvain Wallez
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ExceptionSelector
public ExceptionSelector()
configure
public void configure(Configuration conf)
throws ConfigurationException
- Specified by:
configure
in interface Configurable
- 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
- Specified by:
getSelectorContext
in class AbstractSwitchSelector
- Parameters:
objectModel
- The Map
containing object of the
calling environment which may be used
to select values to test the expression.parameters
- The sitemap parameters, as specified by
<parameter/> tags.
- Returns:
- selector context
- See Also:
ObjectModelHelper.getThrowable(java.util.Map)
select
public boolean select(String expression,
Object selectorContext)
- Description copied from class:
AbstractSwitchSelector
- Selectors test pattern against some objects in a
Map
model and signals success with the returned boolean value
- Specified by:
select
in interface SwitchSelector
- Specified by:
select
in class AbstractSwitchSelector
- Parameters:
expression
- The expression to test.
- Returns:
- boolean Signals successful test.
Copyright ? 1999-2005 The Apache Software Foundation. All Rights Reserved.