jvanzyl     01/06/24 22:09:05

  Modified:    src/java/org/apache/turbine/services BaseService.java
                        BaseServiceBroker.java
                        BaseUnicastRemoteService.java
                        InitializationException.java
                        InstantiationException.java Service.java
                        ServiceBroker.java TurbineServices.java
  Log:
  - removing more cruft from from the services, namely the init(Object)
    junk.
  - adding the ability for the services broker to give a service a logging
    category by name.
  
  Revision  Changes    Path
  1.13      +9 -1      
jakarta-turbine/src/java/org/apache/turbine/services/BaseService.java
  
  Index: BaseService.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/BaseService.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- BaseService.java  2001/06/20 08:35:23     1.12
  +++ BaseService.java  2001/06/25 05:09:02     1.13
  @@ -73,7 +73,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Daniel Rall</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Leonard Richardson</a>
  - * @version $Id: BaseService.java,v 1.12 2001/06/20 08:35:23 dlr Exp $
  + * @version $Id: BaseService.java,v 1.13 2001/06/25 05:09:02 jvanzyl Exp $
    */
   public class BaseService implements Service
   {
  @@ -104,6 +104,8 @@
        */
       protected String name;
   
  +<<<<<<< BaseService.java
  +=======
       /**
        * Performs early initialization.  Used in a manner similar to a
        * ctor.
  @@ -121,6 +123,7 @@
       {
       }
   
  +>>>>>>> 1.12
       /**
        * Performs late initializtion.  Called when the service is requested 
        * for the first time (if not already completely initialized by the 
  @@ -283,5 +286,10 @@
       public Category getCategory()
       {
           return getServiceBroker().getCategory();
  +    }        
  +
  +    public Category getCategory(String name)
  +    {
  +        return getServiceBroker().getCategory(name);
       }        
   }
  
  
  
  1.36      +46 -39    
jakarta-turbine/src/java/org/apache/turbine/services/BaseServiceBroker.java
  
  Index: BaseServiceBroker.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/BaseServiceBroker.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- BaseServiceBroker.java    2001/06/20 08:44:29     1.35
  +++ BaseServiceBroker.java    2001/06/25 05:09:02     1.36
  @@ -96,7 +96,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Rafal Krzewski</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Daniel Rall</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
  - * @version $Id: BaseServiceBroker.java,v 1.35 2001/06/20 08:44:29 dlr Exp $
  + * @version $Id: BaseServiceBroker.java,v 1.36 2001/06/25 05:09:02 jvanzyl Exp $
    */
   public abstract class BaseServiceBroker implements ServiceBroker
   {
  @@ -162,9 +162,9 @@
       protected String applicationRoot;
   
       /**
  -     * Creates a new vanilla instance of the broker.  Protected as a
  -     * further hint to avoid using this <code>ServiceBroker</code>
  -     * implementation directly.
  +     * Default constructor of InitableBorker.
  +     *
  +     * This constructor does nothing.
        */
       protected BaseServiceBroker()
       {
  @@ -206,14 +206,25 @@
       }
   
       /**
  -     * Get the log4j <code>Category</code> used for logging.
  +     * Get the log4j Category used for logging.
        *
  -     * @return The logger for this broker.
  +     * @return Category
        */
       public Category getCategory()
       {
           return category;
       }        
  +    
  +    /**
  +     * Get a log4j Category by name.
  +     *
  +     * @param name log4j category to return
  +     * @return Category log4j category
  +     */
  +    public Category getCategory(String name)
  +    {
  +        return Category.getInstance(name);
  +    }        
   
       /**
        * Initialize this service manager.
  @@ -241,11 +252,12 @@
       }
       
       /**
  -     * Sets an application specific service object that can be used by
  -     * application specific services.
  +     * Set an application specific service object
  +     * that can be used by application specific
  +     * services.
        *
  -     * @param name The name of the service object.
  -     * @param value The value of service object.
  +     * @param String name of service object
  +     * @param Object value of service object
        */
       public void setServiceObject(String name, Object value)
       {
  @@ -253,9 +265,9 @@
       }
       
       /**
  -     * Retrieves an application specific service object.
  +     * Get an application specific service object.
        *
  -     * @return Object An application specific service object.
  +     * @return Object application specific service object
        */
       public Object getServiceObject(String name)
       {
  @@ -301,16 +313,14 @@
           {
               String key = (String)keys.next();
               
  -            if (key.startsWith(SERVICE_PREFIX) &&
  -                key.endsWith(CLASSNAME_SUFFIX))
  +            if(key.startsWith(SERVICE_PREFIX) && key.endsWith(CLASSNAME_SUFFIX))
               {
                   String serviceKey = key.substring(pref, key.length() - suff);
                   notice ("Added Mapping for Service: " + serviceKey);
                   
                   if (! mapping.containsKey(serviceKey))
                   {
  -                    mapping.setProperty(serviceKey,
  -                                        configuration.getString(key));
  +                    mapping.setProperty(serviceKey, configuration.getString(key));
                   }                    
               }
           }
  @@ -336,14 +346,14 @@
       }
   
       /**
  -     * Shuts down a <code>Service</code>.
  -     *
  -     * This method is used to release resources allocated by an
  -     * <code>Service</code>, and return it to its initial (uninitailized)
  -     * state.
  -     *
  -     * @param className The name of the service to be uninitialized.
  -     */
  +        * Shuts down an <code>Initable</code>.
  +        *
  +        * This method is used to release resources allocated by an
  +        * <code>Initable</code>, and return it to its initial (uninitailized)
  +        * state.
  +        *
  +        * @param className The name of the class to be uninitialized.
  +        */
       public void shutdownClass(String className)
       {
           try
  @@ -388,8 +398,8 @@
       }
   
       /**
  -     * Returns an <code>Iterator</code> over all known service names
  -     * beginning with the provided prefix.
  +     * Returns an Iterator over all known service names beginning with
  +     * the provided prefix.
        *
        * @param prefix The prefix against which to test.
        * @return An Iterator of service names which match the prefix.
  @@ -604,11 +614,10 @@
               }
               if (!service.getInit())
               {
  -                // This exception will be caught & rethrown by this
  -                // very method.  getInit() returning false indicates
  -                // some initialization issue, which in turn prevents
  -                // the ServiceBroker from passing a reference to a
  -                // working instance of the initable to the client.
  +                // this exception will be caught & rethrown by this very method.
  +                // getInit() returning false indicates some initialization issue,
  +                // which in turn prevents the InitableBroker from passing a
  +                // reference to a working instance of the initable to the client.
                   throw new InitializationException(
                       "init() failed to initialize service " + name);
               }
  @@ -628,8 +637,8 @@
        * Early initialization of a Service can require access to Service
        * properties.  The Service must have its name and serviceBroker
        * set by then.  Therefore, before calling
  -     * Service.initClass(Object), the class must be instantiated with
  -     * ServiceBroker.getServiceInstance(), and
  +     * Initable.initClass(Object), the class must be instantiated with
  +     * InitableBroker.getInitableInstance(), and
        * Service.setServiceBroker() and Service.setName() must be
        * called.  This calls for two - level accesing the Services
        * instances.
  @@ -689,7 +698,7 @@
                           else if (t instanceof ClassCastException)
                           {
                               msg = "Class " + className + 
  -                                " doesn't implement the Service interface.";
  +                                " doesn't implement Initable.";
                           }
                           else
                           {
  @@ -798,18 +807,16 @@
       }        
   
       /**
  -     * Get the application root as set by the parent application.
  +     * Get the application root as set by
  +     * the parent application.
        *
  -     * @return String The application root for this broker.
  +     * @return String application root
        */
       public String getApplicationRoot()
       {
           return applicationRoot;
       }
   
  -    /**
  -     * @see org.apache.turbine.services.ServiceBroker#getRealPath
  -     */
       public String getRealPath(String path)
       {
           return getApplicationRoot() + '/' + path;
  
  
  
  1.8       +10 -24    
jakarta-turbine/src/java/org/apache/turbine/services/BaseUnicastRemoteService.java
  
  Index: BaseUnicastRemoteService.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/BaseUnicastRemoteService.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- BaseUnicastRemoteService.java     2001/06/20 08:49:26     1.7
  +++ BaseUnicastRemoteService.java     2001/06/25 05:09:02     1.8
  @@ -5,7 +5,6 @@
   import java.rmi.server.UnicastRemoteObject;
   import javax.servlet.ServletConfig;
   
  -import org.apache.turbine.util.TurbineException;
   import org.apache.log4j.Category;
   import org.apache.velocity.runtime.configuration.Configuration;
   
  @@ -20,6 +19,7 @@
   {
       protected Configuration configuration;
       private boolean isInitialized;
  +    //private InitableBroker initableBroker;
       private String name;
       private Properties properties;
       private ServiceBroker serviceBroker;
  @@ -28,6 +28,7 @@
           throws RemoteException
       {
           isInitialized = false;
  +        //initableBroker = null;
           properties = null;
           name = null;
           serviceBroker = null;
  @@ -54,23 +55,12 @@
           }
       }
   
  -    public void init(ServletConfig config)
  +    public void init() 
           throws InitializationException
       {
           setInit(true);
       }
   
  -    public void init(Object data)
  -        throws InitializationException
  -    {
  -        init((ServletConfig) data);
  -    }
  -
  -    public void init() throws InitializationException
  -    {
  -        setInit(true);
  -    }
  -
       protected void setInit(boolean value)
       {
           isInitialized = value;
  @@ -82,15 +72,6 @@
       }
   
       /**
  -     * @see org.apache.turbine.services.Service#getStatus()
  -     */
  -    public String getStatus()
  -        throws TurbineException
  -    {
  -        return (getInit() ? "Initialized" : "Uninitialized");
  -    }
  -
  -    /**
        * Shuts down this service.
        */
       public void shutdown()
  @@ -134,11 +115,16 @@
   
       public String getRealPath(String path)
       {
  -        return getServiceBroker().getRealPath(path);
  +        return null;
       }        
   
       public Category getCategory()
  +    {
  +        return null;
  +    }        
  +
  +    public Category getCategory(String name)
       {
  -        return getServiceBroker().getCategory();
  +        return null;
       }        
   }
  
  
  
  1.8       +3 -1      
jakarta-turbine/src/java/org/apache/turbine/services/InitializationException.java
  
  Index: InitializationException.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/InitializationException.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- InitializationException.java      2001/06/19 21:51:51     1.7
  +++ InitializationException.java      2001/06/25 05:09:02     1.8
  @@ -57,11 +57,13 @@
   import org.apache.turbine.util.TurbineException;
   
   /**
  - * Thrown in case of initialization problems.
  + * Thrown by <code>Initable</code> class in case of initialization
  + * problems.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Kevin Burton</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Rafal Krzewski</a>
  - * @version $Id: InitializationException.java,v 1.7 2001/06/19 21:51:51 mpoeschl 
Exp $
  + * @version $Id: InitializationException.java,v 1.8 2001/06/25 05:09:02 jvanzyl Exp 
$
  + * @see org.apache.turbine.services.Initable
    */
   public class InitializationException
       extends TurbineException
  
  
  
  1.9       +1 -0      
jakarta-turbine/src/java/org/apache/turbine/services/InstantiationException.java
  
  Index: InstantiationException.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/InstantiationException.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- InstantiationException.java       2001/06/19 21:51:51     1.8
  +++ InstantiationException.java       2001/06/25 05:09:03     1.9
  @@ -63,7 +63,8 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Kevin Burton</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Rafal Krzewski</a>
  - * @version $Id: InstantiationException.java,v 1.8 2001/06/19 21:51:51 mpoeschl Exp 
$
  + * @version $Id: InstantiationException.java,v 1.9 2001/06/25 05:09:03 jvanzyl Exp $
  + * @see org.apache.turbine.services.Initable
    */
   public class InstantiationException
       extends TurbineRuntimeException
  
  
  
  1.14      +13 -60    
jakarta-turbine/src/java/org/apache/turbine/services/Service.java
  
  Index: Service.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/Service.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Service.java      2001/06/20 08:43:34     1.13
  +++ Service.java      2001/06/25 05:09:03     1.14
  @@ -55,18 +55,12 @@
    */
   
   import java.util.Properties;
  -
  -import org.apache.turbine.util.TurbineException;
  -
   import org.apache.log4j.Category;
  -
   import org.apache.velocity.runtime.configuration.Configuration;
   
   /**
  - * <code>Service</code> implementations are pluggable, initializable
  - * singletons brokered by a manager class implementing the
  - * <code>ServiceBroker</code> interface.  Turbine's default
  - * implementation is the <code>TurbineServices</code> singleton.
  + * <code>Services</code> are <code>Initables</code> that have a name,
  + * and a set of properties.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Greg Ritter</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Brett McLaughlin</a>
  @@ -74,8 +68,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Rafal Krzewski</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Daniel Rall</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
  - * @author <a href="mailto:[EMAIL PROTECTED]";>Leonard Richardson</a>
  - * @version $Id: Service.java,v 1.13 2001/06/20 08:43:34 dlr Exp $
  + * @version $Id: Service.java,v 1.14 2001/06/25 05:09:03 jvanzyl Exp $
    */
   public interface Service
   {
  @@ -85,44 +78,23 @@
       public static final String SERVICE_NAME = "Service";
   
       /**
  -     * Performs early initailization of a Service
  +     * Performs late initialization of an Initable.
        *
  -     * During the startup of the system, different objects may be
  -     * passed to your class using this method.  It should ignore any
  -     * objects that it doesn't need or understand.
  -     *
  -     * After the class changes its internal state so that getInit()
  -     * returns true, this method will be called no more, and late
  -     * initialization will not be performed.
  -     *
  -     * If your class relies on early initialization, and the object it
  -     * expects was not received, you can use late initialization to
  -     * throw an exception and complain.
  -     *
  -     * @param data An Object to use for initialization activities.
  -     * @exception InitializationException, if initilaization of this
  -     * class was not successful.
  -     */
  -    public void init( Object data )
  -        throws InitializationException;
  -
  -    /**
  -     * Performs late initialization of a Service.
  -     *
  -     * When your class is being requested from a ServiceBroker, it
  +     * When your class is being requested from an InitableBroker, it
        * will call getInit(), and if it returns false, this method will
        * be invoked.
        *
        * @exception InitializationException, if initialization of this
        * class was not successful.
        */
  -    public void init( ) throws InitializationException;
  +    public void init( ) 
  +        throws InitializationException;
   
       /**
  -     * Returns an <code>Service</code> to an uninitialized state.
  +     * Returns an <code>Initable</code> to an uninitialized state.
        *
        * <p>This method must release all resources allocated by the 
  -     * <code>Service</code> implementation, and resetting its internal state.
  +     * <code>Initable</code> implementation, and resetting its internal state.
        * You may chose to implement this operation or not. If you support
        * this operation, getInit() should return false after successful
        * shutdown of the service.
  @@ -130,22 +102,13 @@
       public void shutdown( );
   
       /**
  -     * Returns initialization status of a Service.
  +     * Returns initialization status of an Initable.
        *
  -     * @return Initialization status of a Service.
  +     * @return Initialization status of an Initable.
        */
       public boolean getInit( );
   
       /**
  -     * Returns the current status of this service.
  -     *
  -     * @return The current status of this service.
  -     * @throws TurbineException Error determining service status.
  -     */
  -    public String getStatus()
  -        throws TurbineException;
  -
  -    /**
        * Provides a Service with a reference to the ServiceBroker that
        * instantiated this object, so that it can ask for its properties
        * and access other Services.
  @@ -185,19 +148,9 @@
        */
       public Configuration getConfiguration();    
   
  -    /**
  -     * Gets the version of the supplied path as relative to appliation
  -     * root.  Does not demand strict adherence to the Servlet API's
  -     * definition of <code>getRealPath()</code>.
  -     *
  -     * @return The path, relative to application root.
  -     */
       public String getRealPath(String path);
   
  -    /**
  -     * Returns the logger for this service.
  -     *
  -     * @return The service's logger.
  -     */
       public Category getCategory();
  +
  +    public Category getCategory(String name);
   }
  
  
  
  1.10      +14 -41    
jakarta-turbine/src/java/org/apache/turbine/services/ServiceBroker.java
  
  Index: ServiceBroker.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/ServiceBroker.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ServiceBroker.java        2001/06/20 08:36:24     1.9
  +++ ServiceBroker.java        2001/06/25 05:09:03     1.10
  @@ -63,26 +63,31 @@
    * Classes that implement this interface can act as a broker for
    * <code>Service</code> classes.
    *
  - * Functionality includes:
  + * Functionality that <code>ServiceBroker</code> provides in addition
  + * to <code>InitableBroker</code> functionality includes:
  + *
    * <ul>
  + *
    * <li>Maintaining service name to class name mapping, allowing
    * plugable service implementations.</li>
  + *
    * <li>Providing <code>Services</code> with <code>Properties</code>
    * based on a system wide configuration mechanism.</li>
  + *
    * </ul>
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Kevin Burton</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Rafal Krzewski</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Daniel Rall</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
  - * @version $Id: ServiceBroker.java,v 1.9 2001/06/20 08:36:24 dlr Exp $
  + * @version $Id: ServiceBroker.java,v 1.10 2001/06/25 05:09:03 jvanzyl Exp $
    */
   public interface ServiceBroker
   {
       /**
  -     * Performs early initialization of a <code>Service</code> class.
  +     * Performs early initialization of an Initable class.
        *
  -     * If your class depends on another service being initialized to
  +     * If your class depends on another Initable being initialized to
        * perform early initialization, you should always ask your broker
        * to initialize the other class with the objects that are passed
        * to you, before you try to retrieve that Initable's instance with
  @@ -97,7 +102,7 @@
           throws InitializationException;
   
       /**
  -     * Shutdowns a <code>Service</code> class.
  +     * Shutdowns an Initable class.
        *
        * This method is used to release resources allocated by an 
        * Initable class, and return it to initial (uninitailized)
  @@ -135,7 +140,7 @@
       //public void initServices( Object data );
   
       /**
  -     * Shutdowns a service.
  +     * Shutdowns a Service.
        *
        * This method is used to release resources allocated by a
        * Service, and return it to initial (uninitailized) state.
  @@ -145,7 +150,7 @@
       public void shutdownService( String name );
   
       /**
  -     * Shutdowns all services.
  +     * Shutdowns all Services.
        *
        * This method is used to release resources allocated by 
        * Services, and return them to initial (uninitailized) state.
  @@ -154,11 +159,11 @@
   
   
       /**
  -     * Returns an instance of the requested <code>Service</code>.
  +     * Returns an instance of requested Service.
        *
        * @param name The name of the Service requested.
        * @return An instance of requested Service.
  -     * @exception InstantiationException If the service is unknown or
  +     * @exception InstantiationException, if the service is unknown or
        * can't be initialized.
        */
       public Service getService( String name )
  @@ -182,42 +187,10 @@
        */
       public Configuration getConfiguration( String name );
       
  -    /**
  -     * Sets an application specific service object that can be used by
  -     * application specific services.
  -     *
  -     * @param name The name of the service object.
  -     * @param value The value of service object.
  -     */
       public void setServiceObject(String key, Object value);
  -
  -    /**
  -     * Retrieves an application specific service object.
  -     *
  -     * @return Object An application specific service object.
  -     */
       public Object getServiceObject(String name);
  -
  -    /**
  -     * Gets the version of the supplied path as relative to appliation
  -     * root.  Does not demand strict adherence to the Servlet API's
  -     * definition of <code>getRealPath()</code>.
  -     *
  -     * @return The path, relative to application root.
  -     */
       public String getRealPath(String path);    
  -
  -    /**
  -     * Get the application root as set by the parent application.
  -     *
  -     * @return String The application root for this broker.
  -     */
       public String getApplicationRoot();
  -
  -    /**
  -     * Get the log4j <code>Category</code> used for logging.
  -     *
  -     * @return The logger for this broker.
  -     */
       public Category getCategory();
  +    public Category getCategory(String name);
   }
  
  
  
  1.31      +4 -1      
jakarta-turbine/src/java/org/apache/turbine/services/TurbineServices.java
  
  Index: TurbineServices.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine/src/java/org/apache/turbine/services/TurbineServices.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- TurbineServices.java      2001/06/19 21:51:52     1.30
  +++ TurbineServices.java      2001/06/25 05:09:03     1.31
  @@ -70,7 +70,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]";>Rafal Krzewski</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jon S. Stevens</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
  - * @version $Id: TurbineServices.java,v 1.30 2001/06/19 21:51:52 mpoeschl Exp $
  + * @version $Id: TurbineServices.java,v 1.31 2001/06/25 05:09:03 jvanzyl Exp $
    */
   public class TurbineServices 
       extends BaseServiceBroker
  @@ -117,7 +117,10 @@
        *
        * <p> Note that this way you will receive a 'collapsed' version
        * of your resources - multiple entries with the same key will
  -     * have only one value stored.
  +     * have only one value stored.  Use the {@link #getConfiguration}
  +     * or {@link #getResources} method to take advantage of the capabilities
  +     * of the {@link org.apache.turbine.services.resources.TurbineResources}
  +     * class.
        *
        * @param name The name of the service.
        * @return Properties of requested Service.
  
  
  

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

Reply via email to