cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/session-fw/java/org/apache/cocoon/webapps/session/components ContextInputModule.java
Date Thu, 28 Aug 2003 19:08:23 GMT
cziegeler    2003/08/28 12:08:23

  Modified:    .        status.xml
  Added:       src/blocks/session-fw/conf modules.xconf
               src/blocks/session-fw/java/org/apache/cocoon/webapps/session/components
                        ContextInputModule.java
  Log:
     <action dev="CZ" type="add">
       Add a session-context input module to the session framework to retrieve
       information from a session context in the sitemap.
     </action>
  
  Revision  Changes    Path
  1.130     +5 -1      cocoon-2.1/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/status.xml,v
  retrieving revision 1.129
  retrieving revision 1.130
  diff -u -r1.129 -r1.130
  --- status.xml	21 Aug 2003 12:54:20 -0000	1.129
  +++ status.xml	28 Aug 2003 19:08:23 -0000	1.130
  @@ -189,6 +189,10 @@
     <changes>
   
    <release version="@version@" date="@date@">
  +   <action dev="CZ" type="add">
  +     Add a session-context input module to the session framework to retrieve
  +     information from a session context in the sitemap.
  +   </action>
      <action dev="CZ" type="add" fixes-bug="21399" due-to="Peter Ross" due-to-email="peter@emailross.com">
        Applying patch for processing http.nonProxyHosts in WebServiceProxyGenerator.
      </action>
  
  
  
  1.1                  cocoon-2.1/src/blocks/session-fw/conf/modules.xconf
  
  Index: modules.xconf
  ===================================================================
  <?xml version="1.0"?>
  
  <xconf xpath="/cocoon/input-modules" unless="component-instance[@name='session-context']">
  
        <!-- This input module provides access to the information of a session context
-->
        <component-instance logger="core.modules.input" name="session-context" class="org.apache.cocoon.webapps.session.components.ContextInputModule"/>
  
  </xconf>
  
  
  1.1                  cocoon-2.1/src/blocks/session-fw/java/org/apache/cocoon/webapps/session/components/ContextInputModule.java
  
  Index: ContextInputModule.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.webapps.session.components;
  
  import java.util.Iterator;
  import java.util.Map;
  
  import org.apache.avalon.framework.activity.Disposable;
  import org.apache.avalon.framework.configuration.Configuration;
  import org.apache.avalon.framework.configuration.ConfigurationException;
  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.cocoon.ProcessingException;
  import org.apache.cocoon.components.modules.input.InputModule;
  import org.apache.cocoon.webapps.session.ContextManager;
  import org.apache.cocoon.webapps.session.context.SessionContext;
  
  /**
   * This input module provides access to the information of a session
   * context using an XPath. The XPath expression that can be used
   * is the same as for the session transformer.
   * The first information in the path is the context, so for example
   * {session-context:authentication/authentication/ID} delivers the ID of the
   * current user and therefore delivers the same information as:
   * &lt;session:getxml context="authentication" path="/authentication/ID"/&gt;
   * using the session transformer.
   * 
   * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
   * @version CVS $Id: ContextInputModule.java,v 1.1 2003/08/28 19:08:23 cziegeler Exp $
   */
  public class ContextInputModule
      implements ThreadSafe, Serviceable, Disposable, InputModule {
  
      protected ServiceManager manager;
      
      protected ContextManager contextManager;
      
      /* (non-Javadoc)
       * @see org.apache.cocoon.components.modules.input.InputModule#getAttribute(java.lang.String,
org.apache.avalon.framework.configuration.Configuration, java.util.Map)
       */
      public Object getAttribute(String name,
                                 Configuration modeConf,
                                 Map objectModel)
      throws ConfigurationException {
          if ( name == null ) {
              return null;
          }
          int pos = name.indexOf('/');
          if ( pos != -1 ) {
              final String contextName = name.substring(0, pos);
              final String path = name.substring(pos+1);
              
              try {
                  SessionContext context = this.contextManager.getContext(contextName);
                  if ( context != null ) {
                      return context.getValueOfNode(path);
                  }
              } catch (ProcessingException pe) {
                  throw new ConfigurationException("Unable to get information from context.",
pe);
              }
              
          }
          return null;
      }
  
      /* (non-Javadoc)
       * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeNames(org.apache.avalon.framework.configuration.Configuration,
java.util.Map)
       */
      public Iterator getAttributeNames(Configuration modeConf, Map objectModel)
      throws ConfigurationException {
          return null;
      }
  
      /* (non-Javadoc)
       * @see org.apache.cocoon.components.modules.input.InputModule#getAttributeValues(java.lang.String,
org.apache.avalon.framework.configuration.Configuration, java.util.Map)
       */
      public Object[] getAttributeValues(String name,
                                          Configuration modeConf,
                                          Map objectModel)
      throws ConfigurationException {
          final Object value = this.getAttribute(name, modeConf, objectModel);
          if ( value != null ) {
              return new Object[] {value};
          }
          return null;
      }
  
      /* (non-Javadoc)
       * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
       */
      public void service(ServiceManager manager) throws ServiceException {
          this.manager = manager;
          this.contextManager = (ContextManager) this.manager.lookup(ContextManager.ROLE);
      }
  
      /* (non-Javadoc)
       * @see org.apache.avalon.framework.activity.Disposable#dispose()
       */
      public void dispose() {
          if ( this.manager != null ) {
              this.manager.release(this.contextManager);
              this.contextManager = null;
              this.manager = null;
          }
  
      }
  
  }
  
  
  

Mime
View raw message