You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by da...@apache.org on 2005/06/01 17:13:04 UTC
svn commit: r179385 -
/cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockManager.java
/cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlocksManager.java
Author: danielf
Date: Wed Jun 1 08:13:02 2005
New Revision: 179385
URL: http://svn.apache.org/viewcvs?rev=179385&view=rev
Log:
Implemented polymorphic block inheritance. For the moment one have to call the super block explicitly through block:super:, don't know if this is ok or if we should have implicit sitemap inheritance. Also removed BlockManager.getServiceManager(), no need for it ATM, there will always be a TreeProcessor at the processor stack in cases when the current serviceManager could be needed.
Modified:
cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockManager.java
cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlocksManager.java
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockManager.java?rev=179385&r1=179384&r2=179385&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockManager.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlockManager.java Wed Jun 1 08:13:02 2005
@@ -56,6 +56,7 @@
public static String ROLE = BlockManager.class.getName();
public static String NAME = BlockManager.class.getName() + "-name";
+ public static String SUPER = "super";
private ServiceManager parentServiceManager;
private ServiceManager serviceManager;
@@ -69,6 +70,7 @@
private String location;
private String mountPath;
private String sitemapPath;
+ private String superId;
private Map connections = new HashMap();
private Map properties = new HashMap();
@@ -95,22 +97,25 @@
config.getChild("connections").getChildren("connection");
for (int i = 0; i < connections.length; i++) {
Configuration connection = connections[i];
- this.connections.put(connection.getAttribute("name"),
- connection.getAttribute("block"));
- getLogger().debug("connection: " +
- " name=" + connection.getAttribute("name") +
- " block=" + connection.getAttribute("block"));
+ String name = connection.getAttribute("name");
+ String block = connection.getAttribute("block");
+ if (BlockManager.SUPER.equals(name)) {
+ superId = block;
+ getLogger().debug("super: " + " block=" + block);
+ } else {
+ this.connections.put(name, block);
+ getLogger().debug("connection: " + " name=" + name + " block=" + block);
+ }
}
Configuration[] properties =
config.getChild("properties").getChildren("property");
for (int i = 0; i < properties.length; i++) {
Configuration property = properties[i];
- this.properties.put(property.getAttribute("name"),
- property.getAttribute("value"));
- getLogger().debug("property: " +
- " name=" + property.getAttribute("name") +
- " value=" + property.getAttribute("value"));
+ String name = property.getAttribute("name");
+ String value = property.getAttribute("value");
+ this.properties.put(name, value);
+ getLogger().debug("property: " + " name=" + name + " value=" + value);
}
// Read the block.xml file
@@ -225,12 +230,6 @@
this.blocksManager = blocksManager;
}
- // This is for being able to call EnvironmentHelper.enterProcessor
- // in BlocksManager, don't know if it really is needed
- public ServiceManager getServiceManager() {
- return this.serviceManager;
- }
-
// The Processor methods
public boolean process(Environment environment) throws Exception {
@@ -238,17 +237,51 @@
if (blockName != null) {
// Request to other block.
- // The block name should not be used in the recieving block.
- environment.removeAttribute(BlockManager.NAME);
- String blockId = (String)this.connections.get(blockName);
- if (blockId == null) {
- throw new ProcessingException("Unknown block name " + blockName);
+ if (BlockManager.SUPER.equals(blockName)) {
+ // Explicit call to super block
+ if (superId == null) {
+ throw new ProcessingException("block:super: with no super block");
+ }
+ // The block name should not be used in the recieving block.
+ environment.removeAttribute(BlockManager.NAME);
+ getLogger().debug("Resolving super block to " + superId);
+ return this.blocksManager.process(superId, environment, true);
+ } else {
+ // Call to named block
+ String blockId = (String)this.connections.get(blockName);
+ if (blockId != null) {
+ getLogger().debug("Resolving block: " + blockName + " to " + blockId);
+ // The block name should not be used in the recieving block.
+ environment.removeAttribute(BlockManager.NAME);
+ return this.blocksManager.process(blockId, environment);
+ } else if (superId != null) {
+ // If there is a super block, the connection might
+ // be defined there instead.
+ return this.blocksManager.process(superId, environment, true);
+ } else {
+ throw new ProcessingException("Unknown block name " + blockName);
+ }
}
- getLogger().debug("Resolving block: " + blockName + " to " + blockId);
- return this.blocksManager.process(blockId, environment);
} else {
// Request to the own block
- return this.processor.process(environment);
+ boolean result = this.processor.process(environment);
+
+ return result;
+
+ // Pipelines seem to throw an exception instead of
+ // returning false when the pattern is not found. For the
+ // moment an explicit call of the super block is called in
+ // the end of the sitemap. It might be better to be
+ // explicit about it anyway.
+
+// if (result) {
+// return true;
+// } else if (superId != null) {
+// // Wasn't defined in the current block try super block
+// return this.blocksManager.process(superId, environment, true);
+// } else {
+// return false;
+// }
}
}
Modified: cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlocksManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlocksManager.java?rev=179385&r1=179384&r2=179385&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlocksManager.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/components/blocks/BlocksManager.java Wed Jun 1 08:13:02 2005
@@ -1,256 +1,272 @@
-/*
- * Copyright 1999-2005 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.cocoon.components.blocks;
-
-import java.io.IOException;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeMap;
-
-import org.apache.avalon.framework.activity.Disposable;
-import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.configuration.Configurable;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
-import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.excalibur.source.Source;
-import org.apache.excalibur.source.SourceResolver;
-import org.apache.cocoon.components.LifecycleHelper;
-import org.apache.cocoon.components.container.CocoonServiceManager;
-import org.apache.cocoon.core.Core;
-import org.apache.cocoon.core.CoreUtil;
-import org.apache.cocoon.environment.Environment;
-import org.apache.cocoon.environment.internal.EnvironmentHelper;
-import org.xml.sax.SAXException;
-
-/**
- * @version SVN $Id$
- */
-public class BlocksManager
- extends AbstractLogEnabled
- implements Configurable, Contextualizable, Disposable, Initializable, Serviceable, ThreadSafe {
-
- public static String ROLE = BlocksManager.class.getName();
- public static String CORE_COMPONENTS_XCONF =
- "resource://org/apache/cocoon/components/blocks/core-components.xconf";
- private ServiceManager serviceManager;
- private CocoonServiceManager blockServiceManager;
- private SourceResolver resolver;
- private Context context;
-
- private HashMap blockConfs = new HashMap();
- private HashMap blocks = new HashMap();
- private TreeMap mountedBlocks = new TreeMap(new InverseLexicographicalOrder());
-
- public void service(ServiceManager manager) throws ServiceException {
- this.serviceManager = manager;
- this.resolver = (SourceResolver) this.serviceManager.lookup(SourceResolver.ROLE);
- }
-
- public void contextualize(Context context) throws ContextException {
- this.context = context;
- }
-
- public void configure(Configuration config)
- throws ConfigurationException {
- String file = config.getAttribute("file");
- Source source = null;
- Configuration wiring = null;
-
- // Read the wiring file
- try {
- source = this.resolver.resolveURI(file);
- DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
- wiring = builder.build( source.getInputStream() );
- } catch (SAXException se) {
- String msg = "SAXException while reading " + file + ": " + se.getMessage();
- throw new ConfigurationException(msg, se);
- } catch (IOException ie) {
- String msg = "IOException while reading " + file + ": " + ie.getMessage();
- throw new ConfigurationException(msg, ie);
- } finally {
- this.resolver.release(source);
- }
- Configuration[] blocks = wiring.getChildren("block");
- for (int i = 0; i < blocks.length; i++) {
- Configuration block = blocks[i];
- getLogger().debug("BlocksManager configure: " + block.getName() +
- " id=" + block.getAttribute("id") +
- " location=" + block.getAttribute("location"));
- this.blockConfs.put(block.getAttribute("id"), block);
- }
- }
-
- public void initialize() throws Exception {
- getLogger().debug("Initializing the Blocks Manager");
-
- // Create a root service manager for blocks. This should be
- // the minimal number of components that are needed for any
- // block. Only components that not are context dependent
- // should be defined here. Block that depends on e.g. the root
- // context path should be defined in the BlockManager instead.
-
- Core core = (Core)this.serviceManager.lookup(Core.ROLE);
- ServiceManager blockParentServiceManager =
- new CoreUtil.RootServiceManager(null, core);
- this.blockServiceManager =
- new CocoonServiceManager(blockParentServiceManager);
-
- Source coreComponentsSource =
- this.resolver.resolveURI(CORE_COMPONENTS_XCONF);
- DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
- Configuration coreComponentsConf =
- builder.build(coreComponentsSource.getInputStream());
-
- LifecycleHelper.setupComponent(blockServiceManager,
- this.getLogger(),
- this.context,
- null,
- coreComponentsConf);
-
- // Create and store all blocks
-
- Iterator confIter = this.blockConfs.entrySet().iterator();
- while (confIter.hasNext()) {
- Map.Entry entry = (Map.Entry)confIter.next();
- Configuration blockConf = (Configuration)entry.getValue();
- getLogger().debug("Creating " + blockConf.getName() +
- " id=" + blockConf.getAttribute("id"));
- BlockManager blockManager = new BlockManager();
- LifecycleHelper.setupComponent(blockManager,
- this.getLogger(),
- this.context,
- blockServiceManager,
- blockConf);
- blockManager.setBlocksManager(this);
- this.blocks.put(entry.getKey(), blockManager);
- String mountPath = blockConf.getChild("mount").getAttribute("path", null);
- if (mountPath != null) {
- this.mountedBlocks.put(mountPath, blockManager);
- getLogger().debug("Mounted block " + blockConf.getAttribute("id") +
- " at " + mountPath);
- }
- }
- }
-
- public void dispose() {
- Iterator blocksIter = this.blocks.entrySet().iterator();
- while (blocksIter.hasNext()) {
- LifecycleHelper.dispose(blocksIter.next());
- }
- if (this.blockServiceManager != null) {
- LifecycleHelper.dispose(this.blockServiceManager);
- this.blockServiceManager = null;
- }
- this.blocks = null;
- this.mountedBlocks = null;
- if (this.serviceManager != null) {
- this.serviceManager.release(this.resolver);
- this.resolver = null;
- this.serviceManager = null;
- }
- }
-
- /*
- The BlocksManager could be merged with the Cocoon object and be
- responsible for all processing. In that case it should
- implement Processor, at the moment it is called from a protocol
- and delagates to a BlockManager, so there is no point in
- implementing the whole Processor interface.
-
- The largest mount point that is a prefix of the URI is
- chosen. The implementation could be made much more efficient.
- */
- public boolean process(Environment environment) throws Exception {
- String uri = environment.getURI();
- String oldPrefix = environment.getURIPrefix();
- String oldURI = uri;
- // The mount points start with '/' make sure that the URI also
- // does, so that they are compareable.
- if (uri.length() == 0 || uri.charAt(0) != '/') {
- uri = "/" + uri;
- }
- // All mount points that are before or equal to the URI in
- // lexicographical order. This includes all prefixes.
- Map possiblePrefixes = mountedBlocks.tailMap(uri);
- Iterator possiblePrefixesIt = possiblePrefixes.entrySet().iterator();
- BlockManager block = null;
- String mountPoint = null;
- // Find the largest prefix to the uri
- while (possiblePrefixesIt.hasNext()) {
- Map.Entry entry = (Map.Entry) possiblePrefixesIt.next();
- mountPoint = (String)entry.getKey();
- if (uri.startsWith(mountPoint)) {
- block = (BlockManager)entry.getValue();
- break;
- }
- }
- if (block == null) {
- return false;
- } else {
- // Resolve the URI relative to the mount point
- uri = uri.substring(mountPoint.length());
- getLogger().debug("Enter processing in block at " + mountPoint);
- try {
- environment.setURI("", uri);
- // It is important to set the current block each time
- // a new block is entered, this is used for the block
- // protocol
- EnvironmentHelper.enterProcessor(block, block.getServiceManager(), environment);
- return block.process(environment);
- } finally {
- EnvironmentHelper.leaveProcessor();
- environment.setURI(oldPrefix, oldURI);
- getLogger().debug("Leaving processing in block at " + mountPoint);
- }
- }
- }
-
- public boolean process(String blockId, Environment environment) throws Exception {
- BlockManager block = (BlockManager)this.blocks.get(blockId);
- if (block == null) {
- return false;
- } else {
- getLogger().debug("Enter processing in block " + blockId);
- try {
- // It is important to set the current block each time
- // a new block is entered, this is used for the block
- // protocol
- EnvironmentHelper.enterProcessor(block, block.getServiceManager(), environment);
- return block.process(environment);
- } finally {
- EnvironmentHelper.leaveProcessor();
- getLogger().debug("Leaving processing in block " + blockId);
- }
- }
- }
-
- private static class InverseLexicographicalOrder implements Comparator {
- public int compare(Object o1, Object o2) {
- return ((String)o2).compareTo((String)o1);
- }
- }
-}
+/*
+ * Copyright 1999-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.components.blocks;
+
+import java.io.IOException;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.TreeMap;
+
+import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;
+import org.apache.avalon.framework.context.Context;
+import org.apache.avalon.framework.context.ContextException;
+import org.apache.avalon.framework.context.Contextualizable;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.cocoon.components.LifecycleHelper;
+import org.apache.cocoon.components.container.CocoonServiceManager;
+import org.apache.cocoon.core.Core;
+import org.apache.cocoon.core.CoreUtil;
+import org.apache.cocoon.environment.Environment;
+import org.apache.cocoon.environment.internal.EnvironmentHelper;
+import org.xml.sax.SAXException;
+
+/**
+ * @version SVN $Id$
+ */
+public class BlocksManager
+ extends AbstractLogEnabled
+ implements Configurable, Contextualizable, Disposable, Initializable, Serviceable, ThreadSafe {
+
+ public static String ROLE = BlocksManager.class.getName();
+ public static String CORE_COMPONENTS_XCONF =
+ "resource://org/apache/cocoon/components/blocks/core-components.xconf";
+ private ServiceManager serviceManager;
+ private CocoonServiceManager blockServiceManager;
+ private SourceResolver resolver;
+ private Context context;
+
+ private HashMap blockConfs = new HashMap();
+ private HashMap blocks = new HashMap();
+ private TreeMap mountedBlocks = new TreeMap(new InverseLexicographicalOrder());
+
+ public void service(ServiceManager manager) throws ServiceException {
+ this.serviceManager = manager;
+ this.resolver = (SourceResolver) this.serviceManager.lookup(SourceResolver.ROLE);
+ }
+
+ public void contextualize(Context context) throws ContextException {
+ this.context = context;
+ }
+
+ public void configure(Configuration config)
+ throws ConfigurationException {
+ String file = config.getAttribute("file");
+ Source source = null;
+ Configuration wiring = null;
+
+ // Read the wiring file
+ try {
+ source = this.resolver.resolveURI(file);
+ DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
+ wiring = builder.build( source.getInputStream() );
+ } catch (SAXException se) {
+ String msg = "SAXException while reading " + file + ": " + se.getMessage();
+ throw new ConfigurationException(msg, se);
+ } catch (IOException ie) {
+ String msg = "IOException while reading " + file + ": " + ie.getMessage();
+ throw new ConfigurationException(msg, ie);
+ } finally {
+ this.resolver.release(source);
+ }
+ Configuration[] blocks = wiring.getChildren("block");
+ for (int i = 0; i < blocks.length; i++) {
+ Configuration block = blocks[i];
+ getLogger().debug("BlocksManager configure: " + block.getName() +
+ " id=" + block.getAttribute("id") +
+ " location=" + block.getAttribute("location"));
+ this.blockConfs.put(block.getAttribute("id"), block);
+ }
+ }
+
+ public void initialize() throws Exception {
+ getLogger().debug("Initializing the Blocks Manager");
+
+ // Create a root service manager for blocks. This should be
+ // the minimal number of components that are needed for any
+ // block. Only components that not are context dependent
+ // should be defined here. Block that depends on e.g. the root
+ // context path should be defined in the BlockManager instead.
+
+ Core core = (Core)this.serviceManager.lookup(Core.ROLE);
+ ServiceManager blockParentServiceManager =
+ new CoreUtil.RootServiceManager(null, core);
+ this.blockServiceManager =
+ new CocoonServiceManager(blockParentServiceManager);
+
+ Source coreComponentsSource =
+ this.resolver.resolveURI(CORE_COMPONENTS_XCONF);
+ DefaultConfigurationBuilder builder = new DefaultConfigurationBuilder();
+ Configuration coreComponentsConf =
+ builder.build(coreComponentsSource.getInputStream());
+
+ LifecycleHelper.setupComponent(blockServiceManager,
+ this.getLogger(),
+ this.context,
+ null,
+ coreComponentsConf);
+
+ // Create and store all blocks
+
+ Iterator confIter = this.blockConfs.entrySet().iterator();
+ while (confIter.hasNext()) {
+ Map.Entry entry = (Map.Entry)confIter.next();
+ Configuration blockConf = (Configuration)entry.getValue();
+ getLogger().debug("Creating " + blockConf.getName() +
+ " id=" + blockConf.getAttribute("id"));
+ BlockManager blockManager = new BlockManager();
+ LifecycleHelper.setupComponent(blockManager,
+ this.getLogger(),
+ this.context,
+ blockServiceManager,
+ blockConf);
+ blockManager.setBlocksManager(this);
+ this.blocks.put(entry.getKey(), blockManager);
+ String mountPath = blockConf.getChild("mount").getAttribute("path", null);
+ if (mountPath != null) {
+ this.mountedBlocks.put(mountPath, blockManager);
+ getLogger().debug("Mounted block " + blockConf.getAttribute("id") +
+ " at " + mountPath);
+ }
+ }
+ }
+
+ public void dispose() {
+ Iterator blocksIter = this.blocks.entrySet().iterator();
+ while (blocksIter.hasNext()) {
+ LifecycleHelper.dispose(blocksIter.next());
+ }
+ if (this.blockServiceManager != null) {
+ LifecycleHelper.dispose(this.blockServiceManager);
+ this.blockServiceManager = null;
+ }
+ this.blocks = null;
+ this.mountedBlocks = null;
+ if (this.serviceManager != null) {
+ this.serviceManager.release(this.resolver);
+ this.resolver = null;
+ this.serviceManager = null;
+ }
+ }
+
+ /*
+ The BlocksManager could be merged with the Cocoon object and be
+ responsible for all processing. In that case it should
+ implement Processor, at the moment it is called from a protocol
+ and delagates to a BlockManager, so there is no point in
+ implementing the whole Processor interface.
+
+ The largest mount point that is a prefix of the URI is
+ chosen. The implementation could be made much more efficient.
+ */
+ public boolean process(Environment environment) throws Exception {
+ String uri = environment.getURI();
+ String oldPrefix = environment.getURIPrefix();
+ String oldURI = uri;
+ // The mount points start with '/' make sure that the URI also
+ // does, so that they are compareable.
+ if (uri.length() == 0 || uri.charAt(0) != '/') {
+ uri = "/" + uri;
+ }
+ // All mount points that are before or equal to the URI in
+ // lexicographical order. This includes all prefixes.
+ Map possiblePrefixes = mountedBlocks.tailMap(uri);
+ Iterator possiblePrefixesIt = possiblePrefixes.entrySet().iterator();
+ BlockManager block = null;
+ String mountPoint = null;
+ // Find the largest prefix to the uri
+ while (possiblePrefixesIt.hasNext()) {
+ Map.Entry entry = (Map.Entry) possiblePrefixesIt.next();
+ mountPoint = (String)entry.getKey();
+ if (uri.startsWith(mountPoint)) {
+ block = (BlockManager)entry.getValue();
+ break;
+ }
+ }
+ if (block == null) {
+ return false;
+ } else {
+ // Resolve the URI relative to the mount point
+ uri = uri.substring(mountPoint.length());
+ getLogger().debug("Enter processing in block at " + mountPoint);
+ try {
+ environment.setURI("", uri);
+ // It is important to set the current block each time
+ // a new block is entered, this is used for the block
+ // protocol
+ EnvironmentHelper.enterProcessor(block, null, environment);
+ return block.process(environment);
+ } finally {
+ EnvironmentHelper.leaveProcessor();
+ environment.setURI(oldPrefix, oldURI);
+ getLogger().debug("Leaving processing in block at " + mountPoint);
+ }
+ }
+ }
+
+ public boolean process(String blockId, Environment environment) throws Exception {
+ return process(blockId, environment, false);
+ }
+
+ public boolean process(String blockId, Environment environment, boolean superCall)
+ throws Exception {
+ BlockManager block = (BlockManager)this.blocks.get(blockId);
+ if (block == null) {
+ return false;
+ } else if (superCall) {
+ getLogger().debug("Enter processing in super block " + blockId);
+ try {
+ // A super block should be called in the context of
+ // the called block to get polymorphic calls resolved
+ // in the right way. Therefore no new current block is
+ // set.
+ return block.process(environment);
+ } finally {
+ getLogger().debug("Leaving processing in super block " + blockId);
+ }
+ } else {
+ getLogger().debug("Enter processing in block " + blockId);
+ try {
+ // It is important to set the current block each time
+ // a new block is entered, this is used for the block
+ // protocol
+ EnvironmentHelper.enterProcessor(block, null, environment);
+ return block.process(environment);
+ } finally {
+ EnvironmentHelper.leaveProcessor();
+ getLogger().debug("Leaving processing in block " + blockId);
+ }
+ }
+ }
+
+ private static class InverseLexicographicalOrder implements Comparator {
+ public int compare(Object o1, Object o2) {
+ return ((String)o2).compareTo((String)o1);
+ }
+ }
+}