You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by Jason van Zyl <jv...@apache.org> on 2001/07/14 20:29:35 UTC

Re: cvs commit: jakarta-turbine/src/java/org/apache/turbine Turbine.java

On 7/14/01 2:20 PM, "ilkka@apache.org" <il...@apache.org> wrote:

> ilkka       01/07/14 11:20:47
> 
> Modified:    src/java/org/apache/turbine/services TurbineServices.java
>              src/java/org/apache/turbine Turbine.java
> Added:       src/java/org/apache/turbine/services ServiceManager.java
> Log:

Ilkka can you hold off for a couple minutes! Kasper gave me a patch
to remove all the TurbineExceptions from the services and I'm going
to get some nasty conflicts if you have many more changes to the services
code. I'm trying to separate it today.

> Added some support for customized ServiceBrokers:
> - a new interface named ServiceManager can be implemented to let the
> environment to configure service management  (this removes the type casting
> used in Turbine servlet and forcing TurbineServices to be the only acceptable
> ServiceBroker)
> - two new methods in TurbineServices to get a reference to the current
> ServiceManager and to change the ServiceManager to a customized one
> 
> Revision  Changes    Path
> 1.34      +30 -4 
> 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.33
> retrieving revision 1.34
> diff -u -r1.33 -r1.34
> --- TurbineServices.java    2001/07/12 23:42:51    1.33
> +++ TurbineServices.java    2001/07/14 18:20:45    1.34
> @@ -70,13 +70,14 @@
>   * @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
>   * @author <a href="mailto:jon@latchkey.com">Jon S. Stevens</a>
>   * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
> - * @version $Id: TurbineServices.java,v 1.33 2001/07/12 23:42:51 jvanzyl Exp
> $
> + * @version $Id: TurbineServices.java,v 1.34 2001/07/14 18:20:45 ilkka Exp $
>   */
>  public class TurbineServices
>      extends BaseServiceBroker
> +    implements ServiceManager
>  {
>      /** The single instance of this class. */
> -    protected static ServiceBroker instance = new TurbineServices();
> +    private static ServiceManager instance = new TurbineServices();
>  
>      /**
>       * This constructor is protected to force clients to use
> @@ -88,12 +89,37 @@
>      }
>  
>      /**
> -     * The method through which this class is accessed.
> +     * The method through which this class is accessed as a broker.
>       *
>       * @return The single instance of this class.
>       */
>      public static ServiceBroker getInstance()
>      {
> -        return instance;
> +        return (ServiceBroker) instance;
> +    }
> +
> +    /**
> +     * The method through which this class is accessed as a manager.
> +     *
> +     * @return The single instance of this class.
> +     */
> +    public static ServiceManager getManager()
> +    {
> +        return (ServiceManager) instance;
> +    }
> +
> +    /**
> +     * The method through which to change the default manager.
> +     * Note that services of the previous manager will be shutdown.
> +     * @param manager a new service manager.
> +     */
> +    public static synchronized void setManager(ServiceManager manager)
> +    {
> +        ServiceManager previous = instance;
> +        instance = manager;
> +        if (previous != null)
> +        {
> +            previous.shutdownServices();
> +        }
>      }
>  }
> 
> 
> 
> 1.1              
> jakarta-turbine/src/java/org/apache/turbine/services/ServiceManager.java
> 
> Index: ServiceManager.java
> ===================================================================
> package org.apache.turbine.services;
> 
> /* ====================================================================
>  * The Apache Software License, Version 1.1
>  *
>  * Copyright (c) 2001 The Apache Software Foundation.  All rights
>  * reserved.
>  *
>  * Redistribution and use in source and binary forms, with or without
>  * modification, are permitted provided that the following conditions
>  * are met:
>  *
>  * 1. Redistributions of source code must retain the above copyright
>  *    notice, this list of conditions and the following disclaimer.
>  *
>  * 2. Redistributions in binary form must reproduce the above copyright
>  *    notice, this list of conditions and the following disclaimer in
>  *    the documentation and/or other materials provided with the
>  *    distribution.
>  *
>  * 3. The end-user documentation included with the redistribution,
>  *    if any, must include the following acknowledgment:
>  *       "This product includes software developed by the
>  *        Apache Software Foundation (http://www.apache.org/)."
>  *    Alternately, this acknowledgment may appear in the software itself,
>  *    if and wherever such third-party acknowledgments normally appear.
>  *
>  * 4. The names "Apache" and "Apache Software Foundation" and
>  *    "Apache Turbine" must not be used to endorse or promote products
>  *    derived from this software without prior written permission. For
>  *    written permission, please contact apache@apache.org.
>  *
>  * 5. Products derived from this software may not be called "Apache",
>  *    "Apache Turbine", nor may "Apache" appear in their name, without
>  *    prior written permission of the Apache Software Foundation.
>  *
>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>  * SUCH DAMAGE.
>  * ====================================================================
>  *
>  * This software consists of voluntary contributions made by many
>  * individuals on behalf of the Apache Software Foundation.  For more
>  * information on the Apache Software Foundation, please see
>  * <http://www.apache.org/>.
>  */
> 
> import org.apache.log4j.Category;
> import org.apache.velocity.runtime.configuration.Configuration;
> 
> /**
>  * Classes that implement this interface can act as a mamager for
>  * <code>Service</code> classes.
>  *
>  * Functionality that <code>ServiceManager</code> provides in addition
>  * to <code>ServiceBroker</code> functionality includes configuration
>  * of the manager.
>  *
>  * @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
>  * @version $Id: ServiceManager.java,v 1.1 2001/07/14 18:20:45 ilkka Exp $
>  */
> public interface ServiceManager
>     extends ServiceBroker
> {
>     /**
>      * Initialize this service manager.
>      */
>     public void init()
>         throws InitializationException;
> 
>     /**
>      * Get the configuration for this service manager.
>      *
>      * @return Configuration
>      */
>     public Configuration getConfiguration();
> 
>     /**
>      * Set the configuration object for the services broker.
>      * This is the configuration that contains information
>      * about all services in the care of this service
>      * manager.
>      *
>      * @param Configuration
>      */
>     public void setConfiguration(Configuration configuration);
> 
>     /**
>      * Set the application root.
>      *
>      * @param String application root
>      */
>     public void setApplicationRoot(String applicationRoot);
>     
>     /**
>      * Set the log4j Category that will be used for
>      * logging.
>      *
>      * @param Category
>      */
>     public void setCategory(Category category);
> }
> 
> 
> 
> 1.69      +3 -3      jakarta-turbine/src/java/org/apache/turbine/Turbine.java
> 
> Index: Turbine.java
> ===================================================================
> RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/Turbine.java,v
> retrieving revision 1.68
> retrieving revision 1.69
> diff -u -r1.68 -r1.69
> --- Turbine.java    2001/07/14 14:43:29    1.68
> +++ Turbine.java    2001/07/14 18:20:46    1.69
> @@ -75,6 +75,7 @@
>  import org.apache.turbine.util.RunDataFactory;
>  import org.apache.turbine.util.StringUtils;
>  import org.apache.turbine.util.security.AccessControlList;
> +import org.apache.turbine.services.ServiceManager;
>  import org.apache.turbine.services.TurbineServices;
>  import org.apache.turbine.services.template.TurbineTemplate;
>  import org.apache.log4j.Category;
> @@ -111,7 +112,7 @@
>   * @author <a href="mailto:frank.kim@clearink.com">Frank Y. Kim</a>
>   * @author <a href="mailto:krzewski@e-point.pl">Rafal Krzewski</a>
>   * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
> - * @version $Id: Turbine.java,v 1.68 2001/07/14 14:43:29 jvanzyl Exp $
> + * @version $Id: Turbine.java,v 1.69 2001/07/14 18:20:46 ilkka Exp $
>   */
>  public class Turbine
>      extends HttpServlet
> @@ -191,8 +192,7 @@
>                  setApplicationRoot(getServletContext().getRealPath("/"));
>                  
>                  // Get the instance of the service manager
> -                TurbineServices serviceManager =
> -                    (TurbineServices) TurbineServices.getInstance();
> +                ServiceManager serviceManager = TurbineServices.getManager();
>                  
>                  // This is for our log4j setup. We are embedding
>                  // the log4j configuration in the TRP but log4j
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org

-- 

jvz.

Jason van Zyl

http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons



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