org.apache.cocoon.acting
public class: SectionCutterAction [javadoc |
source]
java.lang.Object
org.apache.avalon.framework.logger.AbstractLogEnabled
org.apache.cocoon.acting.AbstractAction
org.apache.cocoon.acting.AbstractConfigurableAction
org.apache.cocoon.acting.ConfigurableComposerAction
org.apache.cocoon.acting.SectionCutterAction
All Implemented Interfaces:
org.apache.avalon.framework.thread.ThreadSafe, org.apache.avalon.framework.component.Composable, org.apache.avalon.framework.configuration.Configurable, Action
An action designed to set any number of variables, based on the current site
section. The action matches the request uri against a configurable set of
regular expressions (note: currently not implemented. Checking the beggining
of the URI). When an expression matches, the action will set the configured
variable in the Map.
- author:
< - a href="mailto:sergio.carvalho@acm.org">Sergio Carvalho
- version:
CVS - $Id: SectionCutterAction.java,v 1.6 2002/02/22 06:58:02 cziegeler Exp $
| Field Summary |
|---|
| Vector | sections | |
| Method from org.apache.cocoon.acting.SectionCutterAction Summary: |
|---|
|
act, configure |
| Methods from org.apache.cocoon.acting.ConfigurableComposerAction: |
|---|
|
compose |
| Methods from org.apache.cocoon.acting.AbstractConfigurableAction: |
|---|
|
configure |
| Method from org.apache.cocoon.acting.SectionCutterAction Detail: |
public Map act(Redirector redirector,
SourceResolver resolver,
Map objectModel,
String src,
Parameters par) throws Exception {
Request request = ObjectModelHelper.getRequest(objectModel);
Map results = new HashMap();
if (request != null) {
boolean hasMatched = false;
if (getLogger().isDebugEnabled()) {
getLogger().debug("Matching against '" + request.getSitemapURI() + "'");
}
for (Enumeration sectionsEnum = sections.elements(); sectionsEnum.hasMoreElements() && !hasMatched; ) {
Section section = (Section) sectionsEnum.nextElement();
if (section.matches(request.getSitemapURI())) {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Matched '" + section.matchExpression + "'");
}
section.fillMap(results);
hasMatched = true;
}
}
} else {
getLogger().warn("Request was null");
}
return Collections.unmodifiableMap(results);
}
A simple Action that logs if the Session object has been
created |
public void configure(Configuration conf) throws ConfigurationException {
try {
Configuration[] sectionConfigurations;
sectionConfigurations = conf.getChildren("section");
for (int i = 0; i < sectionConfigurations.length; i++) {
try {
if (getLogger().isDebugEnabled()) {
getLogger().debug("Creating one section");
}
sections.add(new Section(sectionConfigurations[i]));
} catch (Exception e) {
getLogger().error("Failed configuring section", e);
if (getLogger().isDebugEnabled()) {
// In production, try to continue. Assume that one rotten section config can't stop the whole app.
// When debug is enabled, scream, screech and grind to a halt.
throw (e);
}
}
}
} catch (Exception e) {
throw new ConfigurationException("Cannot configure action", e);
}
}
Description of the Method |