cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Konstantin Piroumian" <kpiroum...@apache.org>
Subject Re: cvs commit: cocoon-2.2/src/webapp/WEB-INF cocoon.xconf
Date Fri, 31 Oct 2003 13:18:48 GMT
Btw, won't it be better to inherit this module from AbstraxtJXPathModule the
same way as SystemPropertyModule does?
It would be a little bit more flexible, e.g. you could do something like
this:

<map:parameter name="version-details"
value="{cocoon-properties:concat('Major: ', substring-before(version, '.'),
', Minor: ', substring-after(version, '.'), ', Year: ', year)}"/>

Regards,
  Konstantin

----- Original Message ----- 
From: <unico@apache.org>
To: <cocoon-2.2-cvs@apache.org>
Sent: Friday, October 31, 2003 16:12
Subject: cvs commit: cocoon-2.2/src/webapp/WEB-INF cocoon.xconf


> unico       2003/10/31 05:12:06
>
>   Modified:    src/webapp/samples/modules menu.xml index.xhtml
sitemap.xmap
>                src/webapp/WEB-INF cocoon.xconf
>   Added:       src/java/org/apache/cocoon/components/modules/input
>                         PropertiesFileModule.java
>   Log:
>   new properties file input module
>
>   Revision  Changes    Path
>   1.9       +1 -0      cocoon-2.2/src/webapp/samples/modules/menu.xml
>
>   Index: menu.xml
>   ===================================================================
>   RCS file: /home/cvs/cocoon-2.2/src/webapp/samples/modules/menu.xml,v
>   retrieving revision 1.8
>   retrieving revision 1.9
>   diff -u -r1.8 -r1.9
>   --- menu.xml 18 May 2003 16:31:35 -0000 1.8
>   +++ menu.xml 31 Oct 2003 13:12:05 -0000 1.9
>   @@ -24,6 +24,7 @@
>        <menu-item label="ChainMetaModule" href="chain.xsp"/>
>        <menu-item label="RandomNumberModule" href="randomnumber.xsp"/>
>        <menu-item label="RealPathModule" href="realpath.xsp"/>
>   +    <menu-item label="PropertiesFileModule" href="properties.xsp"/>
>      </menu>
>
>      <menu label="Documentation">
>
>
>
>   1.5       +5 -1      cocoon-2.2/src/webapp/samples/modules/index.xhtml
>
>   Index: index.xhtml
>   ===================================================================
>   RCS file: /home/cvs/cocoon-2.2/src/webapp/samples/modules/index.xhtml,v
>   retrieving revision 1.4
>   retrieving revision 1.5
>   diff -u -r1.4 -r1.5
>   --- index.xhtml 17 May 2003 08:11:27 -0000 1.4
>   +++ index.xhtml 31 Oct 2003 13:12:05 -0000 1.5
>   @@ -57,9 +57,13 @@
>                <td><a href="randomnumber.xsp">randomnumber</a></td>
>                <td>Random number</td>
>              </tr>
>   -           <tr>
>   +          <tr>
>                <td><a href="realpath.xsp">realpath</a></td>
>                <td>Real filesystem paths of context paths</td>
>   +          </tr>
>   +          <tr>
>   +            <td><a href="properties.xsp">properties</a></td>
>   +            <td>Properties file values</td>
>              </tr>
>            </table>
>          </td>
>
>
>
>   1.7       +20 -2     cocoon-2.2/src/webapp/samples/modules/sitemap.xmap
>
>   Index: sitemap.xmap
>   ===================================================================
>   RCS file: /home/cvs/cocoon-2.2/src/webapp/samples/modules/sitemap.xmap,v
>   retrieving revision 1.6
>   retrieving revision 1.7
>   diff -u -r1.6 -r1.7
>   --- sitemap.xmap 17 May 2003 08:11:27 -0000 1.6
>   +++ sitemap.xmap 31 Oct 2003 13:12:05 -0000 1.7
>   @@ -261,7 +261,6 @@
>            <map:serialize />
>          </map:match>
>
>   -
>          <map:match pattern="content/realpath.xsp">
>            <map:generate type="serverpages" src="properties.xsp">
>              <map:parameter name="/" value="{realpath:/}"/>
>   @@ -275,6 +274,25 @@
>            </map:transform>
>            <map:serialize />
>          </map:match>
>   +
>   +      <map:match pattern="content/properties.xsp">
>   +        <map:generate type="serverpages" src="properties.xsp">
>   +          <map:parameter name="name" value="{cocoon-properties:name}"/>
>   +          <map:parameter name="Name" value="{cocoon-properties:Name}"/>
>   +          <map:parameter name="fullname"
value="{cocoon-properties:fullname}"/>
>   +          <map:parameter name="version"
value="{cocoon-properties:version}"/>
>   +          <map:parameter name="released.version"
value="{cocoon-properties:released.version}"/>
>   +          <map:parameter name="year" value="{cocoon-properties:year}"/>
>   +        </map:generate>
>   +        <map:transform src="properties2html.xsl">
>   +          <map:parameter name="title" value="Properties File Module
>   +            (PropertiesFileModule)"/>
>   +          <map:parameter name="description" value="PropertiesFileModule
provides access
>   +            to properties from a properties file. In this example the
keys identify properties in
>   +            resource://org/apache/cocoon/cocoon.properties"/>
>   +        </map:transform>
>   +        <map:serialize />
>   +      </map:match>
>
>          <!-- Menu generation -->
>          <map:match pattern="menu/*">
>
>
>
>   1.1
cocoon-2.2/src/java/org/apache/cocoon/components/modules/input/PropertiesFil
eModule.java
>
>   Index: PropertiesFileModule.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
>       apache@apache.org.
>
>    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  <stefano@apache.org>. For more  information on the
Apache
>    Software Foundation, please see <http://www.apache.org/>.
>
>   */
>   package org.apache.cocoon.components.modules.input;
>
>   import java.io.IOException;
>   import java.io.InputStream;
>   import java.util.Iterator;
>   import java.util.Map;
>   import java.util.Properties;
>
>   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.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;
>
>   /**
>    * Input module for accessing properties in a properties file.
>    *
>    * <p>
>    *  The properties file can only be configured statically and
>    *  is resolved via the SourceResolver system.
>    * </p>
>    *
>    * @author <a href="mailto:unico@apache.org">Unico Hommes</a>
>    */
>   public class PropertiesFileModule extends AbstractLogEnabled
>   implements InputModule, Serviceable, Configurable, ThreadSafe {
>
>       private SourceResolver m_resolver;
>
>       private Properties m_properties;
>
>
>       public void service(ServiceManager manager) throws ServiceException
{
>           m_resolver = (SourceResolver)
manager.lookup(SourceResolver.ROLE);
>       }
>
>       /**
>        * Configure the location of the properties file:
>        * <p>
>        *  <code>&lt;file src="resource://my.properties" /&gt;</code>
>        * </p>
>        */
>       public void configure(Configuration configuration) throws
ConfigurationException {
>           String file =
configuration.getChild("file").getAttribute("src");
>           load(file);
>       }
>
>       private void load(String file) throws ConfigurationException {
>           Source source = null;
>           InputStream stream = null;
>           try {
>               source = m_resolver.resolveURI(file);
>               stream = source.getInputStream();
>               m_properties = new Properties();
>               m_properties.load(stream);
>           }
>           catch (IOException e) {
>               throw new ConfigurationException("Cannot load properties
file " + file);
>           }
>           finally {
>               if (source != null) {
>                   m_resolver.release(source);
>               }
>               if (stream != null) {
>                   try {
>                       stream.close();
>                   }
>                   catch (IOException e) {
>                   }
>               }
>           }
>       }
>
>       public Object getAttribute(String name,Configuration modeConf,Map
objectModel)
>           throws ConfigurationException {
>
>           return m_properties.getProperty(name);
>       }
>
>       public Iterator getAttributeNames(Configuration modeConf, Map
objectModel)
>           throws ConfigurationException {
>
>           return m_properties.keySet().iterator();
>       }
>
>       public Object[] getAttributeValues(String name,Configuration
modeConf,Map objectModel)
>           throws ConfigurationException {
>
>           return new Object[] { getAttribute(name,modeConf,objectModel) };
>       }
>
>   }
>
>
>
>   1.32      +3 -0      cocoon-2.2/src/webapp/WEB-INF/cocoon.xconf
>
>   Index: cocoon.xconf
>   ===================================================================
>   RCS file: /home/cvs/cocoon-2.2/src/webapp/WEB-INF/cocoon.xconf,v
>   retrieving revision 1.31
>   retrieving revision 1.32
>   diff -u -r1.31 -r1.32
>   --- cocoon.xconf 9 Oct 2003 20:12:35 -0000 1.31
>   +++ cocoon.xconf 31 Oct 2003 13:12:05 -0000 1.32
>   @@ -174,6 +174,9 @@
>          <input-module name="session-attr"/>
>          <input-module name="defaults"/>
>        </component-instance>
>   +    <component-instance
class="org.apache.cocoon.components.modules.input.PropertiesFileModule"
logger="core.modules.input" name="cocoon-properties">
>   +      <file src="resource://org/apache/cocoon/cocoon.properties" />
>   +    </component-instance>
>
>        <!-- The 'defaults', 'myxml' and 'slashdot' input modules are used
>             in the samples -->
>
>
>
>
>


Mime
View raw message