hlship      2005/02/11 07:29:53

  Modified:    framework/src/documentation/content/xdocs/hivemind
                        ThreadLocalStorage.xml
               src/documentation/content/xdocs index.xml site.xml links.ent
                        localization.xml
               framework/src/descriptor/META-INF hivemodule.xml
               framework/src/java/org/apache/hivemind/impl ModuleImpl.java
                        MessageFormatter.java
               .        status.xml
               framework/src/java/org/apache/hivemind Messages.java
                        HiveMind.java
               examples/src/test/com/panorama/startup/impl
                        TestTaskExecutor.java
  Added:       framework/src/documentation/content/xdocs/hivemind
                        ThreadLocale.xml
               framework/src/java/org/apache/hivemind/service/impl
                        ThreadLocaleFactory.java ThreadLocaleImpl.java
               framework/src/java/org/apache/hivemind/impl
                        MessageFinderImpl.java ModuleMessages.java
                        AbstractMessages.java
               framework/src/java/org/apache/hivemind/service
                        ThreadLocale.java
               framework/src/test/org/apache/hivemind TestThreadLocale.java
               framework/src/java/org/apache/hivemind/internal
                        MessageFinder.java
               framework/src/test/org/apache/hivemind/impl
                        MessageFinder_fr.properties TestMessageFinder.java
                        MessageFinder.properties
  Removed:     framework/src/java/org/apache/hivemind/impl
                        MessagesImpl.java
               framework/src/test/hivemind/test TestMessagesImpl.java
  Log:
  Allow locale to be changed for each thread.
  
  Revision  Changes    Path
  1.7       +14 -21    
jakarta-hivemind/framework/src/documentation/content/xdocs/hivemind/ThreadLocalStorage.xml
  
  Index: ThreadLocalStorage.xml
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/framework/src/documentation/content/xdocs/hivemind/ThreadLocalStorage.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ThreadLocalStorage.xml    6 Jan 2005 01:45:14 -0000       1.6
  +++ ThreadLocalStorage.xml    11 Feb 2005 15:29:51 -0000      1.7
  @@ -14,25 +14,18 @@
      See the License for the specific language governing permissions and
      limitations under the License.
   -->
  -
  -<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.3//EN"
  -     "http://xml.apache.org/forrest/dtd/document-v13.dtd"; [
  -     <!ENTITY projectroot '../'>
  -     <!ENTITY % common-links SYSTEM "../links.ent">
  -     %common-links;
  -     ]>
  +<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.3//EN" 
"http://xml.apache.org/forrest/dtd/document-v13.dtd"; [
  +  <!ENTITY projectroot '../'>
  +  <!ENTITY % common-links SYSTEM "../links.ent">
  +  %common-links;
  +  ]>
   <document>
  -     <header>
  -             <title>hivemind.ThreadLocalStorage Service</title>
  -     </header>
  -     <body>
  -             <p>The <link 
href="&hivedoc;/service/hivemind.ThreadLocalStorage.html">
  -                     ThreadLocalStorage</link> service implements the <link
  -                     
href="&apiroot;/service/ThreadLocalStorage.html">ThreadLocalStorage</link>
  -                     interface. This service acts as a kind of Map for 
temporary data. The map
  -                     is local to the current thread, and is cleared at the 
end of the
  -                     transaction.</p>
  -             <p>It is your responsibility to ensure that keys are unique, 
typically by
  -                     prefixing them with a module id or package name.</p>
  -     </body>
  -</document>
  +  <header>
  +    <title>hivemind.ThreadLocalStorage Service</title>
  +  </header>
  +  <body>
  +    <p>The <link href="&hivedoc;/service/hivemind.ThreadLocalStorage.html"> 
ThreadLocalStorage</link> service implements the <link 
href="&apiroot;/service/ThreadLocalStorage.html">ThreadLocalStorage</link> 
interface. This service acts as a kind of Map for temporary data. The map is 
local to the current thread, and is cleared at the end of the transaction.</p>
  +    <p>It is your responsibility to ensure that keys are unique, typically 
by prefixing them with a module id or package name.</p>
  +    <warning> ThreadLocalStorage is likely to be removed in a future release 
of HiveMind. It is advised that you use the threaded service model instead. 
</warning>
  +  </body>
  +</document>
  \ No newline at end of file
  
  
  
  1.1                  
jakarta-hivemind/framework/src/documentation/content/xdocs/hivemind/ThreadLocale.xml
  
  Index: ThreadLocale.xml
  ===================================================================
  <?xml version="1.0"?>
  <!-- 
     Copyright 2005 The Apache Software Foundation
  
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at
  
         http://www.apache.org/licenses/LICENSE-2.0
  
     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
  -->
  
  <!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V1.3//EN"
        "http://xml.apache.org/forrest/dtd/document-v13.dtd"; [
        <!ENTITY projectroot '../'>
        <!ENTITY % common-links SYSTEM "../links.ent">
        %common-links;
        ]>
  <document>
        <header>
                <title>hivemind.ThreadLocale Service</title>
        </header>
        <body>
                <p>The <link 
href="&hivedoc;/service/hivemind.ThreadLocale.html">
                        ThreadLocale</link> service implements the <link
                        
href="&apiroot;/service/ThreadLocale.html">ThreadLocale</link>
                        interface. This service stores the current thread's 
locale.  You may use
        this service to read or update the thread's current locale.
        </p>
        </body>
  </document>
  
  
  
  1.27      +5 -0      
jakarta-hivemind/src/documentation/content/xdocs/index.xml
  
  Index: index.xml
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/src/documentation/content/xdocs/index.xml,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- index.xml 10 Feb 2005 01:04:34 -0000      1.26
  +++ index.xml 11 Feb 2005 15:29:51 -0000      1.27
  @@ -98,6 +98,11 @@
   </warning>          
       <p>You can now omit the package name (generally) when specifying class 
name in a module descriptor.
         The &module; element's package attribute provides the package name to 
use.</p>
  +      
  +      <p>
  +        The locale (used for localized messages) is no longer fixed, as it 
was in 1.0.  You can change
  +        the locale using the &hivemind.ThreadLocale; service.
  +      </p>
   
                </section>
       <section>
  
  
  
  1.41      +1 -0      jakarta-hivemind/src/documentation/content/xdocs/site.xml
  
  Index: site.xml
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/src/documentation/content/xdocs/site.xml,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- site.xml  16 Jan 2005 15:54:05 -0000      1.40
  +++ site.xml  11 Feb 2005 15:29:51 -0000      1.41
  @@ -78,6 +78,7 @@
             href="LoggingInterceptor.html"/>
           <hivemind.ShutdownCoordinator label="ShutdownCoordinator" 
             href="ShutdownCoordinator.html"/>
  +        <hivemind.ThreadLocale label="ThreadLocale" 
href="ThreadLocale.html"/>
           <hivemind.ThreadLocalStorage label="ThreadLocalStorage" 
             href="ThreadLocalStorage.html"/>
         </services>
  
  
  
  1.23      +1 -0      
jakarta-hivemind/src/documentation/content/xdocs/links.ent
  
  Index: links.ent
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/src/documentation/content/xdocs/links.ent,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- links.ent 16 Jan 2005 15:54:05 -0000      1.22
  +++ links.ent 11 Feb 2005 15:29:51 -0000      1.23
  @@ -150,6 +150,7 @@
   <!ENTITY hivemind.ServiceModels 'hivemind.ServiceModels'>
   <!ENTITY hivemind.SymbolSources '<link 
href="site:hivemind.SymbolSources">hivemind.SymbolSources</link>'>
   <!ENTITY hivemind.ThreadEventNotifier 'hivemind.ThreadEventNotifier'>
  +<!ENTITY hivemind.ThreadLocale '<link 
href="site:hivemind.ThreadLocale">hivemind.ThreadLocale</link>'>
   <!ENTITY hivemind.ThreadLocalStorage '<link 
href="site:hivemind.ThreadLocalStorage">hivemind.ThreadLocalStorage</link>'>
   <!ENTITY hivemind.Translators '<link 
href="site:hivemind.Translators">hivemind.Translators</link>'>
   
  
  
  
  1.8       +28 -2     
jakarta-hivemind/src/documentation/content/xdocs/localization.xml
  
  Index: localization.xml
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/src/documentation/content/xdocs/localization.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- localization.xml  5 Jan 2005 21:53:31 -0000       1.7
  +++ localization.xml  11 Feb 2005 15:29:51 -0000      1.8
  @@ -47,6 +47,13 @@
   </contribution>]]> </source>
                <p>The two keys (<code>message.key</code> and 
<code>other.message.key</code>
                        ) are searched for in the <em>contributing</em> 
module's messages.</p>
  +      
  +      <warning>
  +      Support for this '%' syntax will likely be removed soon. This is 
because
  +      the locale is now changeable; what locale to use when converting 
configuration
  +      data becomes dangerously ambiguous.
  +      </warning>
  +      
                <p>HiveMind gracefully recovers from undefined messages. If a 
message is not
                        in the properties file, then HiveMind provides a 
substitute value by
                        converting the key to upper-case and adding brackets, 
i.e. <code>
  @@ -56,11 +63,30 @@
                        example, adding a second file, 
<code>META-INF/hivemodule_fr.properties</code>
                        would provide French language localizations. Any common 
keys between the
                        two files defer to the more specific file.</p>
  +      
  +      <p>
  +        The &hivemind.BuilderFactory; can inject an &api.Messages; object 
that allows access
  +        to the module's messages.
  +      </p>
                <section>
                        <title>Setting the locale</title>
                        <p>When a &api.Registry; is created by the 
&api.RegistryBuilder;, a locale
  -                             is specified. This is the locale for the 
Registry and, by extension, for
  -                             all Modules in the registry. The locale may not 
be changed.</p>
  +                             is specified. This is the <em>default</em> 
locale for the Registry and, by extension, for
  +                             all Modules in the registry. </p>
  +        
  +        <p>
  +          Threads will always use this locale by default, but the locale for
  +          an individual <em>thread</em> may be changed using the 
&hivemind.ThreadLocale; service.
  +          The &api.Messages; injected into your services automatically 
adjusts for the
  +          thread's current locale.
  +        </p>
  +        
  +        <p>
  +          You should not store, in your services, any localized values, 
since different threads
  +          may want different localizations. Instead, you should always 
obtain values
  +          from the &api.Messages;.
  +        </p>
  +        
                </section>
        </body>
   </document>
  
  
  
  1.1                  
jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/ThreadLocaleFactory.java
  
  Index: ThreadLocaleFactory.java
  ===================================================================
  // Copyright 2005 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.service.impl;
  
  import java.util.Locale;
  
  import org.apache.hivemind.ServiceImplementationFactory;
  import org.apache.hivemind.ServiceImplementationFactoryParameters;
  
  /**
   * Specialized factory used to create instances of
   * [EMAIL PROTECTED] org.apache.hivemind.service.impl.ThreadLocaleImpl}(i.e., 
service hivemind.ThreadLocale).
   * This is necessary because there isn't a way to inject the Registry's 
locale into a property. It's
   * also more efficient, and this is a service that will be constructed 
frequently.
   * 
   * @author Howard M. Lewis Ship
   * @since 1.1
   */
  public class ThreadLocaleFactory implements ServiceImplementationFactory
  {
  
      public Object createCoreServiceImplementation(
              ServiceImplementationFactoryParameters factoryParameters)
      {
          Locale defaultLocale = 
factoryParameters.getInvokingModule().getLocale();
  
          return new ThreadLocaleImpl(defaultLocale);
      }
  
  }
  
  
  1.1                  
jakarta-hivemind/framework/src/java/org/apache/hivemind/service/impl/ThreadLocaleImpl.java
  
  Index: ThreadLocaleImpl.java
  ===================================================================
  // Copyright 2005 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.service.impl;
  
  import java.util.Locale;
  
  import org.apache.hivemind.service.ThreadLocale;
  import org.apache.hivemind.util.Defense;
  
  /**
   * @author Howard M. Lewis Ship
   * @since 1.1
   */
  public class ThreadLocaleImpl implements ThreadLocale
  {
      private Locale _locale;
  
      public ThreadLocaleImpl(Locale locale)
      {
          setLocale(locale);
      }
  
      public void setLocale(Locale locale)
      {
          Defense.notNull(locale, "locale");
  
          _locale = locale;
      }
  
      public Locale getLocale()
      {
          return _locale;
      }
  
  }
  
  
  1.23      +17 -0     
jakarta-hivemind/framework/src/descriptor/META-INF/hivemodule.xml
  
  Index: hivemodule.xml
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/framework/src/descriptor/META-INF/hivemodule.xml,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- hivemodule.xml    10 Feb 2005 01:04:33 -0000      1.22
  +++ hivemodule.xml    11 Feb 2005 15:29:52 -0000      1.23
  @@ -701,4 +701,21 @@
       <provider prefix="service-property" 
service-id="ServicePropertyObjectProvider"/>
     </contribution>
     
  +  <service-point id="ThreadLocale" 
interface="org.apache.hivemind.service.ThreadLocale">
  +    
  +    Stores the locale for the current thread. The default is determined when 
the Registry is first
  +    constructed.  This locale is used for any messages.
  +    
  +    <invoke-factory service-id="ThreadLocaleFactory" model="threaded"/>
  +    
  +  </service-point>
  +  
  +  <service-point id="ThreadLocaleFactory" 
interface="ServiceImplementationFactory" parameters-occurs="none" 
visibility="private">
  +    
  +    Special service implementation factory for the ThreadLocale service.
  +    
  +    <create-instance class="service.impl.ThreadLocaleFactory"/>
  +    
  +  </service-point>
  +  
   </module>
  
  
  
  1.17      +13 -1     
jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ModuleImpl.java
  
  Index: ModuleImpl.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ModuleImpl.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- ModuleImpl.java   10 Feb 2005 01:04:33 -0000      1.16
  +++ ModuleImpl.java   11 Feb 2005 15:29:52 -0000      1.17
  @@ -21,13 +21,16 @@
   import org.apache.hivemind.ApplicationRuntimeException;
   import org.apache.hivemind.ClassResolver;
   import org.apache.hivemind.ErrorHandler;
  +import org.apache.hivemind.HiveMind;
   import org.apache.hivemind.Location;
   import org.apache.hivemind.Messages;
  +import org.apache.hivemind.internal.MessageFinder;
   import org.apache.hivemind.internal.Module;
   import org.apache.hivemind.internal.RegistryInfrastructure;
   import org.apache.hivemind.internal.ServiceModelFactory;
   import org.apache.hivemind.internal.ServicePoint;
   import org.apache.hivemind.schema.Translator;
  +import org.apache.hivemind.service.ThreadLocale;
   import org.apache.hivemind.util.IdUtils;
   import org.apache.hivemind.util.ToStringBuilder;
   
  @@ -122,7 +125,16 @@
       public synchronized Messages getMessages()
       {
           if (_messages == null)
  -            _messages = new MessagesImpl(getLocation().getResource(), 
_registry.getLocale());
  +        {
  +            ThreadLocale threadLocale = (ThreadLocale) _registry.getService(
  +                    HiveMind.THREAD_LOCALE_SERVICE,
  +                    ThreadLocale.class,
  +                    this);
  +
  +            MessageFinder finder = new 
MessageFinderImpl(getLocation().getResource());
  +
  +            _messages = new ModuleMessages(finder, threadLocale);
  +        }
   
           return _messages;
       }
  
  
  
  1.8       +10 -76    
jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/MessageFormatter.java
  
  Index: MessageFormatter.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/MessageFormatter.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- MessageFormatter.java     5 Jan 2005 18:04:09 -0000       1.7
  +++ MessageFormatter.java     11 Feb 2005 15:29:52 -0000      1.8
  @@ -14,23 +14,23 @@
   
   package org.apache.hivemind.impl;
   
  -import java.text.MessageFormat;
  +import java.util.Locale;
   import java.util.MissingResourceException;
   import java.util.ResourceBundle;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  -import org.apache.hivemind.HiveMind;
   
   /**
  - * A wrapper around [EMAIL PROTECTED] java.util.ResourceBundle} that makes
  - * it easier to access and format messages.
  - *
  + * A wrapper around [EMAIL PROTECTED] java.util.ResourceBundle}that makes it 
easier to access and format
  + * messages.
  + * 
    * @author Howard Lewis Ship
    */
  -public class MessageFormatter
  +public class MessageFormatter extends AbstractMessages
   {
       private Log _log;
  +
       private ResourceBundle _bundle;
   
       public MessageFormatter(Log log, ResourceBundle bundle)
  @@ -54,7 +54,7 @@
           this(log, ResourceBundle.getBundle(bundleName));
       }
   
  -    public String getMessage(String key)
  +    protected String findMessage(String key)
       {
           try
           {
  @@ -63,78 +63,12 @@
           catch (MissingResourceException ex)
           {
               _log.error("Missing resource key: " + key + ".");
  -            return "[" + key.toUpperCase() + "]";
  -        }
  -    }
  -
  -    public String format(String key, Object arg)
  -    {
  -        return format(key, new Object[] { arg });
  -    }
  -
  -    public String format(String key, Object arg1, Object arg2)
  -    {
  -        return format(key, new Object[] { arg1, arg2 });
  -    }
  -
  -    public String format(String key, Object arg1, Object arg2, Object arg3)
  -    {
  -        return format(key, new Object[] { arg1, arg2, arg3 });
  -    }
  -
  -     /**
  -      * Formats a message using the key to obtain a pattern, and passing the 
arguments.
  -      * 
  -      * <p>
  -      * It is common to pass an exception instance as an arg.  Those are 
treated specially:
  -      * The exception instance is replaced with its message [EMAIL 
PROTECTED] Throwable#getMessage()}. If the
  -      * message is blank (null or empty), then the exception's class name is 
used.
  -      */
  -    public String format(String key, Object[] args)
  -    {
  -        String pattern = getMessage(key);
  -
  -        if (args == null)
  -            return pattern;
  -
  -        for (int i = 0; i < args.length; i++)
  -        {
  -            if (args[i] instanceof Throwable)
  -            {
  -                Throwable t = (Throwable) args[i];
  -
  -                args[i] = extractMessage(t);
  -            }
  -        }
  -
  -        try
  -        {
  -            return MessageFormat.format(pattern, args);
  -        }
  -        catch (Exception ex)
  -        {
  -            _log.error("Unable to format message: \"" + pattern + "\" from 
key " + key + ".", ex);
  -
               return null;
           }
       }
   
  -    /**
  -     * Extracts the message from an exception. If the message is null, the 
the class name
  -     * of the exception is returned.
  -     * 
  -     */
  -    private String extractMessage(Throwable t)
  +    protected Locale getLocale()
       {
  -        if (t == null)
  -            return null;
  -
  -        String message = t.getMessage();
  -
  -        if (HiveMind.isBlank(message))
  -            return t.getClass().getName();
  -
  -        return message;
  +        return Locale.getDefault();
       }
  -
  -}
  +}
  \ No newline at end of file
  
  
  
  1.1                  
jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/MessageFinderImpl.java
  
  Index: MessageFinderImpl.java
  ===================================================================
  // Copyright 2005 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.impl;
  
  import java.io.BufferedInputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.net.URL;
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Locale;
  import java.util.Map;
  import java.util.Properties;
  
  import org.apache.hivemind.ApplicationRuntimeException;
  import org.apache.hivemind.Resource;
  import org.apache.hivemind.internal.MessageFinder;
  import org.apache.hivemind.util.Defense;
  import org.apache.hivemind.util.LocalizedNameGenerator;
  
  /**
   * @author Howard M. Lewis Ship
   * @since 1.1
   */
  public class MessageFinderImpl implements MessageFinder
  {
      private static final String EXTENSION = ".properties";
  
      private static class Localization
      {
          private Locale _locale;
  
          private Resource _resource;
  
          Localization(Locale locale, Resource resource)
          {
              _locale = locale;
              _resource = resource;
          }
  
          public Locale getLocale()
          {
              return _locale;
          }
  
          public Resource getResource()
          {
              return _resource;
          }
  
      }
  
      private Resource _baseResource;
  
      private String _baseName;
  
      private Map _propertiesMap = new HashMap();
  
      private Properties _emptyProperties = new Properties();
  
      public MessageFinderImpl(Resource baseResource)
      {
          Defense.notNull(baseResource, "baseResource");
  
          _baseResource = baseResource;
  
          // Strip off the extension to form the base name
          // when building new (localized) resources.
  
          String name = _baseResource.getName();
          int dotx = name.lastIndexOf('.');
  
          _baseName = name.substring(0, dotx);
      }
  
      public String getMessage(String key, Locale locale)
      {
          return findProperties(locale).getProperty(key);
      }
  
      private synchronized Properties findProperties(Locale locale)
      {
          Properties result = (Properties) _propertiesMap.get(locale);
  
          // If doesn't exist, build it (which will update the
          // propertiesMap as a side effect.
  
          if (result == null)
              result = buildProperties(locale);
  
          return result;
      }
  
      private Properties buildProperties(Locale locale)
      {
          Properties result = _emptyProperties;
  
          List localizations = findLocalizations(locale);
  
          Iterator i = localizations.iterator();
          while (i.hasNext())
          {
              Localization l = (Localization) i.next();
  
              result = readProperties(l.getLocale(), l.getResource(), result);
          }
  
          return result;
      }
  
      /**
       * Returns the properties, reading them if necessary. Properties may have 
been previously read
       * for this locale, in which case the cached value is returned. Also, if 
the resource doesn't
       * exist, then the parent is returned as is. Updates the propertiesMap 
cache.
       */
  
      private Properties readProperties(Locale locale, Resource 
propertiesResource, Properties parent)
      {
          Properties result = (Properties) _propertiesMap.get(locale);
  
          if (result != null)
              return result;
  
          URL url = propertiesResource.getResourceURL();
  
          if (url == null)
              result = parent;
          else
              result = readPropertiesFile(url, parent);
  
          _propertiesMap.put(locale, result);
  
          return result;
      }
  
      private Properties readPropertiesFile(URL url, Properties parent)
      {
          InputStream stream = null;
  
          Properties result = new Properties(parent);
  
          try
          {
              stream = new BufferedInputStream(url.openStream());
  
              result.load(stream);
  
              stream.close();
  
              stream = null;
          }
          catch (IOException ex)
          {
              throw new 
ApplicationRuntimeException(ImplMessages.unableToReadMessages(url), ex);
  
          }
          finally
          {
              close(stream);
          }
  
          return result;
      }
  
      private void close(InputStream stream)
      {
          if (stream != null)
              try
              {
                  stream.close();
              }
              catch (IOException ex)
              {
                  // Ignore.
              }
      }
  
      /**
       * Returns a List of Localizations, in order from most generic (i.e., 
hivemodule.properties) to
       * most specific (i.e., hivemodule_en_US_yokel.properties).
       */
  
      private List findLocalizations(Locale locale)
      {
          List result = new ArrayList();
  
          LocalizedNameGenerator g = new LocalizedNameGenerator(_baseName, 
locale, EXTENSION);
  
          while (g.more())
          {
              String name = g.next();
  
              Localization l = new Localization(g.getCurrentLocale(), 
_baseResource
                      .getRelativeResource(name));
  
              result.add(l);
          }
  
          Collections.reverse(result);
  
          return result;
      }
  }
  
  
  1.1                  
jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ModuleMessages.java
  
  Index: ModuleMessages.java
  ===================================================================
  // Copyright 2005 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.impl;
  
  import java.util.Locale;
  
  import org.apache.hivemind.internal.MessageFinder;
  import org.apache.hivemind.service.ThreadLocale;
  import org.apache.hivemind.util.Defense;
  
  /**
   * An implementation of [EMAIL PROTECTED] org.apache.hivemind.Messages}that 
obtains messages from a
   * [EMAIL PROTECTED] org.apache.hivemind.internal.MessageFinder}, in a locale 
provided by the
   * [EMAIL PROTECTED] org.apache.hivemind.service.ThreadLocale}service.
   * 
   * @author Howard M. Lewis Ship
   * @since 1.1
   */
  public class ModuleMessages extends AbstractMessages
  {
      private MessageFinder _messageFinder;
  
      private ThreadLocale _threadLocale;
  
      public ModuleMessages(MessageFinder messageFinder, ThreadLocale 
threadLocale)
      {
          Defense.notNull(messageFinder, "messageFinder");
          Defense.notNull(threadLocale, "threadLocale");
  
          _messageFinder = messageFinder;
          _threadLocale = threadLocale;
      }
  
      protected Locale getLocale()
      {
          return _threadLocale.getLocale();
      }
  
      protected String findMessage(String key)
      {
          return _messageFinder.getMessage(key, getLocale());
      }
  
  }
  
  
  1.1                  
jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/AbstractMessages.java
  
  Index: AbstractMessages.java
  ===================================================================
  // Copyright 2005 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.impl;
  
  import java.text.MessageFormat;
  import java.util.Locale;
  
  import org.apache.hivemind.HiveMind;
  import org.apache.hivemind.Messages;
  import org.apache.hivemind.util.Defense;
  
  /**
   * Abstract base class for implementations of [EMAIL PROTECTED] 
org.apache.hivemind.Messages}. Subclasses must
   * provide [EMAIL PROTECTED] #getLocale()}and [EMAIL PROTECTED] 
#findMessage(String)}implementations.
   * 
   * @author Howard M. Lewis Ship
   * @since 1.1
   */
  public abstract class AbstractMessages implements Messages
  {
      public String format(String key, Object[] args)
      {
          String pattern = getMessage(key);
  
          for (int i = 0; i < args.length; i++)
          {
              Object arg = args[i];
  
              if (arg != null && arg instanceof Throwable)
                  args[i] = extractMessage((Throwable) arg);
          }
  
          // This ugliness is mandated for JDK 1.3 compatibility, which has a 
bug
          // in MessageFormat ... the
          // pattern is applied in the constructor, using the system default 
Locale,
          // regardless of what locale is later specified!
          // It appears that the problem does not exist in JDK 1.4.
  
          MessageFormat messageFormat = new MessageFormat("");
          messageFormat.setLocale(getLocale());
          messageFormat.applyPattern(pattern);
  
          return messageFormat.format(args);
      }
  
      private String extractMessage(Throwable t)
      {
          String message = t.getMessage();
  
          return HiveMind.isNonBlank(message) ? message : 
t.getClass().getName();
      }
  
      public String format(String key, Object arg0)
      {
          return format(key, new Object[]
          { arg0 });
      }
  
      public String format(String key, Object arg0, Object arg1)
      {
          return format(key, new Object[]
          { arg0, arg1 });
      }
  
      public String format(String key, Object arg0, Object arg1, Object arg2)
      {
          return format(key, new Object[]
          { arg0, arg1, arg2 });
      }
  
      public String getMessage(String key)
      {
          Defense.notNull(key, "key");
  
          String result = findMessage(key);
  
          if (result == null)
              result = "[" + key.toUpperCase() + "]";
  
          return result;
      }
  
      /**
       * Concrete implementations must provide a non-null Locale.
       */
  
      protected abstract Locale getLocale();
  
      /**
       * Concrete implementations must implement this method.
       * 
       * @param key
       * @returns the localized message for the key, or null if no such message 
exists.
       */
  
      protected abstract String findMessage(String key);
  
  }
  
  
  1.1                  
jakarta-hivemind/framework/src/java/org/apache/hivemind/service/ThreadLocale.java
  
  Index: ThreadLocale.java
  ===================================================================
  // Copyright 2005 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.service;
  
  import java.util.Locale;
  
  /**
   * The hivemind.ThreadLocale service is intrinsic to HiveMind; its a threaded 
service for storing
   * the locale for the <em>current</em> thread (it uses the threaded service).
   * 
   * @author Howard M. Lewis Ship
   * @since 1.1
   */
  public interface ThreadLocale
  {
      /**
       * Changes the locale from the default.
       */
  
      public void setLocale(Locale locale);
  
      /**
       * Returns the current locale. Initially, this is the
       * [EMAIL PROTECTED] org.apache.hivemind.Registry#getLocale()}default 
locale. This may be changed for a
       * thread.
       */
  
      public Locale getLocale();
  }
  
  
  1.97      +113 -373  jakarta-hivemind/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/status.xml,v
  retrieving revision 1.96
  retrieving revision 1.97
  diff -u -r1.96 -r1.97
  --- status.xml        10 Feb 2005 01:04:32 -0000      1.96
  +++ status.xml        11 Feb 2005 15:29:52 -0000      1.97
  @@ -20,7 +20,6 @@
       <person name="Howard M. Lewis Ship" email="[EMAIL PROTECTED]" id="HLS" />
       <person name="Knut Wannheden" email="[EMAIL PROTECTED]" id="KW" />
     </developers>
  -  
     <todo>
       <actions priority="Release 1.1">
         <action context="lib" dev="HLS">JMX Integration</action>
  @@ -29,390 +28,131 @@
         <action context="hivedoc">visibility (configuration points, service 
points), interceptor sets</action>
       </actions>
     </todo>
  -  
  -  
     <changes>
  -  
       <release version="1.1-alpha-2" date="unreleased">
  -      <action type="update" dev="HLS">
  -        Better, prettier HiveDoc.
  -      </action>
  -      <action type="fix" dev="KW" fixes-bug="HIVEMIND-88" due-to="Brian K. 
Wallace">
  -        Error running examples using Ant targets.
  -      </action>
  -      <action type="update" dev="HLS">
  -        Add package attribute to &lt;module&gt; and automatically qualify 
Java class and interface names
  -        into that package.
  -      </action>
  +      <action type="update" dev="HLS"> Better, prettier HiveDoc. </action>
  +      <action type="fix" dev="KW" fixes-bug="HIVEMIND-88" due-to="Brian K. 
Wallace"> Error running examples using Ant targets. </action>
  +      <action type="update" dev="HLS"> Add package attribute to 
&lt;module&gt; and automatically qualify Java class and interface names into 
that package. </action>
  +      <action type="update" dev="HLS"> Allow the locale to be changed. 
</action>
       </release>
  -  
       <release version="1.1-alpha-1" date="Jan 19 2005">
  -      <action type="add" dev="KW">
  -        Added &lt;dependency&gt; construct providing support for 
dependencies between modules.
  -        Refactoring of RegistryBuilder: Now constructs Registry using a 
ModuleProvider.
  -      </action>
  -      <action type="add" dev="HLS" fixes-bug="HIVEMIND-58">
  -        Add visibility (public or private) to configuration points, service 
points and schemas.
  -      </action>
  -      <action type="add" dev="KW" fixes-bug="HIVEMIND-63">
  -        Add &lt;null&gt; constructor parameter element to BuilderFactory 
service.
  -      </action>
  -      <action type="fix" dev="KW" fixes-bug="HIVEMIND-64">
  -        Report error if module descriptors define conflicting service or 
configuration points.
  -      </action>
  -      <action type="update" dev="KW">
  -        HiveDoc is now being generated from the parsed module descriptors 
instead of directly from
  -        the XML files.  This will allow HiveDoc generation for module 
descriptors in other formats.
  -      </action>
  -      <action type="update" dev="HLS">
  -        Upgrade to Forrest 0.6 (still in progress).
  -      </action>
  -      <action type="update" dev="HLS">
  -        Re-work the HiveDoc report to work naturally at the module (not 
project) level.
  -      </action>
  -      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-56" due-to="Bruce 
Synder">
  -        CVS connection string on website is incorrect
  -      </action>
  -      <action type="update" dev="HLS">
  -        Synchronize all access to java.beans.Introspector through a common 
mutex.
  -      </action>
  -      <action type="update" dev="HLS">
  -        Clear the PropertyUtils and Introspector caches when the Registry is 
shutdown.
  -      </action>
  -      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-68">
  -        Properly report the actual method name when invoking a service 
initializer method.
  -      </action>
  -      <action type="add" dev="HLS" fixes-bug="HIVEMIND-66">
  -        Move some logic related to primitive Java types and arrays from 
Tapestry directly into DefaultClassResolver.
  -      </action>
  -      <action type="update" dev="HLS">
  -        ApplicationRuntimeException will now display the location (if known) 
as part of its toString() method, making it
  -        much easier to track down problems in stack traces (especially 
deeply nested ones).
  -      </action>
  -      <action type="add" dev="HLS">
  -        Add support for the ErrorLog (a simple wrapper around an 
ErrorHandler and a Log). Add support
  -        for setting the service's ErrorLog to BuilderFactory.
  -      </action>
  -      <action type="update" dev="HLS">
  -        Switch Javassist to version 3.0-rc-1.
  -      </action>
  -      <action type="add" dev="HLS">
  -        Add toString() support to ClassFab and MethodFab.
  -      </action>
  -      <action type="add" dev="HLS">
  -        Add the hivemind.lib.AdapterRegistryFactory service implementation 
factory.
  -      </action>
  -      <action type="update" dev="HLS"> Removed the module parameter from 
ClassFactory.newClass() and from 
  -        DefaultImplementationBuilder.buildDefaultImplementation(). </action>
  -      <action type="update" dev="KW">
  -        BuilderFactory now supports autowiring through constructor based 
dependency injection.
  -      </action>
  -        <action type="fix" dev="HLS" fixes-bug="HIVEMIND-75">
  -          Add ability to set default value for non-matches in MethodMatcher.
  -        </action>
  -        <action type="fix" dev="HLS" fixes-bug="HIVEMIND-76">
  -          Improve MethodSignature and MethodIterator to filter out duplicate 
methods that differ
  -          only in terms of thrown exceptions.
  -        </action>
  -        <action type="fix" dev="HLS" fixes-bug="HIVEMIND-77">
  -          Change BuilderFactoryLogic to report the actual exception, not the 
InvocationTargetException,
  -          when an exception is thrown by a constructor or by a initializer 
method invocation.
  -        </action>
  -        <action type="add" dev="KW">
  -          Added Groovy support.  Module descriptors can now be defined using 
Groovy scripts.  Although
  -               it requires some additional work in building the Registry.
  -        </action>
  -        <action type="add" dev="HLS">
  -          Support the EasyMock Class Extension, if present on the classpath, 
to allow classes (not just
  -          interfaces) to be mocked.
  -        </action>
  -     <action type="update" dev="HLS">
  -      Refactored SpringLookupFactory to identify a Spring BeanFactory 
directly, rather than
  -      via a SpringBeanFactorySource.
  -     </action>
  -        <action type="add" dev="KW">
  -          Added support for mapped configurations. A configuration schema 
can now specify an attribute
  -          which should be used as the key in a Map of all contributions. The 
BuilderFactory can inject 
  -          such configurations as List or Maps.
  -        </action>
  -     <action type="update" dev="HLS">
  -      Move ContextResource from Tapestry to HiveMind.
  -     </action>
  -     <action type="update" dev="HLS">
  -      Change HiveMindFilter load WEB-INF/hivemodule.xml if present.
  -     </action>
  -     <action type="add" dev="HLS">
  -      Add support for conditional contributions.
  -     </action>
  -      <action type="add" dev="HLS">
  -        Allow services to be serialized (that is, service proxies can be 
serialized and
  -        deserialized).
  -      </action>   
  -        <action type="fix" dev="KW" fixes-bug="HIVEMIND-15" due-to="James 
Carman">
  -          Smart translator properly returns attribute values as Strings when 
used with
  -          a &lt;push-attribute&gt; rule.
  -        </action>
  -        <action type="fix" dev="KW" fixes-bug="HIVEMIND-57">
  -          Attribute values are symbol-expanded by a &lt;push-attribute&gt; 
rule before being
  -          translated and pushed on the stack.
  -        </action> 
  -      <action type="add" dev="HLS">
  -        Add hivemind.lib.ChainBuilder service, an implementation of Gang Of 
Four Chain of Command.
  -      </action> 
  -      <action type="add" dev="HLS">
  -        Add hivemind.lib.ChainFactory service.
  -      </action>
  +      <action type="add" dev="KW"> Added &lt;dependency&gt; construct 
providing support for dependencies between modules. Refactoring of 
RegistryBuilder: Now constructs Registry using a ModuleProvider. </action>
  +      <action type="add" dev="HLS" fixes-bug="HIVEMIND-58"> Add visibility 
(public or private) to configuration points, service points and schemas. 
</action>
  +      <action type="add" dev="KW" fixes-bug="HIVEMIND-63"> Add &lt;null&gt; 
constructor parameter element to BuilderFactory service. </action>
  +      <action type="fix" dev="KW" fixes-bug="HIVEMIND-64"> Report error if 
module descriptors define conflicting service or configuration points. </action>
  +      <action type="update" dev="KW"> HiveDoc is now being generated from 
the parsed module descriptors instead of directly from the XML files. This will 
allow HiveDoc generation for module descriptors in other formats. </action>
  +      <action type="update" dev="HLS"> Upgrade to Forrest 0.6 (still in 
progress). </action>
  +      <action type="update" dev="HLS"> Re-work the HiveDoc report to work 
naturally at the module (not project) level. </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-56" due-to="Bruce 
Synder"> CVS connection string on website is incorrect </action>
  +      <action type="update" dev="HLS"> Synchronize all access to 
java.beans.Introspector through a common mutex. </action>
  +      <action type="update" dev="HLS"> Clear the PropertyUtils and 
Introspector caches when the Registry is shutdown. </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-68"> Properly report 
the actual method name when invoking a service initializer method. </action>
  +      <action type="add" dev="HLS" fixes-bug="HIVEMIND-66"> Move some logic 
related to primitive Java types and arrays from Tapestry directly into 
DefaultClassResolver. </action>
  +      <action type="update" dev="HLS"> ApplicationRuntimeException will now 
display the location (if known) as part of its toString() method, making it 
much easier to track down problems in stack traces (especially deeply nested 
ones). </action>
  +      <action type="add" dev="HLS"> Add support for the ErrorLog (a simple 
wrapper around an ErrorHandler and a Log). Add support for setting the 
service's ErrorLog to BuilderFactory. </action>
  +      <action type="update" dev="HLS"> Switch Javassist to version 3.0-rc-1. 
</action>
  +      <action type="add" dev="HLS"> Add toString() support to ClassFab and 
MethodFab. </action>
  +      <action type="add" dev="HLS"> Add the 
hivemind.lib.AdapterRegistryFactory service implementation factory. </action>
  +      <action type="update" dev="HLS"> Removed the module parameter from 
ClassFactory.newClass() and from 
DefaultImplementationBuilder.buildDefaultImplementation(). </action>
  +      <action type="update" dev="KW"> BuilderFactory now supports autowiring 
through constructor based dependency injection. </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-75"> Add ability to 
set default value for non-matches in MethodMatcher. </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-76"> Improve 
MethodSignature and MethodIterator to filter out duplicate methods that differ 
only in terms of thrown exceptions. </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-77"> Change 
BuilderFactoryLogic to report the actual exception, not the 
InvocationTargetException, when an exception is thrown by a constructor or by a 
initializer method invocation. </action>
  +      <action type="add" dev="KW"> Added Groovy support. Module descriptors 
can now be defined using Groovy scripts. Although it requires some additional 
work in building the Registry. </action>
  +      <action type="add" dev="HLS"> Support the EasyMock Class Extension, if 
present on the classpath, to allow classes (not just interfaces) to be mocked. 
</action>
  +      <action type="update" dev="HLS"> Refactored SpringLookupFactory to 
identify a Spring BeanFactory directly, rather than via a 
SpringBeanFactorySource. </action>
  +      <action type="add" dev="KW"> Added support for mapped configurations. 
A configuration schema can now specify an attribute which should be used as the 
key in a Map of all contributions. The BuilderFactory can inject such 
configurations as List or Maps. </action>
  +      <action type="update" dev="HLS"> Move ContextResource from Tapestry to 
HiveMind. </action>
  +      <action type="update" dev="HLS"> Change HiveMindFilter load 
WEB-INF/hivemodule.xml if present. </action>
  +      <action type="add" dev="HLS"> Add support for conditional 
contributions. </action>
  +      <action type="add" dev="HLS"> Allow services to be serialized (that 
is, service proxies can be serialized and deserialized). </action>
  +      <action type="fix" dev="KW" fixes-bug="HIVEMIND-15" due-to="James 
Carman"> Smart translator properly returns attribute values as Strings when 
used with a &lt;push-attribute&gt; rule. </action>
  +      <action type="fix" dev="KW" fixes-bug="HIVEMIND-57"> Attribute values 
are symbol-expanded by a &lt;push-attribute&gt; rule before being translated 
and pushed on the stack. </action>
  +      <action type="add" dev="HLS"> Add hivemind.lib.ChainBuilder service, 
an implementation of Gang Of Four Chain of Command. </action>
  +      <action type="add" dev="HLS"> Add hivemind.lib.ChainFactory service. 
</action>
  +    </release>
  +    <release version="1.0" date="Sep 22 2004">
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-55"> Ensure that the 
logging interceptor will work properly when wrapping around JDK dynamic 
proxies. </action>
  +    </release>
  +    <release version="1.0-rc-2" date="Sep 11 2004">
  +      <action type="add" dev="HLS"> Add method getSymbolValue() to 
RegistryInfrastructure and Module </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-48"> Fix class loader 
issues concerning fabricated classes in different modules. </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-47"> Allow symbols to 
be escaped rather than expanded. </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-44" due-to="James 
Carman"> The previous fix was incomplete; this should close the remaining 
sychronization gaps. </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-49"> Class loading 
issue inside Tomcat. </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-10" due-to="James 
Carman"> Tweak HiveMind to work properly in a JavaWebStart application. 
</action>
  +      <action type="add" dev="HLS"> Add <code>clearCache()</code> method to 
<code>PropertyUtils</code>. </action>
  +      <action type="update" dev="HLS"> Change the API for 
<code>ClassFactory</code> to take a <code>ClassLoader</code>, not a 
<code>Module</code>. </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-52"> Handle 
duplicated methods in service interfaces, avoiding "attempt to redefine method" 
errors. </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-49"> Class loading 
issue inside Tomcat. </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-10" due-to="James 
Carman"> Tweak HiveMind to work properly in a JavaWebStart application. 
</action>
  +      <action type="add" dev="HLS"> Add clearCache() method to 
PropertyUtils. </action>
  +      <action type="update" dev="HLS"> Change the API for ClassFactory to 
take a ClassLoader, not a Module. </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-52"> Handle 
duplicated methods in service interfaces, avoiding "attempt to redefine method" 
errors. </action>
       </release>
  -
  -   <release version="1.0" date="Sep 22 2004">
  -    <action type="fix" dev="HLS" fixes-bug="HIVEMIND-55">
  -      Ensure that the logging interceptor will work properly when wrapping 
around JDK dynamic proxies.
  -    </action>
  -   </release>
  -
  -   <release version="1.0-rc-2" date="Sep 11 2004">
  -      <action type="add" dev="HLS">
  -        Add method getSymbolValue() to RegistryInfrastructure and Module
  -      </action>
  -      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-48">
  -        Fix class loader issues concerning fabricated classes in different 
modules.
  -      </action>
  -      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-47">
  -        Allow symbols to be escaped rather than expanded.
  -      </action>
  -      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-44" due-to="James 
Carman">
  -        The previous fix was incomplete; this should close the remaining 
sychronization gaps.
  -      </action>
  -      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-49">
  -        Class loading issue inside Tomcat.
  -      </action>
  -      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-10" due-to="James 
Carman">
  -        Tweak HiveMind to work properly in a JavaWebStart application.
  -      </action>
  -      <action type="add" dev="HLS">
  -        Add <code>clearCache()</code> method to <code>PropertyUtils</code>.
  -      </action>
  -      <action type="update" dev="HLS">
  -        Change the API for <code>ClassFactory</code> to take a 
<code>ClassLoader</code>, not a <code>Module</code>.
  -      </action>
  -      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-52">
  -        Handle duplicated methods in service interfaces, avoiding "attempt 
to redefine method" errors.
  -      </action>
  -      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-49">
  -        Class loading issue inside Tomcat.
  -      </action>
  -      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-10" due-to="James 
Carman">
  -        Tweak HiveMind to work properly in a JavaWebStart application.
  -      </action>
  -      <action type="add" dev="HLS">
  -        Add clearCache() method to PropertyUtils.
  -      </action>
  -      <action type="update" dev="HLS">
  -        Change the API for ClassFactory to take a ClassLoader, not a Module.
  -      </action>
  -      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-52">
  -        Handle duplicated methods in service interfaces, avoiding "attempt 
to redefine method" errors.
  -      </action>
  -    </release>
  -  
       <release version="1.0-rc-1" date="Aug 25 2004">
  -      <action type="update" dev="HLS">
  -        Remove support for Simple Data Language ... it's all XML again.
  -      </action>
  -      <action type="update" dev="HLS">
  -        Re-work part of PipelineFactory to take advantage of object 
references.
  -      </action>
  -      <action type="update" dev="HLS">
  -        Make the service-id of &lt;invoke-factory&gt; optional and default
  -        to hivemind.BuilderFactory.
  -      </action>
  -      <action type="update" dev="HLS">
  -        Change the hivemind.Startup configuration to take an object 
reference, not
  -        a service id.
  -      </action>
  -      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-29" due-to="Michael 
Frericks">
  -        SmartTranslator should differentiate between blank strings and null 
input
  -      </action>
  -      <action type="update" dev="HLS">
  -        Improvements to HiveBuild to properly handle changing versions or 
useages of artifacts.
  -      </action>
  -      <action type="add" dev="HLS" fixes-bug="HIVEMIND-43" due-to="Johan 
Lindquist">
  -        Add ability to mark attributes of an element as unique, such that
  -        duplicate values in contributions result in errors.
  -      </action>      
  -      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-41">
  -        Add checks to SchemaProcessorImpl for empty stack conditions
  -      </action>
  -      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-33">
  -        Add parameters-occurs attribute to &lt;service-point&gt; element.
  -      </action>
  -      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-23">
  -        Specify location in all module deployment descriptor parse 
exceptions.
  -      </action>
  -      <action type="add" dev="HLS" due-to="Stefan Liebig" 
fixes-bug="HIVEMIND-42">
  -        Add Quick Reference Sheet.
  -      </action>
  -      <action type="fix" dev="HLS" due-to="Luke Blanshard" 
fixes-bug="HIVEMIND-16">
  -        Add getCause() method to ApplicationRuntimeException
  -      </action>
  -      <action type="add" dev="HLS" due-to="Naresh Sikha" 
fixes-bug="HIVEMIND-37">
  -        Add polling methods to Registry.
  -      </action>
  -      <action type="add" dev="HLS" due-to="Naresh Sikha" 
fixes-bug="HIVEMIND-36">
  -        Add polling methods to BeanFactory.
  -      </action>
  -      <action type="fix" dev="HLS" due-to="James Carman" 
fixes-bug="HIVEMIND-44">
  -        Fix broken synchronization in ThreadedServiceModel and 
PooledServiceModel that could make them
  -        randomly fail when creating a service by invoking a factory.
  -      </action>
  -      <action type="fix" dev="HLS" due-to="Johan Lindquist" 
fixes-bug="HIVEMIND-34">
  -        Check for &lt;sub-module&gt; references that do not exist.
  -      </action>
  +      <action type="update" dev="HLS"> Remove support for Simple Data 
Language ... it's all XML again. </action>
  +      <action type="update" dev="HLS"> Re-work part of PipelineFactory to 
take advantage of object references. </action>
  +      <action type="update" dev="HLS"> Make the service-id of 
&lt;invoke-factory&gt; optional and default to hivemind.BuilderFactory. 
</action>
  +      <action type="update" dev="HLS"> Change the hivemind.Startup 
configuration to take an object reference, not a service id. </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-29" due-to="Michael 
Frericks"> SmartTranslator should differentiate between blank strings and null 
input </action>
  +      <action type="update" dev="HLS"> Improvements to HiveBuild to properly 
handle changing versions or useages of artifacts. </action>
  +      <action type="add" dev="HLS" fixes-bug="HIVEMIND-43" due-to="Johan 
Lindquist"> Add ability to mark attributes of an element as unique, such that 
duplicate values in contributions result in errors. </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-41"> Add checks to 
SchemaProcessorImpl for empty stack conditions </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-33"> Add 
parameters-occurs attribute to &lt;service-point&gt; element. </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-23"> Specify location 
in all module deployment descriptor parse exceptions. </action>
  +      <action type="add" dev="HLS" due-to="Stefan Liebig" 
fixes-bug="HIVEMIND-42"> Add Quick Reference Sheet. </action>
  +      <action type="fix" dev="HLS" due-to="Luke Blanshard" 
fixes-bug="HIVEMIND-16"> Add getCause() method to ApplicationRuntimeException 
</action>
  +      <action type="add" dev="HLS" due-to="Naresh Sikha" 
fixes-bug="HIVEMIND-37"> Add polling methods to Registry. </action>
  +      <action type="add" dev="HLS" due-to="Naresh Sikha" 
fixes-bug="HIVEMIND-36"> Add polling methods to BeanFactory. </action>
  +      <action type="fix" dev="HLS" due-to="James Carman" 
fixes-bug="HIVEMIND-44"> Fix broken synchronization in ThreadedServiceModel and 
PooledServiceModel that could make them randomly fail when creating a service 
by invoking a factory. </action>
  +      <action type="fix" dev="HLS" due-to="Johan Lindquist" 
fixes-bug="HIVEMIND-34"> Check for &lt;sub-module&gt; references that do not 
exist. </action>
       </release>
  -  
       <release version="1.0-beta-2" date="Aug 1 2004">
  -      <action type="fix" dev="KW" fixes-bug="HIVEMIND-6">
  -        Removed dependency on Werkz.
  -      </action>
  -      <action type="update" dev="HLS">
  -        Added link to the Jakarta mailing lists page.
  -      </action>
  -      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-21" due-to="Achim 
Hügen">
  -        Modifed the build scripts to properly include variable info when 
compiling.
  -      </action>
  -      <action type="update" dev="HLS">
  -        Moved the Ant build scripts to a new directory, hivebuild, in 
preparation
  -        for making hivebuild reusable on new projects.
  -      </action>
  -      <action type="update" dev="HLS">
  -        Added protected method constructRegistry() to HiveMindFilter.
  -      </action>
  -      <action type="update" dev="HLS">
  -        Renamed existing 'object' translator to 'instance', and created
  -        a new 'object' translator with great flexibility. Extend 
BuilderFactory
  -        to add a set-object element that leverages the object translator.
  -      </action>
  -      <action type="update" dev="HLS">
  -        Created service-property object translator.
  -      </action>
  -      <action type="update" dev="HLS" fixes-bug="HIVEMIND-20" due-to="Marcus 
Brito">
  -       Added a version of Registry.getService() that omits the service id
  -       (but requires that exactly one service point implements the service 
interface).
  -      </action>
  -      <action type="update" dev="HLS" fixes-bug="HIVEMIND-22">
  -        Extended the BuilderFactory to autowire services.
  -      </action>
  -      <action type="add" dev="HLS">
  -        Added a new module that contains HiveMind example code.
  -      </action>
  -      <action type="update" dev="HLS">
  -        Fixed some latent bugs related to submodules inside the 
constructRegistry task.
  -        Made some more improvements to the hivebuild scripts.
  -      </action> 
  -      <action type="update" dev="HLS">
  -        Updated the download location for the Forrest distribution.
  -      </action>
  -      <action type="update" dev="HLS">
  -        Added more examples and examples documentation.
  -      </action>
  -      <action type="add" dev="HLS">
  -        Added StrictErrorHandler, an implementation of ErrorHandler that 
always throws an ApplicationRuntimeException.
  -      </action>
  -      <action type="update" dev="HLS">
  -        Moved the code for the Grabber Ant task into the tree and improve 
the build scripts to dynamically
  -        compile and use it.
  -      </action>
  -      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-31" due-to="Johan 
Lindquist">
  -        Typo in jar-module.xml causes broken build if junit library is 
missing
  -      </action>
  -      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-35">
  -        Made a number of changes to ensure HiveMind compatibility with JDK 
1.3.
  -      </action>
  -      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-26">
  -        Changed some unit tests to adapt to platform line endings.
  -      </action>
  -      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-46" due-to="Johan 
Lindquist">
  -        Fix the HiveDoc XSL to use XML (not SDL) output.
  -      </action>
  +      <action type="fix" dev="KW" fixes-bug="HIVEMIND-6"> Removed dependency 
on Werkz. </action>
  +      <action type="update" dev="HLS"> Added link to the Jakarta mailing 
lists page. </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-21" due-to="Achim 
Hügen"> Modifed the build scripts to properly include variable info when 
compiling. </action>
  +      <action type="update" dev="HLS"> Moved the Ant build scripts to a new 
directory, hivebuild, in preparation for making hivebuild reusable on new 
projects. </action>
  +      <action type="update" dev="HLS"> Added protected method 
constructRegistry() to HiveMindFilter. </action>
  +      <action type="update" dev="HLS"> Renamed existing 'object' translator 
to 'instance', and created a new 'object' translator with great flexibility. 
Extend BuilderFactory to add a set-object element that leverages the object 
translator. </action>
  +      <action type="update" dev="HLS"> Created service-property object 
translator. </action>
  +      <action type="update" dev="HLS" fixes-bug="HIVEMIND-20" due-to="Marcus 
Brito"> Added a version of Registry.getService() that omits the service id (but 
requires that exactly one service point implements the service interface). 
</action>
  +      <action type="update" dev="HLS" fixes-bug="HIVEMIND-22"> Extended the 
BuilderFactory to autowire services. </action>
  +      <action type="add" dev="HLS"> Added a new module that contains 
HiveMind example code. </action>
  +      <action type="update" dev="HLS"> Fixed some latent bugs related to 
submodules inside the constructRegistry task. Made some more improvements to 
the hivebuild scripts. </action>
  +      <action type="update" dev="HLS"> Updated the download location for the 
Forrest distribution. </action>
  +      <action type="update" dev="HLS"> Added more examples and examples 
documentation. </action>
  +      <action type="add" dev="HLS"> Added StrictErrorHandler, an 
implementation of ErrorHandler that always throws an 
ApplicationRuntimeException. </action>
  +      <action type="update" dev="HLS"> Moved the code for the Grabber Ant 
task into the tree and improve the build scripts to dynamically compile and use 
it. </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-31" due-to="Johan 
Lindquist"> Typo in jar-module.xml causes broken build if junit library is 
missing </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-35"> Made a number of 
changes to ensure HiveMind compatibility with JDK 1.3. </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-26"> Changed some 
unit tests to adapt to platform line endings. </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-46" due-to="Johan 
Lindquist"> Fix the HiveDoc XSL to use XML (not SDL) output. </action>
       </release>
  -  
       <release version="1.0-beta-1" date="Jun 26 2004">
         <action type="update" dev="HLS">Added change log. </action>
  -      <action type="update" dev="HLS">Refactored ClassFab and related 
classes 
  -        for easier reuse outside of HiveMind. Added a new suite of tests 
  -        related to ClassFab.</action>
  -      <action type="add" dev="HLS">Created two new services in hivemind-lib 
for 
  -        creating default implementations of arbitrary interfaces (<link 
  -        
href="site:hivemind.lib.DefaultImplementationBuilder">DefaultImplementationBuilder</link>)
 
  -        and for using that to create placeholder services (<link 
  -        
href="site:hivemind.lib.PlaceholderFactory">PlaceholderFactory</link>).</action>
  -      <action type="add" dev="HLS">Created MessageFormatter class as a 
wrapper 
  -        around ResourceBundle and an easy way for individual packages to 
gain 
  -        access to runtime messages. </action>
  -      <action type="update" dev="HLS">Modified the read-attribute rule to 
allow 
  -        a translator to be specified (overriding the translator for the 
  -        attribute).</action>
  -      <action type="add" dev="HLS">Added the qualified-id and 
  -        id-list translators.</action>
  -      <action type="add" dev="HLS">Added the <link 
  -        
href="site:hivemind.lib.PipelineFactory">hivemind.lib.PipelineFactory</link> 
  -        and related code, schemas, tests and documentation. </action>
  -      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-4"> Enhance logging 
of 
  -        exceptions when setting a service property to a contribution 
</action>
  -      <action type="add" dev="HLS"> Added service <link 
  -        
href="site:hivemind.lib.BeanFactoryBuilder">hivemind.lib.BeanFactoryBuilder</link>.
 
  -        </action>
  -      <action type="update" dev="HLS"> Removed the &lt;description&gt; 
element 
  -        from the module descriptor format; descriptions are now provided as 
  -        enclosed text for element that support descriptions. </action>
  -      <action type="update" dev="HLS"> Changed the MethodMatcher classes to 
use 
  -        a MethodSignature rather than a Method. </action>
  -      <action type="update" dev="HLS"> Changed MessageFormatter to 
  -        automatically convert Throwables into their message or class name. 
  -        </action>
  +      <action type="update" dev="HLS">Refactored ClassFab and related 
classes for easier reuse outside of HiveMind. Added a new suite of tests 
related to ClassFab.</action>
  +      <action type="add" dev="HLS">Created two new services in hivemind-lib 
for creating default implementations of arbitrary interfaces (<link 
href="site:hivemind.lib.DefaultImplementationBuilder">DefaultImplementationBuilder</link>)
 and for using that to create placeholder services (<link 
href="site:hivemind.lib.PlaceholderFactory">PlaceholderFactory</link>).</action>
  +      <action type="add" dev="HLS">Created MessageFormatter class as a 
wrapper around ResourceBundle and an easy way for individual packages to gain 
access to runtime messages. </action>
  +      <action type="update" dev="HLS">Modified the read-attribute rule to 
allow a translator to be specified (overriding the translator for the 
attribute).</action>
  +      <action type="add" dev="HLS">Added the qualified-id and id-list 
translators.</action>
  +      <action type="add" dev="HLS">Added the <link 
href="site:hivemind.lib.PipelineFactory">hivemind.lib.PipelineFactory</link> 
and related code, schemas, tests and documentation. </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-4"> Enhance logging 
of exceptions when setting a service property to a contribution </action>
  +      <action type="add" dev="HLS"> Added service <link 
href="site:hivemind.lib.BeanFactoryBuilder">hivemind.lib.BeanFactoryBuilder</link>.
 </action>
  +      <action type="update" dev="HLS"> Removed the &lt;description&gt; 
element from the module descriptor format; descriptions are now provided as 
enclosed text for element that support descriptions. </action>
  +      <action type="update" dev="HLS"> Changed the MethodMatcher classes to 
use a MethodSignature rather than a Method. </action>
  +      <action type="update" dev="HLS"> Changed MessageFormatter to 
automatically convert Throwables into their message or class name. </action>
         <action type="add" dev="HLS"> Added FileResource. </action>
  -      <action type="update" dev="HLS"> Extended <link 
  -        href="site:hivemind.BuilderFactory">hivemind.BuilderFactory</link> 
to 
  -        be able to set the ClassResolver; for a service 
  -        implementation, and to autowire common properties (log, messages, 
  -        serviceId, errorHandler, classResolver) if the properties are 
writeable 
  -        and of the correct type. </action>
  -      <action type="update" dev="HLS">
  -        Added methods newControl(), newMock(),
  -        addControl(), replayControls()
  -        and verifyControls() to HiveMindTestCase
  -        to simplify test cases that use multiple 
  -        <link href="http://www.easymock.org";>EasyMock</link> mock objects.
  -      </action>
  -      <action type="update" dev="HLS">
  -        Changed HiveMindFilter to log a message after it stores
  -        the registry into the servlet context.
  -      </action>
  -      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-11">
  -        Restore the getConfiguration() and expandSymbols()
  -        methods to the Registry interface.
  -      </action>
  -      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-9" 
  -        due-to="Dieter Bogdoll"> SimpleDataLanguageParser calls the 
  -        ContentHandler with a null namespace argument instead of "". That 
leads 
  -        to some problems if you want to use transformers. </action>
  -      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-7" due-to="Achim 
Hügen">
  -        Fix how certain translator messages are generated to avoid unit test 
failures.
  -      </action>
  -      <action type="update" dev="HLS" fixes-bug="HIVEMIND-12">
  -        Modify the build files to enable debugging by default.
  -      </action>
  -      <action type="update" dev="HLS">
  -        Added validation of id attributes in module deployment descriptors 
(using ORO regular expressions).
  -      </action>
  -      <action type="fix" dev="HLS">
  -        Fix some typos in definition of the 
  -        <link 
href="site:hivemind.lib.NameLookup">hivemind.lib.NameLookup</link>
  -        service.
  -      </action>
  -      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-25" due-to="Naresh 
Sikha">
  -      Fix a mistake in the BuilderFactory's set-object element, and add 
integration tests.
  -      </action>
  +      <action type="update" dev="HLS"> Extended <link 
href="site:hivemind.BuilderFactory">hivemind.BuilderFactory</link> to be able 
to set the ClassResolver; for a service implementation, and to autowire common 
properties (log, messages, serviceId, errorHandler, classResolver) if the 
properties are writeable and of the correct type. </action>
  +      <action type="update" dev="HLS"> Added methods newControl(), 
newMock(), addControl(), replayControls() and verifyControls() to 
HiveMindTestCase to simplify test cases that use multiple <link 
href="http://www.easymock.org";>EasyMock</link> mock objects. </action>
  +      <action type="update" dev="HLS"> Changed HiveMindFilter to log a 
message after it stores the registry into the servlet context. </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-11"> Restore the 
getConfiguration() and expandSymbols() methods to the Registry interface. 
</action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-9" due-to="Dieter 
Bogdoll"> SimpleDataLanguageParser calls the ContentHandler with a null 
namespace argument instead of "". That leads to some problems if you want to 
use transformers. </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-7" due-to="Achim 
Hügen"> Fix how certain translator messages are generated to avoid unit test 
failures. </action>
  +      <action type="update" dev="HLS" fixes-bug="HIVEMIND-12"> Modify the 
build files to enable debugging by default. </action>
  +      <action type="update" dev="HLS"> Added validation of id attributes in 
module deployment descriptors (using ORO regular expressions). </action>
  +      <action type="fix" dev="HLS"> Fix some typos in definition of the 
<link href="site:hivemind.lib.NameLookup">hivemind.lib.NameLookup</link> 
service. </action>
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-25" due-to="Naresh 
Sikha"> Fix a mistake in the BuilderFactory's set-object element, and add 
integration tests. </action>
       </release>
     </changes>
   </status>
  \ No newline at end of file
  
  
  
  1.1                  
jakarta-hivemind/framework/src/test/org/apache/hivemind/TestThreadLocale.java
  
  Index: TestThreadLocale.java
  ===================================================================
  // Copyright 2005 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind;
  
  import java.util.Locale;
  
  import org.apache.hivemind.impl.RegistryBuilder;
  import org.apache.hivemind.service.ThreadLocale;
  import org.apache.hivemind.test.HiveMindTestCase;
  
  /**
   * Tests for [EMAIL PROTECTED] 
org.apache.hivemind.service.ThreadLocale}service. We revert to using
   * integration tests because unit tests would not be very meaningful.
   * 
   * @author Howard M. Lewis Ship
   * @since 1.1
   */
  public class TestThreadLocale extends HiveMindTestCase
  {
      public void testThreadSpecific() throws Exception
      {
          final Registry r = RegistryBuilder.constructDefaultRegistry();
  
          final ThreadLocale tl = (ThreadLocale) 
r.getService(ThreadLocale.class);
  
          assertSame(r.getLocale(), tl.getLocale());
  
          tl.setLocale(Locale.KOREAN);
  
          assertSame(Locale.KOREAN, tl.getLocale());
  
          Thread t = new Thread()
          {
              public void run()
              {
                  assertSame(r.getLocale(), tl.getLocale());
              }
          };
  
          t.start();
          t.join();
      }
  
      public void testResetOnThreadCleanup() throws Exception
      {
          Registry r = RegistryBuilder.constructDefaultRegistry();
  
          ThreadLocale tl = (ThreadLocale) r.getService(ThreadLocale.class);
  
          Locale start = r.getLocale();
  
          assertSame(start, tl.getLocale());
  
          tl.setLocale(Locale.CANADA_FRENCH);
  
          r.cleanupThread();
  
          assertSame(start, tl.getLocale());
      }
  
  }
  
  
  1.4       +12 -27    
jakarta-hivemind/framework/src/java/org/apache/hivemind/Messages.java
  
  Index: Messages.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/Messages.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Messages.java     5 Jan 2005 18:05:21 -0000       1.3
  +++ Messages.java     11 Feb 2005 15:29:52 -0000      1.4
  @@ -15,43 +15,28 @@
   package org.apache.hivemind;
   
   /**
  - * A set of localized message strings.  This is somewhat like
  - * a [EMAIL PROTECTED] java.util.ResourceBundle}, but with more
  - * flexibility about where the messages come from.  In addition,
  - * it includes methods similar to [EMAIL PROTECTED] java.text.MessageFormat}
  - * for treating the messages as patterns.
  + * A set of localized message strings. This is somewhat like a [EMAIL 
PROTECTED] java.util.ResourceBundle},
  + * but with more flexibility about where the messages come from. In 
addition, it includes methods
  + * similar to [EMAIL PROTECTED] java.text.MessageFormat}for treating the 
messages as patterns.
    * 
    * @author Howard Lewis Ship
  - *
    */
   public interface Messages
   {
       /**
  -     * Searches for a localized string with the given key.
  -     * If not found, a modified version of the key
  -     * is returned (all upper-case and surrounded by square
  -     * brackets).
  +     * Searches for a localized string with the given key. If not found, a 
modified version of the
  +     * key is returned (all upper-case and surrounded by square brackets).
        */
   
       public String getMessage(String key);
   
       /**
  -     * Searches for a localized string with the given key.
  -     * If not found, then the default value (which should already
  -     * be localized) is returned.  Passing a default of null
  -     * is useful when trying to determine if the strings contains
  -     * a given key.
  -     */
  -
  -    public String getMessage(String key, String defaultValue);
  -
  -    /**
  -     * Formats a string, using
  -     * [EMAIL PROTECTED] MessageFormat#format(java.lang.String, 
java.lang.Object[])}.
  -     *
  -     * @param key the key used to obtain a localized pattern using
  -     * [EMAIL PROTECTED] #getMessage(String)}
  -     * @param arguments passed to the formatter
  +     * Formats a string, using [EMAIL PROTECTED] 
MessageFormat#format(java.lang.String, java.lang.Object[])}.
  +     * 
  +     * @param key
  +     *            the key used to obtain a localized pattern using [EMAIL 
PROTECTED] #getMessage(String)}
  +     * @param arguments
  +     *            passed to the formatter
        */
   
       public String format(String key, Object[] arguments);
  @@ -71,4 +56,4 @@
        * Convienience method for invoking [EMAIL PROTECTED] #format(String, 
Object[])}.
        */
       public String format(String key, Object argument1, Object argument2, 
Object argument3);
  -}
  +}
  \ No newline at end of file
  
  
  
  1.16      +7 -1      
jakarta-hivemind/framework/src/java/org/apache/hivemind/HiveMind.java
  
  Index: HiveMind.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/HiveMind.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- HiveMind.java     5 Jan 2005 18:05:21 -0000       1.15
  +++ HiveMind.java     11 Feb 2005 15:29:52 -0000      1.16
  @@ -29,10 +29,16 @@
       public static final String THREAD_EVENT_NOTIFIER_SERVICE = 
"hivemind.ThreadEventNotifier";
   
       /**
  +     * The full id of the [EMAIL PROTECTED] 
org.apache.hivemind.service.ThreadLocale}service.
  +     */
  +
  +    public static final String THREAD_LOCALE_SERVICE = 
"hivemind.ThreadLocale";
  +
  +    /**
        * An object used to synchronize access to [EMAIL PROTECTED] 
java.beans.Introspector}(which is not fully
        * threadsafe).
        * 
  -     * @since 3.1
  +     * @since 1.1
        */
   
       public static final Object INTROSPECTOR_MUTEX = new Object();
  
  
  
  1.1                  
jakarta-hivemind/framework/src/java/org/apache/hivemind/internal/MessageFinder.java
  
  Index: MessageFinder.java
  ===================================================================
  // Copyright 2005 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.internal;
  
  import java.util.Locale;
  
  /**
   * An abstraction around the ResourceBundler-style property names and 
localized messages. The goal
   * is to implement a [EMAIL PROTECTED] org.apache.hivemind.Messages}that 
obtains the actual localizations from
   * an external source.
   * 
   * @author Howard M. Lewis Ship
   */
  public interface MessageFinder
  {
      /**
       * Returns a message matching the key, in the indicated locale.
       */
  
      public String getMessage(String key, Locale locale);
  }
  
  
  1.1                  
jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/MessageFinder_fr.properties
  
  Index: MessageFinder_fr.properties
  ===================================================================
  # Copyright 2005 The Apache Software Foundation
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #     http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  overridden-in-base=MessageFinder_fr.overriden-in-base
  
  
  1.1                  
jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/TestMessageFinder.java
  
  Index: TestMessageFinder.java
  ===================================================================
  // Copyright 2005 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.impl;
  
  import java.util.Locale;
  
  import org.apache.hivemind.internal.MessageFinder;
  import org.apache.hivemind.test.HiveMindTestCase;
  import org.apache.hivemind.util.ClasspathResource;
  
  /**
   * @author Howard M. Lewis Ship
   */
  public class TestMessageFinder extends HiveMindTestCase
  {
      private MessageFinder newFinder()
      {
          ClasspathResource r = new ClasspathResource(new 
DefaultClassResolver(),
                  "org/apache/hivemind/impl/MessageFinder.xml");
  
          return new MessageFinderImpl(r);
      }
  
      public void testLocaleOverridesBase()
      {
          MessageFinder mf = newFinder();
  
          assertEquals("MessageFinder_fr.overriden-in-base", mf.getMessage(
                  "overridden-in-base",
                  Locale.FRENCH));
  
          // FRANCE is more detailed than FRENCH
          // Also, there is no MessageFinder_fr_FR.properties file,
          // and that's ok.
  
          assertEquals("MessageFinder_fr.overriden-in-base", mf.getMessage(
                  "overridden-in-base",
                  Locale.FRANCE));
      }
  
      public void testLocaleDoeNotObscureBase()
      {
          MessageFinder mf = newFinder();
  
          assertEquals("MessageFinder.only-in-properties", mf.getMessage(
                  "only-in-base",
                  Locale.FRENCH));
      }
  }
  
  
  1.1                  
jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/MessageFinder.properties
  
  Index: MessageFinder.properties
  ===================================================================
  # Copyright 2005 The Apache Software Foundation
  #
  # Licensed under the Apache License, Version 2.0 (the "License");
  # you may not use this file except in compliance with the License.
  # You may obtain a copy of the License at
  #
  #     http://www.apache.org/licenses/LICENSE-2.0
  #
  # Unless required by applicable law or agreed to in writing, software
  # distributed under the License is distributed on an "AS IS" BASIS,
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  # See the License for the specific language governing permissions and
  # limitations under the License.
  
  only-in-base=MessageFinder.only-in-properties
  
  overridden-in-base=MessageFinder.overriden-in-base
  
  
  1.10      +8 -2      
jakarta-hivemind/examples/src/test/com/panorama/startup/impl/TestTaskExecutor.java
  
  Index: TestTaskExecutor.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/examples/src/test/com/panorama/startup/impl/TestTaskExecutor.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TestTaskExecutor.java     5 Jan 2005 18:06:00 -0000       1.9
  +++ TestTaskExecutor.java     11 Feb 2005 15:29:53 -0000      1.10
  @@ -24,7 +24,11 @@
   import org.apache.hivemind.ErrorLog;
   import org.apache.hivemind.Messages;
   import org.apache.hivemind.Resource;
  -import org.apache.hivemind.impl.MessagesImpl;
  +import org.apache.hivemind.impl.MessageFinderImpl;
  +import org.apache.hivemind.impl.ModuleMessages;
  +import org.apache.hivemind.internal.MessageFinder;
  +import org.apache.hivemind.service.ThreadLocale;
  +import org.apache.hivemind.service.impl.ThreadLocaleImpl;
   import org.apache.hivemind.test.AggregateArgumentsMatcher;
   import org.apache.hivemind.test.ArgumentMatcher;
   import org.apache.hivemind.test.HiveMindTestCase;
  @@ -69,8 +73,10 @@
           String path = projectRoot + 
"/examples/src/descriptor/META-INF/panorama.startup.xml";
   
           Resource r = new FileResource(path);
  +        MessageFinder mf = new MessageFinderImpl(r);
  +        ThreadLocale tl = new ThreadLocaleImpl(Locale.getDefault());
   
  -        return new MessagesImpl(r, Locale.getDefault());
  +        return new ModuleMessages(mf, tl);
       }
   
       public void testSuccess()
  
  
  

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

Reply via email to