cziegeler 2003/06/10 12:38:54
Modified: src/blocks/portal/conf portal.xconf src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl XSLTAspect.java Added: src/blocks/portal/java/org/apache/cocoon/components/variables NOPVariableResolver.java DefaultVariableResolverFactory.java PreparedVariableResolver.java VariableResolverFactory.java VariableResolver.java Log: Making portal skinable by adding a common variable resolver factory (taken from the treeprocessor) Revision Changes Path 1.1 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/components/variables/NOPVariableResolver.java Index: NOPVariableResolver.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. */ package org.apache.cocoon.components.variables; import org.apache.avalon.framework.activity.Disposable; import org.apache.cocoon.sitemap.PatternException; /** * No-op implementation of [EMAIL PROTECTED] VariableResolver} for constant expressions * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * * @version CVS $Id: NOPVariableResolver.java,v 1.1 2003/06/10 19:38:54 cziegeler Exp $ */ public class NOPVariableResolver implements VariableResolver, Disposable { protected String expression; public NOPVariableResolver(String expression) { this.expression = this.unescape(expression); } /** * Unescape an expression that doesn't need to be resolved, but may contain * escaped '{' characters. * * @param expression the expression to unescape. * @return the unescaped result, or <code>expression</code> if unescaping isn't necessary. */ protected String unescape(String expression) { // Does it need escaping ? if (expression == null || expression.indexOf("\\{") == -1) { return expression; } StringBuffer buf = new StringBuffer(); for (int i = 0; i < expression.length(); i++) { char ch = expression.charAt(i); if (ch != '\\' || i >= (expression.length() - 1) || expression.charAt(i+1) != '{') { buf.append(ch); } } return buf.toString(); } /* (non-Javadoc) * @see org.apache.cocoon.components.variables.VariableResolver#resolve() */ public String resolve() throws PatternException { return this.expression; } public void dispose() { } } 1.1 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/components/variables/DefaultVariableResolverFactory.java Index: DefaultVariableResolverFactory.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. */ package org.apache.cocoon.components.variables; import org.apache.avalon.framework.activity.Disposable; import org.apache.avalon.framework.component.Component; import org.apache.avalon.framework.component.ComponentException; import org.apache.avalon.framework.component.ComponentManager; import org.apache.avalon.framework.component.Composable; 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.thread.ThreadSafe; import org.apache.cocoon.sitemap.PatternException; /** * This factory component creates a [EMAIL PROTECTED] VariableResolver} for an expression. * A [EMAIL PROTECTED] VariableResolver} can then be used at runtime to resolve * a variable with the current value. * A variable can contain dynamic parts that are contained in {...}, * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * * @version CVS $Id: DefaultVariableResolverFactory.java,v 1.1 2003/06/10 19:38:54 cziegeler Exp $ */ public class DefaultVariableResolverFactory extends AbstractLogEnabled implements ThreadSafe, VariableResolverFactory, Component, Composable, Contextualizable { protected ComponentManager manager; protected Context context; /** * Get a resolver for a given expression. Chooses the most efficient implementation * depending on <code>expression</code>. * Don't forget to release the resolver */ public VariableResolver lookup(String expression) throws PatternException { if ( this.needsResolve( expression ) ) { return new PreparedVariableResolver( expression, this.manager, this.context); } else { return new NOPVariableResolver( expression ); } } public void release(VariableResolver resolver) { if ( resolver != null ) { ((Disposable)resolver).dispose(); } } /** * Does an expression need resolving (i.e. contain {...} patterns) ? */ protected boolean needsResolve(String expression) { if (expression == null || expression.length() == 0) { return false; } // Is the first char a '{' ? if (expression.charAt(0) == '{') { return true; } if (expression.length() < 2) { return false; } // Is there any unescaped '{' ? int pos = 1; while ( (pos = expression.indexOf('{', pos)) != -1) { // Found a '{' : is it escaped ? if (expression.charAt(pos - 1) != '\\') { // No : need to resolve return true; } pos++; } // Nothing found... return false; } /* (non-Javadoc) * @see org.apache.avalon.framework.component.Composable#compose(org.apache.avalon.framework.component.ComponentManager) */ public void compose(ComponentManager manager) throws ComponentException { this.manager = manager; } /* (non-Javadoc) * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context) */ public void contextualize(Context context) throws ContextException { this.context = context; } } 1.1 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/components/variables/PreparedVariableResolver.java Index: PreparedVariableResolver.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. */ package org.apache.cocoon.components.variables; import java.util.ArrayList; import java.util.List; import org.apache.avalon.framework.component.ComponentException; import org.apache.avalon.framework.component.ComponentManager; import org.apache.avalon.framework.component.ComponentSelector; import org.apache.avalon.framework.configuration.ConfigurationException; import org.apache.avalon.framework.context.Context; import org.apache.avalon.framework.thread.ThreadSafe; import org.apache.cocoon.components.ContextHelper; import org.apache.cocoon.components.modules.input.InputModule; import org.apache.cocoon.sitemap.PatternException; /** * Prepared implementation of [EMAIL PROTECTED] VariableResolver} for fast evaluation. * * @author <a href="mailto:[EMAIL PROTECTED]">Sylvain Wallez</a> * @author <a href="mailto:[EMAIL PROTECTED]">Torsten Curdt</a> * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * @version CVS $Id: PreparedVariableResolver.java,v 1.1 2003/06/10 19:38:54 cziegeler Exp $ */ public class PreparedVariableResolver extends NOPVariableResolver { protected ComponentManager manager; protected ComponentSelector selector; protected Context context; protected List items = new ArrayList(); // Special constants used for levels static final int LITERAL = -2; static final int THREADSAFE_MODULE = -3; static final int STATEFUL_MODULE = -4; private static final Integer LITERAL_OBJ = new Integer(LITERAL); private static final Integer THREADSAFE_MODULE_OBJ = new Integer(THREADSAFE_MODULE); private static final Integer STATEFUL_MODULE_OBJ = new Integer(STATEFUL_MODULE); public PreparedVariableResolver(String expr, ComponentManager manager, Context context) throws PatternException { super(null); this.expression = expr; this.manager = manager; this.context = context; int length = expr.length(); int prev = 0; // position after last closing brace compile : while(prev < length) { // find next unescaped '{' int pos = prev; while(pos < length && (pos = expr.indexOf('{', pos)) != -1 && (pos != 0 && expr.charAt(pos - 1) == '\\')) { pos++; } if (pos >= length || pos == -1) { // no more braces : add ending literal if (prev < length) { addLiteral(expr.substring(prev)); } break compile; } // Pass closing brace pos++; // Add litteral strings between closing and next opening brace if (prev < pos-1) { addLiteral(expr.substring(prev, pos - 1)); } int end = expr.indexOf('}', pos); if (end == -1) { throw new PatternException("Unmatched '{' in " + expr); } int colon = expr.indexOf(':', pos); if (colon != -1 && colon < end) { String module = expr.substring(pos, colon); String variable = expr.substring(colon + 1, end); // Module used addModuleVariable(module, variable); } else { throw new PatternException("Unknown variable format " + expr.substring(pos, end)); } prev = end + 1; } } protected void addLiteral(String litteral) { this.items.add(LITERAL_OBJ); this.items.add(litteral); } protected void addModuleVariable(String moduleName, String variable) throws PatternException { if (this.selector == null) { try { // First access to a module : lookup selector this.selector = (ComponentSelector)this.manager.lookup(InputModule.ROLE + "Selector"); } catch(ComponentException ce) { throw new PatternException("Cannot access input modules selector", ce); } } // Get the module InputModule module; try { module = (InputModule)this.selector.select(moduleName); } catch(ComponentException ce) { throw new PatternException("Cannot get InputModule named '" + moduleName + "' in expression '" + this.expression + "'", ce); } // Is this module threadsafe ? if (module instanceof ThreadSafe) { this.items.add(THREADSAFE_MODULE_OBJ); this.items.add(module); this.items.add(variable); } else { // Statefull module : release it this.selector.release(module); this.items.add(STATEFUL_MODULE_OBJ); this.items.add(moduleName); this.items.add(variable); } } public String resolve() throws PatternException { List mapStack = null; // get the stack only when necessary - lazy inside the loop int stackSize = 0; StringBuffer result = new StringBuffer(); for (int i = 0; i < this.items.size(); i++) { int type = ((Integer)this.items.get(i)).intValue(); switch(type) { case LITERAL : result.append(items.get(++i)); break; case THREADSAFE_MODULE : { InputModule module = (InputModule)items.get(++i); String variable = (String)items.get(++i); try { Object value = module.getAttribute(variable, null, ContextHelper.getObjectModel(this.context)); if (value != null) { result.append(value); } } catch(ConfigurationException confEx) { throw new PatternException("Cannot get variable '" + variable + "' in expression '" + this.expression + "'", confEx); } } break; case STATEFUL_MODULE : { InputModule module = null; String moduleName = (String)items.get(++i); String variableName = (String)items.get(++i); try { module = (InputModule)this.selector.select(moduleName); Object value = module.getAttribute(variableName, null, ContextHelper.getObjectModel(this.context)); if (value != null) { result.append(value); } } catch(ComponentException compEx) { throw new PatternException("Cannot get module '" + moduleName + "' in expression '" + this.expression + "'", compEx); } catch(ConfigurationException confEx) { throw new PatternException("Cannot get variable '" + variableName + "' in expression '" + this.expression + "'", confEx); } finally { this.selector.release(module); } } break; } } return result.toString(); } public void dispose() { super.dispose(); if (this.selector != null) { for (int i = 0; i < this.items.size(); i++) { int type = ((Integer) this.items.get(i)).intValue(); switch (type) { case LITERAL: i++; // literal string break; case THREADSAFE_MODULE: i++; // module this.selector.release((InputModule) this.items.get(i)); i++; // variable break; case STATEFUL_MODULE: i += 2; // module name, variable break; default: } } this.manager.release(this.selector); this.selector = null; this.manager = null; } } } 1.1 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/components/variables/VariableResolverFactory.java Index: VariableResolverFactory.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. */ package org.apache.cocoon.components.variables; import org.apache.cocoon.sitemap.PatternException; /** * This factory component creates a [EMAIL PROTECTED] VariableResolver} for an expression. * A [EMAIL PROTECTED] VariableResolver} can then be used at runtime to resolve * a variable with the current value. * A variable can contain dynamic parts that are contained in {...}, * * NOTE: This interface is work in progress, so chances are that it will * change. * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * * @version CVS $Id: VariableResolverFactory.java,v 1.1 2003/06/10 19:38:54 cziegeler Exp $ */ public interface VariableResolverFactory { String ROLE = VariableResolverFactory.class.getName(); /** * Get a resolver for a given expression. Chooses the most efficient implementation * depending on <code>expression</code>. * Don't forget to release the resolver */ VariableResolver lookup(String expression) throws PatternException; void release(VariableResolver resolver); } 1.1 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/components/variables/VariableResolver.java Index: VariableResolver.java =================================================================== /* ============================================================================ The Apache Software License, Version 1.1 ============================================================================ Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modifica- tion, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: "This product includes software developed by the Apache Software Foundation (http://www.apache.org/)." Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. 4. The names "Apache Cocoon" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact [EMAIL PROTECTED] 5. Products derived from this software may not be called "Apache", nor may "Apache" appear in their name, without prior written permission of the Apache Software Foundation. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. This software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally created by Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache Software Foundation, please see <http://www.apache.org/>. */ package org.apache.cocoon.components.variables; import org.apache.cocoon.sitemap.PatternException; /** * Object that resolves the {...} patterns and returns the current value. * * NOTE: This interface is work in progress, so chances are that it will * change. * * @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a> * * @version CVS $Id: VariableResolver.java,v 1.1 2003/06/10 19:38:54 cziegeler Exp $ */ public interface VariableResolver { /** * Resolve all {...} patterns . */ String resolve() throws PatternException; } 1.15 +6 -4 cocoon-2.1/src/blocks/portal/conf/portal.xconf Index: portal.xconf =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/conf/portal.xconf,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- portal.xconf 6 Jun 2003 11:35:46 -0000 1.14 +++ portal.xconf 10 Jun 2003 19:38:54 -0000 1.15 @@ -66,7 +66,7 @@ <renderer name="column" class="org.apache.cocoon.portal.layout.renderer.impl.AspectRenderer" logger="portal" > <aspects> <aspect type="xslt"> - <parameter name="style" value="skins/common/styles/column.xsl"/> + <parameter name="style" value="{global:skin}styles/column.xsl"/> </aspect> <aspect type="composite-content"> <parameter name="tag-name" value="column-layout"/> @@ -76,7 +76,7 @@ <renderer name="row" class="org.apache.cocoon.portal.layout.renderer.impl.AspectRenderer" logger="portal" > <aspects> <aspect type="xslt"> - <parameter name="style" value="skins/common/styles/row.xsl"/> + <parameter name="style" value="{global:skin}styles/row.xsl"/> </aspect> <aspect type="composite-content"> <parameter name="tag-name" value="row-layout"/> @@ -86,7 +86,7 @@ <renderer name="tab" class="org.apache.cocoon.portal.layout.renderer.impl.AspectRenderer" logger="portal" > <aspects> <aspect type="xslt"> - <parameter name="style" value="skins/common/styles/tab.xsl"/> + <parameter name="style" value="{global:skin}styles/tab.xsl"/> </aspect> <aspect type="tab-content"> <parameter name="tag-name" value="tab-layout"/> @@ -96,7 +96,7 @@ <renderer name="window" class="org.apache.cocoon.portal.layout.renderer.impl.AspectRenderer" logger="portal" > <aspects> <aspect type="xslt"> - <parameter name="style" value="skins/common/styles/window.xsl"/> + <parameter name="style" value="{global:skin}styles/window.xsl"/> </aspect> <aspect type="window"> <parameter name="tag-name" value="window"/> @@ -202,4 +202,6 @@ <mapping-source source="copletinstancedata">context://samples/portal/profiles/mapping/copletinstancedata.xml</mapping-source> </component> <component class="org.apache.cocoon.portal.profile.impl.MapSourceAdapter" role="org.apache.cocoon.portal.profile.impl.MapSourceAdapter" /> + + <component class="org.apache.cocoon.components.variables.DefaultVariableResolverFactory" role="org.apache.cocoon.components.variables.VariableResolverFactory" /> </xconf> 1.3 +21 -2 cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/XSLTAspect.java Index: XSLTAspect.java =================================================================== RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/XSLTAspect.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- XSLTAspect.java 16 May 2003 11:39:11 -0000 1.2 +++ XSLTAspect.java 10 Jun 2003 19:38:54 -0000 1.3 @@ -55,11 +55,14 @@ import javax.xml.transform.sax.SAXResult; import javax.xml.transform.sax.TransformerHandler; +import org.apache.avalon.framework.component.Component; import org.apache.avalon.framework.component.ComponentException; import org.apache.avalon.framework.component.ComponentManager; import org.apache.avalon.framework.component.Composable; import org.apache.avalon.framework.logger.AbstractLogEnabled; import org.apache.avalon.framework.thread.ThreadSafe; +import org.apache.cocoon.components.variables.VariableResolver; +import org.apache.cocoon.components.variables.VariableResolverFactory; import org.apache.cocoon.portal.PortalService; import org.apache.cocoon.portal.layout.Layout; import org.apache.cocoon.portal.layout.renderer.aspect.RendererAspect; @@ -129,7 +132,23 @@ protected String getStylesheetURI(RendererAspectContext context, Layout layout) { // FIXME Get the stylesheet either from a layout attribute or another aspect - return context.getAspectParameters().getParameter("style", "NOTFOUND"); + String stylesheet = context.getAspectParameters().getParameter("style", "NOTFOUND"); + // TODO make this more faster + VariableResolverFactory factory = null; + try { + factory = (VariableResolverFactory) this.manager.lookup(VariableResolverFactory.ROLE); + VariableResolver resolver = null; + try { + resolver = factory.lookup( stylesheet ); + stylesheet = resolver.resolve(); + } finally { + factory.release( resolver ); + } + } catch (Exception ignore) { + } finally { + this.manager.release((Component)factory); + } + return stylesheet; } /* (non-Javadoc) * @see org.apache.avalon.framework.component.Composable#compose(org.apache.avalon.framework.component.ComponentManager)