bloritsch    01/04/04 08:29:50

  Modified:    proposal/4.0 changes.txt
               proposal/4.0/src/java/org/apache/avalon/aut/io FileUtil.java
               proposal/4.0/src/java/org/apache/avalon/aut/security
                        AbstractPolicy.java
               proposal/4.0/src/java/org/apache/avalon/camelot
                        AbstractContainer.java AbstractDeployer.java
                        AvalonState.java CamelotUtil.java Container.java
                        ContainerException.java DefaultFactory.java
                        DefaultLoader.java DefaultLocator.java
                        DefaultRegistry.java Deployer.java
                        DeployerUtil.java DeploymentException.java
                        Entry.java Factory.java FactoryException.java
                        Loader.java Locator.java MetaInfo.java
                        Registry.java RegistryException.java State.java
               proposal/4.0/src/java/org/apache/avalon/datasource
                        DataSourceComponent.java J2eeDataSource.java
                        JdbcConnection.java JdbcConnectionPool.java
                        JdbcDataSource.java
               proposal/4.0/src/java/org/apache/avalon/pool Recyclable.java
               proposal/4.0/src/java/org/apache/framework/configuration
                        AbstractConfiguration.java
                        DefaultConfiguration.java
  Added:       proposal/4.0/src/java/org/apache/avalon/aut BinaryHeap.java
                        Circuit.java CircularBuffer.java
                        CircularDependencyException.java
                        DependencyGraph.java Lock.java LockException.java
                        Primes.java PriorityQueue.java
                        PropertyException.java PropertyUtil.java
                        ProxyClassLoader.java ProxyGenerator.java
                        SynchronizedPriorityQueue.java
               proposal/4.0/src/java/org/apache/avalon/aut/io
                        AndFileFilter.java InvertedFileFilter.java
                        OrFileFilter.java
  Log:
  Made a bit more solid with compilation, etc.
  
  Revision  Changes    Path
  1.5       +9 -1      jakarta-avalon/proposal/4.0/changes.txt
  
  Index: changes.txt
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon/proposal/4.0/changes.txt,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- changes.txt       2001/04/03 23:40:27     1.4
  +++ changes.txt       2001/04/04 15:29:46     1.5
  @@ -49,4 +49,12 @@
   -moved cli package to org.apache.avalon.cli
   -moved all container interfaces back to camelot (will stabilize later)
   -moved implementations of framework related classes to live with their interfaces
  --moved thread related interfaces to live with their component until further 
stabilisation
  \ No newline at end of file
  +-moved thread related interfaces to live with their component until further 
stabilisation
  +
  +BL:
  +-Added Utility classes as DataSources (stable) needs Lock/LockException
  +-Added CLI classes as Cocoon uses them for command line mode
  +-Made sure everything is compilable
  +-Updated DataSources code so that it is the stable version
  +-Moved all Camelot code to Camelot as it is quite messy to have packages
  + not match the directory heirarchy and Camelot is under construction
  
  
  
  1.1                  
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/aut/BinaryHeap.java
  
  Index: BinaryHeap.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.aut;
  
  import java.util.NoSuchElementException;
  
  /**
   * Iterface for priority queues.
   * This interface does not dictate whether it is min or max heap.
   *
   * @author  <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   * @author  <a href="mailto:[EMAIL PROTECTED]">Ram Chidambaram</a>
   */
  public final class BinaryHeap
      implements PriorityQueue
  {
      protected final static int      DEFAULT_CAPACITY   = 13;
  
      protected int                   m_size;
      protected Comparable[]          m_elements;
      protected boolean               m_isMinHeap;
  
      public BinaryHeap()
      {
          this( DEFAULT_CAPACITY, true );
      }
  
      public BinaryHeap( final int capacity )
      {
          this( capacity, true );
      }
  
      public BinaryHeap( final boolean isMinHeap )
      {
          this( DEFAULT_CAPACITY, isMinHeap );
      }
  
      public BinaryHeap( final int capacity, final boolean isMinHeap )
      {
          m_isMinHeap = isMinHeap;
  
          //+1 as 0 is noop
          m_elements = new Comparable[ capacity + 1 ];
      }
  
      /**
       * Clear all elements from queue.
       */
      public void clear()
      {
          m_size = 0;
      }
  
      /**
       * Test if queue is empty.
       *
       * @return true if queue is empty else false.
       */
      public boolean isEmpty()
      {
          return ( 0 == m_size );
      }
  
      /**
       * Test if queue is full.
       *
       * @return true if queue is full else false.
       */
      public boolean isFull()
      {
          //+1 as element 0 is noop
          return ( m_elements.length == m_size+1 );
      }
  
      /**
       * Insert an element into queue.
       *
       * @param element the element to be inserted
       */
      public void insert( final Comparable element )
      {
          if( isFull() ) grow();
  
          //percolate element to it's place in tree
          if( m_isMinHeap ) percolateUpMinHeap( element );
          else percolateUpMaxHeap( element );
      }
  
      /**
       * Return element on top of heap but don't remove it.
       *
       * @return the element at top of heap
       * @exception NoSuchElementException if isEmpty() == true
       */
      public Comparable peek() throws NoSuchElementException
      {
          if( isEmpty() ) throw new NoSuchElementException();
          else return m_elements[ 1 ];
      }
  
      /**
       * Return element on top of heap and remove it.
       *
       * @return the element at top of heap
       * @exception NoSuchElementException if isEmpty() == true
       */
      public Comparable pop() throws NoSuchElementException
      {
          final Comparable result = peek();
          m_elements[ 1 ] = m_elements[ m_size-- ];
  
          //set the unused element to 'null' so that the garbage collector
          //can free the object if not used anywhere else.(remove reference)
          m_elements[ m_size + 1 ] = null;
  
          if( m_size != 0 )
          {
              //percolate top element to it's place in tree
              if( m_isMinHeap ) percolateDownMinHeap( 1 );
              else percolateDownMaxHeap( 1 );
          }
  
          return result;
      }
  
      /**
       * Percolate element down heap from top.
       * Assume it is a maximum heap.
       *
       * @param element the element
       */
      protected void percolateDownMinHeap( final int index )
      {
          final Comparable element = m_elements[ index ];
  
          int hole = index;
  
          while( (hole * 2) <= m_size )
          {
              int child = hole * 2;
  
              //if we have a right child and that child can not be percolated
              //up then move onto other child
              if( child != m_size &&
                  m_elements[ child + 1 ].compareTo( m_elements[ child ] ) < 0 )
              {
                  child++;
              }
  
              //if we found resting place of bubble then terminate search
              if( m_elements[ child ].compareTo( element ) >= 0 )
              {
                  break;
              }
  
              m_elements[ hole ] = m_elements[ child ];
              hole = child;
          }
  
          m_elements[ hole ] = element;
      }
  
      /**
       * Percolate element down heap from top.
       * Assume it is a maximum heap.
       *
       * @param element the element
       */
      protected void percolateDownMaxHeap( final int index )
      {
          final Comparable element = m_elements[ index ];
  
          int hole = index;
  
          while( (hole * 2) <= m_size )
          {
              int child = hole * 2;
  
              //if we have a right child and that child can not be percolated
              //up then move onto other child
              if( child != m_size &&
                  m_elements[ child + 1 ].compareTo( m_elements[ child ] ) > 0 )
              {
                  child++;
              }
  
              //if we found resting place of bubble then terminate search
              if( m_elements[ child ].compareTo( element ) <= 0 )
              {
                  break;
              }
  
              m_elements[ hole ] = m_elements[ child ];
              hole = child;
          }
  
          m_elements[ hole ] = element;
      }
  
      /**
       * Percolate element up heap from bottom.
       * Assume it is a maximum heap.
       *
       * @param element the element
       */
      protected void percolateUpMinHeap( final Comparable element )
      {
          int hole = ++m_size;
  
          m_elements[ hole ] = element;
  
          while( hole > 1 &&
                 element.compareTo( m_elements[ hole / 2 ] ) < 0 )
          {
              //save element that is being pushed down
              //as the element "bubble" is percolated up
              final int next = hole / 2;
              m_elements[ hole ] = m_elements[ next ];
              hole = next;
          }
  
          m_elements[ hole ] = element;
      }
  
      /**
       * Percolate element up heap from bottom.
       * Assume it is a maximum heap.
       *
       * @param element the element
       */
      protected void percolateUpMaxHeap( final Comparable element )
      {
          int hole = ++m_size;
  
          while( hole > 1 &&
                 element.compareTo( m_elements[ hole / 2 ] ) > 0 )
          {
              //save element that is being pushed down
              //as the element "bubble" is percolated up
              final int next = hole / 2;
              m_elements[ hole ] = m_elements[ next ];
              hole = next;
          }
  
          m_elements[ hole ] = element;
      }
  
      protected void grow()
      {
          final Comparable[] elements =
              new Comparable[ m_elements.length * 2 ];
          System.arraycopy( m_elements, 0, elements, 0, m_elements.length );
          m_elements = elements;
      }
  
      public String toString()
      {
          final StringBuffer sb = new StringBuffer();
  
          sb.append( "[ " );
  
          for( int i = 1; i < m_size + 1; i++ )
          {
              if( i != 1 ) sb.append( ", " );
              sb.append( m_elements[ i ] );
          }
  
          sb.append( " ]" );
  
          return sb.toString();
      }
  }
  
  
  
  
  1.1                  
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/aut/Circuit.java
  
  Index: Circuit.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.aut;
  
  import java.util.Enumeration;
  import java.util.Hashtable;
  import java.util.Vector;
  
  /**
   *
   * @version 0.0.20, 04/07/1998
   * @author  Federico Barbieri <[EMAIL PROTECTED]>
   * @author  Stefano Mazzocchi <[EMAIL PROTECTED]>
   */
  public class Circuit
  {
      protected Hashtable m_map;
  
      public Circuit()
      {
          m_map = new Hashtable();
      }
  
      public void addNode( final String name )
      {
          if( null == m_map.get( name ) )
          {
              m_map.put( name, new Node( name ) );
          }
      }
  
      public void removeNode( final String name )
      {
          String tmp = null;
          Enumeration e = m_map.keys();
  
          while( e.hasMoreElements() )
          {
              tmp = (String)e.nextElement();
  
              if( !tmp.equals( name ) )
              {
                  try { unlink( tmp, name ); }
                  catch( final CircuitException ce) {}
                  try { unlink( name, tmp ); }
                  catch( final CircuitException ce ) {}
              }
  
          }
  
          m_map.remove( name );
      }
  
      public void link( final String parent, final String child )
          throws CircuitException
      {
          Node tempNode = null;
          Node pnode = (Node)m_map.get( parent );
          Node cnode = (Node)m_map.get( child );
          if( null == pnode )
          {
              throw new CircuitException( "Unknown node " + parent );
          }
          else if( null == cnode )
          {
              throw new CircuitException( "Unknown node " + child );
          }
          else if( pnode.isChildOf( cnode ) )
          {
              throw new CircuitException( "Loop! Node " + parent +
                                          " is already child of node " + child );
          }
          else
          {
              final Enumeration e = m_map.elements();
  
              while( e.hasMoreElements() )
              {
                  tempNode = (Node)e.nextElement();
                  if( tempNode.isChildOf( cnode ) )
                  {
                      tempNode.m_parents.addAll( pnode.m_parents );
                  }
              }
          }
      }
  
      public void unlink( final String parent, final String child )
          throws CircuitException
      {
          Node cnode = (Node)m_map.get( child );
          Node pnode = (Node)m_map.get( parent );
  
          if( cnode.m_parents.contains( pnode ) )
          {
              Node tempNode = null;
              Enumeration e = m_map.elements();
  
              while( e.hasMoreElements() )
              {
                  tempNode = (Node)e.nextElement();
  
                  if( tempNode.m_parents.contains( cnode ) )
                  {
                      tempNode.m_parents.removeAll( pnode.m_parents );
                  }
              }
          }
          else
          {
              throw new CircuitException( "Node " + parent + " is not parent of node " 
+ child );
          }
      }
  
      public Vector getAncestors()
      {
          Vector ancestors = new Vector();
          String name = null;
          Node tempNode = null;
          Enumeration e = m_map.keys();
  
          while( e.hasMoreElements() )
          {
              name = (String)e.nextElement();
              tempNode = (Node)m_map.get( name );
  
              if( 1 == tempNode.m_parents.size() )
              {
                  ancestors.addElement( name );
              }
          }
  
          return ancestors;
      }
  
      public String getAncestor()
      {
          String name = null;
          Node tempNode = null;
          Enumeration e = m_map.keys();
  
          while( e.hasMoreElements() )
          {
              name = (String)e.nextElement();
              tempNode = (Node)m_map.get( name );
  
              if( 1 == tempNode.m_parents.size() )
              {
                  return name;
              }
          }
  
          return null;
      }
  
      public boolean isEmpty()
      {
          return m_map.isEmpty();
      }
  
      protected final class Node
      {
          protected Vector m_parents;
          protected String m_name;
  
          protected Node( final String name )
          {
              m_parents = new Vector( 5 );
              m_parents.addElement( this );
              m_name = name;
          }
  
          protected boolean isChildOf( final Node parent )
          {
              return m_parents.contains( parent );
          }
  
          public String toString()
          {
              StringBuffer buffer = new StringBuffer();
              Enumeration e = m_parents.elements();
              buffer.append( m_name + "[" );
  
              while( e.hasMoreElements() )
              {
                  buffer.append(((Node) e.nextElement()).m_name + " ");
              }
  
              buffer.append("]");
              return buffer.toString();
          }
      }
  
      public final class CircuitException
          extends RuntimeException
      {
          public CircuitException()
          {
          }
  
          public CircuitException( final String message )
          {
              super( message );
          }
      }
  
      public String toString()
      {
          StringBuffer buffer = new StringBuffer();
          String name = null;
          Node tempNode = null;
          Enumeration e = m_map.keys();
  
          while( e.hasMoreElements() )
          {
              name = (String)e.nextElement();
              tempNode = (Node)m_map.get( name );
              buffer.append( name + "(" + ( tempNode.m_parents.size() - 1 ) + ") " );
          }
  
          return buffer.toString();
      }
  }
  
  
  
  
  1.1                  
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/aut/CircularBuffer.java
  
  Index: CircularBuffer.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.aut;
  /**
   *
   * @author  Federico Barbieri <[EMAIL PROTECTED]>
   */
  public class CircularBuffer
  {
      protected Object[]   m_buffer;
      protected int        m_bufferSize;
      protected int        m_contentSize;
      protected int        m_head;
      protected int        m_tail;
  
      public CircularBuffer( int size )
      {
          m_buffer = new Object[size];
          m_bufferSize = size;
          m_contentSize = 0;
          m_head = 0;
          m_tail = 0;
      }
  
      public CircularBuffer()
      {
          this( 32 );
      }
  
      public boolean isEmpty()
      {
          return (m_contentSize == 0);
      }
  
      public int getContentSize()
      {
          return m_contentSize;
      }
  
      public int getBufferSize()
      {
          return m_bufferSize;
      }
  
      public void append( final Object o )
      {
          if( m_contentSize >= m_bufferSize )
          {
              int j = 0;
              int i = m_tail;
              Object[] tmp = new Object[ m_bufferSize * 2 ];
  
              while( m_contentSize > 0 )
              {
                  i++;
                  i %= m_bufferSize;
                  j++;
                  m_contentSize--;
                  tmp[ j ] = m_buffer[ i ];
              }
              m_buffer = tmp;
              m_tail = 0;
              m_head = j;
              m_contentSize = j;
              m_bufferSize *= 2;
          }
  
          m_buffer[ m_head ] = o;
          m_head++;
          m_head %= m_bufferSize;
          m_contentSize++;
      }
  
      public Object get()
      {
          if( m_contentSize <= 0 )
          {
              return null;
          }
  
          Object o = m_buffer[ m_tail ];
          m_tail++;
          m_tail %= m_bufferSize;
          m_contentSize--;
          return o;
      }
  }
  
  
  
  
  1.1                  
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/aut/CircularDependencyException.java
  
  Index: CircularDependencyException.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.aut;
  
  import java.util.List;
  import org.apache.framework.CascadingException;
  
  /**
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   */
  public class CircularDependencyException
      extends CascadingException
  {
      protected List   m_stack;
  
      public CircularDependencyException( final String dependee,
                                          final String dependent,
                                          final List stack )
      {
          super( dependee + " depends upon " + dependent + " which depends upong " + 
dependee );
          m_stack = stack;
      }
  
      public List getStack()
      {
          return m_stack;
      }
  }
  
  
  
  1.1                  
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/aut/DependencyGraph.java
  
  Index: DependencyGraph.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.aut;
  
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.List;
  
  /**
   * DirectedGraph is a acyclic Directed graph implementation.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   */
  public class DependencyGraph
  {
      protected final HashMap  m_map               = new HashMap();
      protected boolean        m_allowCircularity  = true;
  
      public void setAllowCircularity( final boolean allowCircularity )
      {
          m_allowCircularity = allowCircularity;
      }
  
      public void add( final String name, final String[] dependencies )
      {
          m_map.put( name, new GraphNode( name, dependencies ) );
      }
  
      public void remove( final String name )
      {
          m_map.remove( name );
      }
  
      public Dependency[] getDependencyList( final String name )
          throws CircularDependencyException
      {
          final ArrayList list = new ArrayList();
          final Dependency dependency = new Dependency( name , null );
          list.add( dependency );
  
          if( null != m_map.get( name ) )
          {
              final ArrayList stack = new ArrayList();
              stack.add( name );
              buildDependencyList( name, list, new ArrayList(), stack );
          }
  
          return (Dependency[])list.toArray( new Dependency[ 0 ] );
      }
  
      protected void buildDependencyList( final String name,
                                          final ArrayList list,
                                          final ArrayList done,
                                          final ArrayList stack )
          throws CircularDependencyException
      {
          if( done.contains( name ) ) return;
          done.add( name );
  
          final GraphNode node = (GraphNode)m_map.get( name );
          if( null == node ) return;
  
          final String[] dependencies = node.getDependencies();
          for( int i = 0; i < dependencies.length; i++ )
          {
              if( stack.contains( dependencies[ i ] ) )
              {
                  if( m_allowCircularity ) continue;
                  else
                  {
                      throw new CircularDependencyException( dependencies[ i ], name, 
stack );
                  }
              }
  
              if( done.contains( dependencies[ i ] ) ) continue;
  
              final Dependency dependency = new Dependency( dependencies[ i ], name );
              list.add( dependency );
  
              stack.add( dependencies[ i ] );
              buildDependencyList( dependencies[ i ], list, done, stack );
              stack.remove( stack.size() - 1 );
          }
      }
  
      public final static class Dependency
      {
          protected final String       m_name;
          protected final String       m_requiredBy;
  
          protected Dependency( final String name, final String requiredBy )
          {
              m_name = name;
              m_requiredBy = requiredBy;
          }
  
          public String getName()
          {
              return m_name;
          }
  
          public String getRequiredBy()
          {
              return m_requiredBy;
          }
  
          public String toString()
          {
              return getName();
          }
      }
  
      protected final static class GraphNode
      {
          protected final String     m_name;
          protected final String[]   m_dependencies;
  
          protected GraphNode( final String name, final String[] dependencies )
          {
              m_name = name;
              m_dependencies = dependencies;
          }
  
          public String getName()
          {
              return m_name;
          }
  
          public String[] getDependencies()
          {
              return m_dependencies;
          }
      }
  }
  
  
  
  1.1                  
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/aut/Lock.java
  
  Index: Lock.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.aut;
  
  import java.util.Hashtable;
  
  /**
   * @author Federico Barbieri <[EMAIL PROTECTED]>
   */
  public class Lock
  {
      private Hashtable locks = new Hashtable();
  
      public boolean isLocked( final Object key )
      {
          return (locks.get(key) != null);
      }
  
      public boolean canI( final Object key )
      {
          Object o = locks.get( key );
  
          if( null == o || o == this.getCallerId() )
          {
              return true;
          }
  
          return false;
      }
  
      public boolean lock( final Object key )
      {
          Object theLock;
  
          synchronized( this )
          {
              theLock = locks.get( key );
  
              if( null == theLock )
              {
                  locks.put( key, getCallerId() );
                  return true;
              }
              else if( getCallerId() == theLock )
              {
                  return true;
              }
              else
              {
                  return false;
              }
          }
      }
  
      public boolean unlock( final Object key )
      {
          Object theLock;
          synchronized( this )
          {
              theLock = locks.get( key );
  
              if( null == theLock )
              {
                  return true;
              }
              else if( getCallerId() == theLock )
              {
                  locks.remove( key );
                  return true;
              }
              else
              {
                  return false;
              }
          }
      }
  
      private Object getCallerId()
      {
          return Thread.currentThread();
      }
  }
  
  
  
  1.1                  
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/aut/LockException.java
  
  Index: LockException.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.aut;
  
  public class LockException
      extends RuntimeException
  {
      public LockException( final String message )
      {
          super( message );
      }
  
      public LockException()
      {
      }
  }
  
  
  
  1.1                  
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/aut/Primes.java
  
  Index: Primes.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.aut;
  
  /**
   *
   * @author  Federico Barbieri <[EMAIL PROTECTED]>
   * @author  Stefano Mazzocchi <[EMAIL PROTECTED]>
   */
  public class Primes
  {
      /**
       * Last prime found.
       *
       */
      protected static long                c_lastPrime              = 1;
  
      /**
       * Return next prime.
       *
       */
      public static long nextPrime()
      {
          long l = c_lastPrime + 1;
          long v = 2;
  
          while( true )
          {
              l++;
  
              while( v < l )
              {
                  v++;
  
                  if( (l % v) == 0 )
                  {
                      v = 0;
                      break;
                  }
              } // while v < l
  
              if( v == l )
              {
                  c_lastPrime = l;
                  return l;
              } // if v is l
          } // while true (break is used to escape)
      }
  }
  
  
  
  1.1                  
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/aut/PriorityQueue.java
  
  Index: PriorityQueue.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.aut;
  
  import java.util.NoSuchElementException;
  
  /**
   * Iterface for priority queues.
   * This interface does not dictate whether it is min or max heap.
   *
   * @author  <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   */
  public interface PriorityQueue
  {
      /**
       * Clear all elements from queue.
       */
      void clear();
  
      /**
       * Test if queue is empty.
       *
       * @return true if queue is empty else false.
       */
      boolean isEmpty();
  
      /**
       * Insert an element into queue.
       *
       * @param element the element to be inserted
       */
      void insert( Comparable element );
  
      /**
       * Return element on top of heap but don't remove it.
       *
       * @return the element at top of heap
       * @exception NoSuchElementException if isEmpty() == true
       */
      Comparable peek() throws NoSuchElementException;
  
      /**
       * Return element on top of heap and remove it.
       *
       * @return the element at top of heap
       * @exception NoSuchElementException if isEmpty() == true
       */
      Comparable pop() throws NoSuchElementException;
  }
  
  
  
  
  1.1                  
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/aut/PropertyException.java
  
  Index: PropertyException.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.aut;
  
  import org.apache.framework.CascadingException;
  
  /**
   * Thrown when a property can not be resolved properly.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   */
  public class PropertyException
      extends CascadingException
  {
      /**
       * Construct a new <code>PropertyException</code> instance.
       *
       * @param message The detail message for this exception.
       */
      public PropertyException( final String message )
      {
          this( message, null );
      }
  
      /**
       * Construct a new <code>PropertyException</code> instance.
       *
       * @param message The detail message for this exception.
       * @param throwable the root cause of the exception
       */
      public PropertyException( final String message, final Throwable throwable )
      {
          super( message, throwable );
      }
  }
  
  
  
  1.1                  
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/aut/PropertyUtil.java
  
  Index: PropertyUtil.java
  ===================================================================
  package org.apache.avalon.aut;
  
  import org.apache.framework.context.Context;
  import org.apache.framework.context.Resolvable;
  
  /**
   * This provides utility methods for properties.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   */
  public final class PropertyUtil
  {
      private PropertyUtil()
      {
      }
  
      /**
       * Resolve property.
       * This evaluates all property substitutions based on current context.
       *
       * @param property the property to resolve
       * @param context the context in which to resolve property
       * @param ignoreUndefined if false will throw an PropertyException if property 
is not found
       * @return the reolved property
       * @exception PropertyException if an error occurs
       */
      public static Object resolveProperty( final String property,
                                            final Context context,
                                            final boolean ignoreUndefined )
          throws PropertyException
      {
          int start = property.indexOf( "${" );
          if( -1 == start ) return property;
  
          int end = property.indexOf( '}', start );
          if( -1 == end ) return property;
  
          final int length = property.length();
  
          if( 0 == start && end == (length - 1) )
          {
              return resolveValue( property.substring( start + 2, end ),
                                   context,
                                   ignoreUndefined );
          }
  
          final StringBuffer sb = new StringBuffer();
          int lastPlace = 0;
  
          while( true )
          {
              final Object value =
                  resolveValue( property.substring( start + 2, end ),
                                context,
                                ignoreUndefined );
  
              sb.append( property.substring( lastPlace, start ) );
              sb.append( value );
  
              lastPlace = end + 1;
  
              start = property.indexOf( "${", end );
              if( -1 == start ) break;
  
              end = property.indexOf( '}', start );
              if( -1 == end ) break;
          }
  
          sb.append( property.substring( lastPlace, length ) );
  
          return sb.toString();
      }
  
      protected static Object resolveValue( final String key,
                                            final Context context,
                                            final boolean ignoreUndefined )
          throws PropertyException
      {
          Object value = context.get( key );
  
          while( null != value && value instanceof Resolvable )
          {
              value = ((Resolvable)value).resolve( context );
          }
  
          if( null == value )
          {
              if( ignoreUndefined )
              {
                  return "";
              }
              else
              {
                  throw new PropertyException( "Unable to find " + key + " to expand 
during " +
                                               "property resolution." );
              }
          }
  
          return value;
      }
  }
  
  
  
  1.1                  
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/aut/ProxyClassLoader.java
  
  Index: ProxyClassLoader.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.aut;
  
  /**
   * Utility class to help load dynamically generated classes.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   */
  public class ProxyClassLoader
      extends ClassLoader
  {
      public ProxyClassLoader( final ClassLoader parent )
      {
          super( parent );
      }
  
      public Class loadClass( final String name,
                              final boolean resolve,
                              final byte[] classData )
          throws ClassNotFoundException
      {
          final Class result =
              defineClass( name, classData, 0, classData.length );
  
          if( resolve )
          {
              resolveClass( result );
          }
  
          return result;
      }
  }
  
  
  
  
  1.1                  
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/aut/ProxyGenerator.java
  
  Index: ProxyGenerator.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.aut;
  
  import gnu.bytecode.Access;
  import gnu.bytecode.ClassType;
  import gnu.bytecode.ClassTypeWriter;
  import gnu.bytecode.CodeAttr;
  import gnu.bytecode.Field;
  import gnu.bytecode.Scope;
  import gnu.bytecode.Type;
  import gnu.bytecode.Variable;
  import java.lang.reflect.Constructor;
  import java.lang.reflect.Method;
  import java.util.HashMap;
  import java.util.Iterator;
  import org.apache.log.LogKit;
  import org.apache.log.Logger;
  
  /**
   * A class to generate proxies for objects.
   *
   * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
   */
  public final class ProxyGenerator
  {
      protected final static boolean    DEBUG       = false;
      protected final static Logger     LOGGER      =
          ( DEBUG ) ? LogKit.getLoggerFor( "ProxyGenerator" ) : null;
  
      protected final static Object     MONITOR     = new Object();
      protected final static ClassType  BASE_CLASS  =
          (ClassType)Type.getType( "java.lang.Object" );
  
      protected static long             c_currentId;
  
      /**
       * Private constructor to block subclassing.
       *
       */
      private ProxyGenerator()
      {
      }
  
      /**
       * Way to generate unique id for each class.
       *
       * @return a unique id
       */
      protected static long getNextId()
      {
          synchronized( MONITOR )
          {
              return c_currentId++;
          }
      }
  
      /**
       * Generate a proxy for object with certain interfaces.
       *
       * @param object the object
       * @param interfaces[] the interfaces
       * @return the proxy object
       * @exception IllegalArgumentException if an error occurs
       */
      public static Object generateProxy( final Object object,
                                          final Class[] interfaces )
          throws IllegalArgumentException
      {
          if( DEBUG )
          {
              LOGGER.debug( "Generating proxy for " + object.getClass().getName() );
              LOGGER.debug( "Interfaces generating:" );
  
              for( int i = 0; i < interfaces.length; i++ )
              {
                  LOGGER.debug( interfaces[ i ].getName() );
              }
          }
  
          for( int i = 0; i < interfaces.length; i++ )
          {
              if( !interfaces[ i ].isInterface() )
              {
                  throw new IllegalArgumentException( "Class " + interfaces[ i 
].getName() +
                                                      " is not an interface" );
              }
              else if( !interfaces[ i ].isInstance( object ) )
              {
                  throw new IllegalArgumentException( "Object does not implement 
interface " +
                                                      interfaces[ i ].getName() );
              }
          }
  
          final HashMap methodSet = determineMethods( interfaces );
  
          final String classname = "org.apache.avalon.tmp.Proxy" + getNextId();
  
          if( DEBUG ) { LOGGER.debug( "Generating proxy named " + classname ); }
  
          final ClassType proxy = createProxyType( classname );
  
          //generate all interface declarations
          generateInterfaces( proxy, interfaces );
  
          final ClassType target =
              (ClassType)Type.make( object.getClass() );
  
          target.doFixups();
  
          //generate variables/constructor
          generateBase( proxy, target );
  
          //generate methods
          final Iterator methods = methodSet.values().iterator();
          while( methods.hasNext() )
          {
              generateMethod( proxy, target, (Method)methods.next() );
          }
  
          if( DEBUG )
          {
              //help while debugging
              //ClassTypeWriter.print( target, System.out, 0 );
              //try { proxy.writeToFile( "/tmp/" + classname.replace('.','/') + 
".class" ); }
              //catch( final Throwable throwable ) { throwable.printStackTrace(); }
          }
  
          proxy.doFixups();
  
          Class proxyClass = null;
          try
          {
              final byte[] classData = proxy.writeToArray();
  
              //extremely inneficient - must fix in future
              final ProxyClassLoader classLoader =
                  new ProxyClassLoader( object.getClass().getClassLoader() );
  
              proxyClass = classLoader.loadClass( classname, true, classData );
              final Constructor ctor =
                  proxyClass.getConstructor( new Class[] { object.getClass() } );
              return ctor.newInstance( new Object[] { object } );
          }
          catch( final Throwable throwable ) { throwable.printStackTrace(); }
  
          return null;
      }
  
      /**
       * Create Proxy class.
       *
       * @param classname name of class
       * @return the proxy class
       */
      protected static ClassType createProxyType( final String classname )
      {
          final ClassType proxy = new ClassType( classname );
          proxy.setModifiers( Access.PUBLIC | /*ACC_SUPER*/ 0x0020 | Access.FINAL );
          proxy.setSuper( BASE_CLASS );
  
          return proxy;
      }
  
      /**
       * generate the list of Interfaces class implements.
       *
       * @param proxy the proxy class
       * @param interfaces[] the interfaces to add
       */
      protected static void generateInterfaces( final ClassType proxy,
                                                final Class[] interfaces )
      {
          final ClassType[] interfaceTypes = new ClassType[ interfaces.length ];
  
          for( int i = 0; i < interfaceTypes.length; i++ )
          {
              interfaceTypes[ i ] = (ClassType)Type.getType( interfaces[ i ].getName() 
);
          }
  
          proxy.setInterfaces( interfaceTypes );
      }
  
      /**
       * Generate code for wrapper method.
       *
       * @param proxy the class to add to
       * @param target the class wrapping
       * @param method the method to wrap
       */
      protected static void generateMethod( final ClassType proxy,
                                            final ClassType target,
                                            final Method method )
      {
          final Class[] parameters = method.getParameterTypes();
          final Type[] parameterTypes = new Type[ parameters.length ];
  
          for( int i = 0; i < parameterTypes.length; i++ )
          {
              parameterTypes[ i ] = Type.getType( parameters[ i ].getName() );
          }
  
          final Type returnType =
              Type.getType( method.getReturnType().getName() );
  
          final gnu.bytecode.Method newMethod =
              proxy.addMethod( method.getName(),
                               Access.PUBLIC,
                               parameterTypes,
                               returnType );
  
          newMethod.init_param_slots();
          newMethod.pushScope();
          final CodeAttr code = newMethod.getCode();
  
          //put m_core on stack;
          final Field field = proxy.getField( "m_core" );
  
          code.emitPushThis();
          code.emitGetField( field );
  
          for( int i = 0; i < parameterTypes.length; i++ )
          {
              code.emitLoad( code.getArg( 1 + i ) );
          }
  
          //call target method
          final gnu.bytecode.Method targetMethod =
              target.getMethod( method.getName(), parameterTypes );
          code.emitInvokeVirtual( targetMethod );
  
          //return
          code.emitReturn();
          newMethod.popScope();
      }
  
      /**
       * Generate constructor code and field data.
       *
       * @param proxy the representation of class so far
       * @param target the type that is wrapped
       */
      protected static void generateBase( final ClassType proxy,
                                          final Type target )
      {
          final Field field = proxy.addField( "m_core", target );
          field.flags |= Access.PRIVATE;
  
          final gnu.bytecode.Method constructor =
              proxy.addMethod( "<init>",
                               Access.PUBLIC,
                               new Type[] { target },
                               Type.void_type );
  
          final gnu.bytecode.Method superConstructor
              = proxy.getSuperclass().addMethod( "<init>",
                                                 Access.PUBLIC,
                                                 null,
                                                 Type.void_type );
  
          constructor.init_param_slots();
          constructor.pushScope();
          final CodeAttr code = constructor.getCode();
  
          //super();
          code.emitPushThis();
          code.emitInvokeSpecial( superConstructor );
  
          //m_core = param1;
          code.emitPushThis();
          code.emitLoad( code.getArg( 1 ) );
          code.emitPutField( field );
  
          //return
          code.emitReturn();
  
          constructor.popScope();
      }
  
      /**
       * Determine the methods that must be implemented to
       * implement interface, eliminating duplicates.
       *
       * @param interfaces[] the interfaces to extract methods from
       * @return methods
       */
      protected static HashMap determineMethods( final Class[] interfaces )
      {
          final HashMap methodSet = new HashMap();
          final StringBuffer sb = new StringBuffer();
  
          for( int i = 0; i < interfaces.length; i++ )
          {
              if( DEBUG )
              {
                  LOGGER.debug( "Scanning interface " + interfaces[ i ].getName() +
                                " for methods" );
              }
  
              final Method[] methods = interfaces[ i ].getMethods();
  
              //for each method generate a pseudo signature
              //Add the method to methodSet under that signature.
              //This is to ensure that only one version of a method is
              //entered into set even if multiple interfaces declare it
  
              for( int j = 0; j < methods.length; j++ )
              {
                  sb.append( methods[ j ].getName() );
                  sb.append( '(' );
  
                  final Class[] parameters = methods[ j ].getParameterTypes();
  
                  for( int k = 0; k < parameters.length; k++ )
                  {
                      sb.append( parameters[ k ].getName() );
                      sb.append( ' ' );
                  }
  
                  sb.append( ";)" );
  
                  if( DEBUG )
                  {
                      LOGGER.debug( "Found method with pseudo-signature " + sb );
                  }
  
                  methodSet.put( sb.toString(), methods[ j ] );
                  sb.setLength( 0 );
              }
          }
  
          return methodSet;
      }
  }
  
  
  
  
  
  1.1                  
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/aut/SynchronizedPriorityQueue.java
  
  Index: SynchronizedPriorityQueue.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.aut;
  
  import java.util.NoSuchElementException;
  
  /**
   * A thread safe version of the PriorityQueue.
   * Provides synchronized wrapper methods for all the methods
   * defined in the PriorityQueue interface.
   *
   * @author  <a href="mailto:[EMAIL PROTECTED]">Ram Chidambaram</a>
   */
  public final class SynchronizedPriorityQueue
      implements PriorityQueue
  {
      protected final PriorityQueue   m_priorityQueue;
  
      public SynchronizedPriorityQueue( final PriorityQueue priorityQueue )
      {
          m_priorityQueue = priorityQueue;
      }
  
      /**
       * Clear all elements from queue.
       */
      public synchronized void clear()
      {
          m_priorityQueue.clear();
      }
  
      /**
       * Test if queue is empty.
       *
       * @return true if queue is empty else false.
       */
      public synchronized boolean isEmpty()
      {
          return m_priorityQueue.isEmpty();
      }
  
      /**
       * Insert an element into queue.
       *
       * @param element the element to be inserted
       */
      public synchronized void insert( final Comparable element )
      {
          m_priorityQueue.insert( element );
      }
  
      /**
       * Return element on top of heap but don't remove it.
       *
       * @return the element at top of heap
       * @exception NoSuchElementException if isEmpty() == true
       */
      public synchronized Comparable peek() throws NoSuchElementException
      {
          return m_priorityQueue.peek();
      }
  
      /**
       * Return element on top of heap and remove it.
       *
       * @return the element at top of heap
       * @exception NoSuchElementException if isEmpty() == true
       */
      public synchronized Comparable pop() throws NoSuchElementException
      {
          return m_priorityQueue.pop();
      }
  
      public synchronized String toString()
      {
          return m_priorityQueue.toString();
      }
  }
  
  
  
  1.2       +57 -57    
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/aut/io/FileUtil.java
  
  Index: FileUtil.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/aut/io/FileUtil.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FileUtil.java     2001/04/03 23:35:23     1.1
  +++ FileUtil.java     2001/04/04 15:29:47     1.2
  @@ -9,7 +9,7 @@
   
   import java.io.*;
   import java.net.URL;
  -import org.apache.aut.StringUtil;
  +import org.apache.avalon.aut.StringUtil;
   
   /**
    * This class provides basic facilities for manipulating files.
  @@ -36,7 +36,7 @@
           {
               final String filename = url.getFile().replace( '/', File.separatorChar 
);
               return new File( filename );
  -        }        
  +        }
       }
   
       /**
  @@ -52,8 +52,8 @@
       public static String removeExtention( final String filename )
       {
           final int index = filename.lastIndexOf( '.' );
  -        
  -        if( -1 == index ) 
  +
  +        if( -1 == index )
           {
               return filename;
           }
  @@ -76,7 +76,7 @@
       {
           final int index = filepath.lastIndexOf( File.separator );
   
  -        if( -1 == index ) 
  +        if( -1 == index )
           {
               return filepath;
           }
  @@ -89,9 +89,9 @@
       /**
        * Copy file from source to destination.
        */
  -    public static void copyFileToDirectory( final String source, 
  -                                            final String destinationDirectory ) 
  -        throws IOException 
  +    public static void copyFileToDirectory( final String source,
  +                                            final String destinationDirectory )
  +        throws IOException
       {
           copyFileToDirectory( new File( source ), new File( destinationDirectory ) );
       }
  @@ -99,9 +99,9 @@
       /**
        * Copy file from source to destination.
        */
  -    public static void copyFileToDirectory( final File source, 
  -                                            final File destinationDirectory ) 
  -        throws IOException 
  +    public static void copyFileToDirectory( final File source,
  +                                            final File destinationDirectory )
  +        throws IOException
       {
           if( destinationDirectory.exists() && !destinationDirectory.isDirectory() )
           {
  @@ -114,8 +114,8 @@
       /**
        * Copy file from source to destination.
        */
  -    public static void copyFile( final File source, final File destination ) 
  -        throws IOException 
  +    public static void copyFile( final File source, final File destination )
  +        throws IOException
       {
           //check source exists
           if( !source.exists() )
  @@ -139,39 +139,39 @@
   
           if( source.length() != destination.length() )
           {
  -            throw new IOException( "Failed to copy full contents from " + source + 
  +            throw new IOException( "Failed to copy full contents from " + source +
                                      " to " + destination );
           }
  -    } 
  +    }
   
  -    public static void copyURLToFile( final URL source, final File destination ) 
  -        throws IOException 
  +    public static void copyURLToFile( final URL source, final File destination )
  +        throws IOException
       {
           //does destinations directory exist ?
           if( !destination.getParentFile().exists() )
           {
               destination.mkdirs();
           }
  -        
  +
           //make sure we can write to destination
           if( destination.exists() && !destination.canWrite() )
           {
               throw new IOException( "Unable to open file " + destination + " for 
writing." );
           }
  -        
  +
           IOUtil.copy( source.openStream(), new FileOutputStream( destination ) );
  -    } 
  +    }
   
       public static String normalize( String location )
       {
           location = StringUtil.replaceSubString( location, "/./", "/" );
  -        
  +
           final StringBuffer sb = new StringBuffer();
  -        
  +
           int trail = 0;
           int end = location.indexOf( "/../" );
           int start = 0;
  -        
  +
           while( end != -1 )
           {
               //TODO: fix when starts with /../
  @@ -181,18 +181,18 @@
               start = end + 4;
               end = location.indexOf( "/../", start );
           }
  -        
  +
           end = location.length();
           sb.append( location.substring( start, end ) );
  -        
  +
           return sb.toString();
       }
   
       /** Will concatenate 2 paths, dealing with ..
        * ( /a/b/c + d = /a/b/d, /a/b/c + ../d = /a/d )
  -     * 
  +     *
        * Thieved from Tomcat sources...
  -     * 
  +     *
        * @return null if error occurs
        */
       public static String catPath( String lookupPath, String path )
  @@ -200,36 +200,36 @@
           // Cut off the last slash and everything beyond
           int index = lookupPath.lastIndexOf( "/" );
           lookupPath = lookupPath.substring( 0, index );
  -        
  +
           // Deal with .. by chopping dirs off the lookup path
  -        while( path.startsWith( "../" ) ) 
  -        { 
  +        while( path.startsWith( "../" ) )
  +        {
               if( lookupPath.length() > 0 )
               {
                   index = lookupPath.lastIndexOf( "/" );
                   lookupPath = lookupPath.substring( 0, index );
  -            } 
  +            }
               else
               {
                   // More ..'s than dirs, return null
                   return null;
               }
  -            
  +
               index = path.indexOf( "../" ) + 3;
               path = path.substring( index );
           }
  -        
  +
           return lookupPath + "/" + path;
       }
   
  -    public static File resolveFile( final File baseFile, String filename ) 
  +    public static File resolveFile( final File baseFile, String filename )
       {
  -        if( '/' != File.separatorChar ) 
  +        if( '/' != File.separatorChar )
           {
               filename = filename.replace( '/', File.separatorChar );
           }
   
  -        if( '\\' != File.separatorChar ) 
  +        if( '\\' != File.separatorChar )
           {
               filename = filename.replace( '\\', File.separatorChar );
           }
  @@ -239,7 +239,7 @@
           {
               File file = new File( filename );
   
  -            try { file = file.getCanonicalFile(); } 
  +            try { file = file.getCanonicalFile(); }
               catch( final IOException ioe ) {}
   
               return file;
  @@ -248,10 +248,10 @@
           final char[] chars = filename.toCharArray();
           final StringBuffer sb = new StringBuffer();
   
  -        //remove duplicate file seperators in succession - except 
  +        //remove duplicate file seperators in succession - except
           //on win32 as UNC filenames can be \\AComputer\AShare\myfile.txt
           int start = 0;
  -        if( '\\' == File.separatorChar ) 
  +        if( '\\' == File.separatorChar )
           {
               sb.append( filename.charAt( 0 ) );
               start++;
  @@ -259,12 +259,12 @@
   
           for( int i = start; i < chars.length; i++ )
           {
  -            final boolean doubleSeperator = 
  +            final boolean doubleSeperator =
                   File.separatorChar == chars[ i ] && File.separatorChar == chars[ i 
- 1 ];
   
               if( !doubleSeperator ) sb.append( chars[ i ] );
           }
  -        
  +
           filename = sb.toString();
   
           //must be relative
  @@ -280,7 +280,7 @@
        * Delete a file. If file is directory delete it and all sub-directories.
        */
       public static void forceDelete( final String file )
  -        throws IOException 
  +        throws IOException
       {
           forceDelete( new File( file ) );
       }
  @@ -289,7 +289,7 @@
        * Delete a file. If file is directory delete it and all sub-directories.
        */
       public static void forceDelete( final File file )
  -        throws IOException 
  +        throws IOException
       {
           if( file.isDirectory() ) deleteDirectory( file );
           else
  @@ -305,7 +305,7 @@
        * Recursively delete a directory.
        */
       public static void deleteDirectory( final String directory )
  -        throws IOException 
  +        throws IOException
       {
           deleteDirectory( new File( directory ) );
       }
  @@ -314,7 +314,7 @@
        * Recursively delete a directory.
        */
       public static void deleteDirectory( final File directory )
  -        throws IOException 
  +        throws IOException
       {
           if( !directory.exists() ) return;
   
  @@ -323,41 +323,41 @@
           {
               throw new IOException( "Directory " + directory + " unable to be 
deleted." );
           }
  -    }  
  +    }
   
       /**
        * Clean a directory without deleting it.
        */
       public static void cleanDirectory( final String directory )
  -        throws IOException 
  +        throws IOException
       {
           cleanDirectory( new File( directory ) );
       }
  -    
  +
       /**
        * Clean a directory without deleting it.
        */
       public static void cleanDirectory( final File directory )
  -        throws IOException 
  +        throws IOException
       {
  -        if( !directory.exists() ) 
  +        if( !directory.exists() )
           {
               throw new IllegalArgumentException( directory + " does not exist" );
           }
  -        
  +
           if( !directory.isDirectory() )
           {
               throw new IllegalArgumentException( directory + " is not a directory" );
           }
  -        
  +
           final File[] files = directory.listFiles();
  -        
  -        for( int i = 0; i < files.length; i++ ) 
  +
  +        for( int i = 0; i < files.length; i++ )
           {
               final File file = files[ i ];
  -            
  +
               if( file.isFile() ) file.delete();
  -            else if( file.isDirectory() ) 
  +            else if( file.isDirectory() )
               {
                   cleanDirectory( file );
                   if( false == file.delete() )
  @@ -366,5 +366,5 @@
                   }
               }
           }
  -    } 
  +    }
   }
  
  
  
  1.1                  
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/aut/io/AndFileFilter.java
  
  Index: AndFileFilter.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.aut.io;
  
  import java.io.File;
  import java.io.FilenameFilter;
  
  /**
   * This takes two file fiters as input. Accepts a selection only if it is
   * accpetable to both the input filters
   *
   * @author  Harmeet Bedi <[EMAIL PROTECTED]>
   */
  public class AndFileFilter
      implements FilenameFilter
  {
      private final FilenameFilter m_filter1;
      private final FilenameFilter m_filter2;
  
      public AndFileFilter( FilenameFilter filter1, FilenameFilter filter2 )
      {
          m_filter1 = filter1;
          m_filter2 = filter2;
      }
  
      public boolean accept( final File file, final String name )
      {
          return m_filter1.accept( file, name ) && m_filter2.accept( file, name );
      }
  }
  
  
  
  
  
  1.1                  
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/aut/io/InvertedFileFilter.java
  
  Index: InvertedFileFilter.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.aut.io;
  
  import java.io.File;
  import java.io.FilenameFilter;
  
  /**
   * This takes a file filter as input and inverts the selection.
   * This is used in retrieving files that are not accepted by a filter.
   *
   * @author  Harmeet Bedi <[EMAIL PROTECTED]>
   */
  public class InvertedFileFilter implements FilenameFilter
  {
      private final FilenameFilter m_originalFilter;
  
      public InvertedFileFilter( final FilenameFilter originalFilter )
      {
          m_originalFilter = originalFilter;
      }
  
      public boolean accept( final File file, final String name )
      {
          return !m_originalFilter.accept( file, name );
      }
  }
  
  
  
  
  
  1.1                  
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/aut/io/OrFileFilter.java
  
  Index: OrFileFilter.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.aut.io;
  
  import java.io.File;
  import java.io.FilenameFilter;
  
  /**
   * This takes two file fiters as input. Accepts a selection if it is
   * accpetable to either input filter
   *
   * @author  Harmeet Bedi <[EMAIL PROTECTED]>
   */
  public class OrFileFilter
      implements FilenameFilter
  {
      private final FilenameFilter m_filter1;
      private final FilenameFilter m_filter2;
  
      public OrFileFilter( final FilenameFilter filter1, final FilenameFilter filter2 )
      {
          m_filter1 = filter1;
          m_filter2 = filter2;
      }
  
      public boolean accept( final File file, final String name )
      {
          return m_filter1.accept( file, name ) || m_filter2.accept( file, name );
      }
  }
  
  
  
  
  
  
  
  1.2       +33 -33    
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/aut/security/AbstractPolicy.java
  
  Index: AbstractPolicy.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/aut/security/AbstractPolicy.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractPolicy.java       2001/04/03 23:35:23     1.1
  +++ AbstractPolicy.java       2001/04/04 15:29:47     1.2
  @@ -1,9 +1,9 @@
  -/* 
  - * 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. 
  +/*
  + * 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.aut.security;
   
  @@ -22,14 +22,14 @@
   import java.util.ArrayList;
   import java.util.Enumeration;
   import java.util.PropertyPermission;
  -import org.apache.aut.io.FileUtil;
  +import org.apache.avalon.aut.io.FileUtil;
   import org.apache.framework.component.Component;
   import org.apache.framework.logger.Loggable;
   import org.apache.log.Logger;
   
   /**
    * Abstract policy extended in avalon.
  - * 
  + *
    * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
    */
   public abstract class AbstractPolicy
  @@ -39,7 +39,7 @@
       protected final static boolean   DEBUG         = true;
   
       protected final ArrayList        m_entries     = new ArrayList();
  -    
  +
       protected Logger                 m_logger;
   
       /**
  @@ -57,10 +57,10 @@
       }
   
       /**
  -     * Overide so we can have a per-application security policy with 
  +     * Overide so we can have a per-application security policy with
        * no side-effects to other applications.
        *
  -     * @param codeSource the codeSource to get permissions for 
  +     * @param codeSource the codeSource to get permissions for
        * @return the PermissionCollection
        */
       public PermissionCollection getPermissions( CodeSource codeSource )
  @@ -68,14 +68,14 @@
           codeSource = normalize( codeSource );
   
           getLogger().debug( "getPermissions(" + codeSource.getLocation() + ");" );
  -        
  +
           final Permissions permissions = new Permissions();
           final int size = m_entries.size();
  -        
  +
           for( int i = 0; i < size; i++ )
           {
               final PolicyEntry entry = (PolicyEntry)m_entries.get( i );
  -            
  +
               if( entry.m_codeSource.implies( codeSource ) )
               {
                   if( DEBUG )
  @@ -87,13 +87,13 @@
                   copyPermissions( permissions, entry.m_permissions );
               }
           }
  -        
  +
           if( DEBUG )
           {
               getLogger().debug( codeSource.getLocation() + " permissions = " + 
permissions );
           }
  -        
  -        return permissions;        
  +
  +        return permissions;
       }
   
       /**
  @@ -102,9 +102,9 @@
       public void refresh()
       {
       }
  -    
  +
       /**
  -     * Normalizing CodeSource involves removing relative addressing 
  +     * Normalizing CodeSource involves removing relative addressing
        * (like .. and .) for file urls.
        *
        * @param codeSource the codeSource to be normalized
  @@ -113,14 +113,14 @@
       protected CodeSource normalize( final CodeSource codeSource )
       {
           final URL initialLocation = codeSource.getLocation();
  -        
  +
           // This is a bit of a hack.  I don't know why CodeSource should behave like 
this
           // Fear not, this only seems to be a problem for home grown classloaders.
           // - Paul Hammant, Nov 2000
           if( null == initialLocation ) return codeSource;
   
           String location = null;
  -        
  +
           if( !initialLocation.getProtocol().equalsIgnoreCase( "file" ) )
           {
               location = initialLocation.getFile();
  @@ -132,9 +132,9 @@
               location = file.getAbsoluteFile().toString().replace( 
File.separatorChar, '/' );
               location =  FileUtil.normalize( location );
           }
  -        
  +
           URL finalLocation = null;
  -        
  +
           try
           {
               finalLocation = new URL( initialLocation.getProtocol(),
  @@ -142,7 +142,7 @@
                                        initialLocation.getPort(),
                                        location );
           }
  -        catch( final MalformedURLException mue ) 
  +        catch( final MalformedURLException mue )
           {
               getLogger().warn( "Error building codeBase", mue );
           }
  @@ -158,10 +158,10 @@
               destination.add( (Permission)enum.nextElement() );
           }
       }
  -    
  +
       /**
  -     * Create a permission set for a codeBase. 
  -     * These are read-write permissions and can be written till until the 
  +     * Create a permission set for a codeBase.
  +     * These are read-write permissions and can be written till until the
        * time in which they are applied to code.
        *
        * @param location the location of codes to apply permission set to.
  @@ -169,22 +169,22 @@
        * @return the new permission set
        * @exception MalformedURLException if location string is malformed
        */
  -    protected Permissions createPermissionSetFor( final String location, 
  +    protected Permissions createPermissionSetFor( final String location,
                                                     final Certificate[] signers )
           throws MalformedURLException
       {
           final PolicyEntry entry = new PolicyEntry();
           entry.m_codeSource = new CodeSource( new URL( location ), signers );
           entry.m_codeSource = normalize( entry.m_codeSource );
  -        
  -        getLogger().debug( "createPermissionSetFor(" + 
  +
  +        getLogger().debug( "createPermissionSetFor(" +
                              entry.m_codeSource.getLocation() + ");" );
  -        
  +
           entry.m_permissions = new Permissions();
  -        
  +
           m_entries.add( entry );
           return entry.m_permissions;
  -    }   
  +    }
   
       protected final Logger getLogger()
       {
  
  
  
  1.6       +20 -23    
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/AbstractContainer.java
  
  Index: AbstractContainer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/AbstractContainer.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AbstractContainer.java    2001/04/03 23:17:59     1.5
  +++ AbstractContainer.java    2001/04/04 15:29:47     1.6
  @@ -1,22 +1,19 @@
  -/* 
  - * 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. 
  +/*
  + * 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.camelot;
   
   import java.util.HashMap;
   import java.util.Iterator;
   import org.apache.framework.component.Component;
  -import org.apache.framework.container.Container;
  -import org.apache.framework.container.ContainerException;
  -import org.apache.framework.container.Entry;
   import org.apache.framework.logger.AbstractLoggable;
   
   /**
  - * This contains it during execution and may provide certain 
  + * This contains it during execution and may provide certain
    * facilities (like a thread per EJB etc).
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
  @@ -72,7 +69,7 @@
           throws ContainerException
       {
           final Entry entry = (Entry)m_entries.get( name );
  -        
  +
           if( null == entry )
           {
               throw new ContainerException( "Name " + name + " not contained" );
  @@ -94,7 +91,7 @@
       }
   
       /**
  -     * This method is called before entry is added to give chance for 
  +     * This method is called before entry is added to give chance for
        * sub-class to veto removal.
        *
        * @param name the name of entry
  @@ -107,7 +104,7 @@
       }
   
       /**
  -     * This method is called after entry is added to give chance for 
  +     * This method is called after entry is added to give chance for
        * sub-class to do some cleanup.
        *
        * @param name the name of entry
  @@ -116,9 +113,9 @@
       protected void postAdd( final String name, final Entry entry )
       {
       }
  -    
  +
       /**
  -     * This method is called before entry is removed to give chance for 
  +     * This method is called before entry is removed to give chance for
        * sub-class to veto removal.
        *
        * @param name the name of entry
  @@ -131,7 +128,7 @@
       }
   
       /**
  -     * This method is called after entry is removed to give chance for 
  +     * This method is called after entry is removed to give chance for
        * sub-class to do some cleanup.
        *
        * @param name the name of entry
  @@ -140,7 +137,7 @@
       protected void postRemove( final String name, final Entry entry )
       {
       }
  -    
  +
       /**
        * List all entries in container.
        *
  @@ -149,26 +146,26 @@
       protected Iterator listEntries()
       {
           return m_entries.values().iterator();
  -    }   
  -     
  +    }
  +
       protected void checkEntry( final String name, final Entry entry )
           throws ContainerException
       {
           if( null != m_entries.get( name ) )
           {
  -            throw new ContainerException( "Can not add component to container 
because " + 
  +            throw new ContainerException( "Can not add component to container 
because " +
                                             "entry already exists with name " + name 
);
           }
   
           if( !isValidName( name ) )
           {
  -            throw new ContainerException( "Can not add component to container 
because " + 
  +            throw new ContainerException( "Can not add component to container 
because " +
                                             "invalid name " + name );
           }
  -        
  +
           if( !isValidEntry( entry ) )
           {
  -            throw new ContainerException( "Can not add component to container 
because " + 
  +            throw new ContainerException( "Can not add component to container 
because " +
                                             "invalid entry for " + name );
           }
   
  
  
  
  1.6       +12 -14    
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/AbstractDeployer.java
  
  Index: AbstractDeployer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/AbstractDeployer.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AbstractDeployer.java     2001/04/03 23:17:59     1.5
  +++ AbstractDeployer.java     2001/04/04 15:29:47     1.6
  @@ -1,9 +1,9 @@
  -/* 
  - * 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. 
  +/*
  + * 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.camelot;
   
  @@ -16,10 +16,8 @@
   import java.util.HashMap;
   import org.apache.framework.logger.AbstractLoggable;
   import org.apache.framework.component.Component;
  -import org.apache.aut.io.FileUtil;
  +import org.apache.avalon.aut.io.FileUtil;
   import org.apache.log.Logger;
  -import org.apache.framework.container.Deployer;
  -import org.apache.framework.container.DeploymentException;
   
   /**
    * A Deployer is responsible for taking a URL (ie a jar/war/ear) and deploying
  @@ -55,10 +53,10 @@
           {
               throw new DeploymentException( m_type + " already exists at " + 
location );
           }
  -        
  +
           if( !isValidLocation( location ) )
           {
  -            throw new DeploymentException( "Invalid location (" + location + 
  +            throw new DeploymentException( "Invalid location (" + location +
                                              ") for " + m_type );
           }
       }
  @@ -80,7 +78,7 @@
               if( !m_autoUndeploy )
               {
                   //we are midstream but not allowed to automagically undeploy .. 
therefore
  -                throw new DeploymentException( m_type + " not ready to undeploy at 
" + 
  +                throw new DeploymentException( m_type + " not ready to undeploy at 
" +
                                                  location );
               }
               else
  @@ -123,13 +121,13 @@
   
           if( !file.exists() )
           {
  -            throw new DeploymentException( "Could not find application archive at " 
+ 
  +            throw new DeploymentException( "Could not find application archive at " 
+
                                              file );
           }
   
           if( file.isDirectory() )
           {
  -            throw new DeploymentException( "Could not find application archive at " 
+ 
  +            throw new DeploymentException( "Could not find application archive at " 
+
                                              file + " as it is a directory." );
           }
   
  
  
  
  1.4       +6 -8      
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/AvalonState.java
  
  Index: AvalonState.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/AvalonState.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AvalonState.java  2001/03/15 04:34:44     1.3
  +++ AvalonState.java  2001/04/04 15:29:47     1.4
  @@ -1,13 +1,11 @@
  -/* 
  - * 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. 
  +/*
  + * 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.camelot;
  -
  -import org.apache.framework.container.State;
   
   public final class AvalonState
       extends State
  
  
  
  1.4       +15 -17    
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/CamelotUtil.java
  
  Index: CamelotUtil.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/CamelotUtil.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- CamelotUtil.java  2001/03/15 04:34:44     1.3
  +++ CamelotUtil.java  2001/04/04 15:29:47     1.4
  @@ -1,9 +1,9 @@
  -/* 
  - * 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. 
  +/*
  + * 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.camelot;
   
  @@ -11,10 +11,8 @@
   import java.io.IOException;
   import java.net.MalformedURLException;
   import java.util.Iterator;
  -import org.apache.aut.io.ExtensionFileFilter;
  +import org.apache.avalon.aut.io.ExtensionFileFilter;
   import org.apache.framework.component.Component;
  -import org.apache.framework.container.Deployer;
  -import org.apache.framework.container.DeploymentException;
   
   /**
    * Utility methods for Camelot related facilities.
  @@ -30,7 +28,7 @@
       {
       }
   
  -    public static void deployFromDirectory( final Deployer deployer, 
  +    public static void deployFromDirectory( final Deployer deployer,
                                               final File directory,
                                               final String extention )
           throws DeploymentException
  @@ -38,11 +36,11 @@
           deployFromDirectory( deployer, directory, new String[] { extention } );
       }
   
  -    public static void deployFromDirectory( final Deployer deployer, 
  +    public static void deployFromDirectory( final Deployer deployer,
                                               final File directory,
                                               final String[] extentions )
           throws DeploymentException
  -                                          
  +
       {
           final ExtensionFileFilter filter = new ExtensionFileFilter( extentions );
           final File[] files = directory.listFiles( filter );
  @@ -59,14 +57,14 @@
           for( int i = 0; i < files.length; i++ )
           {
               final String filename = files[ i ].getName();
  -            
  +
               int index = filename.lastIndexOf( '.' );
               if( -1 == index ) index = filename.length();
  -            
  +
               final String name = filename.substring( 0, index );
  -            
  +
               try
  -            { 
  +            {
                   final File file = files[ i ].getCanonicalFile();
                   deployer.deploy( name, file.toURL() );
               }
  @@ -76,7 +74,7 @@
               }
               catch( final IOException ioe )
               {
  -                throw new DeploymentException( "Unable to get canonical 
representation " + 
  +                throw new DeploymentException( "Unable to get canonical 
representation " +
                                                  "for file " + files[ i ], ioe );
               }
           }
  
  
  
  1.2       +8 -8      
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/Container.java
  
  Index: Container.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/Container.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Container.java    2001/04/03 23:17:59     1.1
  +++ Container.java    2001/04/04 15:29:47     1.2
  @@ -1,17 +1,17 @@
  -/* 
  - * 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. 
  +/*
  + * 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.framework.container;
  +package org.apache.avalon.camelot;
   
   import java.util.Iterator;
   import org.apache.framework.component.Component;
   
   /**
  - * This contains it during execution and may provide certain 
  + * This contains it during execution and may provide certain
    * facilities (like a thread per EJB etc).
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
  
  
  
  1.2       +5 -5      
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/ContainerException.java
  
  Index: ContainerException.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/ContainerException.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ContainerException.java   2001/04/03 23:17:59     1.1
  +++ ContainerException.java   2001/04/04 15:29:48     1.2
  @@ -5,16 +5,16 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    */
  -package org.apache.framework.container;
  +package org.apache.avalon.camelot;
   
   import org.apache.framework.CascadingException;
   
   /**
    * Exception to indicate error manipulating container.
  - * 
  + *
    * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
    */
  -public final class ContainerException 
  +public final class ContainerException
       extends CascadingException
   {
       /**
  @@ -22,7 +22,7 @@
        *
        * @param message The detail message for this exception.
        */
  -    public ContainerException( final String message ) 
  +    public ContainerException( final String message )
       {
           this( message, null );
       }
  @@ -33,7 +33,7 @@
        * @param message The detail message for this exception.
        * @param throwable the root cause of the exception
        */
  -    public ContainerException( final String message, final Throwable throwable ) 
  +    public ContainerException( final String message, final Throwable throwable )
       {
           super( message, throwable );
       }
  
  
  
  1.6       +16 -20    
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/DefaultFactory.java
  
  Index: DefaultFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/DefaultFactory.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultFactory.java       2001/04/03 23:17:59     1.5
  +++ DefaultFactory.java       2001/04/04 15:29:48     1.6
  @@ -1,9 +1,9 @@
  -/* 
  - * 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. 
  +/*
  + * 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.camelot;
   
  @@ -11,13 +11,9 @@
   import java.util.HashMap;
   import org.apache.framework.logger.AbstractLoggable;
   import org.apache.framework.component.Component;
  -import org.apache.framework.container.Factory;
  -import org.apache.framework.container.FactoryException;
  -import org.apache.framework.container.Loader;
  -import org.apache.framework.container.Locator;
   
   /**
  - * This is the component that creates the components. 
  + * This is the component that creates the components.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
    */
  @@ -40,7 +36,7 @@
        * @return the component
        * @exception FactoryException if an error occurs
        */
  -    public Object create( final Locator locator ) 
  +    public Object create( final Locator locator )
           throws FactoryException
       {
           final Loader loader = getLoaderFor( locator.getLocation() );
  @@ -48,7 +44,7 @@
           try { return loader.load( locator.getName() ); }
           catch( final Exception e )
           {
  -            throw new FactoryException( "Unable to create " + locator.getName() + 
  +            throw new FactoryException( "Unable to create " + locator.getName() +
                                           " from " + locator.getLocation(), e );
           }
       }
  @@ -57,13 +53,13 @@
           throws FactoryException
       {
           final Object object = create( locator );
  -        
  +
           if( !clazz.isInstance( object ) )
           {
               throw new FactoryException( "Created object of type " + 
object.getClass().getName() +
                                           " not compatable with type " + 
clazz.getName() );
           }
  -        
  +
           return object;
       }
   
  @@ -71,7 +67,7 @@
       {
           final String location = url.toString();
           LoaderEntry loader = (LoaderEntry)m_loaders.get( location );
  -        
  +
           if( null == loader )
           {
               getLogger().info( "Creating ClassLoader for " + location );
  @@ -79,14 +75,14 @@
   
               loader.m_loader = setupLoader( url );
               loader.m_lastModified = System.currentTimeMillis();
  -            
  +
               m_loaders.put( location, loader );
           }
           else
           {
               //TODO: Check it up to date and reload if necessary
           }
  -        
  +
           return loader.m_loader;
       }
   
  @@ -95,12 +91,12 @@
           final ClassLoader classLoader = 
Thread.currentThread().getContextClassLoader();
           final Loader loader = createLoader( url, classLoader );
   
  -/* FIX ME 
  +/* FIX ME
           setupLogger( loader );
   */
           return loader;
       }
  -    
  +
       /**
        * Create a new loader.
        * Put in another method so that it can be overridden.
  
  
  
  1.6       +10 -12    
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/DefaultLoader.java
  
  Index: DefaultLoader.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/DefaultLoader.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DefaultLoader.java        2001/04/03 23:17:59     1.5
  +++ DefaultLoader.java        2001/04/04 15:29:48     1.6
  @@ -1,9 +1,9 @@
  -/* 
  - * 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. 
  +/*
  + * 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.camelot;
   
  @@ -11,12 +11,10 @@
   import java.net.URLClassLoader;
   import org.apache.framework.ExceptionUtil;
   import org.apache.framework.component.Component;
  -import org.apache.framework.container.FactoryException;
  -import org.apache.framework.container.Loader;
   
   /**
    * Class used to load resources from a source.
  - * 
  + *
    * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
    */
   public class DefaultLoader
  @@ -37,7 +35,7 @@
       public DefaultLoader( final URL location )
       {
           this( location, Thread.currentThread().getContextClassLoader() );
  -    }    
  +    }
   
       public DefaultLoader()
       {
  @@ -93,13 +91,13 @@
           }
           catch( final IllegalAccessException iae )
           {
  -            throw new FactoryException( "Failed to instantiate class " + classname 
+ 
  +            throw new FactoryException( "Failed to instantiate class " + classname +
                                           " as it does not have a publicly accesable 
" +
                                           "default constructor", iae );
           }
           catch( final Throwable t )
           {
  -            throw new FactoryException( "Failed to get class " + classname + 
  +            throw new FactoryException( "Failed to get class " + classname +
                                           " due to " + ExceptionUtil.printStackTrace( 
t, 5, true ),
                                           t );
           }
  
  
  
  1.4       +9 -10     
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/DefaultLocator.java
  
  Index: DefaultLocator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/DefaultLocator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultLocator.java       2001/03/15 04:34:45     1.3
  +++ DefaultLocator.java       2001/04/04 15:29:48     1.4
  @@ -1,19 +1,18 @@
  -/* 
  - * 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. 
  +/*
  + * 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.camelot;
   
   import java.net.URL;
   import org.apache.framework.component.Component;
  -import org.apache.framework.container.Locator;
  - 
  +
   /**
    * This contains information required to locate a component.
  - * 
  + *
    * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
    */
   public class DefaultLocator
  @@ -27,7 +26,7 @@
           m_name = name;
           m_location = location;
       }
  -    
  +
       /**
        * Retrieve "name" of component type.
        * The "name" usually indicates the classname.
  
  
  
  1.4       +6 -10     
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/DefaultRegistry.java
  
  Index: DefaultRegistry.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/DefaultRegistry.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DefaultRegistry.java      2001/03/15 04:34:45     1.3
  +++ DefaultRegistry.java      2001/04/04 15:29:48     1.4
  @@ -1,19 +1,15 @@
  -/* 
  - * 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. 
  +/*
  + * 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.camelot;
   
   import java.util.HashMap;
   import java.util.Iterator;
   import org.apache.framework.component.Component;
  -import org.apache.framework.container.Registry;
  -import org.apache.framework.container.RegistryException;
  -import org.apache.framework.container.MetaInfo;
  -
   
   /**
    * Represents a Registry of names to types.
  
  
  
  1.2       +7 -7      
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/Deployer.java
  
  Index: Deployer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/Deployer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Deployer.java     2001/04/03 23:17:59     1.1
  +++ Deployer.java     2001/04/04 15:29:48     1.2
  @@ -1,11 +1,11 @@
  -/* 
  - * 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. 
  +/*
  + * 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.framework.container;
  +package org.apache.avalon.camelot;
   
   import java.net.URL;
   import org.apache.framework.component.Component;
  
  
  
  1.5       +21 -22    
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/DeployerUtil.java
  
  Index: DeployerUtil.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/DeployerUtil.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DeployerUtil.java 2001/04/03 23:17:59     1.4
  +++ DeployerUtil.java 2001/04/04 15:29:48     1.5
  @@ -23,7 +23,6 @@
   import org.apache.framework.component.Composer;
   import org.apache.framework.configuration.Configuration;
   import org.apache.framework.configuration.ConfigurationException;
  -import org.apache.framework.container.DeploymentException;
   import org.xml.sax.SAXException;
   
   /**
  @@ -66,7 +65,7 @@
           final File file = getFileFor( url );
           return getZipFileFor( file );
       }
  -*/  
  +*/
       /**
        * Retrieve zip file for file.
        *
  @@ -80,12 +79,12 @@
           try { return new ZipFile( file ); }
           catch( final IOException ioe )
           {
  -            throw new DeploymentException( "Error opening " + file + 
  +            throw new DeploymentException( "Error opening " + file +
                                              " due to " + ioe.getMessage(),
                                              ioe );
  -        }        
  +        }
       }
  -    
  +
       /**
        * Utility method to load configuration from zip.
        *
  @@ -94,13 +93,13 @@
        * @return the Configuration
        * @exception DeploymentException if an error occurs
        */
  -    public final static Configuration loadConfiguration( final ZipFile zipFile, 
  +    public final static Configuration loadConfiguration( final ZipFile zipFile,
                                                            final String filename )
           throws DeploymentException
       {
           return buildConfiguration( loadResourceStream( zipFile, filename ) );
       }
  -    
  +
       /**
        * Build a configuration tree based on input stream.
        *
  @@ -125,7 +124,7 @@
               throw new DeploymentException( "Error reading configuration", ioe );
           }
       }
  -    
  +
       /**
        * Utility method to load a manifest from a zip file.
        *
  @@ -136,9 +135,9 @@
           throws DeploymentException
       {
           final InputStream input = loadResourceStream( zipFile, 
"META-INF/MANIFEST.MF" );
  -        
  +
           try { return new Manifest( input ); }
  -        catch( final IOException ioe ) 
  +        catch( final IOException ioe )
           {
               throw new DeploymentException( "Error reading manifest", ioe );
           }
  @@ -148,7 +147,7 @@
               catch( final IOException ioe ) {}
           }
       }
  -    
  +
       /**
        * Utility method to load properties from zip.
        *
  @@ -157,23 +156,23 @@
        * @return the Properties
        * @exception DeploymentException if an error occurs
        */
  -    public final static Properties loadProperties( final ZipFile zipFile, 
  +    public final static Properties loadProperties( final ZipFile zipFile,
                                                      final String filename )
           throws DeploymentException
       {
           final Properties properties = new Properties();
  -        
  +
           try { properties.load( loadResourceStream( zipFile, filename ) ); }
           catch( final IOException ioe )
           {
  -            throw new DeploymentException( "Error reading " + filename + 
  +            throw new DeploymentException( "Error reading " + filename +
                                              " from " + zipFile.getName(),
                                              ioe );
           }
  -        
  +
           return properties;
       }
  -    
  +
       /**
        * Load a resource from a zip file.
        *
  @@ -182,24 +181,24 @@
        * @return the InputStream
        * @exception DeploymentException if an error occurs
        */
  -    public final static InputStream loadResourceStream( final ZipFile zipFile, 
  +    public final static InputStream loadResourceStream( final ZipFile zipFile,
                                                           final String filename )
           throws DeploymentException
       {
           final ZipEntry entry = zipFile.getEntry( filename );
  -        
  +
           if( null == entry )
           {
  -            throw new DeploymentException( "Unable to locate " + filename + 
  +            throw new DeploymentException( "Unable to locate " + filename +
                                              " in " + zipFile.getName() );
           }
  -        
  +
           try { return zipFile.getInputStream( entry ); }
           catch( final IOException ioe )
           {
  -            throw new DeploymentException( "Error reading " + filename + 
  +            throw new DeploymentException( "Error reading " + filename +
                                              " from " + zipFile.getName(),
                                              ioe );
  -        }        
  +        }
       }
   }
  
  
  
  1.2       +5 -5      
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/DeploymentException.java
  
  Index: DeploymentException.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/DeploymentException.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DeploymentException.java  2001/04/03 23:17:59     1.1
  +++ DeploymentException.java  2001/04/04 15:29:48     1.2
  @@ -5,16 +5,16 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    */
  -package org.apache.framework.container;
  +package org.apache.avalon.camelot;
   
   import org.apache.framework.CascadingException;
   
   /**
    * Exception to indicate error deploying.
  - * 
  + *
    * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
    */
  -public final class DeploymentException 
  +public final class DeploymentException
       extends CascadingException
   {
       /**
  @@ -22,7 +22,7 @@
        *
        * @param message The detail message for this exception.
        */
  -    public DeploymentException( final String message ) 
  +    public DeploymentException( final String message )
       {
           this( message, null );
       }
  @@ -33,7 +33,7 @@
        * @param message The detail message for this exception.
        * @param throwable the root cause of the exception
        */
  -    public DeploymentException( final String message, final Throwable throwable ) 
  +    public DeploymentException( final String message, final Throwable throwable )
       {
           super( message, throwable );
       }
  
  
  
  1.2       +12 -12    
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/Entry.java
  
  Index: Entry.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/Entry.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Entry.java        2001/04/03 23:17:59     1.1
  +++ Entry.java        2001/04/04 15:29:48     1.2
  @@ -1,17 +1,17 @@
  -/* 
  - * 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. 
  +/*
  + * 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.framework.container;
  +package org.apache.avalon.camelot;
   
   import org.apache.framework.component.Component;
   
   /**
  - * Contains information about a particular instance of contained component. 
  - * This would contain name, configuration data, parameters, log entries etc. 
  + * Contains information about a particular instance of contained component.
  + * This would contain name, configuration data, parameters, log entries etc.
    * Basically instance data.
   *
    * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
  @@ -63,7 +63,7 @@
       {
           return m_instance;
       }
  -    
  +
       /**
        * Set instance of component.
        *
  @@ -73,7 +73,7 @@
       {
           m_instance = instance;
       }
  -    
  +
       /**
        * Retrieve state of a component.
        *
  @@ -83,7 +83,7 @@
       {
           return m_state;
       }
  -    
  +
       /**
        * set state of a component.
        *
  
  
  
  1.2       +11 -11    
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/Factory.java
  
  Index: Factory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/Factory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Factory.java      2001/04/03 23:17:59     1.1
  +++ Factory.java      2001/04/04 15:29:48     1.2
  @@ -1,16 +1,16 @@
  -/* 
  - * 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. 
  +/*
  + * 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.framework.container;
  +package org.apache.avalon.camelot;
   
   import org.apache.framework.component.Component;
   
   /**
  - * This is the component that creates the components. 
  + * This is the component that creates the components.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
    */
  @@ -24,11 +24,11 @@
        * @return the component
        * @exception FactoryException if an error occurs
        */
  -    Object create( Locator locator ) 
  +    Object create( Locator locator )
           throws FactoryException;
   
       /**
  -     * Create a component whos position is indicated by locator. 
  +     * Create a component whos position is indicated by locator.
        * Make sure it is of the correct type.
        *
        * @param locator the locator indicating the component location
  @@ -36,6 +36,6 @@
        * @return the component
        * @exception FactoryException if an error occurs
        */
  -    Object create( Locator locator, Class clazz ) 
  +    Object create( Locator locator, Class clazz )
           throws FactoryException;
   }
  
  
  
  1.2       +5 -5      
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/FactoryException.java
  
  Index: FactoryException.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/FactoryException.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FactoryException.java     2001/04/03 23:17:59     1.1
  +++ FactoryException.java     2001/04/04 15:29:48     1.2
  @@ -5,16 +5,16 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    */
  -package org.apache.framework.container;
  +package org.apache.avalon.camelot;
   
   import org.apache.framework.CascadingException;
   
   /**
    * Exception to indicate error creating entries in factory.
  - * 
  + *
    * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
    */
  -public final class FactoryException 
  +public final class FactoryException
       extends CascadingException
   {
       /**
  @@ -22,7 +22,7 @@
        *
        * @param message The detail message for this exception.
        */
  -    public FactoryException( final String message ) 
  +    public FactoryException( final String message )
       {
           this( message, null );
       }
  @@ -33,7 +33,7 @@
        * @param message The detail message for this exception.
        * @param throwable the root cause of the exception
        */
  -    public FactoryException( final String message, final Throwable throwable ) 
  +    public FactoryException( final String message, final Throwable throwable )
       {
           super( message, throwable );
       }
  
  
  
  1.2       +8 -8      
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/Loader.java
  
  Index: Loader.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/Loader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Loader.java       2001/04/03 23:17:59     1.1
  +++ Loader.java       2001/04/04 15:29:48     1.2
  @@ -1,17 +1,17 @@
  -/* 
  - * 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. 
  +/*
  + * 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.framework.container;
  +package org.apache.avalon.camelot;
   
   import org.apache.framework.component.Component;
   
   /**
    * Class used to load resources from a source.
  - * 
  + *
    * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
    */
   public interface Loader
  
  
  
  1.2       +8 -8      
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/Locator.java
  
  Index: Locator.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/Locator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Locator.java      2001/04/03 23:17:59     1.1
  +++ Locator.java      2001/04/04 15:29:48     1.2
  @@ -1,18 +1,18 @@
  -/* 
  - * 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. 
  +/*
  + * 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.framework.container;
  +package org.apache.avalon.camelot;
   
   import java.net.URL;
   import org.apache.framework.component.Component;
   
   /**
    * This contains information required to locate a component.
  - * 
  + *
    * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
    */
   public interface Locator
  
  
  
  1.2       +7 -7      
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/MetaInfo.java
  
  Index: MetaInfo.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/MetaInfo.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MetaInfo.java     2001/04/03 23:17:59     1.1
  +++ MetaInfo.java     2001/04/04 15:29:48     1.2
  @@ -1,11 +1,11 @@
  -/* 
  - * 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. 
  +/*
  + * 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.framework.container;
  +package org.apache.avalon.camelot;
   
   /**
    * This contains information about the component.
  
  
  
  1.2       +7 -7      
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/Registry.java
  
  Index: Registry.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/Registry.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Registry.java     2001/04/03 23:17:59     1.1
  +++ Registry.java     2001/04/04 15:29:48     1.2
  @@ -1,11 +1,11 @@
  -/* 
  - * 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. 
  +/*
  + * 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.framework.container;
  +package org.apache.avalon.camelot;
   
   import java.util.Iterator;
   import org.apache.framework.component.Component;
  
  
  
  1.2       +6 -6      
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/RegistryException.java
  
  Index: RegistryException.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/RegistryException.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RegistryException.java    2001/04/03 23:17:59     1.1
  +++ RegistryException.java    2001/04/04 15:29:48     1.2
  @@ -5,16 +5,16 @@
    * version 1.1, a copy of which has been included with this distribution in
    * the LICENSE file.
    */
  -package org.apache.framework.container;
  +package org.apache.avalon.camelot;
   
   import org.apache.framework.CascadingException;
   
   /**
    * Exception to indicate registry error.
  - * 
  + *
    * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
    */
  -public final class RegistryException 
  +public final class RegistryException
       extends CascadingException
   {
       /**
  @@ -22,18 +22,18 @@
        *
        * @param message The detail message for this exception.
        */
  -    public RegistryException( final String message ) 
  +    public RegistryException( final String message )
       {
           this( message, null );
       }
  -    
  +
       /**
        * Construct a new <code>RegistryException</code> instance.
        *
        * @param message The detail message for this exception.
        * @param throwable the root cause of the exception
        */
  -    public RegistryException( final String message, final Throwable throwable ) 
  +    public RegistryException( final String message, final Throwable throwable )
       {
           super( message, throwable );
       }
  
  
  
  1.2       +9 -9      
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/State.java
  
  Index: State.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/camelot/State.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- State.java        2001/04/03 23:17:59     1.1
  +++ State.java        2001/04/04 15:29:48     1.2
  @@ -1,16 +1,16 @@
  -/* 
  - * 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. 
  +/*
  + * 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.framework.container;
  +package org.apache.avalon.camelot;
   
  -import org.apache.aut.ValuedEnum;
  +import org.apache.avalon.util.ValuedEnum;
   
   /**
  - * Defines possible states for contained components. 
  + * Defines possible states for contained components.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
    */
  
  
  
  1.4       +10 -10    
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/datasource/DataSourceComponent.java
  
  Index: DataSourceComponent.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/datasource/DataSourceComponent.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DataSourceComponent.java  2001/04/03 04:41:42     1.3
  +++ DataSourceComponent.java  2001/04/04 15:29:49     1.4
  @@ -1,10 +1,10 @@
  -/* 
  - * 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. 
  - */ 
  +/*
  + * 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.datasource;
   
   import java.sql.Connection;
  @@ -17,14 +17,14 @@
    * The standard interface for DataSources in Avalon.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
  - * @version CVS $Revision: 1.3 $ $Date: 2001/04/03 04:41:42 $
  + * @version CVS $Revision: 1.4 $ $Date: 2001/04/04 15:29:49 $
    */
  -public interface DataSourceComponent 
  +public interface DataSourceComponent
       extends Component, Configurable, ThreadSafe
   {
       /**
        * Gets the Connection to the database
        */
  -    Connection getConnection() 
  +    Connection getConnection()
           throws SQLException;
   }
  
  
  
  1.3       +14 -14    
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/datasource/J2eeDataSource.java
  
  Index: J2eeDataSource.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/datasource/J2eeDataSource.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- J2eeDataSource.java       2001/03/15 04:34:50     1.2
  +++ J2eeDataSource.java       2001/04/04 15:29:49     1.3
  @@ -1,10 +1,10 @@
  -/* 
  - * 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. 
  - */ 
  +/*
  + * 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.datasource;
   
   import java.sql.Connection;
  @@ -15,7 +15,7 @@
   import javax.sql.DataSource;
   import org.apache.framework.configuration.Configuration;
   import org.apache.framework.configuration.ConfigurationException;
  -import org.apache.avalon.logger.AbstractLoggable;
  +import org.apache.framework.logger.AbstractLoggable;
   
   /**
    * The J2EE implementation for DataSources in Cocoon.  This uses the
  @@ -23,9 +23,9 @@
    * J2EE container pools the datasources properly.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
  - * @version CVS $Revision: 1.2 $ $Date: 2001/03/15 04:34:50 $
  + * @version CVS $Revision: 1.3 $ $Date: 2001/04/04 15:29:49 $
    */
  -public class J2eeDataSource 
  +public class J2eeDataSource
       extends AbstractLoggable
       implements DataSourceComponent
   {
  @@ -45,7 +45,7 @@
       public void configure( final Configuration configuration )
           throws ConfigurationException
       {
  -        if( null == m_dataSource ) 
  +        if( null == m_dataSource )
           {
               final String databaseName = configuration.getChild("dbname").getValue();
   
  @@ -53,8 +53,8 @@
               {
                   final Context initialContext = new InitialContext();
                   m_dataSource = (DataSource)initialContext.lookup( JDBC_NAME + 
databaseName );
  -            } 
  -            catch( final NamingException ne ) 
  +            }
  +            catch( final NamingException ne )
               {
                   getLogger().error( "Problem with JNDI lookup of datasource", ne );
                   throw new ConfigurationException( "Could not use JNDI to find 
datasource", ne );
  @@ -64,7 +64,7 @@
   
       /** Get the database connection */
       public Connection getConnection()
  -        throws SQLException 
  +        throws SQLException
       {
           if( null == m_dataSource )
           {
  
  
  
  1.7       +41 -42    
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/datasource/JdbcConnection.java
  
  Index: JdbcConnection.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/datasource/JdbcConnection.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JdbcConnection.java       2001/04/03 23:18:01     1.6
  +++ JdbcConnection.java       2001/04/04 15:29:49     1.7
  @@ -1,10 +1,10 @@
  -/* 
  - * 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. 
  - */ 
  +/*
  + * 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.datasource;
   
   import java.sql.CallableStatement;
  @@ -18,8 +18,7 @@
   import org.apache.framework.logger.AbstractLoggable;
   import org.apache.avalon.pool.Recyclable;
   import org.apache.avalon.pool.Pool;
  -import org.apache.avalon.pool.Poolable;
  - 
  +
   /**
    * The Connection object used in conjunction with the JdbcDataSource
    * object.
  @@ -29,11 +28,11 @@
    * total number of Connection objects that are created.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
  - * @version CVS $Revision: 1.6 $ $Date: 2001/04/03 23:18:01 $
  + * @version CVS $Revision: 1.7 $ $Date: 2001/04/04 15:29:49 $
    */
  -public class JdbcConnection 
  +public class JdbcConnection
       extends AbstractLoggable
  -    implements Connection, Recyclable, Poolable
  +    implements Connection, Recyclable
   {
       private Connection         m_connection;
       private Pool               m_pool;
  @@ -44,154 +43,154 @@
           m_pool = pool;
       }
   
  -    public Statement createStatement() 
  +    public Statement createStatement()
           throws SQLException
       {
           return m_connection.createStatement();
       }
   
  -    public PreparedStatement prepareStatement( final String sql ) 
  +    public PreparedStatement prepareStatement( final String sql )
           throws SQLException
       {
           return m_connection.prepareStatement( sql );
       }
   
  -    public CallableStatement prepareCall( final String sql ) 
  +    public CallableStatement prepareCall( final String sql )
           throws SQLException
       {
           return m_connection.prepareCall( sql );
       }
   
  -    public String nativeSQL( final String sql ) 
  +    public String nativeSQL( final String sql )
           throws SQLException
       {
           return m_connection.nativeSQL( sql );
       }
   
  -    public void setAutoCommit( final boolean autoCommit ) 
  +    public void setAutoCommit( final boolean autoCommit )
           throws SQLException
       {
           m_connection.setAutoCommit( autoCommit );
       }
   
  -    public boolean getAutoCommit() 
  +    public boolean getAutoCommit()
           throws SQLException
       {
           return m_connection.getAutoCommit();
       }
   
  -    public void commit() 
  +    public void commit()
           throws SQLException
       {
           m_connection.commit();
       }
   
  -    public void rollback() 
  +    public void rollback()
           throws SQLException
       {
           m_connection.rollback();
       }
   
  -    public void close() 
  +    public void close()
           throws SQLException
       {
  -        setAutoCommit( false );
  +        clearWarnings();
           m_pool.put( this );
       }
   
  -    public void recycle() 
  +    public void recycle()
       {
  -        try { m_connection.close(); } 
  +        try { m_connection.close(); }
           catch( final SQLException se )
           {
               getLogger().warn( "Could not close connection", se );
           }
       }
   
  -    public boolean isClosed() 
  +    public boolean isClosed()
           throws SQLException
       {
           return m_connection.isClosed();
       }
   
  -    public DatabaseMetaData getMetaData() 
  +    public DatabaseMetaData getMetaData()
           throws SQLException
       {
           return m_connection.getMetaData();
       }
   
  -    public void setReadOnly( final boolean readOnly ) 
  +    public void setReadOnly( final boolean readOnly )
           throws SQLException
       {
           m_connection.setReadOnly( readOnly );
       }
   
  -    public boolean isReadOnly() 
  +    public boolean isReadOnly()
           throws SQLException
       {
           return m_connection.isReadOnly();
       }
   
  -    public void setCatalog( final String catalog ) 
  +    public void setCatalog( final String catalog )
           throws SQLException
       {
           m_connection.setCatalog( catalog );
       }
   
  -    public String getCatalog() 
  +    public String getCatalog()
           throws SQLException
       {
           return m_connection.getCatalog();
       }
   
  -    public void setTransactionIsolation( final int level ) 
  +    public void setTransactionIsolation( final int level )
           throws SQLException
       {
           m_connection.setTransactionIsolation(level);
       }
   
  -    public int getTransactionIsolation() 
  +    public int getTransactionIsolation()
           throws SQLException
       {
           return m_connection.getTransactionIsolation();
       }
   
  -    public SQLWarning getWarnings() 
  +    public SQLWarning getWarnings()
           throws SQLException
       {
           return m_connection.getWarnings();
       }
   
  -    public void clearWarnings() 
  +    public void clearWarnings()
           throws SQLException
       {
           m_connection.clearWarnings();
       }
   
  -    public Statement createStatement( final int resultSetType, 
  -                                      final int resultSetConcurrency ) 
  +    public Statement createStatement( final int resultSetType,
  +                                      final int resultSetConcurrency )
           throws SQLException
       {
           return m_connection.createStatement(resultSetType, resultSetConcurrency);
       }
   
  -    public PreparedStatement prepareStatement( final String sql, 
  -                                               final int resultSetType, 
  -                                               final int resultSetConcurrency ) 
  +    public PreparedStatement prepareStatement( final String sql,
  +                                               final int resultSetType,
  +                                               final int resultSetConcurrency )
           throws SQLException
       {
           return m_connection.prepareStatement( sql, resultSetType, 
resultSetConcurrency );
       }
   
  -    public CallableStatement prepareCall( final String sql, 
  -                                          final int resultSetType, 
  +    public CallableStatement prepareCall( final String sql,
  +                                          final int resultSetType,
                                             final int resultSetConcurrency )
           throws SQLException
       {
           return m_connection.prepareCall( sql, resultSetType, resultSetConcurrency );
       }
   
  -    public Map getTypeMap() 
  +    public Map getTypeMap()
           throws SQLException
       {
           return m_connection.getTypeMap();
  
  
  
  1.8       +99 -101   
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/datasource/JdbcConnectionPool.java
  
  Index: JdbcConnectionPool.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/datasource/JdbcConnectionPool.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- JdbcConnectionPool.java   2001/04/03 23:18:01     1.7
  +++ JdbcConnectionPool.java   2001/04/04 15:29:49     1.8
  @@ -12,19 +12,21 @@
   import java.sql.SQLException;
   import java.util.ArrayList;
   import java.util.List;
  -import org.apache.avalon.pool.Pool;
  -import org.apache.avalon.pool.Poolable;
  -import org.apache.avalon.pool.Recyclable;
  +import java.util.Date;
  +import org.apache.framework.logger.AbstractLoggable;
   import org.apache.framework.lifecycle.Disposable;
   import org.apache.framework.lifecycle.Initializable;
  -import org.apache.framework.logger.AbstractLoggable;
  +import org.apache.avalon.pool.Poolable;
  +import org.apache.avalon.pool.Recyclable;
  +import org.apache.avalon.pool.Pool;
  +import org.apache.avalon.util.Lock;
   
   /**
    * The Pool implementation for JdbcConnections.  It uses a background
    * thread to manage the number of SQL Connections.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
  - * @version CVS $Revision: 1.7 $ $Date: 2001/04/03 23:18:01 $
  + * @version CVS $Revision: 1.8 $ $Date: 2001/04/04 15:29:49 $
    */
   public class JdbcConnectionPool
       extends AbstractLoggable
  @@ -33,84 +35,64 @@
       private final String           m_dburl;
       private final String           m_username;
       private final String           m_password;
  -    private final int              m_min;
       private final int              m_max;
  -    private int                    m_currentCount;
  +    private final boolean          m_autoCommit;
       private List                   m_active        = new ArrayList();
       private List                   m_ready         = new ArrayList();
  -    private boolean                m_monitoring    = true;
  +    private boolean                m_initialized   = false;
  +    private boolean                m_disposed      = false;
  +    private Lock                   m_lock          = new Lock();
  +    private Thread                 m_initThread;
   
       public JdbcConnectionPool( final String url,
                                  final String username,
                                  final String password,
  -                               final int min,
  -                               final int max )
  +                               final int max,
  +                               final boolean autoCommit )
       {
           m_dburl = url;
           m_username = username;
           m_password = password;
   
  -        if( min < 0 )
  +        if( max < 1 )
           {
  -            getLogger().warn( "Minumum number of connections specified is " +
  -                              "less than 0, using 0" );
  -            m_min = 0;
  -        }
  -        else
  -        {
  -            m_min = min;
  -        }
  -
  -        if( ( max < min ) || ( max < 1 ) )
  -        {
               getLogger().warn( "Maximum number of connections specified must be at " 
+
                                 "least 1 and must be greater than the minumum number 
" +
                                 "of connections" );
  -            m_max = ( min > 1 ) ? min : 1;
  +            m_max = 1;
           }
           else
           {
               m_max = max;
           }
  +
  +        m_autoCommit = autoCommit;
       }
   
       public void init()
       {
  -        for( int i = 0; i < m_min; i++ )
  -        {
  -            m_ready.add( createJdbcConnection() );
  -        }
  -
  -        new Thread( this );
  +        m_initThread = new Thread( this );
  +        m_initThread.start();
       }
   
       private JdbcConnection createJdbcConnection()
  +    throws SQLException
       {
           JdbcConnection connection = null;
   
  -        try
  +        if( null == m_username )
           {
  -            if( null == m_username )
  -            {
  -                connection = new JdbcConnection( DriverManager.getConnection( 
m_dburl ), this );
  -                connection.setLogger(getLogger());
  -                m_currentCount++;
  -            }
  -            else
  -            {
  -                connection =
  -                    new JdbcConnection( DriverManager.getConnection( m_dburl,
  -                                                                     m_username,
  -                                                                     m_password ),
  -                                        this);
  -                connection.setLogger(getLogger());
  -                m_currentCount++;
  -            }
  +            connection = new JdbcConnection( DriverManager.getConnection( m_dburl 
), this );
  +            connection.setLogger(getLogger());
           }
  -
  -        catch( final SQLException se )
  +        else
           {
  -            getLogger().error( "Could not create connection to database", se );
  +            connection =
  +                new JdbcConnection( DriverManager.getConnection( m_dburl,
  +                                                                 m_username,
  +                                                                 m_password ),
  +                                    this);
  +            connection.setLogger(getLogger());
           }
   
           getLogger().debug( "JdbcConnection object created" );
  @@ -126,98 +108,114 @@
       public Poolable get()
           throws Exception
       {
  -        Poolable obj = null;
  -
  -        if( 0 == m_ready.size() )
  +        if (! m_initialized)
           {
  -            if( m_currentCount < m_max )
  +            if (m_initThread == null)
               {
  -                synchronized( m_active )
  -                {
  -                    obj = createJdbcConnection();
  -                    m_active.add( obj );
  -                }
  +                throw new IllegalStateException("You cannot get a Connection before 
the pool is initialized");
               }
               else
               {
  -                throw new SQLException("There are no more Connections available");
  +                m_initThread.join();
               }
           }
  +
  +        if (m_disposed)
  +        {
  +            throw new IllegalStateException("You cannot get a Connection after the 
pool is disposed");
  +        }
  +
  +        m_lock.lock(m_ready);
  +        Poolable obj = null;
  +        final int size;
  +
  +        if( 0 == m_ready.size() )
  +        {
  +            throw new SQLException("There are no more Connections available");
  +        }
           else
           {
  -            synchronized( m_active )
  -            {
  -                obj = (Poolable)m_ready.remove( 0 );
  -                m_active.add( obj );
  -            }
  +            obj = (Poolable)m_ready.remove( 0 );
  +
  +            m_lock.lock(m_active);
  +            m_active.add( obj );
  +            m_lock.unlock(m_active);
           }
   
  +        m_lock.unlock(m_ready);
  +
  +        if (((Connection)obj).getAutoCommit() != m_autoCommit) {
  +            ((Connection)obj).setAutoCommit(m_autoCommit);
  +        }
  +
           getLogger().debug( "JdbcConnection '" + m_dburl +
                              "' has been requested from pool." );
   
           return obj;
       }
   
  -    public synchronized void put( final Poolable obj )
  +    public void put( final Poolable obj )
       {
  -        int location = m_active.indexOf( obj );
  +        if (! m_initialized)
  +        {
  +            throw new IllegalStateException("You cannot return an object to an 
uninitialized pool");
  +        }
  +
  +        m_lock.lock(m_active);
           m_active.remove( obj );
   
  -        if( m_monitoring )
  +        if(! m_disposed)
           {
  +            m_lock.lock(m_ready);
               m_ready.add( obj );
  +            m_lock.unlock(m_ready);
  +        } else {
  +            recycle((Recyclable) obj);
           }
   
  +        m_lock.unlock(m_active);
  +
           getLogger().debug( "JdbcConnection '" + m_dburl + "' has been returned to 
the pool." );
       }
   
       public void run()
       {
  -        while( m_monitoring )
  +        m_lock.lock(m_ready);
  +        for (int i = 0; i < m_max; i++)
           {
  -            synchronized( m_ready )
  -            {
  -                if( m_ready.size() < m_min )
  -                {
  -                    getLogger().debug( "There are not enough Connections for pool: 
" + m_dburl );
  -                    
  -                    while( ( m_ready.size() < m_min ) && ( m_currentCount < m_max ) 
)
  -                    {
  -                        m_ready.add( createJdbcConnection() );
  -                    }
  -                }
  -                else
  -                {
  -                    getLogger().debug( "Trimming excess fat from pool: " + m_dburl 
);
  -
  -                    while( m_ready.size() > m_min ) 
  -                    {
  -                        recycle( (Recyclable)m_ready.remove( 0 ) );
  -                    } 
  -                }
  +            try {
  +                m_ready.add( createJdbcConnection() );
  +            } catch (SQLException se) {
  +                getLogger().error( "Could not create connection to database", se );
               }
  +        }
   
  -            try
  -            {
  -                Thread.sleep( 1 * 60 * 1000 );
  -            } 
  -            catch( final InterruptedException ie )
  -            {
  -                getLogger().warn( "Caught an InterruptedException", ie );
  +        if ((m_ready.size() < m_max) && (m_ready.size() > 0)) {
  +            while (m_ready.size() < m_max) {
  +                try {
  +                    m_ready.add( createJdbcConnection() );
  +                } catch (SQLException se) {
  +                    getLogger().error( "Could not create connection to database", 
se );
  +                }
               }
           }
  +
  +        if (m_ready.size() > 0) {
  +            m_initialized = true;
  +        }
  +        m_lock.unlock(m_ready);
       }
   
       public void dispose()
       {
  -        m_monitoring = false;
  +        m_lock.lock(m_ready);
  +        m_disposed = true;
   
  -        synchronized (m_ready)
  +        while( ! m_ready.isEmpty() )
           {
  -            while( !m_ready.isEmpty() )
  -            {
  -                recycle( (Recyclable)m_ready.remove( 0 ) );
  -            }
  +            recycle( (Recyclable)m_ready.remove( 0 ) );
           }
  +
  +        m_lock.unlock(m_ready);
       }
   }
  
  
  
  1.6       +14 -14    
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/datasource/JdbcDataSource.java
  
  Index: JdbcDataSource.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/datasource/JdbcDataSource.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- JdbcDataSource.java       2001/04/03 23:18:01     1.5
  +++ JdbcDataSource.java       2001/04/04 15:29:50     1.6
  @@ -1,10 +1,10 @@
  -/* 
  - * 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. 
  - */ 
  +/*
  + * 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.datasource;
   
   import java.sql.Connection;
  @@ -20,9 +20,9 @@
    * <code>java.sql.DriverManager</code>.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
  - * @version CVS $Revision: 1.5 $ $Date: 2001/04/03 23:18:01 $
  + * @version CVS $Revision: 1.6 $ $Date: 2001/04/04 15:29:50 $
    */
  -public class JdbcDataSource 
  +public class JdbcDataSource
       extends AbstractLoggable
       implements DataSourceComponent
   {
  @@ -48,10 +48,10 @@
               final String passwd = configuration.getChild( "password" ).getValue( 
null );
               final Configuration controler = configuration.getChild( 
"pool-controller" );
   
  -            final int min = controler.getAttributeAsInt( "min", 0 );
               final int max = controler.getAttributeAsInt( "max", 3 );
  +            final boolean autoCommit = 
configuration.getChild("auto-commit").getValueAsBoolean(true);
   
  -            m_pool = new JdbcConnectionPool( dburl, user, passwd, min, max );
  +            m_pool = new JdbcConnectionPool( dburl, user, passwd, max, autoCommit );
               m_pool.setLogger(getLogger());
               m_pool.init();
           }
  @@ -59,9 +59,9 @@
   
       /** Get the database connection */
       public Connection getConnection()
  -        throws SQLException 
  +        throws SQLException
       {
  -        try { return (Connection) m_pool.get(); } 
  +        try { return (Connection) m_pool.get(); }
           catch( final Exception e )
           {
               getLogger().error( "Could not return Connection", e );
  @@ -70,7 +70,7 @@
       }
   
       /** Dispose properly of the pool */
  -    public void dispose() 
  +    public void dispose()
       {
           m_pool.dispose();
           m_pool = null;
  
  
  
  1.2       +9 -9      
jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/pool/Recyclable.java
  
  Index: Recyclable.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/avalon/pool/Recyclable.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Recyclable.java   2001/04/02 04:06:30     1.1
  +++ Recyclable.java   2001/04/04 15:29:50     1.2
  @@ -12,21 +12,21 @@
    * A recyclable object is defined as an object that can be used to
    * encapsulate another object without being altered by its content.
    * Therefore, a recyclable object may be recycled and reused many times.
  - * 
  - * This is helpful in cases where recyclable objects are continously 
  - * created and destroied, causing a much greater amount of garbage to 
  - * be collected by the JVM garbage collector. By making it recyclable, 
  - * it is possible to reduce the GC execution time thus incrementing the 
  - * overall performance of a process and decrementing the chance of 
  + *
  + * This is helpful in cases where recyclable objects are continously
  + * created and destroied, causing a much greater amount of garbage to
  + * be collected by the JVM garbage collector. By making it recyclable,
  + * it is possible to reduce the GC execution time thus incrementing the
  + * overall performance of a process and decrementing the chance of
    * memory overflow.
  - * 
  - * Every implementation must provide their own method to allow this 
  + *
  + * Every implementation must provide their own method to allow this
    * recyclable object to be reused by setting its content.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
    */
  -public interface Recyclable
  +public interface Recyclable extends Poolable
   {
       /**
        * This method should be implemented to remove all costly resources
  
  
  
  1.2       +1 -2      
jakarta-avalon/proposal/4.0/src/java/org/apache/framework/configuration/AbstractConfiguration.java
  
  Index: AbstractConfiguration.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/framework/configuration/AbstractConfiguration.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractConfiguration.java        2001/04/03 23:18:02     1.1
  +++ AbstractConfiguration.java        2001/04/04 15:29:50     1.2
  @@ -17,8 +17,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2001/04/03 23:18:02 $
  - * @deprecated This has been deprecated in favour of configuration interface in 
org.apache.avalon.configuration interface
  + * @version CVS $Revision: 1.2 $ $Date: 2001/04/04 15:29:50 $
    */
   public abstract class AbstractConfiguration
       implements Configuration
  
  
  
  1.2       +23 -24    
jakarta-avalon/proposal/4.0/src/java/org/apache/framework/configuration/DefaultConfiguration.java
  
  Index: DefaultConfiguration.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon/proposal/4.0/src/java/org/apache/framework/configuration/DefaultConfiguration.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultConfiguration.java 2001/04/03 23:18:02     1.1
  +++ DefaultConfiguration.java 2001/04/04 15:29:50     1.2
  @@ -18,10 +18,9 @@
    * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Pierpaolo Fumagalli</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
  - * @deprecated This has been deprecated in favour of configuration interface in 
org.apache.avalon.configuration interface
    */
  -public class DefaultConfiguration 
  -    extends AbstractConfiguration 
  +public class DefaultConfiguration
  +    extends AbstractConfiguration
   {
       protected final static Iterator          EMPTY_ITERATOR = (new 
ArrayList(1)).iterator();
   
  @@ -34,7 +33,7 @@
       /**
        * Create a new <code>DefaultConfiguration</code> instance.
        */
  -    public DefaultConfiguration( final String name, final String location ) 
  +    public DefaultConfiguration( final String name, final String location )
       {
           m_name = name;
           m_location = location;
  @@ -43,7 +42,7 @@
       /**
        * Returns the name of this configuration element.
        */
  -    public String getName() 
  +    public String getName()
       {
           return m_name;
       }
  @@ -61,7 +60,7 @@
        *
        * @exception ConfigurationException If the value is not present.
        */
  -    public String getValue() throws ConfigurationException 
  +    public String getValue() throws ConfigurationException
       {
           if( null != m_value ) return m_value;
           else
  @@ -77,10 +76,10 @@
        *
        * @exception ConfigurationException If the attribute is not present.
        */
  -    public String getAttribute( final String name ) 
  -        throws ConfigurationException 
  +    public String getAttribute( final String name )
  +        throws ConfigurationException
       {
  -        final String value = 
  +        final String value =
               (null != m_attributes) ? (String)m_attributes.get( name ) : null;
   
           if( null != value ) return value;
  @@ -98,16 +97,16 @@
        *
        * @param name The name of the required child <code>Configuration</code>.
        */
  -    public Configuration getChild( final String name ) 
  +    public Configuration getChild( final String name )
       {
  -        if( null == m_children ) 
  +        if( null == m_children )
           {
               return new DefaultConfiguration( name, "-" );
           }
           else
           {
               final int size = m_children.size();
  -            for( int i = 0; i < size; i++ ) 
  +            for( int i = 0; i < size; i++ )
               {
                   final Configuration configuration = (Configuration)m_children.get( 
i );
                   if( name.equals( configuration.getName() ) )
  @@ -128,7 +127,7 @@
        *
        * @param name The name of the required children <code>Configuration</code>.
        */
  -    public Iterator getChildren( final String name ) 
  +    public Iterator getChildren( final String name )
       {
           if( null == m_children ) return EMPTY_ITERATOR;
           else
  @@ -136,7 +135,7 @@
               final ArrayList children = new ArrayList();
               final int size = m_children.size();
   
  -            for( int i = 0; i < size; i++ ) 
  +            for( int i = 0; i < size; i++ )
               {
                   final Configuration configuration = (Configuration)m_children.get( 
i );
                   if( name.equals( configuration.getName() ) )
  @@ -149,7 +148,7 @@
           }
       }
   
  -    public Configuration[] getChildrenAsArray( final String name ) 
  +    public Configuration[] getChildrenAsArray( final String name )
       {
           if( null == m_children ) return new Configuration[0];
           else
  @@ -157,7 +156,7 @@
               final ArrayList children = new ArrayList();
               final int size = m_children.size();
   
  -            for( int i = 0; i < size; i++ ) 
  +            for( int i = 0; i < size; i++ )
               {
                   final Configuration configuration = (Configuration)m_children.get( 
i );
                   if( name.equals( configuration.getName() ) )
  @@ -172,19 +171,19 @@
               return response;
           }
       }
  -    
  +
   
   
       /**
        * Append data to the value of this configuration element.
        */
  -    public void appendValueData( final String value ) 
  +    public void appendValueData( final String value )
       {
  -        if( null == m_value ) 
  +        if( null == m_value )
           {
               m_value = value;
           }
  -        else 
  +        else
           {
               m_value = m_value + value;
           }
  @@ -194,7 +193,7 @@
        * Add an attribute to this configuration element, returning its old
        * value or <b>null</b>.
        */
  -    public String addAttribute( final String name, String value ) 
  +    public String addAttribute( final String name, String value )
       {
           if( null == m_attributes ) m_attributes = new HashMap();
   
  @@ -204,7 +203,7 @@
       /**
        * Add a child <code>Configuration</code> to this configuration element.
        */
  -    public void addChild( final Configuration configuration ) 
  +    public void addChild( final Configuration configuration )
       {
           if( null == m_children )
           {
  @@ -217,13 +216,13 @@
       /**
        * Return count of children.
        */
  -    public int getChildCount() 
  +    public int getChildCount()
       {
           if( null == m_children )
           {
               return 0;
           }
  -        
  +
           return m_children.size();
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to