avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dona...@apache.org
Subject cvs commit: jakarta-avalon/src/java/org/apache/avalon/context ContextException.java Context.java Contextualizable.java DefaultContext.java
Date Mon, 23 Apr 2001 10:14:06 GMT
donaldp     01/04/23 03:14:06

  Modified:    src/java/org/apache/avalon/context Context.java
                        Contextualizable.java DefaultContext.java
  Added:       src/java/org/apache/avalon/context ContextException.java
  Log:
  Update Context to throw ContextException
  
  Revision  Changes    Path
  1.2       +26 -1     jakarta-avalon/src/java/org/apache/avalon/context/Context.java
  
  Index: Context.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon/src/java/org/apache/avalon/context/Context.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Context.java	2001/04/18 12:35:08	1.1
  +++ Context.java	2001/04/23 10:13:59	1.2
  @@ -8,12 +8,37 @@
   package org.apache.avalon.context;
   
   /**
  + * The context is the interface through which the Component 
  + * and it's Container communicate.
  + * 
  + * Each Container-Component relationship will also involve defining 
  + * a contract between two entities. This contract will specify the
  + * services, settings and information that is supplied by the 
  + * Container to the Component. 
    *
  + * This relationship should be documented in a well known place.
  + * It is sometimes convenient to derive from Context to provide
  + * a particular style of Context for your Component-Container
  + * relationship. The documentation for required entries in context 
  + * can then be defined there. (examples include MailetContext, 
  + * BlockContext etc.)
  + *
    * @author <a href="mailto:fede@apache.org">Federico Barbieri</a>
    * @author <a href="mailto:pier@apache.org">Pierpaolo Fumagalli</a>
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  + * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
    */
   public interface Context
   {
  -    Object get( Object key );
  +    /**
  +     * Retrieve an object from Context.
  +     *
  +     * @param key the key into context
  +     * @return the object
  +     * @exception ContextException if object not found. Note that this 
  +     *            means that either Component is asking for invalid entry
  +     *            or the Container is not living up to contract.
  +     */
  +    Object get( Object key )
  +        throws ContextException;
   }
  
  
  
  1.2       +2 -1      jakarta-avalon/src/java/org/apache/avalon/context/Contextualizable.java
  
  Index: Contextualizable.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon/src/java/org/apache/avalon/context/Contextualizable.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Contextualizable.java	2001/04/18 12:35:09	1.1
  +++ Contextualizable.java	2001/04/23 10:14:00	1.2
  @@ -24,5 +24,6 @@
        * after configure but before any other method.
        *
        */
  -    void contextualize( Context context );
  +    void contextualize( Context context ) 
  +        throws ContextException;
   }
  
  
  
  1.2       +8 -1      jakarta-avalon/src/java/org/apache/avalon/context/DefaultContext.java
  
  Index: DefaultContext.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon/src/java/org/apache/avalon/context/DefaultContext.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultContext.java	2001/04/18 12:35:09	1.1
  +++ DefaultContext.java	2001/04/23 10:14:01	1.2
  @@ -47,12 +47,19 @@
       }
   
       public Object get( final Object key )
  +        throws ContextException
       {
           final Object data = m_contextData.get( key );
   
  -        if( null == m_parent || null != data )
  +        if( null != data )
           {
               return data;
  +        }
  +
  +        //thus data == null
  +        if( null == m_parent )
  +        {
  +            throw new ContextException( "Unable to locate " + key );
           }
   
           return m_parent.get( key );
  
  
  
  1.1                  jakarta-avalon/src/java/org/apache/avalon/context/ContextException.java
  
  Index: ContextException.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  package org.apache.avalon.context;
  
  import org.apache.avalon.CascadingException;
  
  /**
   * Exception signalling a badly formed Context.
   *
   * This can be thrown by Context object when a entry is not 
   * found. It can also be thrown manually in contextualize()
   * when Component detects a malformed context value.
   *
   * @author <a href="mailto:mail@leosimons.com">Leo Simons</a>
   * @author <a href="mailto:donaldp@apache.org">Peter Donald</a>
   */
  public class ContextException
      extends CascadingException
  {
      /**
       * Construct a new <code>ContextException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public ContextException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>ContextException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public ContextException( final String message, final Throwable throwable )
      {
          super( message, throwable );
      }
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org


Mime
View raw message