You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by James Taylor <jt...@4lane.com> on 2002/02/13 13:45:41 UTC

RE: cvs commit: jakarta-turbine-stratum/src/java/org/apache/stratum/jcs JCS.java

> Ya, but it isn't a singleton.  I was considering making the access
> objects store locks.  But this would be too limiting, and to prevent
> myself form doing this, I'll name it getInstance.

This pattern need not be limited to singletons. From _Effective Java_
(which seems to be the closest thing we've got to a style guide these
days), describing common static factory method naming conventions:
    
    getInstance -- Returns an instance that is described by its
    parameters but cannot be said to have the same value [this
    references valueOf which is describe immediately prior]. In the case
    of singletons it returns the sole instance.

> Thanks.  I won't have to do this.
> 
> I guess the next big task is the log4j conversion?

Yup, scary huh?

I noticed you've begun making some log4j conversions in various classes.
Is that working out? One minor change is that we should probably use
commons-logging between the application and log4j. This is just a thin
wrapper to logging systems and is API compatible with log4j. However if
log4j is not available then it will use platform logging on JDK1.4, and
if neither is available it will gracefully log to nowhere.

Thanks,
James

> 
> > -----Original Message-----
> > From: jtaylor@apache.org [mailto:jtaylor@apache.org]
> > Sent: Tuesday, February 12, 2002 9:55 PM
> > To: jakarta-turbine-stratum-cvs@apache.org
> > Subject: cvs commit: jakarta-turbine-
> > stratum/src/java/org/apache/stratum/jcs JCS.java
> > 
> > jtaylor     02/02/12 18:54:50
> > 
> >   Modified:    src/java/org/apache/stratum/jcs JCS.java
> >   Log:
> >   Implementing Dan's suggestion that the static factory methods should
> be
> > named
> >   getInstance(). Also, license, javadoc, extracting duplicate code.
> > 
> >   Revision  Changes    Path
> >   1.2       +88 -37    jakarta-turbine-
> > stratum/src/java/org/apache/stratum/jcs/JCS.java
> > 
> >   Index: JCS.java
> >   ===================================================================
> >   RCS file: /home/cvs/jakarta-turbine-
> > stratum/src/java/org/apache/stratum/jcs/JCS.java,v
> >   retrieving revision 1.1
> >   retrieving revision 1.2
> >   diff -u -r1.1 -r1.2
> >   --- JCS.java	12 Feb 2002 15:47:21 -0000	1.1
> >   +++ JCS.java	13 Feb 2002 02:54:50 -0000	1.2
> >   @@ -1,5 +1,59 @@
> >    package org.apache.stratum.jcs;
> > 
> >   +/*
> >   + * 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 acknowlegement:
> >   + *       "This product includes software developed by the
> >   + *        Apache Software Foundation (http://www.apache.org/)."
> >   + *    Alternately, this acknowlegement may appear in the software
> > itself,
> >   + *    if and wherever such third-party acknowlegements normally
> appear.
> >   + *
> >   + * 4. The names "The Jakarta Project", "Velocity", and "Apache
> Software
> >   + *    Foundation" 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"
> >   + *    nor may "Apache" appear in their names without prior written
> >   + *    permission of the Apache Group.
> >   + *
> >   + * 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.stratum.jcs.access.GroupCacheAccess;
> >    import org.apache.stratum.jcs.engine.control.Cache;
> >    import org.apache.stratum.jcs.engine.control.CacheAttributes;
> >   @@ -12,65 +66,67 @@
> >    import
> > org.apache.stratum.jcs.engine.behavior.ICompositeCacheAttributes;
> > 
> >    /**
> >   - *  To make using JCS a bit easier.
> >   + * To make using JCS a bit easier.
> >     *
> >   - *@author     asmuts
> >   - *@created    February 12, 2002
> >   + * @author <a href="mailto:asmuts@yahoo.com">Aaron Smuts</a>
> >   + * @author <a href="mailto:jtaylor@apache.org">James Taylor</a>
> >   + * @version $Id: JCS.java,v 1.2 2002/02/13 02:54:50 jtaylor Exp $
> >     */
> >    public class JCS extends GroupCacheAccess
> >    {
> >   -
> >        private static GroupCacheManager cacheMgr;
> > 
> >   -    ///////////////////////////////////////////
> >        /**
> >   -     *  Constructor for the JCS object
> >   +     * Protected constructor for use by the static factory methods.
> >         *
> >   -     *@param  cacheControl  Description of the Parameter
> >   +     * @param cacheControl Cache which the instance will provide
> access
> > to
> >         */
> >        protected JCS( Cache cacheControl )
> >        {
> >            super( cacheControl );
> >        }
> > 
> >   -
> >   -    /////////////////////////////////////////
> >        /**
> >   -     *  Gets the groupAccess attribute of the GroupCacheAccess
> class
> >   +     * Get a JCS which accesses the provided region.
> >         *
> >   -     *@param  region              Description of the Parameter
> >   -     *@return                     The groupAccess value
> >   -     *@exception  CacheException  Description of the Exception
> >   +     * @param region Region that return JCS will provide access to
> >   +     * @return A JCS which provides access to a given region.
> >   +     * @exception CacheException
> >         */
> >   -    public static JCS getJCS( String region )
> >   +    public static JCS getInstance( String region )
> >            throws CacheException
> >        {
> >   -        if ( cacheMgr == null )
> >   -        {
> >   -            synchronized ( GroupCacheAccess.class )
> >   -            {
> >   -                if ( cacheMgr == null )
> >   -                {
> >   -                    cacheMgr =
> GroupCacheManagerFactory.getInstance();
> >   -                }
> >   -            }
> >   -        }
> >   +        ensureCacheManager();
> >   +
> >            return new JCS( ( Cache ) cacheMgr.getCache( region ) );
> >        }
> > 
> >   -
> >   -    /////////////////////////////////////////
> >        /**
> >   -     *  Gets the groupAccess attribute of the GroupCacheAccess
> class
> >   +     * Get a JCS which accesses the provided region.
> >         *
> >   -     *@param  region              Description of the Parameter
> >   -     *@param  icca                Description of the Parameter
> >   -     *@return                     The groupAccess value
> >   -     *@exception  CacheException  Description of the Exception
> >   +     * @param region Region that return JCS will provide access to
> >   +     * @param icca Cache attributes for region
> >   +     * @return A JCS which provides access to a given region.
> >   +     * @exception CacheException
> >         */
> >   -    public static JCS getJCS( String region,
> ICompositeCacheAttributes
> > icca )
> >   +    public static JCS getInstance( String region,
> >   +                                   ICompositeCacheAttributes icca )
> >            throws CacheException
> >        {
> >   +        ensureCacheManager();
> >   +
> >   +        return new JCS( ( Cache ) cacheMgr.getCache( region, icca )
> );
> >   +    }
> >   +
> >   +    /**
> >   +     * Gets an instance of GroupCacheManager and stores it in the
> > cacheMgr
> >   +     * class field, if it is not already set. Unlike the
> implementation
> > in
> >   +     * CacheAccess, the cache manager is a GroupCacheManager.
> >   +     *
> >   +     * NOTE: This can / will be moved up into GroupCacheAccess.
> >   +     */
> >   +    protected static void ensureCacheManager()
> >   +    {
> >            if ( cacheMgr == null )
> >            {
> >                synchronized ( GroupCacheAccess.class )
> >   @@ -81,10 +137,5 @@
> >                    }
> >                }
> >            }
> >   -
> >   -        return new JCS( ( Cache ) cacheMgr.getCache( region, icca )
> );
> >        }
> >   -
> >   -
> >   -
> >    }
> > 
> > 
> > 
> > 
> > --
> > To unsubscribe, e-mail:   <mailto:turbine-dev-
> > unsubscribe@jakarta.apache.org>
> > For additional commands, e-mail: <mailto:turbine-dev-
> > help@jakarta.apache.org>
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 
> 



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: cvs commit:jakarta-turbine-stratum/src/java/org/apache/stratum/jcs JCS.java

Posted by Aaron Smuts <aa...@verizon.net>.
 
> > I guess the next big task is the log4j conversion?
> 
> Yup, scary huh?
> 
> I noticed you've begun making some log4j conversions in various
classes.
> Is that working out? One minor change is that we should probably use
> commons-logging between the application and log4j. This is just a thin
> wrapper to logging systems and is API compatible with log4j. However
if
> log4j is not available then it will use platform logging on JDK1.4,
and
> if neither is available it will gracefully log to nowhere.
 
Ok.  Could you do an example.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>