commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject cvs commit: jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl ServiceExtensionPointImpl.java RegistryImpl.java
Date Tue, 15 Jul 2003 17:36:22 GMT
hlship      2003/07/15 10:36:21

  Modified:    hivemind/src/java/org/apache/commons/hivemind/service/impl
                        EJBProxyFactory.java
                        AbstractServiceInterceptorFactory.java
                        NameLookupImpl.java
               hivemind/xdocs configuration.xml ioc.xml services.xml
               hivemind/src/java/org/apache/commons/hivemind
                        HiveMindMessages.properties
                        SymbolSourceContribution.java HiveMind.java
                        ServiceExtensionPoint.java
                        ServiceInterceptorContribution.java
               hivemind/src/test/hivemind/test/services
                        CheckInitializeService.java
               hivemind/src/java/org/apache/commons/hivemind/parse
                        InterceptorDescriptor.java
               hivemind/src/test/hivemind/test/services/impl
                        CheckInitializeServiceImpl.java
               hivemind/src/java/org/apache/commons/hivemind/impl
                        ServiceExtensionPointImpl.java RegistryImpl.java
  Added:       hivemind/src/java/org/apache/commons/hivemind
                        Initializable.java Orderable.java
  Removed:     hivemind/src/java/org/apache/commons/hivemind
                        InitializeService.java
  Log:
  Rename interface InitializeService to Initializable.
  Add Orderable interface, and convienience methods for sorting lists of Orderable.
  
  Revision  Changes    Path
  1.3       +3 -3      jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/service/impl/EJBProxyFactory.java
  
  Index: EJBProxyFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/service/impl/EJBProxyFactory.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EJBProxyFactory.java	1 Jul 2003 11:28:53 -0000	1.2
  +++ EJBProxyFactory.java	15 Jul 2003 17:36:19 -0000	1.3
  @@ -61,7 +61,7 @@
   import java.lang.reflect.Proxy;
   
   import org.apache.commons.hivemind.HiveMind;
  -import org.apache.commons.hivemind.InitializeService;
  +import org.apache.commons.hivemind.Initializable;
   import org.apache.commons.hivemind.Registry;
   import org.apache.commons.hivemind.ServiceExtensionPoint;
   import org.apache.commons.hivemind.ServiceImplementationFactory;
  @@ -76,7 +76,7 @@
    * @author Howard Lewis Ship
    * @version $Id$
    */
  -public class EJBProxyFactory implements ServiceImplementationFactory, InitializeService
  +public class EJBProxyFactory implements ServiceImplementationFactory, Initializable
   {
       private String _serviceId;
   
  
  
  
  1.2       +3 -3      jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/service/impl/AbstractServiceInterceptorFactory.java
  
  Index: AbstractServiceInterceptorFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/service/impl/AbstractServiceInterceptorFactory.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractServiceInterceptorFactory.java	9 Jul 2003 11:27:24 -0000	1.1
  +++ AbstractServiceInterceptorFactory.java	15 Jul 2003 17:36:19 -0000	1.2
  @@ -62,7 +62,7 @@
   import java.util.LinkedList;
   
   import org.apache.commons.hivemind.HiveMind;
  -import org.apache.commons.hivemind.InitializeService;
  +import org.apache.commons.hivemind.Initializable;
   import org.apache.commons.hivemind.InterceptorStack;
   import org.apache.commons.hivemind.ServiceExtensionPoint;
   import org.apache.commons.hivemind.ServiceInterceptorFactory;
  @@ -78,7 +78,7 @@
    * @version $Id$
    */
   public abstract class AbstractServiceInterceptorFactory
  -    implements ServiceInterceptorFactory, InitializeService
  +    implements ServiceInterceptorFactory, Initializable
   {
       private ClassFactory _factory;
       private String _extensionId;
  
  
  
  1.2       +3 -3      jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/service/impl/NameLookupImpl.java
  
  Index: NameLookupImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/service/impl/NameLookupImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- NameLookupImpl.java	1 Jul 2003 11:28:53 -0000	1.1
  +++ NameLookupImpl.java	15 Jul 2003 17:36:19 -0000	1.2
  @@ -64,7 +64,7 @@
   import javax.naming.NamingException;
   
   import org.apache.commons.hivemind.HiveMind;
  -import org.apache.commons.hivemind.InitializeService;
  +import org.apache.commons.hivemind.Initializable;
   import org.apache.commons.hivemind.Registry;
   import org.apache.commons.hivemind.ServiceExtensionPoint;
   import org.apache.commons.hivemind.service.NameLookup;
  @@ -80,7 +80,7 @@
    * @author Howard Lewis Ship
    * @version $Id$
    */
  -public class NameLookupImpl implements NameLookup, InitializeService, RemoteExceptionListener
  +public class NameLookupImpl implements NameLookup, Initializable, RemoteExceptionListener
   {
       private RemoteExceptionCoordinator _coordinator;
       private InitialContext _initialContext;
  
  
  
  1.7       +3 -3      jakarta-commons-sandbox/hivemind/xdocs/configuration.xml
  
  Index: configuration.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/xdocs/configuration.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- configuration.xml	1 Jul 2003 20:12:57 -0000	1.6
  +++ configuration.xml	15 Jul 2003 17:36:20 -0000	1.7
  @@ -171,14 +171,14 @@
   <subsection name="Symbol Sources">
   
   <p>
  -This begs the question: where do variable values come from?	The answser is: its application
dependent.
  +This begs the question: where do symbol values come from?	The answser is: its application
dependent.
   HiveMind itself defines a configuration extension point for this purpose: 
   <code>org.apache.commons.hivemind.SymbolSource</code>.  Contributions
   to this extension point are of type
   <a href="apidocs/org/apache/commons/hivemind/SymbolSourceContribution.html">SymbolSourceContribution</a>.
   The contribution consists of an order number (used to sort the contributions into
   an order to query) and a 
  -variable source (of type
  +symbol source (of type
   <a href="apidocs/org/apache/commons/hivemind/SymbolSource.html">SymbolSource</a>).
   
   </p>
  
  
  
  1.2       +2 -2      jakarta-commons-sandbox/hivemind/xdocs/ioc.xml
  
  Index: ioc.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/xdocs/ioc.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ioc.xml	9 Jul 2003 18:55:44 -0000	1.1
  +++ ioc.xml	15 Jul 2003 17:36:20 -0000	1.2
  @@ -30,7 +30,7 @@
   <p>
   HiveMind is much looser than Avalon.  HiveMind doesn't have an explicit assembly stage;
it wires together
   all the modules it can find at runtime.  Service implementations may implement the
  -<a href="apidocs/org/apache/commons/hivemind/InitializeService.html">InitializeService</a>

  +<a href="apidocs/org/apache/commons/hivemind/Initializable.html">Initializable</a>

   interface, which is essentially a post-creation callback; the implementation can, if it
likes, look up other
   services by their well-known name.
   </p>
  
  
  
  1.9       +2 -2      jakarta-commons-sandbox/hivemind/xdocs/services.xml
  
  Index: services.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/xdocs/services.xml,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- services.xml	30 Jun 2003 23:04:28 -0000	1.8
  +++ services.xml	15 Jul 2003 17:36:20 -0000	1.9
  @@ -223,7 +223,7 @@
   				is constructed), then
   				your class should implement the
   				
  -				<a href="apidocs/org/apache/commons/hivemind/InitializeService.html">InitializeService</a>
  +				<a href="apidocs/org/apache/commons/hivemind/Initializable.html">Initializable</a>
   				interface (in addition to the service interface).
   				  This interface defines a callback that occurs only after
   				the core service has been constructed and configured, and the interceptor stack
  
  
  
  1.11      +2 -2      jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/HiveMindMessages.properties
  
  Index: HiveMindMessages.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/HiveMindMessages.properties,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- HiveMindMessages.properties	9 Jul 2003 11:27:24 -0000	1.10
  +++ HiveMindMessages.properties	15 Jul 2003 17:36:20 -0000	1.11
  @@ -8,7 +8,7 @@
   service-wrong-parameter-count=Service factory {0} expects {1,choice,0#no parameters,1#one
parameter, 1>#{1} parameters} , but was passed {2,choice,0#no parameters,1#one parameter,
1>#{2} parameters} parameters.
   
   HiveMind.default-registry-not-set=HiveMind.getDefault() invoked before default registry
has been set.
  -
  +HiveMind.elements-not-orderable=Elements of list {0} do not implement the Orderable interface
and can not be sorted.
   # impl package
   
   BaseRegistry.no-such-module-id=Registry does not contain module ''{0}''.
  
  
  
  1.2       +5 -24     jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/SymbolSourceContribution.java
  
  Index: SymbolSourceContribution.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/SymbolSourceContribution.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SymbolSourceContribution.java	30 Jun 2003 23:04:30 -0000	1.1
  +++ SymbolSourceContribution.java	15 Jul 2003 17:36:20 -0000	1.2
  @@ -67,11 +67,11 @@
    * @author Howard Lewis Ship
    * @version $Id$
    */
  -public class SymbolSourceContribution implements Comparable
  +public class SymbolSourceContribution implements Orderable
   {
  -	private int _order;
  -	private SymbolSource _source;
  -	
  +    private int _order;
  +    private SymbolSource _source;
  +
       public int getOrder()
       {
           return _order;
  @@ -91,23 +91,4 @@
       {
           _source = source;
       }
  -
  -	/**
  -	 * Compares this instance to the other instance, which is
  -	 * expected to be an instance of {@link SymbolSourceContribution}.
  -	 * Returns the values sorted based on the order property.
  -	 */
  -    public int compareTo(Object o)
  -    {
  -		if (! (o instanceof SymbolSourceContribution))
  -			return 0;
  -			
  -		SymbolSourceContribution c = (SymbolSourceContribution)o;
  -		
  -		// I guess I'm just a slut for high code coverage;
  -		// let Hotspot optimize this.
  -		
  -		return _order - c.getOrder();
  -    }
  -
   }
  
  
  
  1.9       +49 -2     jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/HiveMind.java
  
  Index: HiveMind.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/HiveMind.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- HiveMind.java	9 Jul 2003 11:27:24 -0000	1.8
  +++ HiveMind.java	15 Jul 2003 17:36:20 -0000	1.9
  @@ -59,7 +59,9 @@
   
   import java.text.MessageFormat;
   import java.util.ArrayList;
  +import java.util.Collection;
   import java.util.Collections;
  +import java.util.Comparator;
   import java.util.List;
   import java.util.Map;
   import java.util.ResourceBundle;
  @@ -184,7 +186,7 @@
   
           int count = keys.size();
   
  -        return (String[]) keys.toArray(new String[count]);
  +        return (String[])keys.toArray(new String[count]);
       }
   
       public static ApplicationRuntimeException createMissingServiceException(
  @@ -195,4 +197,49 @@
               HiveMind.format("no-such-service", serviceId, interfaceClass.getName()));
   
       }
  +
  +    /**
  +     * Used to sort elements of a list that implement the
  +     * {@link Orderable} interface.
  +     */
  +    private static class OrderableSorter implements Comparator
  +    {
  +
  +        public int compare(Object o1, Object o2)
  +        {
  +            Orderable left = (Orderable)o1;
  +            Orderable right = (Orderable)o2;
  +
  +            return left.getOrder() - right.getOrder();
  +        }
  +
  +    }
  +
  +    /**
  +     * Sorts a list of elements implementing the {@link Orderable} interface.
  +     * A copy of the input list is returned, with the elements sorted
  +     * into ascending order.  The returned list is unmodifiable.
  +     * 
  +     */
  +    public static List sortOrderables(List list)
  +    {
  +        if (list.isEmpty())
  +            return Collections.EMPTY_LIST;
  +
  +        List sorted = new ArrayList(list);
  +
  +        try
  +        {
  +            Collections.sort(sorted, new OrderableSorter());
  +        }
  +        catch (ClassCastException ex)
  +        {
  +            throw new ApplicationRuntimeException(
  +                format("HiveMind.elements-not-orderable", list),
  +                ex);
  +        }
  +
  +        return Collections.unmodifiableList(sorted);
  +    }
  +
   }
  
  
  
  1.3       +3 -3      jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/ServiceExtensionPoint.java
  
  Index: ServiceExtensionPoint.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/ServiceExtensionPoint.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ServiceExtensionPoint.java	2 Jul 2003 21:41:12 -0000	1.2
  +++ ServiceExtensionPoint.java	15 Jul 2003 17:36:20 -0000	1.3
  @@ -105,8 +105,8 @@
        * 
        * <p>Once the core implementation is created and the interceptor
        * stack is assembled, the core implementation is checked
  -     * to see if it implements {@link InitializeService}.
  -     * If so {@link InitializeService#initializeService(ServiceExtensionPoint, Object)}
  +     * to see if it implements {@link Initializable}.
  +     * If so {@link Initializable#initializeService(ServiceExtensionPoint, Object)}
        * is invoked, to let the core service implementation
        * initialize.
        * 
  
  
  
  1.2       +2 -2      jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/ServiceInterceptorContribution.java
  
  Index: ServiceInterceptorContribution.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/ServiceInterceptorContribution.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ServiceInterceptorContribution.java	30 Jun 2003 23:04:30 -0000	1.1
  +++ ServiceInterceptorContribution.java	15 Jul 2003 17:36:20 -0000	1.2
  @@ -63,7 +63,7 @@
    * @author Howard Lewis Ship
    * @version $Id$
    */
  -public interface ServiceInterceptorContribution extends ServiceContribution
  +public interface ServiceInterceptorContribution extends ServiceContribution, Orderable
   {
   
       /**
  
  
  
  1.1                  jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/Initializable.java
  
  Index: Initializable.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2003 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", "Commons", 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/>.
   *
   */
  
  package org.apache.commons.hivemind;
  
  /**
   * Interface that may be implemented by a core service implementation
   * (in addition to the service interface), which is used by HiveMind
   * to inform a newly created implementation service extension point
   * it was created for.
   * 
   * <p>
   * The final version of the service is provided (this will
   * be the receiver if the service extension point has no interceptors; otherwise,
   * it will be the outermost interceptor).  This allows the
   * service to, for example, establish a callback to the core implementation that
   * uses the interceptor stack (rather than bypassing it).
   *
   * @author Howard Lewis Ship
   * @version $Id: Initializable.java,v 1.1 2003/07/15 17:36:20 hlship Exp $
   */
  public interface Initializable
  {
      /**
       * Invoked after the core implementation is instantiated, and the interceptor
       * stack has been created.
       * @param point the service extension point the core service was created for.
       * @param factoryContribution the contribution which created the core implementation.
       * @param service the outside representation of the service, this may be the
       * same as the receiver, or can be the outermost interceptor.
       */
      public void initializeService(
          ServiceExtensionPoint point,
          Object service);
  }
  
  
  
  1.1                  jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/Orderable.java
  
  Index: Orderable.java
  ===================================================================
  package org.apache.commons.hivemind;
  
  /**
   * Interface typically used by configuration elements that wish to be ordered.
   * Implements an <code>order</code> property that is used to sort elements into
   * a particular order.
   * 
   * @author Howard M. Lewis Ship
   * @version $Id: Orderable.java,v 1.1 2003/07/15 17:36:20 hlship Exp $
   */
  public interface Orderable
  {
      /**
       * Returns the sort order for this element.  Lower numbers are sorted first,
       * higher numbers are sorted last.
       */
      public int getOrder();
  }
  
  
  
  1.2       +2 -2      jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/CheckInitializeService.java
  
  Index: CheckInitializeService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/CheckInitializeService.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CheckInitializeService.java	30 Jun 2003 23:04:45 -0000	1.1
  +++ CheckInitializeService.java	15 Jul 2003 17:36:21 -0000	1.2
  @@ -58,7 +58,7 @@
   package hivemind.test.services;
   
   /**
  - * Used for testing support of {@link org.apache.commons.hivemind.InitializeService}.
  + * Used for testing support of {@link org.apache.commons.hivemind.Initializable}.
    *
    * @author Howard Lewis Ship
    * @version $Id$
  
  
  
  1.5       +3 -1      jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/parse/InterceptorDescriptor.java
  
  Index: InterceptorDescriptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/parse/InterceptorDescriptor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- InterceptorDescriptor.java	4 Jun 2003 23:52:47 -0000	1.4
  +++ InterceptorDescriptor.java	15 Jul 2003 17:36:21 -0000	1.5
  @@ -57,6 +57,7 @@
   
   package org.apache.commons.hivemind.parse;
   
  +import org.apache.commons.hivemind.Orderable;
   import org.apache.commons.lang.builder.ToStringBuilder;
   import org.apache.tapestry.spec.BaseLocatable;
   
  @@ -67,6 +68,7 @@
    * @version $Id$
    */
   public class InterceptorDescriptor extends BaseLocatable
  +implements Orderable
   {
       private int _order;
       private String _serviceId;
  
  
  
  1.2       +4 -4      jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/impl/CheckInitializeServiceImpl.java
  
  Index: CheckInitializeServiceImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/impl/CheckInitializeServiceImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CheckInitializeServiceImpl.java	30 Jun 2003 23:08:04 -0000	1.1
  +++ CheckInitializeServiceImpl.java	15 Jul 2003 17:36:21 -0000	1.2
  @@ -59,16 +59,16 @@
   
   import hivemind.test.services.CheckInitializeService;
   
  -import org.apache.commons.hivemind.InitializeService;
  +import org.apache.commons.hivemind.Initializable;
   import org.apache.commons.hivemind.ServiceExtensionPoint;
   
   /**
  - * Used for testing support of {@link org.apache.commons.hivemind.InitializeService}.
  + * Used for testing support of {@link org.apache.commons.hivemind.Initializable}.
    *
    * @author Howard Lewis Ship
    * @version $Id$
    */
  -public class CheckInitializeServiceImpl implements InitializeService, CheckInitializeService
  +public class CheckInitializeServiceImpl implements Initializable, CheckInitializeService
   {
       private boolean _didInitialize;
   
  
  
  
  1.4       +20 -37    jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/ServiceExtensionPointImpl.java
  
  Index: ServiceExtensionPointImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/ServiceExtensionPointImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ServiceExtensionPointImpl.java	2 Jul 2003 21:41:12 -0000	1.3
  +++ ServiceExtensionPointImpl.java	15 Jul 2003 17:36:21 -0000	1.4
  @@ -59,14 +59,13 @@
   
   import java.util.ArrayList;
   import java.util.Collections;
  -import java.util.Comparator;
   import java.util.List;
   
   import org.apache.commons.hivemind.HiveMind;
  +import org.apache.commons.hivemind.Initializable;
  +import org.apache.commons.hivemind.ServiceExtensionPoint;
   import org.apache.commons.hivemind.ServiceImplementationContribution;
  -import org.apache.commons.hivemind.InitializeService;
   import org.apache.commons.hivemind.ServiceInterceptorContribution;
  -import org.apache.commons.hivemind.ServiceExtensionPoint;
   import org.apache.commons.lang.builder.ToStringBuilder;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  @@ -79,7 +78,9 @@
    * @author Howard Lewis Ship
    * @version $Id$
    */
  -public class ServiceExtensionPointImpl extends AbstractExtensionPoint implements ServiceExtensionPoint
  +public class ServiceExtensionPointImpl
  +    extends AbstractExtensionPoint
  +    implements ServiceExtensionPoint
   {
       private static final Log LOG = LogFactory.getLog(ServiceExtensionPointImpl.class);
   
  @@ -101,23 +102,6 @@
           builder.append("interceptorContributions", _interceptorContributions);
       }
   
  -    /**
  -     * Used for sorting interceptor contributions into ascending
  -     * order by {@link ServiceInterceptorContribution#getOrder()}.
  -     */
  -    private static class InterceptorContributionSorter implements Comparator
  -    {
  -
  -        public int compare(Object o1, Object o2)
  -        {
  -            ServiceInterceptorContribution left = (ServiceInterceptorContribution) o1;
  -            ServiceInterceptorContribution right = (ServiceInterceptorContribution) o2;
  -
  -            return left.getOrder() - right.getOrder();
  -        }
  -
  -    }
  -
       public ServiceImplementationContribution getFactoryContribution()
       {
           return _factoryContribution;
  @@ -199,16 +183,15 @@
   
       public synchronized List getInterceptorContributions()
       {
  -        if (_sortedInterceptorContributions != null)
  -            return _sortedInterceptorContributions;
  -
  -        if (_interceptorContributions == null)
  -            return Collections.EMPTY_LIST;
  -
  -        List sorted = new ArrayList(_interceptorContributions);
  -        Collections.sort(sorted, new InterceptorContributionSorter());
  +        if (_sortedInterceptorContributions == null)
  +        {
   
  -        _sortedInterceptorContributions = Collections.unmodifiableList(sorted);
  +            if (_interceptorContributions == null)
  +                _sortedInterceptorContributions = Collections.EMPTY_LIST;
  +            else
  +                _sortedInterceptorContributions =
  +                    HiveMind.sortOrderables(_interceptorContributions);
  +        }
   
           return _sortedInterceptorContributions;
       }
  @@ -223,8 +206,8 @@
   
           try
           {
  -        	_building = true;
  -        	
  +            _building = true;
  +
               return constructServiceInner();
           }
           finally
  @@ -281,9 +264,9 @@
   
               Object intercepted = addInterceptors(core);
   
  -            if (core instanceof InitializeService)
  +            if (core instanceof Initializable)
               {
  -                InitializeService initializeCore = (InitializeService) core;
  +                Initializable initializeCore = (Initializable)core;
                   initializeCore.initializeService(this, intercepted);
               }
   
  @@ -314,7 +297,7 @@
   
           for (int i = 0; i < count; i++)
           {
  -            ServiceInterceptorContribution ic = (ServiceInterceptorContribution) interceptors.get(i);
  +            ServiceInterceptorContribution ic = (ServiceInterceptorContribution)interceptors.get(i);
   
               stack.process(ic);
           }
  @@ -323,7 +306,7 @@
   
           return stack.peek();
       }
  -    
  +
       public boolean isOverridable()
       {
           return _overridable;
  
  
  
  1.3       +21 -26    jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/RegistryImpl.java
  
  Index: RegistryImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/RegistryImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RegistryImpl.java	2 Jul 2003 21:41:12 -0000	1.2
  +++ RegistryImpl.java	15 Jul 2003 17:36:21 -0000	1.3
  @@ -88,30 +88,30 @@
       private Map _modules = new HashMap();
       private SymbolSource[] _variableSources;
       private Locale _locale;
  -    
  +
       public RegistryImpl(Locale locale)
       {
  -    	_locale = locale;
  +        _locale = locale;
       }
   
  -	public Locale getLocale()
  -	{
  -		return _locale;
  -	}
  -	
  -	// Only invoked during the non-threaded initialization phase.
  -	
  -    public  void addModule(Module module)
  +    public Locale getLocale()
  +    {
  +        return _locale;
  +    }
  +
  +    // Only invoked during the non-threaded initialization phase.
  +
  +    public void addModule(Module module)
       {
           _modules.put(module.getModuleId(), module);
       }
   
  -	// Invoked post-initialization, but _modules
  -	// is stable
  -	
  -    public  Module getModule(String moduleId)
  +    // Invoked post-initialization, but _modules
  +    // is stable
  +
  +    public Module getModule(String moduleId)
       {
  -        Module result = (Module) _modules.get(moduleId);
  +        Module result = (Module)_modules.get(moduleId);
   
           if (result == null)
               throw new ApplicationRuntimeException(
  @@ -153,7 +153,7 @@
       {
           ToStringBuilder builder = new ToStringBuilder(this);
   
  -		builder.append("locale", _locale);
  +        builder.append("locale", _locale);
           builder.append("modules", _modules.size());
   
           return builder.toString();
  @@ -324,21 +324,16 @@
           if (_variableSources != null)
               return _variableSources;
   
  -        List unsorted = getConfiguration("org.apache.commons.hivemind.SymbolSource");
  +        List contributions =
  +            HiveMind.sortOrderables(getConfiguration("org.apache.commons.hivemind.SymbolSource"));
   
  -        int count = unsorted.size();
  +        int count = contributions.size();
   
           _variableSources = new SymbolSource[count];
   
  -        List contributions = new ArrayList(unsorted);
  -
  -        // Sort them into specified order.
  -
  -        Collections.sort(contributions);
  -
           for (int i = 0; i < count; i++)
           {
  -            SymbolSourceContribution c = (SymbolSourceContribution) contributions.get(i);
  +            SymbolSourceContribution c = (SymbolSourceContribution)contributions.get(i);
               _variableSources[i] = c.getSource();
           }
   
  
  
  

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


Mime
View raw message