avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/pool Controller.java DefaultPoolManager.java ManagablePool.java PoolManager.java
Date Wed, 26 Dec 2001 17:59:20 GMT
bloritsch    01/12/26 09:59:20

  Modified:    src/scratchpad/org/apache/avalon/excalibur/pool
                        DefaultPoolManager.java ManagablePool.java
                        PoolManager.java
  Added:       src/scratchpad/org/apache/avalon/excalibur/pool
                        Controller.java
  Log:
  addition of Controller interface.
  
  Revision  Changes    Path
  1.2       +21 -3     jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/pool/DefaultPoolManager.java
  
  Index: DefaultPoolManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/pool/DefaultPoolManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultPoolManager.java	2001/12/26 16:15:23	1.1
  +++ DefaultPoolManager.java	2001/12/26 17:59:20	1.2
  @@ -7,23 +7,28 @@
    */
   package org.apache.avalon.excalibur.pool;
   
  +import java.security.SecureRandom;
  +
   /**
    * This interface is for a PoolManager that creates pools that are managed
    * asynchronously.  The contract is that the controller type is specified in
    * the constructor.
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2001/12/26 16:15:23 $
  + * @version CVS $Revision: 1.2 $ $Date: 2001/12/26 17:59:20 $
    * @since 4.1
    */
   public class DefaultPoolManager implements PoolManager
   {
       private final ObjectFactory m_controllerFactory;
       private final long          m_managerKey;
  +    private final SecureRandom  m_keyGenerator;
   
       public DefaultPoolManager( final Class klass )
  +        throws Exception
       {
  -        m_managerKey = new java.util.Random().nextLong();
  +        m_keyGenerator = new SecureRandom();
  +        m_managerKey = m_keyGenerator.nextLong();
   
           m_controllerFactory = new DefaultObjectFactory( klass,
                                                           new Class[] {long.class},
  @@ -36,7 +41,20 @@
        * Return a managed pool that has a controller.
        */
       public Pool getManagedPool( ObjectFactory factory, int initialEntries )
  +        throws Exception
  +    {
  +        final long poolKey = getKey();
  +        final Controller controller = (Controller) m_controllerFactory.newInstance();
  +        controller.setPoolKey( poolKey, m_managerKey );
  +
  +        return new VariableSizePool( factory, initialEntries, poolKey );
  +    }
  +
  +    /**
  +     * Return a new key for the pool and controller.
  +     */
  +    private final long getKey()
       {
  -        return new VariableSizePool( factory, initialEntries, m_managerKey );
  +        return m_keyGenerator.nextLong();
       }
   }
  
  
  
  1.2       +2 -2      jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/pool/ManagablePool.java
  
  Index: ManagablePool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/pool/ManagablePool.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ManagablePool.java	2001/12/26 16:15:23	1.1
  +++ ManagablePool.java	2001/12/26 17:59:20	1.2
  @@ -24,10 +24,10 @@
    * </p>
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2001/12/26 16:15:23 $
  + * @version CVS $Revision: 1.2 $ $Date: 2001/12/26 17:59:20 $
    * @since 4.1
    */
  -public interface ManagablePool
  +public interface ManagablePool extends Pool
   {
       /**
        * Grow by the specified amount.  The pool should trust the Controller for
  
  
  
  1.2       +3 -2      jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/pool/PoolManager.java
  
  Index: PoolManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/pool/PoolManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PoolManager.java	2001/12/26 16:15:23	1.1
  +++ PoolManager.java	2001/12/26 17:59:20	1.2
  @@ -13,7 +13,7 @@
    * the constructor.
    *
    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2001/12/26 16:15:23 $
  + * @version CVS $Revision: 1.2 $ $Date: 2001/12/26 17:59:20 $
    * @since 4.1
    */
   public interface PoolManager
  @@ -21,5 +21,6 @@
       /**
        * Return a managed pool that has a controller.
        */
  -    Pool getManagedPool( ObjectFactory factory, int initialEntries );
  +    Pool getManagedPool( ObjectFactory factory, int initialEntries )
  +        throws Exception;
   }
  
  
  
  1.1                  jakarta-avalon-excalibur/src/scratchpad/org/apache/avalon/excalibur/pool/Controller.java
  
  Index: Controller.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.txt file.
   */
  package org.apache.avalon.excalibur.pool;
  
  /**
   * This interface is for a Controller that controls the Pool in question.
   *
   * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
   * @version CVS $Revision: 1.1 $ $Date: 2001/12/26 17:59:20 $
   * @since 4.1
   */
  public interface Controller
  {
      /**
       * Set the pool key for the Controller.  The Controller has the same
       * authorization semantics as the ManagablePool interface.  The manager key
       * is supplied by the constructor.  This is to allow Controllers to be
       * created by ObjectFactories--which don't allow you to pass new parameters
       * for each new object.
       */
      void setKey( long poolKey, long managerKey )
          throws IllegalAccessException;
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message