You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by dl...@apache.org on 2001/08/09 22:37:16 UTC

cvs commit: jakarta-turbine-fulcrum/src/core/java/org/apache/fulcrum BaseService.java BaseServiceBroker.java Service.java

dlr         01/08/09 13:37:16

  Modified:    src/core/java/org/apache/fulcrum BaseService.java
                        BaseServiceBroker.java Service.java
  Log:
  * Deprecated getInit() in favor of more-beanlike isInitialized().
  
  * Brought other classes more up to date.
  
  Revision  Changes    Path
  1.5       +6 -6      jakarta-turbine-fulcrum/src/core/java/org/apache/fulcrum/BaseService.java
  
  Index: BaseService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/core/java/org/apache/fulcrum/BaseService.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -u -r1.4 -r1.5
  --- BaseService.java	2001/08/09 20:19:44	1.4
  +++ BaseService.java	2001/08/09 20:37:16	1.5
  @@ -69,7 +69,7 @@
    * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
    * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
    * @author <a href="mailto:leonardr@segfault.org">Leonard Richardson</a>
  - * @version $Id: BaseService.java,v 1.4 2001/08/09 20:19:44 dlr Exp $
  + * @version $Id: BaseService.java,v 1.5 2001/08/09 20:37:16 dlr Exp $
    */
   public abstract class BaseService 
       implements Service
  @@ -127,11 +127,13 @@
        * Returns initialization status.
        *
        * @return True if the service is initialized.
  +     * @see org.apache.fulcrum.Service#getInit()
  +     * @see org.apache.fulcrum.Service#isInitialized()
        * @deprecated use isInitialized() which uses proper bean semantics.
        */
       public boolean getInit()
       {
  -        return isInitialized;
  +        return isInitialized();
       }
   
       /**
  @@ -144,13 +146,11 @@
       public String getStatus()
           throws ServiceException
       {
  -        return (getInit() ? "Initialized" : "Uninitialized");
  +        return (isInitialized() ? "Initialized" : "Uninitialized");
       }
   
       /**
  -     * Returns initialization status.
  -     *
  -     * @return True if the service is initialized.
  +     * @see org.apache.fulcrum.Service#isInitialized()
        */
       public boolean isInitialized()
       {
  
  
  
  1.3       +21 -19    jakarta-turbine-fulcrum/src/core/java/org/apache/fulcrum/BaseServiceBroker.java
  
  Index: BaseServiceBroker.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/core/java/org/apache/fulcrum/BaseServiceBroker.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -u -r1.2 -r1.3
  --- BaseServiceBroker.java	2001/08/05 16:04:51	1.2
  +++ BaseServiceBroker.java	2001/08/09 20:37:16	1.3
  @@ -94,7 +94,7 @@
    * @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
    * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
    * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
  - * @version $Id: BaseServiceBroker.java,v 1.2 2001/08/05 16:04:51 jvanzyl Exp $
  + * @version $Id: BaseServiceBroker.java,v 1.3 2001/08/09 20:37:16 dlr Exp $
    */
   public abstract class BaseServiceBroker implements ServiceBroker
   {
  @@ -162,7 +162,7 @@
       protected String applicationRoot;
   
       /**
  -     * Default constructor of InitableBorker.
  +     * Default constructor, protected as to only be useable by subclasses.
        *
        * This constructor does nothing.
        */
  @@ -352,7 +352,7 @@
       {
           Service instance = getServiceInstance(className);
   
  -        if (!instance.getInit())
  +        if (!instance.isInitialized())
           {
               // this call might result in an indirect recursion
               instance.init();
  @@ -360,11 +360,11 @@
       }
   
       /**
  -        * Shuts down an <code>Initable</code>.
  +        * Shuts down a <code>Service</code>.
           *
           * This method is used to release resources allocated by an
  -        * <code>Initable</code>, and return it to its initial (uninitailized)
  -        * state.
  +        * <code>Service</code>, and return it to its initial
  +        * (uninitailized) state.
           *
           * @param className The name of the class to be uninitialized.
           */
  @@ -372,11 +372,11 @@
       {
           try
           {
  -            Service initable = getServiceInstance(className);
  -            if (initable.getInit())
  +            Service service = getServiceInstance(className);
  +            if (service.isInitialized())
               {
  -                initable.shutdown();
  -                ((BaseService) initable).setInit(false);
  +                service.shutdown();
  +                ((BaseService) service).setInit(false);
               }
           }
           catch (InstantiationException e)
  @@ -614,11 +614,11 @@
           try
           {
               service = getServiceInstance(name);
  -            if (!service.getInit())
  +            if (!service.isInitialized())
               {
                   synchronized (service.getClass())
                   {
  -                    if (!service.getInit())
  +                    if (!service.isInitialized())
                       {
                           notice("Start Initializing service (late): " + name);
                           service.init();
  @@ -626,12 +626,14 @@
                       }
                   }
               }
  -            if (!service.getInit())
  +            if (!service.isInitialized())
               {
  -                // 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.
  +                // This exception will be caught & rethrown by this
  +                // very method.  isInitialized() returning false
  +                // indicates some initialization issue, which in turn
  +                // prevents the ServiceBroker from passing a
  +                // reference to a working instance of the service to
  +                // the client.
                   throw new InitializationException(
                       "init() failed to initialize service " + name);
               }
  @@ -652,7 +654,7 @@
        * properties.  The Service must have its name and serviceBroker
        * set by then.  Therefore, before calling
        * Initable.initClass(Object), the class must be instantiated with
  -     * InitableBroker.getInitableInstance(), and
  +     * ServiceBroker.getServiceInstance(), and
        * Service.setServiceBroker() and Service.setName() must be
        * called.  This calls for two - level accesing the Services
        * instances.
  @@ -712,7 +714,7 @@
                           else if (t instanceof ClassCastException)
                           {
                               msg = "Class " + className + 
  -                                " doesn't implement Initable.";
  +                                " doesn't implement Service interface";
                           }
                           else
                           {
  
  
  
  1.5       +36 -23    jakarta-turbine-fulcrum/src/core/java/org/apache/fulcrum/Service.java
  
  Index: Service.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/src/core/java/org/apache/fulcrum/Service.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -u -r1.4 -r1.5
  --- Service.java	2001/08/09 20:17:34	1.4
  +++ Service.java	2001/08/09 20:37:16	1.5
  @@ -68,7 +68,7 @@
    * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
    * @author <a href="mailto:leonardr@collab.net">Leonard Richardson</a>
    * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
  - * @version $Id: Service.java,v 1.4 2001/08/09 20:17:34 dlr Exp $
  + * @version $Id: Service.java,v 1.5 2001/08/09 20:37:16 dlr Exp $
    */
   public interface Service
   {
  @@ -81,24 +81,28 @@
        * Performs late initialization of an Initable.
        *
        * When your class is being requested from an InitableBroker, it
  -     * will call getInit(), and if it returns false, this method will
  -     * be invoked.  A typical implementation for classes extending
  -     * {@link org.apache.fulcrum.BaseService} will look something like
  -     * the following:
  +     * will call isInitialized(), and if it returns false, this method
  +     * will be invoked.  A typical implementation for classes
  +     * extending {@link org.apache.fulcrum.BaseService} will look
  +     * something like the following:
        * 
        * <blockquote><code><pre>
  -     * try
  +     * if (!isInitialized())
        * {
  -     *     // Your initialization activities ...
  -     *     setInit(true);
  +     *     try
  +     *     {
  +     *         // Your initialization activities ...
  +     *         setInit(true);
  +     *     }
  +     *     catch (Exception e)
  +     *     {
  +     *         throw new InitializationException("Something bad happened " +
  +     *                                           "during " +
  +     *                                           Service.SERVICE_NAME +
  +     *                                           " initialization: " +
  +     *                                           e.getMessage());
  +     *     }
        * }
  -     * catch (Exception e)
  -     * {
  -     *     throw new InitializationException("Something bad happened during " +
  -     *                                       Service.SERVICE_NAME +
  -     *                                       " initialization: " +
  -     *                                       e.getMessage());
  -     * }
        * </pre></code></blockquote>
        *
        * @exception InitializationException, if initialization of this
  @@ -108,22 +112,31 @@
           throws InitializationException;
   
       /**
  -     * Returns an <code>Initable</code> to an uninitialized state.
  +     * Returns a <code>Service</code> to an uninitialized state.
        *
  -     * <p>This method must release all resources allocated by the 
  -     * <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.
  +     * <p>This method must release all resources allocated by the
  +     * <code>Initable</code> implementation, and resetting its
  +     * internal state.  You may chose to implement this operation or
  +     * not. If you support this operation, {@link #isInitialized()}
  +     * should return false after successful shutdown of the service.
        */
  -    public void shutdown( );
  +    public void shutdown();
   
       /**
        * Returns initialization status of an Initable.
        *
        * @return Initialization status of an Initable.
  +     * @see org.apache.fulcrum.Service#isInitialized()
  +     * @deprecated use isInitialized() which uses proper bean semantics.
  +     */
  +    public boolean getInit();
  +
  +    /**
  +     * Returns initialization state.
  +     *
  +     * @return Whether the service has been initialized.
        */
  -    public boolean getInit( );
  +    public boolean isInitialized();
   
       /**
        * Provides a Service with a reference to the ServiceBroker that
  
  
  

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