hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From k...@apache.org
Subject cvs commit: jakarta-hivemind/framework/src/test/org/apache/hivemind/servlet TestHiveMindFilter.java
Date Thu, 09 Sep 2004 16:06:47 GMT
knut        2004/09/09 09:06:46

  Modified:    framework/src/test/hivemind/test/config
                        TestConfigurationPoint.java
               framework/src/java/org/apache/hivemind/parse
                        DescriptorParser.properties DescriptorParser.java
                        ModuleDescriptor.java
               framework/src/java/org/apache/hivemind/test
                        HiveMindTestCase.java
               framework/src/java/org/apache/hivemind/impl
                        ImplStrings.properties ImplMessages.java
                        RegistryBuilder.java
               examples/src/java/org/apache/hivemind/examples
                        ExampleUtils.java
               framework/src/java/org/apache/hivemind/servlet
                        HiveMindFilter.java
               framework/src/test/hivemind/test TestRegistryBuilder.java
               framework/src/java/org/apache/hivemind/ant
                        ConstructRegistry.java
               src/documentation/content/xdocs links.ent descriptor.xml
               .        status.xml
               framework/src/test/org/apache/hivemind/servlet
                        TestHiveMindFilter.java
  Added:       framework/src/java/org/apache/hivemind/parse
                        DependencyDescriptor.java
               framework/src/java/org/apache/hivemind/impl
                        AggregateModuleProvider.java ModuleProvider.java
                        XmlModuleProvider.java
               framework/src/test/hivemind/test TestDependency.java
  Log:
  - Added DependencyDescriptor for inter-module dependencies. Currently limited to specifying dependencies w/o version matching and with exact version matching.
  - Refactored RegistryBuilder by factoring out a ModuleProvider interfaces (with implemtations XmlModuleProvider, AggregateModuleProvider)
  
  Revision  Changes    Path
  1.19      +7 -3      jakarta-hivemind/framework/src/test/hivemind/test/config/TestConfigurationPoint.java
  
  Index: TestConfigurationPoint.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/test/hivemind/test/config/TestConfigurationPoint.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- TestConfigurationPoint.java	29 Jul 2004 13:18:51 -0000	1.18
  +++ TestConfigurationPoint.java	9 Sep 2004 16:06:45 -0000	1.19
  @@ -31,7 +31,9 @@
   import org.apache.hivemind.Element;
   import org.apache.hivemind.Registry;
   import org.apache.hivemind.Resource;
  +import org.apache.hivemind.impl.AggregateModuleProvider;
   import org.apache.hivemind.impl.RegistryBuilder;
  +import org.apache.hivemind.impl.XmlModuleProvider;
   import org.apache.hivemind.internal.Module;
   import org.apache.hivemind.internal.RegistryInfrastructure;
   import org.apache.hivemind.util.ClasspathResource;
  @@ -440,10 +442,12 @@
           Resource moduleResource =
               new ClasspathResource(_resolver, "/hivemind/test/config/ResourceTranslator.xml");
   
  -        builder.processModules(_resolver);
  -        builder.processModule(_resolver, moduleResource);
  +        AggregateModuleProvider provider = new AggregateModuleProvider();
   
  -        Registry r = (Registry) builder.constructRegistry(Locale.FRENCH);
  +        provider.addModuleProvider(new XmlModuleProvider(_resolver, XmlModuleProvider.HIVE_MODULE_XML));
  +        provider.addModuleProvider(new XmlModuleProvider(_resolver, moduleResource));
  +
  +        Registry r = (Registry) builder.constructRegistry(provider, Locale.FRENCH);
   
           List l = r.getConfiguration("hivemind.test.config.ResourceTranslator");
   
  
  
  
  1.12      +3 -0      jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/DescriptorParser.properties
  
  Index: DescriptorParser.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/DescriptorParser.properties,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DescriptorParser.properties	18 Aug 2004 19:34:11 -0000	1.11
  +++ DescriptorParser.properties	9 Sep 2004 16:06:45 -0000	1.12
  @@ -84,3 +84,6 @@
   required.set-property.value=true
   
   required.push-attribute.attribute=true
  +
  +required.dependency.module-id=true
  +required.dependency.version=false
  
  
  
  1.33      +22 -1     jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/DescriptorParser.java
  
  Index: DescriptorParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/DescriptorParser.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- DescriptorParser.java	6 Sep 2004 09:19:47 -0000	1.32
  +++ DescriptorParser.java	9 Sep 2004 16:06:45 -0000	1.33
  @@ -494,7 +494,12 @@
               return;
           }
   
  -        // TODO: dependency
  +        if (elementName.equals("dependency"))
  +        {
  +            enterDependency(elementName);
  +
  +            return;
  +        }
   
           unexpectedElement(elementName);
       }
  @@ -1116,6 +1121,22 @@
           smd.setDescriptor(descriptor);
   
           md.addSubModule(smd);
  +    }
  +
  +    private void enterDependency(String elementName)
  +    {
  +        ModuleDescriptor md = (ModuleDescriptor) peekObject();
  +
  +        DependencyDescriptor dd = new DependencyDescriptor();
  +
  +        push(elementName, dd, STATE_NO_CONTENT);
  +
  +        checkAttributes();
  +
  +        dd.setModuleId(getAttribute("module-id"));
  +        dd.setVersion(getAttribute("version"));
  +
  +        md.addDependency(dd);
       }
   
       private String getAttribute(String name)
  
  
  
  1.6       +14 -0     jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/ModuleDescriptor.java
  
  Index: ModuleDescriptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/ModuleDescriptor.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ModuleDescriptor.java	6 Sep 2004 09:19:47 -0000	1.5
  +++ ModuleDescriptor.java	9 Sep 2004 16:06:45 -0000	1.6
  @@ -37,6 +37,7 @@
       private List _configurationPoints;
       private List _contributions;
       private List _subModules;
  +    private List _dependencies;
       private ClassResolver _resolver;
   
       public String toString()
  @@ -112,6 +113,19 @@
       public List getSubModules()
       {
           return _subModules;
  +    }
  +
  +    public void addDependency(DependencyDescriptor dependency)
  +    {
  +        if (_dependencies == null)
  +            _dependencies = new ArrayList();
  +
  +        _dependencies.add(dependency);
  +    }
  +
  +    public List getDependencies()
  +    {
  +        return _dependencies;
       }
   
       public String getModuleId()
  
  
  
  1.1                  jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/DependencyDescriptor.java
  
  Index: DependencyDescriptor.java
  ===================================================================
  //  Copyright 2004 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.parse;
  
  import org.apache.hivemind.impl.BaseLocatable;
  import org.apache.hivemind.util.ToStringBuilder;
  
  /**
   * Descriptor for <dependency> element.
   *
   * @author Knut Wannheden
   */
  public final class DependencyDescriptor extends BaseLocatable
  {
  
      private String _moduleId;
      private String _version;
  
      public String getModuleId()
      {
          return _moduleId;
      }
  
      public void setModuleId(String moduleId)
      {
          _moduleId = moduleId;
      }
  
      public String getVersion()
      {
          return _version;
      }
  
      public void setVersion(String version)
      {
          _version = version;
      }
  
      public String toString()
      {
          ToStringBuilder builder = new ToStringBuilder(this);
          builder.append("moduleId", _moduleId);
          builder.append("version", _version);
  
          return builder.toString();
      }
  
  }
  
  
  
  1.13      +31 -9     jakarta-hivemind/framework/src/java/org/apache/hivemind/test/HiveMindTestCase.java
  
  Index: HiveMindTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/test/HiveMindTestCase.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- HiveMindTestCase.java	19 Aug 2004 23:24:55 -0000	1.12
  +++ HiveMindTestCase.java	9 Sep 2004 16:06:45 -0000	1.13
  @@ -28,9 +28,12 @@
   import org.apache.hivemind.Location;
   import org.apache.hivemind.Registry;
   import org.apache.hivemind.Resource;
  +import org.apache.hivemind.impl.AggregateModuleProvider;
   import org.apache.hivemind.impl.DefaultClassResolver;
   import org.apache.hivemind.impl.LocationImpl;
  +import org.apache.hivemind.impl.ModuleProvider;
   import org.apache.hivemind.impl.RegistryBuilder;
  +import org.apache.hivemind.impl.XmlModuleProvider;
   import org.apache.hivemind.util.ClasspathResource;
   import org.apache.hivemind.util.URLResource;
   import org.apache.log4j.Level;
  @@ -315,7 +318,7 @@
   
           }
   
  -        throw new AssertionFailedError("Could not find logging event: " + pattern);
  +        throw new AssertionFailedError("Could not find logged message with pattern: " + pattern);
       }
   
       private void setupMatcher()
  @@ -345,18 +348,36 @@
       {
           ClassResolver resolver = new DefaultClassResolver();
   
  -        RegistryBuilder builder = new RegistryBuilder();
  -
  +        List descriptorResources = new ArrayList();
           for (int i = 0; i < files.length; i++)
           {
               Resource resource = getResource(files[i]);
   
  -            builder.processModule(resolver, resource);
  +            descriptorResources.add(resource);
           }
   
  -        builder.processModules(resolver);
  +        ModuleProvider provider = new XmlModuleProvider(resolver, descriptorResources);
  +
  +        return buildFrameworkRegistry(provider);
  +    }
   
  -        return builder.constructRegistry(Locale.getDefault());
  +    /**
  +     * Builds a registry, containing only the modules delivered by the specified 
  +     * {@link org.apache.hivemind.impl.ModuleProvider}, plus
  +     * the master module descriptor (i.e., those visible on the classpath).
  +     */
  +    protected Registry buildFrameworkRegistry(ModuleProvider customProvider)
  +    {
  +        ClassResolver resolver = new DefaultClassResolver();
  +    
  +        RegistryBuilder builder = new RegistryBuilder();
  +    
  +        AggregateModuleProvider provider = new AggregateModuleProvider();
  +    
  +        provider.addModuleProvider(new XmlModuleProvider(resolver, XmlModuleProvider.HIVE_MODULE_XML));
  +        provider.addModuleProvider(customProvider);
  +    
  +        return builder.constructRegistry(provider, Locale.getDefault());
       }
   
       /**
  @@ -365,11 +386,11 @@
        */
       protected Registry buildMinimalRegistry(Resource l) throws Exception
       {
  -        RegistryBuilder builder = new RegistryBuilder();
  +        ClassResolver resolver = new DefaultClassResolver();
   
  -        builder.processModule(new DefaultClassResolver(), l);
  +        RegistryBuilder builder = new RegistryBuilder();
   
  -        return builder.constructRegistry(Locale.getDefault());
  +        return builder.constructRegistry(new XmlModuleProvider(resolver, l), Locale.getDefault());
       }
   
       /**
  @@ -469,4 +490,5 @@
   
           return _matcher.matches(input, compiled);
       }
  +
   }
  
  
  
  1.11      +3 -0      jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ImplStrings.properties
  
  Index: ImplStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ImplStrings.properties,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ImplStrings.properties	6 Sep 2004 09:19:47 -0000	1.10
  +++ ImplStrings.properties	9 Sep 2004 16:06:45 -0000	1.11
  @@ -62,6 +62,9 @@
   shutdown-coordinator-failure=Unable to shutdown {0}: {1}
   sub-module-does-not-exist=Sub-module {0} does not exist.
   
  +dependency-on-unknown-module=Required module {0} does not exist.
  +dependency-version-mismatch=Version of required module {0} does not match expected version {1}.
  +
   unlocated-error=Error: {0}
   located-error=Error at {0}: {1}
   
  
  
  
  1.18      +43 -62    jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ImplMessages.java
  
  Index: ImplMessages.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ImplMessages.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- ImplMessages.java	6 Sep 2004 09:19:47 -0000	1.17
  +++ ImplMessages.java	9 Sep 2004 16:06:45 -0000	1.18
  @@ -30,20 +30,20 @@
   import org.apache.hivemind.internal.ServiceInterceptorContribution;
   import org.apache.hivemind.internal.ServicePoint;
   import org.apache.hivemind.parse.ContributionDescriptor;
  +import org.apache.hivemind.parse.DependencyDescriptor;
   import org.apache.hivemind.parse.ModuleDescriptor;
   import org.apache.hivemind.schema.Schema;
   import org.apache.hivemind.schema.SchemaProcessor;
   
   /**
  - * Used to format messages used in errors and log output for classes within the
  - * impl package.
  - *
  + * Used to format messages used in errors and log output for classes within the impl package.
  + * 
    * @author Howard Lewis Ship
    */
   final class ImplMessages
   {
  -    private static final MessageFormatter _formatter =
  -        new MessageFormatter(ImplMessages.class, "ImplStrings");
  +    private static final MessageFormatter _formatter = new MessageFormatter(ImplMessages.class,
  +            "ImplStrings");
   
       public static String recursiveServiceBuild(ServicePoint point)
       {
  @@ -57,10 +57,8 @@
   
       public static String unableToConstructConfiguration(String pointId, Throwable exception)
       {
  -        return _formatter.format(
  -            "unable-to-construct-configuration",
  -            pointId,
  -            exception.getMessage());
  +        return _formatter.format("unable-to-construct-configuration", pointId, exception
  +                .getMessage());
       }
   
       public static String unknownServiceModel(String name)
  @@ -80,10 +78,8 @@
   
       public static String duplicateTranslatorName(String name, Location oldLocation)
       {
  -        return _formatter.format(
  -            "duplicate-translator-name",
  -            name,
  -            HiveMind.getLocationString(oldLocation));
  +        return _formatter.format("duplicate-translator-name", name, HiveMind
  +                .getLocationString(oldLocation));
       }
   
       public static String translatorInstantiationFailure(Class translatorClass, Throwable cause)
  @@ -104,28 +100,18 @@
           return _formatter.format("unable-to-load-class", name, loader, cause);
       }
   
  -    public static String nullInterceptor(
  -        ServiceInterceptorContribution contribution,
  +    public static String nullInterceptor(ServiceInterceptorContribution contribution,
           ServicePoint point)
       {
  -        return _formatter.format(
  -            "null-interceptor",
  -            contribution.getFactoryServiceId(),
  -            point.getExtensionPointId());
  +        return _formatter.format("null-interceptor", contribution.getFactoryServiceId(), point
  +                .getExtensionPointId());
       }
   
  -    public static String interceptorDoesNotImplementInterface(
  -        Object interceptor,
  -        ServiceInterceptorContribution contribution,
  -        ServicePoint point,
  -        Class serviceInterface)
  +    public static String interceptorDoesNotImplementInterface(Object interceptor,
  +        ServiceInterceptorContribution contribution, ServicePoint point, Class serviceInterface)
       {
  -        return _formatter.format(
  -            "interceptor-does-not-implement-interface",
  -            new Object[] {
  -                interceptor,
  -                contribution.getFactoryServiceId(),
  -                point.getExtensionPointId(),
  +        return _formatter.format("interceptor-does-not-implement-interface", new Object[]{
  +                interceptor, contribution.getFactoryServiceId(), point.getExtensionPointId(),
                   serviceInterface.getName()});
       }
   
  @@ -158,14 +144,11 @@
               descriptor.getLocation().getResource());
       }
   
  -    public static String unknownConfigurationPoint(
  -        String moduleId,
  +    public static String unknownConfigurationPoint(String moduleId,
           ContributionDescriptor descriptor)
       {
  -        return _formatter.format(
  -            "unknown-configuration-extension-point",
  -            moduleId,
  -            descriptor.getConfigurationId());
  +        return _formatter.format("unknown-configuration-extension-point", moduleId, descriptor
  +                .getConfigurationId());
       }
   
       public static String unknownServicePoint(Module sourceModule, String pointId)
  @@ -181,21 +164,14 @@
           return _formatter.format("missing-service", point.getExtensionPointId());
       }
   
  -    public static String duplicateFactory(
  -        Module sourceModule,
  -        String pointId,
  +    public static String duplicateFactory(Module sourceModule, String pointId,
           ServicePointImpl existing)
       {
  -        return _formatter.format(
  -            "duplicate-factory",
  -            sourceModule.getModuleId(),
  -            pointId,
  -            existing.getServiceConstructor().getContributingModule().getModuleId());
  +        return _formatter.format("duplicate-factory", sourceModule.getModuleId(), pointId, existing
  +                .getServiceConstructor().getContributingModule().getModuleId());
       }
   
  -    public static String wrongNumberOfContributions(
  -        ConfigurationPoint point,
  -        int actualCount,
  +    public static String wrongNumberOfContributions(ConfigurationPoint point, int actualCount,
           Occurances expectation)
       {
           return _formatter.format(
  @@ -215,9 +191,7 @@
           return _formatter.format("contribution-count", new Integer(count));
       }
   
  -    public static String wrongNumberOfParameters(
  -        String factoryServiceId,
  -        int actualCount,
  +    public static String wrongNumberOfParameters(String factoryServiceId, int actualCount,
           Occurances expectation)
       {
           return _formatter.format(
  @@ -253,9 +227,7 @@
           return _formatter.format("missing-attribute", name);
       }
   
  -    public static String uniqueAttributeConstraintBroken(
  -        String name,
  -        String value,
  +    public static String uniqueAttributeConstraintBroken(String name, String value,
           Location priorLocation)
       {
           return _formatter.format("unique-attribute-constraint-broken", name, value, priorLocation);
  @@ -263,10 +235,8 @@
   
       public static String elementErrors(SchemaProcessor processor, Element element)
       {
  -        return _formatter.format(
  -            "element-errors",
  -            processor.getElementPath(),
  -            element.getLocation());
  +        return _formatter.format("element-errors", processor.getElementPath(), element
  +                .getLocation());
       }
   
       public static String unknownElement(SchemaProcessor processor, Element element)
  @@ -293,8 +263,7 @@
               servicePoint.getServiceInterface().getName());
       }
   
  -    public static String shutdownCoordinatorFailure(
  -        RegistryShutdownListener listener,
  +    public static String shutdownCoordinatorFailure(RegistryShutdownListener listener,
           Throwable cause)
       {
           return _formatter.format("shutdown-coordinator-failure", listener, cause);
  @@ -325,8 +294,7 @@
           return _formatter.format("no-service-point-for-interface", interfaceClass.getName());
       }
   
  -    public static String multipleServicePointsForInterface(
  -        Class interfaceClass,
  +    public static String multipleServicePointsForInterface(Class interfaceClass,
           Collection matchingPoints)
       {
           StringBuffer buffer = new StringBuffer("{");
  @@ -368,4 +336,17 @@
       {
           return _formatter.format("sub-module-does-not-exist", subModuleDescriptor);
       }
  -}
  +
  +    public static String dependencyOnUnknownModule(DependencyDescriptor dependency)
  +    {
  +        return _formatter.format("dependency-on-unknown-module", dependency.getModuleId());
  +    }
  +
  +    public static String dependencyVersionMismatch(DependencyDescriptor dependency)
  +    {
  +        return _formatter.format(
  +            "dependency-version-mismatch",
  +            dependency.getModuleId(),
  +            dependency.getVersion());
  +    }
  +}
  \ No newline at end of file
  
  
  
  1.20      +59 -107   jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/RegistryBuilder.java
  
  Index: RegistryBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/RegistryBuilder.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- RegistryBuilder.java	6 Sep 2004 09:19:47 -0000	1.19
  +++ RegistryBuilder.java	9 Sep 2004 16:06:45 -0000	1.20
  @@ -14,11 +14,8 @@
   
   package org.apache.hivemind.impl;
   
  -import java.io.IOException;
  -import java.net.URL;
   import java.util.ArrayList;
   import java.util.Collection;
  -import java.util.Enumeration;
   import java.util.HashMap;
   import java.util.Iterator;
   import java.util.List;
  @@ -27,32 +24,27 @@
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  -import org.apache.hivemind.ApplicationRuntimeException;
   import org.apache.hivemind.ClassResolver;
   import org.apache.hivemind.ErrorHandler;
  -import org.apache.hivemind.HiveMind;
   import org.apache.hivemind.Occurances;
   import org.apache.hivemind.Registry;
  -import org.apache.hivemind.Resource;
   import org.apache.hivemind.ShutdownCoordinator;
   import org.apache.hivemind.internal.Module;
   import org.apache.hivemind.parse.ConfigurationPointDescriptor;
   import org.apache.hivemind.parse.ContributionDescriptor;
  -import org.apache.hivemind.parse.DescriptorParser;
  +import org.apache.hivemind.parse.DependencyDescriptor;
   import org.apache.hivemind.parse.ImplementationDescriptor;
   import org.apache.hivemind.parse.InstanceBuilder;
   import org.apache.hivemind.parse.InterceptorDescriptor;
   import org.apache.hivemind.parse.ModuleDescriptor;
   import org.apache.hivemind.parse.ServicePointDescriptor;
  -import org.apache.hivemind.parse.SubModuleDescriptor;
   import org.apache.hivemind.util.IdUtils;
  -import org.apache.hivemind.util.URLResource;
   
   /**
    * Class used to build a {@link org.apache.hivemind.Registry} from individual
    * {@link org.apache.hivemind.parse.ModuleDescriptor}.  The descriptors
  - * are processed one at a time and the registry is constructed using a single call
  - * to {@link #constructRegistry(Locale)} at the end.
  + * are provided by the {@link ModuleProvider} parameter passed to 
  + * {@link #constructRegistry(Locale)} method.
    * 
    * <p>
    * A note about threadsafety: The assumption is that a single thread will access the RegistryBuilder
  @@ -99,12 +91,6 @@
       }
   
       /**
  -     * The path, within a JAR or the classpath, to the XML HiveMind module
  -     * deployment descriptor: <code>META-INF/hivemodule.xml</code>.
  -     */
  -    public static final String HIVE_MODULE_XML = "META-INF/hivemodule.xml";
  -
  -    /**
        * List of {@link ModuleDescriptor}.
        */
   
  @@ -134,11 +120,6 @@
       private ErrorHandler _errorHandler;
   
       /**
  -     * Parser instance used by all parsing for this builder.
  -     */
  -    private DescriptorParser _parser;
  -
  -    /**
        * Shutdown coordinator shared by all objects.
        */
   
  @@ -154,7 +135,7 @@
       {
           this(new DefaultErrorHandler());
       }
  -
  +    
       public RegistryBuilder(ErrorHandler handler)
       {
           _errorHandler = handler;
  @@ -163,103 +144,73 @@
       }
   
       /**
  -     * Processes all modules that can be found using the resolver.
  -     */
  -    public void processModules(ClassResolver resolver)
  -    {
  -        if (LOG.isDebugEnabled())
  -            LOG.debug("Processing modules visible to " + resolver);
  -
  -        processModulesResources(resolver, HIVE_MODULE_XML);
  -    }
  -
  -    /**
  -     * Locates module deployment descriptors in the "standard" location (META-INF).
  +     * This class is used to check the dependencies of a ModuleDescriptor.  As the checker
  +     * is run it will log errors to the ErrorHandler if dependencies don't resolve or the
  +     * versions dont match.
        */
  -    private void processModulesResources(ClassResolver resolver, String resourcePath)
  +    private class ModuleDependencyChecker implements Runnable
       {
  -        ClassLoader loader = resolver.getClassLoader();
  -        Enumeration e = null;
  +        private ModuleDescriptor _source;
   
  -        try
  -        {
  -            e = loader.getResources(resourcePath);
  -        }
  -        catch (IOException ex)
  +        public ModuleDependencyChecker(ModuleDescriptor source)
           {
  -            throw new ApplicationRuntimeException(
  -                ImplMessages.unableToFindModules(resolver, ex),
  -                ex);
  +            _source = source;
           }
   
  -        while (e.hasMoreElements())
  +        public void run()
           {
  -            URL descriptorURL = (URL) e.nextElement();
  -            Resource descriptorResource = new URLResource(descriptorURL);
  +            List dependencies = _source.getDependencies();
  +            int count = size(dependencies);
   
  -            processModule(resolver, descriptorResource);
  +            for (int i = 0; i < count; i++)
  +            {
  +                DependencyDescriptor dependency = (DependencyDescriptor) dependencies.get(i);
  +                checkDependency(dependency);
  +            }
           }
  -    }
   
  -    /**
  -     * Parses a module and processes its contents.  This is often used
  -     * in conjunction with {@link #processModules(ClassResolver)} to
  -     * parse additional modules that are not in the standard location
  -     * (for whatever reason).
  -     */
  -    public void processModule(ClassResolver resolver, Resource moduleDescriptorResource)
  -    {
  -        if (_parser == null)
  -            _parser = new DescriptorParser(_errorHandler, _registryAssembly);
  -
  -        try
  +        private void checkDependency(DependencyDescriptor dependency)
           {
  -            ModuleDescriptor md = _parser.parse(moduleDescriptorResource, resolver);
  -
  -            processModule(md);
  +            ModuleDescriptor requiredModule = getRequiredModuleDescriptor(dependency);
   
  -            // After parsing a module, parse any additional modules identified
  -            // within the module (using the <sub-module> element recursively.
  -            List subModules = md.getSubModules();
  -            int count = size(subModules);
  -
  -            for (int i = 0; i < count; i++)
  +            if (requiredModule == null)
               {
  -                SubModuleDescriptor smd = (SubModuleDescriptor) subModules.get(i);
  -                
  -                Resource descriptorResource = smd.getDescriptor();
  -
  -                if (descriptorResource.getResourceURL() == null)
  -                {
  -                    _errorHandler.error(
  -                        LOG,
  -                        ImplMessages.subModuleDoesNotExist(descriptorResource),
  -                        smd.getLocation(),
  -                        null);
  -                    continue;
  -                }
  +                _errorHandler.error(LOG, ImplMessages.dependencyOnUnknownModule(dependency),
  +                        dependency.getLocation(), null);
  +                return;
  +            }
   
  -                processModule(resolver, smd.getDescriptor());
  +            if (dependency.getVersion() != null && !dependency.getVersion().equals(requiredModule.getVersion()))
  +            {
  +                _errorHandler.error(LOG, ImplMessages.dependencyVersionMismatch(dependency),
  +                    dependency.getLocation(), null);
  +                return;
               }
           }
  -        catch (RuntimeException ex)
  +
  +        private ModuleDescriptor getRequiredModuleDescriptor(DependencyDescriptor dependency)
           {
  -            // An exception may leave the parser in an unknown state, so
  -            // give up on that instance and start with a fresh one.
  +            for (Iterator i = _moduleDescriptors.iterator(); i.hasNext(); )
  +            {
  +                ModuleDescriptor md = (ModuleDescriptor) i.next();
   
  -            _parser = null;
  +                if (md.getModuleId().equals(dependency.getModuleId()))
  +                    return md;
  +            }
   
  -            _errorHandler.error(LOG, ex.getMessage(), HiveMind.getLocation(ex), ex);
  +            return null;
           }
       }
   
       /**
  -     * Processes a parsed HiveMind module descriptor.  This may be called
  -     * repeatedly before invoking {@link #constructRegistry(Locale)}.
  +     * Processes a parsed HiveMind module descriptor.  A corresponding
  +     * {@link org.apache.hivemind.internal.Module} is constructed.  
  +     * 
  +     * This method is called by {@link #constructRegistry(Locale)}.
        * 
        * @param md the parsed module descriptor
        */
  -    public void processModule(ModuleDescriptor md)
  +    private void processModule(ModuleDescriptor md)
       {
           String id = md.getModuleId();
   
  @@ -282,6 +233,9 @@
           module.setModuleId(id);
           module.setClassResolver(md.getClassResolver());
   
  +        if (size(md.getDependencies()) > 0)
  +            _registryAssembly.addPostProcessor(new ModuleDependencyChecker(md));
  +
           _modules.put(id, module);
   
           _moduleDescriptors.add(md);
  @@ -403,13 +357,16 @@
       }
   
       /**
  -     * Invoked after all modules have been added with 
  -     * {@link #processModule(ClassResolver, Resource)}.
  -     * This first resolves all the contributions, then constructs and returns
  -     * the registry.
  +     * This first loads all modules provided by the ModuleProvider, then resolves all the 
  +     * contributions, then constructs and returns the Registry.
        */
  -    public Registry constructRegistry(Locale locale)
  +    public Registry constructRegistry(ModuleProvider provider, Locale locale)
       {
  +        List descriptors = provider.getModuleDescriptors(_errorHandler, _registryAssembly);
  +        for (int j = 0; j < descriptors.size(); j++)
  +        {
  +            processModule((ModuleDescriptor) descriptors.get(j));
  +        }
   
           // Process any deferred operations
   
  @@ -584,12 +541,8 @@
       }
   
       /**
  -     * Adds an {@link InstanceBuilder}
  -     * to a service extension point.
  -     * 
  -      * 
  +     * Adds an {@link InstanceBuilder} to a service extension point.
        */
  -
       private void addServiceInstanceBuilder(
           ModuleImpl sourceModule,
           String pointId,
  @@ -720,10 +673,9 @@
       {
           ClassResolver resolver = new DefaultClassResolver();
           RegistryBuilder builder = new RegistryBuilder();
  +        ModuleProvider provider = new XmlModuleProvider(resolver, XmlModuleProvider.HIVE_MODULE_XML);
   
  -        builder.processModules(resolver);
  -
  -        return builder.constructRegistry(Locale.getDefault());
  +        return builder.constructRegistry(provider, Locale.getDefault());
       }
   
   }
  
  
  
  1.1                  jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/AggregateModuleProvider.java
  
  Index: AggregateModuleProvider.java
  ===================================================================
  package org.apache.hivemind.impl;
  
  import java.util.ArrayList;
  import java.util.HashSet;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Set;
  
  import org.apache.hivemind.ErrorHandler;
  
  /**
   * An implementation of the {@link ModuleProvider} interface which aggregates multiple
   * ModuleProviders.
   */
  public class AggregateModuleProvider implements ModuleProvider
  {
  
      private Set _moduleProviders;
  
      public AggregateModuleProvider()
      {
          this(new HashSet());
      }
  
      public AggregateModuleProvider(Set moduleProviders)
      {
          _moduleProviders = moduleProviders;
      }
  
      public void addModuleProvider(ModuleProvider provider)
      {
          _moduleProviders.add(provider);
      }
  
      public List getModuleDescriptors(ErrorHandler handler, RegistryAssembly assembly)
      {
          List result = new ArrayList();
  
          for (Iterator i = _moduleProviders.iterator(); i.hasNext();)
          {
              ModuleProvider provider = (ModuleProvider) i.next();
              result.addAll(provider.getModuleDescriptors(handler, assembly));
          }
  
          return result;
      }
  
  }
  
  
  1.1                  jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ModuleProvider.java
  
  Index: ModuleProvider.java
  ===================================================================
  package org.apache.hivemind.impl;
  
  import java.util.List;
  
  import org.apache.hivemind.ErrorHandler;
  
  /**
   * A ModuleProvider is used by the {@link RegistryBuilder} (see
   * {@link RegistryBuilder#constructRegistry(ModuleProvider, java.util.Locale)}) to
   * load the {@link org.apache.hivemind.parse.ModuleDescriptor} objects.
   * 
   * HiveMind's default ModuleProvider is the {@link XmlModuleProvider}, which can 
   * load module descriptors from XML files or resources on the classpath.
   */
  public interface ModuleProvider
  {
      public List getModuleDescriptors(ErrorHandler handler, RegistryAssembly assembly);
  }
  
  
  1.1                  jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/XmlModuleProvider.java
  
  Index: XmlModuleProvider.java
  ===================================================================
  package org.apache.hivemind.impl;
  
  import java.io.IOException;
  import java.net.URL;
  import java.util.ArrayList;
  import java.util.Collection;
  import java.util.Enumeration;
  import java.util.Iterator;
  import java.util.List;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.apache.hivemind.ApplicationRuntimeException;
  import org.apache.hivemind.ClassResolver;
  import org.apache.hivemind.ErrorHandler;
  import org.apache.hivemind.HiveMind;
  import org.apache.hivemind.Resource;
  import org.apache.hivemind.parse.DescriptorParser;
  import org.apache.hivemind.parse.ModuleDescriptor;
  import org.apache.hivemind.parse.SubModuleDescriptor;
  import org.apache.hivemind.util.URLResource;
  
  /**
   * Implementation of the {@link ModuleProvider}interface which uses the
   * {@link org.apache.hivemind.parse.DescriptorParser}to provide module descriptors defined in XML.
   * The module descriptors are loaded from files or resources on the classpath.
   * 
   * @author Knut Wannheden
   */
  public class XmlModuleProvider implements ModuleProvider
  {
  
      private static final Log LOG = LogFactory.getLog(XmlModuleProvider.class);
  
      /**
       * The default path, within a JAR or the classpath, to the XML HiveMind module deployment
       * descriptor: <code>META-INF/hivemodule.xml</code>.
       * 
       * Use this constant with the {@link XmlModuleProvider(ClassResolver, String)} constructor.
       */
      public static final String HIVE_MODULE_XML = "META-INF/hivemodule.xml";
  
      /**
       * Parser instance used by all parsing of module descriptors.
       */
      private DescriptorParser _parser;
  
      /**
       * List of all specified resources processed by this ModuleProvider. Descriptors of sub-modules
       * are not included.
       */
      private List _resources = new ArrayList();
  
      /**
       * List of parsed {@link ModuleDescriptor}instances. Also includes referenced sub-modules.
       */
      private List _moduleDescriptors = new ArrayList();
  
      private ClassResolver _resolver;
  
      /**
       * Loads all XML module descriptors found on the classpath (using the given 
       * {@link org.apache.hivemind.ClassResolver}.  Only module descriptors matching the
       * specified path are loaded.  Use the {@link XmlModuleProvider#HIVE_MODULE_XML} 
       * constant to load all descriptors in the default location. 
       */
      public XmlModuleProvider(ClassResolver resolver, String resourcePath)
      {
          _resolver = resolver;
          _resources.addAll(getDescriptorResources(resourcePath, _resolver));
      }
  
      /**
       * Constructs an XmlModuleProvider only loading the ModuleDescriptor identified by the
       * given {@link org.apache.hivemind.Resource}.
       */
      public XmlModuleProvider(ClassResolver reslover, Resource resource)
      {
          _resolver = reslover;
          _resources.add(resource);
      }
  
      /**
       * Constructs an XmlModuleProvider loading all ModuleDescriptor identified by the
       * given List of {@link org.apache.hivemind.Resource} objects.
       */
      public XmlModuleProvider(ClassResolver reslover, List resources)
      {
          _resolver = reslover;
          _resources.addAll(resources);
      }
  
      public List getModuleDescriptors(ErrorHandler handler, RegistryAssembly assembly)
      {
          for (Iterator i = _resources.iterator(); i.hasNext();)
          {
              Resource resource = (Resource) i.next();
              processModule(resource, handler, assembly);
          }
  
          return _moduleDescriptors;
      }
  
      private List getDescriptorResources(String resourcePath, ClassResolver resolver)
      {
          if (LOG.isDebugEnabled())
              LOG.debug("Processing modules visible to " + resolver);
  
          List descriptors = new ArrayList();
  
          ClassLoader loader = resolver.getClassLoader();
          Enumeration e = null;
  
          try
          {
              e = loader.getResources(resourcePath);
          }
          catch (IOException ex)
          {
              throw new ApplicationRuntimeException(ImplMessages.unableToFindModules(resolver, ex),
                      ex);
          }
  
          while (e.hasMoreElements())
          {
              URL descriptorURL = (URL) e.nextElement();
  
              descriptors.add(new URLResource(descriptorURL));
          }
  
          return descriptors;
      }
  
      private void processModule(Resource moduleDescriptorResource, ErrorHandler handler,
          RegistryAssembly assembly)
      {
          if (_parser == null)
              _parser = new DescriptorParser(handler, assembly);
  
          try
          {
              ModuleDescriptor md = _parser.parse(moduleDescriptorResource, _resolver);
              _moduleDescriptors.add(md);
  
              // After parsing a module, parse any additional modules identified
              // within the module (using the <sub-module> element) recursively.
              processSubModules(md, handler, assembly);
          }
          catch (RuntimeException ex)
          {
              // An exception may leave the parser in an unknown state, so
              // give up on that instance and start with a fresh one.
              _parser = null;
  
              handler.error(LOG, ex.getMessage(), HiveMind.getLocation(ex), ex);
          }
      }
  
      private void processSubModules(ModuleDescriptor moduleDescriptor, ErrorHandler handler,
          RegistryAssembly assembly)
      {
          List subModules = moduleDescriptor.getSubModules();
          int count = size(subModules);
  
          for (int i = 0; i < count; i++)
          {
              SubModuleDescriptor smd = (SubModuleDescriptor) subModules.get(i);
  
              Resource descriptorResource = smd.getDescriptor();
  
              if (descriptorResource.getResourceURL() == null)
              {
                  handler.error(LOG, ImplMessages.subModuleDoesNotExist(descriptorResource), smd
                          .getLocation(), null);
                  continue;
              }
  
              processModule(smd.getDescriptor(), handler, assembly);
          }
      }
  
      private static int size(Collection c)
      {
          return c == null ? 0 : c.size();
      }
  
  }
  
  
  1.4       +7 -7      jakarta-hivemind/examples/src/java/org/apache/hivemind/examples/ExampleUtils.java
  
  Index: ExampleUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/examples/src/java/org/apache/hivemind/examples/ExampleUtils.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ExampleUtils.java	16 Aug 2004 14:42:24 -0000	1.3
  +++ ExampleUtils.java	9 Sep 2004 16:06:46 -0000	1.4
  @@ -18,8 +18,10 @@
   
   import org.apache.hivemind.ClassResolver;
   import org.apache.hivemind.Registry;
  +import org.apache.hivemind.impl.AggregateModuleProvider;
   import org.apache.hivemind.impl.DefaultClassResolver;
   import org.apache.hivemind.impl.RegistryBuilder;
  +import org.apache.hivemind.impl.XmlModuleProvider;
   import org.apache.hivemind.util.FileResource;
   
   /**
  @@ -43,19 +45,17 @@
           String projectRoot = System.getProperty("PROJECT_ROOT", ".");
           String path = projectRoot + "/examples/src/descriptor/META-INF/" + fileName;
   
  -        RegistryBuilder builder = new RegistryBuilder();
           ClassResolver resolver = new DefaultClassResolver();
  -
  -        // Process standard files, on the classpath.
  -
  -        builder.processModules(resolver);
  +        RegistryBuilder builder = new RegistryBuilder();
   
           // Process the examples.xml file, which (given its non-standard name) 
           // is not visible.
  +        AggregateModuleProvider provider = new AggregateModuleProvider();
   
  -        builder.processModule(resolver, new FileResource(path));
  +        provider.addModuleProvider(new XmlModuleProvider(resolver, XmlModuleProvider.HIVE_MODULE_XML));
  +        provider.addModuleProvider(new XmlModuleProvider(resolver, new FileResource(path)));
   
  -        return builder.constructRegistry(Locale.getDefault());
  +        return builder.constructRegistry(provider, Locale.getDefault());
       }
   
   }
  
  
  
  1.11      +8 -11     jakarta-hivemind/framework/src/java/org/apache/hivemind/servlet/HiveMindFilter.java
  
  Index: HiveMindFilter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/servlet/HiveMindFilter.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- HiveMindFilter.java	12 Aug 2004 21:27:35 -0000	1.10
  +++ HiveMindFilter.java	9 Sep 2004 16:06:46 -0000	1.11
  @@ -30,7 +30,9 @@
   import org.apache.hivemind.ClassResolver;
   import org.apache.hivemind.Registry;
   import org.apache.hivemind.impl.DefaultClassResolver;
  +import org.apache.hivemind.impl.ModuleProvider;
   import org.apache.hivemind.impl.RegistryBuilder;
  +import org.apache.hivemind.impl.XmlModuleProvider;
   
   /**
    * Servlet filter that constructs the Registry at startup. It ensures that each request is
  @@ -57,14 +59,6 @@
       private Registry _registry;
   
       /**
  -     * Package private method used for testing.
  -     */
  -    Registry getRegistry()
  -    {
  -        return _registry;
  -    }
  -
  -    /**
        * Constructs a {@link Registry} and stores it into the
        * <code>ServletContext</code>. Any exception throws is logged.
        */
  @@ -108,9 +102,7 @@
           ClassResolver resolver = new DefaultClassResolver();
           RegistryBuilder builder = new RegistryBuilder();
   
  -        builder.processModules(resolver);
  -
  -        return builder.constructRegistry(getRegistryLocale());
  +        return builder.constructRegistry(getModuleProvider(resolver), getRegistryLocale());
       }
   
       /**
  @@ -120,6 +112,11 @@
       protected Locale getRegistryLocale()
       {
           return Locale.getDefault();
  +    }
  +
  +    protected ModuleProvider getModuleProvider(ClassResolver resolver)
  +    {
  +        return new XmlModuleProvider(resolver, XmlModuleProvider.HIVE_MODULE_XML);
       }
   
       /**
  
  
  
  1.15      +5 -2      jakarta-hivemind/framework/src/test/hivemind/test/TestRegistryBuilder.java
  
  Index: TestRegistryBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/test/hivemind/test/TestRegistryBuilder.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- TestRegistryBuilder.java	1 Aug 2004 17:40:37 -0000	1.14
  +++ TestRegistryBuilder.java	9 Sep 2004 16:06:46 -0000	1.15
  @@ -25,7 +25,9 @@
   import org.apache.hivemind.ClassResolver;
   import org.apache.hivemind.Registry;
   import org.apache.hivemind.impl.DefaultClassResolver;
  +import org.apache.hivemind.impl.ModuleProvider;
   import org.apache.hivemind.impl.RegistryBuilder;
  +import org.apache.hivemind.impl.XmlModuleProvider;
   import org.apache.hivemind.internal.RegistryInfrastructure;
   import org.apache.hivemind.service.ClassFactory;
   
  @@ -56,10 +58,11 @@
           ClassResolver resolver = new DefaultClassResolver(loader);
   
           RegistryBuilder b = new RegistryBuilder();
  -        b.processModules(resolver);
   
  +        ModuleProvider provider = new XmlModuleProvider(resolver, XmlModuleProvider.HIVE_MODULE_XML);
  +        
           RegistryInfrastructure r =
  -            (RegistryInfrastructure) b.constructRegistry(Locale.getDefault());
  +            (RegistryInfrastructure) b.constructRegistry(provider, Locale.getDefault());
   
           List l = r.getConfiguration("hivemind.test.config.Symbols");
           assertEquals(1, l.size());
  
  
  
  1.1                  jakarta-hivemind/framework/src/test/hivemind/test/TestDependency.java
  
  Index: TestDependency.java
  ===================================================================
  //  Copyright 2004 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 hivemind.test;
  
  import java.util.ArrayList;
  import java.util.HashSet;
  import java.util.List;
  import java.util.Set;
  
  import org.apache.hivemind.ErrorHandler;
  import org.apache.hivemind.Registry;
  import org.apache.hivemind.impl.ModuleProvider;
  import org.apache.hivemind.impl.RegistryAssembly;
  import org.apache.hivemind.parse.DependencyDescriptor;
  import org.apache.hivemind.parse.ModuleDescriptor;
  
  /**
   * Tests the module dependencies (specified using &lt;dependency.&gt;).
   * 
   * @author Knut Wannheden
   */
  public class TestDependency extends FrameworkTestCase
  {
  
      /**
       * An implementation of the {@link org.apache.hivemind.impl.ModuleProvider}
       * interface convenient for testing purposes.  This provider simply provides
       * ModuleDescriptors registered with it beforehand.
       */
      private static class SimpleModuleProvider implements ModuleProvider
      {
          private Set _moduleDescriptors = new HashSet();
  
          public void addModuleDescriptor(ModuleDescriptor moduleDescriptor)
          {
              _moduleDescriptors.add(moduleDescriptor);
          }
  
          public List getModuleDescriptors(ErrorHandler handler, RegistryAssembly assembly)
          {
              return new ArrayList(_moduleDescriptors);
          }
      }
  
      public void testMissingRequiredModule() throws Exception
      {
          ModuleDescriptor dependingModule = createModuleDescriptor(
              "dependency.declaring.module",
              null);
  
          DependencyDescriptor unresolvableDependency = createDependencyDescriptor(
              "required.module",
              null);
          dependingModule.addDependency(unresolvableDependency);
  
          SimpleModuleProvider provider = new SimpleModuleProvider();
          provider.addModuleDescriptor(dependingModule);
  
          interceptLogging();
  
          Registry r = buildFrameworkRegistry(provider);
  
          assertLoggedMessage("Required module required.module does not exist.");
      }
  
      public void testDependencyWithoutVersion() throws Exception
      {
          ModuleDescriptor dependingModule = createModuleDescriptor(
              "dependency.declaring.module",
              null);
  
          ModuleDescriptor requiredModule = createModuleDescriptor("required.module", "1.0.0");
  
          DependencyDescriptor unversionedDependency = createDependencyDescriptor(
              "required.module",
              null);
          dependingModule.addDependency(unversionedDependency);
  
          SimpleModuleProvider provider = new SimpleModuleProvider();
          provider.addModuleDescriptor(dependingModule);
          provider.addModuleDescriptor(requiredModule);
  
          Registry r = buildFrameworkRegistry(provider);
      }
  
      public void testVersionMismatch() throws Exception
      {
          ModuleDescriptor dependingModule = createModuleDescriptor(
              "dependency.declaring.module",
              null);
  
          ModuleDescriptor requiredModuleOfWrongVersion = createModuleDescriptor(
              "required.module",
              "1.0.1");
  
          DependencyDescriptor dependency = createDependencyDescriptor("required.module", "1.0.0");
          dependingModule.addDependency(dependency);
  
          SimpleModuleProvider provider = new SimpleModuleProvider();
          provider.addModuleDescriptor(dependingModule);
          provider.addModuleDescriptor(requiredModuleOfWrongVersion);
  
          interceptLogging();
  
          Registry r = buildFrameworkRegistry(provider);
  
          assertLoggedMessage("Version of required module required.module does not match expected version 1.0.0.");
      }
  
      /**
       * Convenience method for creating a {@link org.apache.hivemind.parse.ModuleDescriptor}.
       */
      private ModuleDescriptor createModuleDescriptor(String moduleId, String version)
      {
          ModuleDescriptor result = new ModuleDescriptor();
  
          result.setModuleId(moduleId);
          result.setVersion(version);
  
          return result;
      }
  
      /**
       * Convenience method for creating a {@link org.apache.hivemind.parse.DependencyDescriptor}.
       */
      private DependencyDescriptor createDependencyDescriptor(String moduleId, String version)
      {
          DependencyDescriptor result = new DependencyDescriptor();
  
          result.setModuleId(moduleId);
          result.setVersion(version);
  
          return result;
      }
  
  }
  
  
  1.13      +2 -2      jakarta-hivemind/framework/src/java/org/apache/hivemind/ant/ConstructRegistry.java
  
  Index: ConstructRegistry.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/ant/ConstructRegistry.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- ConstructRegistry.java	20 Aug 2004 12:55:15 -0000	1.12
  +++ ConstructRegistry.java	9 Sep 2004 16:06:46 -0000	1.13
  @@ -30,7 +30,7 @@
   import javax.xml.parsers.ParserConfigurationException;
   
   import org.apache.hivemind.Resource;
  -import org.apache.hivemind.impl.RegistryBuilder;
  +import org.apache.hivemind.impl.XmlModuleProvider;
   import org.apache.hivemind.util.FileResource;
   import org.apache.hivemind.util.URLResource;
   import org.apache.tools.ant.BuildException;
  @@ -198,7 +198,7 @@
   
           Resource jarResource = new URLResource(jarRootURL);
   
  -        enqueueIfExists(jarResource, RegistryBuilder.HIVE_MODULE_XML);
  +        enqueueIfExists(jarResource, XmlModuleProvider.HIVE_MODULE_XML);
       }
   
       private void enqueueIfExists(Resource jarResource, String path)
  
  
  
  1.15      +3 -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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- links.ent	16 Aug 2004 14:42:25 -0000	1.14
  +++ links.ent	9 Sep 2004 16:06:46 -0000	1.15
  @@ -98,6 +98,9 @@
   <!ENTITY _sub-module '&lt;sub-module&gt;'>
   <!ENTITY sub-module '<link href="&projectroot;descriptor.html#sub-module">&_sub-module;</link>'>
   
  +<!ENTITY _sub-module '&lt;dependency&gt;'>
  +<!ENTITY dependency '<link href="&projectroot;descriptor.html#dependency">&_dependency;</link>'>
  +
   <!-- XML entities for the XML processing rules (documented seperately from the rest). -->
   
   <!ENTITY _create-object '&lt;create-object&gt;'>
  
  
  
  1.11      +30 -1     jakarta-hivemind/src/documentation/content/xdocs/descriptor.xml
  
  Index: descriptor.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/src/documentation/content/xdocs/descriptor.xml,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- descriptor.xml	18 Aug 2004 19:34:12 -0000	1.10
  +++ descriptor.xml	9 Sep 2004 16:06:46 -0000	1.11
  @@ -216,6 +216,35 @@
   				configuration point.</p>
   		</section>
   		<section>
  +			<title>dependency</title>
  +			<p> &_dependency; is used, within &module; to specify a dependency upon another
  +				required module.</p>
  +			<table>
  +				<tr>
  +					<th>Attribute</th>
  +					<th>Type</th>
  +					<th>Required ?</th>
  +					<th>Description</th>
  +				</tr>
  +				<tr>
  +					<td>module-id</td>
  +					<td>string</td>
  +					<td>yes</td>
  +					<td>The id of the required module.</td>
  +				</tr>
  +				<tr>
  +					<td>version</td>
  +					<td>version number</td>
  +					<td>no</td>
  +					<td>The version of the required module as a dotted sequence of three numbers.
  +						Example: "1.0.0".  With no version specified any version of the required
  +						module is matched.</td>
  +				</tr>
  +			</table>
  +			<p>In the future HiveMind will support other more sophisticated version matching
  +			   types for dependencies.</p>
  +		</section>
  +		<section>
   			<title>element</title>
   			<p>The &_element; element is used to define an element in a the &schema;. &_element;
   				may also be nested within another &_element;, to indicate an element
  @@ -416,7 +445,7 @@
   						Example: "1.0.0"</td>
   				</tr>
   			</table>
  -			<p>Contains: &contribution;, &configuration-point;, &implementation;
  +			<p>Contains: &contribution;, &configuration-point;, &dependency;, &implementation;
   				, &service-point;, &schema;, &sub-module; </p>
   			<warning>The version is not currently used, but a later release of
   				HiveMind will include runtime dependency checking based on version
  
  
  
  1.58      +7 -0      jakarta-hivemind/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/status.xml,v
  retrieving revision 1.57
  retrieving revision 1.58
  diff -u -r1.57 -r1.58
  --- status.xml	4 Sep 2004 13:45:28 -0000	1.57
  +++ status.xml	9 Sep 2004 16:06:46 -0000	1.58
  @@ -30,6 +30,13 @@
     
     <changes>
     
  +    <release version="1.1-alpha" date="unreleased">
  +      <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>
  +    </release>
  +
       <release version="1.0-rc-2" date="unreleased">
         <action type="add" dev="HLS">
           Add method <code>getSymbolValue()</code> to RegistryInfrastructure and Module
  
  
  
  1.3       +22 -4     jakarta-hivemind/framework/src/test/org/apache/hivemind/servlet/TestHiveMindFilter.java
  
  Index: TestHiveMindFilter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/test/org/apache/hivemind/servlet/TestHiveMindFilter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestHiveMindFilter.java	12 Aug 2004 21:27:35 -0000	1.2
  +++ TestHiveMindFilter.java	9 Sep 2004 16:06:46 -0000	1.3
  @@ -74,7 +74,7 @@
   
       }
   
  -    private static class HiveMindFilterFixture extends HiveMindFilter
  +    private static class FailingHiveMindFilterFixture extends HiveMindFilter
       {
   
           protected Registry constructRegistry(FilterConfig config)
  @@ -84,6 +84,24 @@
   
       }
   
  +    private static class RegistryExposingHiveMindFilterFixture extends HiveMindFilter
  +    {
  +
  +        private Registry _registry;
  +        
  +        public Registry getRegistry()
  +        {
  +            return _registry;
  +        }
  +        
  +        protected Registry constructRegistry(FilterConfig config)
  +        {
  +            _registry = super.constructRegistry(config);
  +            return _registry;
  +        }
  +
  +    }
  +
       private static class RebuildRegistryChainFixture implements FilterChain
       {
           public void doFilter(ServletRequest request, ServletResponse response)
  @@ -99,7 +117,7 @@
   
           replayControls();
   
  -        HiveMindFilter f = new HiveMindFilter();
  +        RegistryExposingHiveMindFilterFixture f = new RegistryExposingHiveMindFilterFixture();
   
           f.init(filterConfig);
   
  @@ -162,7 +180,7 @@
   
           replayControls();
   
  -        HiveMindFilter f = new HiveMindFilter();
  +        RegistryExposingHiveMindFilterFixture f = new RegistryExposingHiveMindFilterFixture();
   
           f.init(filterConfig);
   
  @@ -202,7 +220,7 @@
   
       public void testExceptionInInit() throws Exception
       {
  -        Filter f = new HiveMindFilterFixture();
  +        Filter f = new FailingHiveMindFilterFixture();
   
           interceptLogging(HiveMindFilter.class.getName());
   
  
  
  

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


Mime
View raw message