avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mcconn...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/all/src/scratchpad/org/apache/avalon/excalibur/service AbstractManager.java
Date Fri, 03 May 2002 03:40:44 GMT
mcconnell    02/05/02 20:40:43

  Modified:    all/src/scratchpad/org/apache/avalon/excalibur/service
                        AbstractManager.java
  Log:
  no message
  
  Revision  Changes    Path
  1.5       +55 -53    jakarta-avalon-excalibur/all/src/scratchpad/org/apache/avalon/excalibur/service/AbstractManager.java
  
  Index: AbstractManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/all/src/scratchpad/org/apache/avalon/excalibur/service/AbstractManager.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- AbstractManager.java	24 Mar 2002 09:56:41 -0000	1.4
  +++ AbstractManager.java	3 May 2002 03:40:43 -0000	1.5
  @@ -7,53 +7,56 @@
   
   package org.apache.avalon.excalibur.service;
   
  -import java.util.Hashtable;
  +import java.util.Enumeration;
   import java.util.Map;
  +import java.util.Hashtable;
  +import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.ServiceException;
   
  +
   /**
  - * Internal helper class the handles the functional requirements of
  + * Internal helper class the handles the functional requirements of 
    * both ComponetManager and ServiceManager.
    */
  -class AbstractManager
  +class AbstractManager 
   {
   
  -    /**
  -     * Hashtable containing service providers keyed by role name.
  -     * The manager use the providers in this table to aquire services
  -     * in response to <code>lookup</code> invocations.  Provider
  -     * types fall into one of the following three catagories:
  -     *
  -     * <table>
  -     * <tr><td><b>Policy</b></td><td><b>Description</b></td><tr>
  -     * <tr><td>SINGLETON_LIFETIME_POLICY</td><td>
  -     * Service of the type singleton are distinguished by the fact
  -     * that they do not inherit from Pool or Transient.  The singleton
  -     * provider object is a reference to the singleton service and is
  -     * return directly by the implemetation on invocation of lookup.
  -     * </td>
  -     * <tr><td>POOLED_LIFETIME_POLICY</td><td>
  -     * Pooled services implement the Pool interface.  The service
  -     * resolves lookup aquires the pooled service by invoking
  -     * <code>checkout</code> on the pool implementation. Clients
  -     * using pooled services are required to release services using
  -     * the manager <code>release</code> method.  The implementation will
  -     * attempt to locate the issuing pool and release the object on
  -     * behalf of the client.
  -     * </td>
  -     * <tr><td>TRANSIENT_LIFETIME_POLICY</td><td>
  -     * A transient provider is factory from which new instances are
  -     * created and pipelined following a invocation of <code>lookup</code>.
  -     * The invocing client is totally responsible for service disposal.
  -     * </td>
  -     */
  +   /**
  +    * Hashtable containing service providers keyed by role name.  
  +    * The manager use the providers in this table to aquire services
  +    * in response to <code>lookup</code> invocations.  Provider 
  +    * types fall into one of the following three catagories:
  +    *
  +    * <table>
  +    * <tr><td><b>Policy</b></td><td><b>Description</b></td><tr>
  +    * <tr><td>SINGLETON_LIFETIME_POLICY</td><td>
  +    * Service of the type singleton are distinguished by the fact 
  +    * that they do not inherit from Pool or Transient.  The singleton
  +    * provider object is a reference to the singleton service and is 
  +    * return directly by the implemetation on invocation of lookup.
  +    * </td>
  +    * <tr><td>POOLED_LIFETIME_POLICY</td><td>
  +    * Pooled services implement the Pool interface.  The service
  +    * resolves lookup aquires the pooled service by invoking 
  +    * <code>checkout</code> on the pool implementation. Clients 
  +    * using pooled services are required to release services using
  +    * the manager <code>release</code> method.  The implementation will
  +    * attempt to locate the issuing pool and release the object on 
  +    * behalf of the client. 
  +    * </td>
  +    * <tr><td>TRANSIENT_LIFETIME_POLICY</td><td>
  +    * A transient provider is factory from which new instances are 
  +    * created and pipelined following a invocation of <code>lookup</code>.
  +    * The invocing client is totally responsible for service disposal.
  +    * </td>
  +    */
       private Map m_providers;
   
  -    /**
  -     * Internal table that maintains a mapping betyween pooled objects and
  -     * the issuing pool.  The object is used as the key to lookup the pool
  -     * when handling object release.
  -     */
  +   /**
  +    * Internal table that maintains a mapping betyween pooled objects and
  +    * the issuing pool.  The object is used as the key to lookup the pool
  +    * when handling object release.
  +    */
       private Hashtable m_pooled_table = new Hashtable();
   
       public AbstractManager( Map providers )
  @@ -63,15 +66,14 @@
   
       public boolean has( String role )
       {
  -        return ( m_providers.get( role ) != null );
  +        return (m_providers.get( role ) != null );
       }
   
       public Object resolve( String role ) throws ServiceException
       {
           Object provider = m_providers.get( role );
  -        if( provider == null )
  -            throw new ServiceException(
  -                "Could not locate a provider for the role: " + role );
  +        if( provider == null ) throw new ServiceException(
  +            "Could not locate a provider for the role: " + role );
   
           if( provider instanceof TransientProvider )
           {
  @@ -79,7 +81,7 @@
               // return a transient instance
               //
   
  -            return ( (TransientProvider)provider ).create();
  +            return ((TransientProvider)provider).create( );
           }
           else if( provider instanceof PooledProvider )
           {
  @@ -90,7 +92,7 @@
               Object object = null;
               try
               {
  -                object = ( (PooledProvider)provider ).acquire();
  +                object = ((PooledProvider)provider).acquire( );
               }
               catch( Throwable e )
               {
  @@ -102,11 +104,11 @@
                   // it is invalid for a pool to provide the same object without
                   // it being released beforehand
   
  -                if( m_pooled_table.get( object ) != null )
  +                if( m_pooled_table.get( object ) != null ) 
                   {
  -                    final String error =
  -                        "Manager has an existing reference to an aquired object from '"
  -                        + role + "'.";
  +                    final String error = 
  +                      "Manager has an existing reference to an aquired object from '" 
  +                      + role + "'.";
                       throw new ServiceException( error );
                   }
                   m_pooled_table.put( object, provider );
  @@ -119,21 +121,21 @@
               // return a singleton service
               //
   
  -            return ( (SingletonProvider)provider ).provide();
  +            return ((SingletonProvider)provider).provide( );
           }
       }
   
  -    /**
  -     * Release a pooled object.
  -     * @param object a pooled object
  -     */
  +   /**
  +    * Release a pooled object.
  +    * @param object a pooled object
  +    */
       public void disgard( Object object )
       {
           //
           // release a pooled service
           //
   
  -        PooledProvider provider = (PooledProvider)m_pooled_table.get( object );
  +        PooledProvider provider = (PooledProvider) m_pooled_table.get( object );
           if( provider != null ) provider.release( object );
       }
   }
  
  
  

--
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