commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject cvs commit: jakarta-commons-sandbox/hivemind/src/test/hivemind/test/external TestExternalParser.java
Date Wed, 02 Jul 2003 15:40:43 GMT
hlship      2003/07/02 08:40:43

  Modified:    hivemind/src/java/org/apache/commons/hivemind/parse
                        ServiceDescriptor.java DescriptorParser.java
                        HiveMind_1.0.xsd
               hivemind/xdocs descriptor.xml
               hivemind/src/java/org/apache/commons/hivemind/impl
                        ConfigurationExtensionPointImpl.java
                        ServiceExtensionPointImpl.java RegistryBuilder.java
               hivemind/src/test/hivemind/test HiveMindTestCase.java
               hivemind/src/xsl hivemind.xsl
               hivemind/src/test/hivemind/test/services TestServices.java
               hivemind/src/test/hivemind/test/config
                        TestConfiguration.java WrongElementType.xml
               hivemind/src/test/hivemind/test/parse
                        TestDescriptorParser.java
               hivemind/src/java/org/apache/commons/hivemind HiveMind.java
               hivemind/src/META-INF hivemodule.xml
               hivemind/src/test-data/TestConstructRegistry testBasic.xml
                        testUptoDate.xml
               hivemind/src/test/hivemind/test/external
                        TestExternalParser.java
  Added:       hivemind/src/test/hivemind/test StoreAppender.java
               hivemind/src/test/hivemind/test/services ServiceOverride.xml
               hivemind/src/test/hivemind/test/parse OverridableService.xml
               hivemind/src/test/hivemind/test/services/impl
                        BaseSimpleServiceImpl.java
  Removed:     hivemind/src/test/hivemind/test/services StoreAppender.java
  Log:
  Add overridable attribute to <service>
  
  Revision  Changes    Path
  1.5       +12 -1     jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/parse/ServiceDescriptor.java
  
  Index: ServiceDescriptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/parse/ServiceDescriptor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ServiceDescriptor.java	4 Jun 2003 23:52:47 -0000	1.4
  +++ ServiceDescriptor.java	2 Jul 2003 15:40:36 -0000	1.5
  @@ -71,6 +71,7 @@
       private String _id;
       private String _interfaceClassName;
       private boolean _required = true;
  +    private boolean _overridable;
       private String _description;
   
       public String getId()
  @@ -118,6 +119,16 @@
           builder.append("id", _id);
           builder.append("interfaceClassName", _interfaceClassName);
           builder.append("required", _required);
  +    }
  +
  +    public boolean isOverridable()
  +    {
  +        return _overridable;
  +    }
  +
  +    public void setOverridable(boolean b)
  +    {
  +        _overridable = b;
       }
   
   }
  
  
  
  1.11      +23 -23    jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/parse/DescriptorParser.java
  
  Index: DescriptorParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/parse/DescriptorParser.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DescriptorParser.java	1 Jul 2003 20:13:01 -0000	1.10
  +++ DescriptorParser.java	2 Jul 2003 15:40:37 -0000	1.11
  @@ -189,8 +189,8 @@
           result.addRule(pattern, setLocationRule);
           result.addSetLimitedProperties(
               pattern,
  -            new String[] { "id", "interface", "required" },
  -            new String[] { "id", "interfaceClassName", "required" });
  +            new String[] { "id", "interface", "required", "overridable" },
  +            new String[] { "id", "interfaceClassName", "required", "overridable" });
           result.addSetNext(pattern, "addService");
   
           pattern = "module/contribute-service";
  @@ -263,10 +263,10 @@
           addFactoryRules(result, "module/configuration/factory", "addProvider");
           addFactoryRules(result, "module/contribute-configuration/factory", "addProvider");
   
  -		pattern = "*/parameters";
  -		result.addObjectCreate(pattern, ParametersDescriptor.class);
  -		result.addRule(pattern, setLocationRule);
  -		result.addSetNext(pattern, "setParameters");
  +        pattern = "*/parameters";
  +        result.addObjectCreate(pattern, ParametersDescriptor.class);
  +        result.addRule(pattern, setLocationRule);
  +        result.addSetNext(pattern, "setParameters");
   
           pattern = "*/value";
   
  @@ -314,13 +314,13 @@
           result.addSetLimitedProperties(pattern, "path", "path");
           result.addSetNext(pattern, "addProvider");
   
  -		pattern = "*/resource";
  +        pattern = "*/resource";
  +
  +        result.addObjectCreate(pattern, ResourceDescriptor.class);
  +        result.addRule(pattern, setLocationRule);
  +        result.addSetLimitedProperties(pattern, "path", "path");
  +        result.addSetNext(pattern, "addProvider");
   
  -		result.addObjectCreate(pattern, ResourceDescriptor.class);
  -		result.addRule(pattern, setLocationRule);
  -		result.addSetLimitedProperties(pattern, "path", "path");
  -		result.addSetNext(pattern, "addProvider");
  -		
           pattern = "*/new";
   
           result.addObjectCreate(pattern, NewDescriptor.class);
  @@ -336,17 +336,17 @@
               new String[] { "property", "path" },
               new String[] { "propertyName", "path" });
           result.addSetNext(pattern, "addConfigurator");
  -        
  -		pattern = "*/set-resource";
   
  -		result.addObjectCreate(pattern, ResourceDescriptor.class);
  -		result.addRule(pattern, setLocationRule);
  -		result.addSetLimitedProperties(
  -			pattern,
  -			new String[] { "property", "path" },
  -			new String[] { "propertyName", "path" });
  -		result.addSetNext(pattern, "addConfigurator");
  -		
  +        pattern = "*/set-resource";
  +
  +        result.addObjectCreate(pattern, ResourceDescriptor.class);
  +        result.addRule(pattern, setLocationRule);
  +        result.addSetLimitedProperties(
  +            pattern,
  +            new String[] { "property", "path" },
  +            new String[] { "propertyName", "path" });
  +        result.addSetNext(pattern, "addConfigurator");
  +
           pattern = "*/set-expression";
   
           result.addObjectCreate(pattern, ExpressionDescriptor.class);
  
  
  
  1.11      +22 -3     jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/parse/HiveMind_1.0.xsd
  
  Index: HiveMind_1.0.xsd
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/parse/HiveMind_1.0.xsd,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- HiveMind_1.0.xsd	1 Jul 2003 20:13:01 -0000	1.10
  +++ HiveMind_1.0.xsd	2 Jul 2003 15:40:38 -0000	1.11
  @@ -51,14 +51,33 @@
   								<xs:element ref="description" minOccurs="0" maxOccurs="1"/>
   								<xs:group ref="service-contribution-group"/>
   							</xs:sequence>
  -							<xs:attribute name="id" type="simple-id" use="required"/>
  -							<xs:attribute name="interface" type="xs:string" use="required"/>
  +							<xs:attribute name="id" type="simple-id" use="required">
  +								<xs:annotation>
  +								<xs:documentation>The simple id for the service; the module's id will be prefixed 
  +									to form the complete service id.</xs:documentation>	
  +								</xs:annotation>	
  +							</xs:attribute>
  +							<xs:attribute name="interface" type="xs:string" use="required">
  +								<xs:annotation>
  +									<xs:documentation>
  +									The fully qualified name of a Java interface for the service.
  +									</xs:documentation>	
  +								</xs:annotation>	
  +							</xs:attribute>
   							<xs:attribute name="required" type="xs:boolean" use="optional"
   								default="true">
   								<xs:annotation>
   									<xs:documentation>If true (the default), then an
   										implementation of the service must be provided. If false,
   										then the service is optional.</xs:documentation>
  +								</xs:annotation>
  +							</xs:attribute>
  +							<xs:attribute name="overridable" type="xs:boolean" use="optional" default="false">
  +								<xs:annotation>
  +								<xs:documentation>
  +								If true, then the core implementation provided as an internal contribution
  +								may be overriden by another module.	
  +								</xs:documentation>
   								</xs:annotation>
   							</xs:attribute>
   						</xs:complexType>
  
  
  
  1.11      +11 -1     jakarta-commons-sandbox/hivemind/xdocs/descriptor.xml
  
  Index: descriptor.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/xdocs/descriptor.xml,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- descriptor.xml	1 Jul 2003 20:12:57 -0000	1.10
  +++ descriptor.xml	2 Jul 2003 15:40:38 -0000	1.11
  @@ -209,6 +209,16 @@
   						extension point is optional.</td>
   				</tr>
   				<tr>
  +					<td>overridable</td>	
  +					<td>boolean</td>
  +					<td>no</td>
  +					<td>
  +					If true, then the factory contribution provided as an internal contribution
  +					may be overriden by another module.  The core implementation is therefore
  +					just a placeholder.  The default is false.	
  +					</td>
  +				</tr>
  +				<tr>
   					<th colspan="2">Element</th>
   					<th>Count</th>
   					<th>Description</th>
  
  
  
  1.2       +3 -11     jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/ConfigurationExtensionPointImpl.java
  
  Index: ConfigurationExtensionPointImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/ConfigurationExtensionPointImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConfigurationExtensionPointImpl.java	30 Jun 2003 23:04:29 -0000	1.1
  +++ ConfigurationExtensionPointImpl.java	2 Jul 2003 15:40:38 -0000	1.2
  @@ -237,7 +237,7 @@
   
                   if (element == null)
                   {
  -                    error(
  +					LOG.error(
                           HiveMind.format(
                               "ConfigurationExtensionPoint.element-is-null",
                               c.getContributingModule().getModuleId(),
  @@ -250,7 +250,7 @@
   
                   if (!elementType.isAssignableFrom(coerced.getClass()))
                   {
  -                    error(
  +                    LOG.error(
                           HiveMind.format(
                               "ConfigurationExtensionPoint.element-not-allowed",
                               new Object[] {
  @@ -324,14 +324,6 @@
                   location,
                   ex);
           }
  -    }
  -
  -    protected void error(String message)
  -    {
  -        if (HiveMind.isBrittle())
  -            throw new ApplicationRuntimeException(message);
  -
  -        LOG.error(message);
       }
   
       public boolean getCacheElements()
  
  
  
  1.2       +14 -1     jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/ServiceExtensionPointImpl.java
  
  Index: ServiceExtensionPointImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/ServiceExtensionPointImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ServiceExtensionPointImpl.java	30 Jun 2003 23:04:29 -0000	1.1
  +++ ServiceExtensionPointImpl.java	2 Jul 2003 15:40:38 -0000	1.2
  @@ -89,12 +89,14 @@
       private List _interceptorContributions;
       private List _sortedInterceptorContributions;
       private boolean _required;
  +    private boolean _overridable;
       private boolean _building;
   
       protected void extendDescription(ToStringBuilder builder)
       {
           builder.append("serviceIntrerfaceName", _serviceInterfaceName);
           builder.append("required", _required);
  +        builder.append("overridable", _overridable);
           builder.append("factoryContribution", _factoryContribution);
           builder.append("interceptorContributions", _interceptorContributions);
       }
  @@ -321,4 +323,15 @@
   
           return stack.peek();
       }
  +    
  +    public boolean isOverridable()
  +    {
  +        return _overridable;
  +    }
  +
  +    public void setOverridable(boolean b)
  +    {
  +        _overridable = b;
  +    }
  +
   }
  
  
  
  1.10      +23 -27    jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/RegistryBuilder.java
  
  Index: RegistryBuilder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/RegistryBuilder.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- RegistryBuilder.java	1 Jul 2003 20:13:03 -0000	1.9
  +++ RegistryBuilder.java	2 Jul 2003 15:40:38 -0000	1.10
  @@ -68,14 +68,13 @@
   
   import org.apache.commons.hivemind.HiveMind;
   import org.apache.commons.hivemind.Module;
  -import org.apache.commons.hivemind.Registry;
   import org.apache.commons.hivemind.Occurances;
  -import org.apache.commons.hivemind.parse.AbstractInstanceBuilderDescriptor;
  +import org.apache.commons.hivemind.Registry;
   import org.apache.commons.hivemind.parse.ConfigurationDescriptor;
  +import org.apache.commons.hivemind.parse.ConfigurationElementProvider;
   import org.apache.commons.hivemind.parse.ContributeConfigurationDescriptor;
   import org.apache.commons.hivemind.parse.ContributeServiceDescriptor;
   import org.apache.commons.hivemind.parse.DescriptorParser;
  -import org.apache.commons.hivemind.parse.ConfigurationElementProvider;
   import org.apache.commons.hivemind.parse.InstanceBuilder;
   import org.apache.commons.hivemind.parse.InterceptorDescriptor;
   import org.apache.commons.hivemind.parse.ModuleDescriptor;
  @@ -206,7 +205,7 @@
           {
               Module existing = (Module) _modules.get(id);
   
  -            error(
  +            LOG.error(
                   HiveMind.format(
                       "RegistryBuilder.duplicate-module-id",
                       id,
  @@ -255,6 +254,7 @@
               point.setLocation(sd.getLocation());
               point.setModule(module);
               point.setRequired(sd.isRequired());
  +            point.setOverridable(sd.isOverridable());
               point.setServiceInterfaceName(sd.getInterfaceClassName());
   
               module.addServiceExtensionPoint(point);
  @@ -362,7 +362,7 @@
   
           if (!BaseModule.class.isAssignableFrom(moduleClass))
           {
  -            error(
  +            LOG.error(
                   HiveMind.format(
                       "RegistryBuilder.must-extend-class",
                       new Object[] { md.getModuleId(), className, BaseModule.class.getName()}));
  @@ -463,7 +463,7 @@
   
               if (point == null)
               {
  -                error(
  +                LOG.error(
                       HiveMind.format(
                           "RegistryBuilder.unknown-configuration-extension-point",
                           moduleId,
  @@ -492,7 +492,7 @@
               return;
   
           if (builder != null)
  -            addServiceExtension(sourceModule, pointId, builder);
  +            addServiceExtension(sourceModule, pointId, builder, true);
   
           int count = Tapestry.size(interceptors);
           for (int i = 0; i < count; i++)
  @@ -515,7 +515,7 @@
           List interceptors = csd.getInterceptors();
   
           if (builder != null)
  -            addServiceExtension(sourceModule, pointId, builder);
  +            addServiceExtension(sourceModule, pointId, builder, false);
   
           int count = Tapestry.size(interceptors);
           for (int i = 0; i < count; i++)
  @@ -535,7 +535,8 @@
       protected void addServiceExtension(
           BaseModule sourceModule,
           String pointId,
  -        InstanceBuilder builder)
  +        InstanceBuilder builder,
  +        boolean isInternal)
       {
           if (LOG.isDebugEnabled())
               LOG.debug("Adding " + builder + " to service extension point " + pointId);
  @@ -544,7 +545,7 @@
   
           if (sep == null)
           {
  -            error(
  +            LOG.error(
                   HiveMind.format(
                       "RegistryBuilder.unknown-service-extension-point",
                       sourceModule.getModuleId(),
  @@ -553,9 +554,9 @@
               return;
           }
   
  -        if (sep.getFactoryContribution() != null)
  +        if (sep.getFactoryContribution() != null && !sep.isOverridable())
           {
  -            error(
  +            LOG.error(
                   HiveMind.format(
                       "RegistryBuilder.duplicate-factory",
                       sourceModule.getModuleId(),
  @@ -571,6 +572,11 @@
           fc.setServiceExtensionPoint(sep);
   
           sep.setFactoryContribution(fc);
  +
  +        // The first non-internal contribution "locks" the 
  +        // extension point so that no further contribution may be made.
  +        if (!isInternal)
  +            sep.setOverridable(false);
       }
   
       protected void addServiceExtension(
  @@ -585,7 +591,7 @@
   
           if (sep == null)
           {
  -            error(
  +            LOG.error(
                   HiveMind.format(
                       "RegistryBuilder.unknown-service-extension-point",
                       sourceModule.getModuleId(),
  @@ -617,7 +623,8 @@
               if (point.getFactoryContribution() != null)
                   continue;
   
  -            error(HiveMind.format("RegistryBuilder.missing-service", point.getExtensionPointId()));
  +            LOG.error(
  +                HiveMind.format("RegistryBuilder.missing-service", point.getExtensionPointId()));
           }
       }
   
  @@ -677,20 +684,9 @@
                       new Integer(count),
                       HiveMind.getMessage(key));
   
  -            error(message);
  +            LOG.error(message);
           }
   
       }
   
  -    /**
  -     * Pass non-fatal errors through this method.  During testing, this method
  -     * may instead cause a fatal error (that the test case can catch).
  -     */
  -    protected void error(String message)
  -    {
  -        if (HiveMind.isBrittle())
  -            throw new ApplicationRuntimeException(message);
  -
  -        LOG.error(message);
  -    }
   }
  
  
  
  1.10      +103 -22   jakarta-commons-sandbox/hivemind/src/test/hivemind/test/HiveMindTestCase.java
  
  Index: HiveMindTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/HiveMindTestCase.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- HiveMindTestCase.java	30 Jun 2003 23:04:34 -0000	1.9
  +++ HiveMindTestCase.java	2 Jul 2003 15:40:39 -0000	1.10
  @@ -57,6 +57,7 @@
   
   package hivemind.test;
   
  +
   import java.io.File;
   import java.net.URL;
   import java.util.List;
  @@ -70,6 +71,9 @@
   import org.apache.commons.hivemind.parse.DescriptorParser;
   import org.apache.commons.hivemind.parse.ModuleDescriptor;
   import org.apache.commons.hivemind.util.URLResourceLocation;
  +import org.apache.log4j.Level;
  +import org.apache.log4j.LogManager;
  +import org.apache.log4j.Logger;
   import org.apache.log4j.spi.LoggingEvent;
   import org.apache.tapestry.ApplicationRuntimeException;
   import org.apache.tapestry.IResourceLocation;
  @@ -88,6 +92,9 @@
   
       private DescriptorParser _parser = new DescriptorParser();
   
  +    private String _interceptedLoggerName;
  +    private StoreAppender _appender;
  +
       public HiveMindTestCase(String name)
       {
           super(name);
  @@ -162,13 +169,52 @@
                   "Exception message (" + message + ") does not contain [" + substring + "]");
       }
   
  +    protected void interceptLogging()
  +    {
  +        interceptLogging("org.apache.commons.hivemind");
  +    }
  +
  +    /**
  +     * Sets up a {@link StoreLogger} to intercept logging.
  +     */
  +
  +    protected void interceptLogging(String loggerName)
  +    {
  +        Logger logger = LogManager.getLogger(loggerName);
  +
  +        logger.removeAllAppenders();
  +
  +        _interceptedLoggerName = loggerName;
  +        _appender = new StoreAppender();
  +
  +        logger.setLevel(Level.DEBUG);
  +        logger.setAdditivity(false);
  +        logger.addAppender(_appender);
  +    }
  +
       /**
  -     * Resets the brittle flag to false.
  +     * Gets the list of events most recently intercepted.
  +     * @see #interceptLogging(String)
  +     * @see StoreAppender#getEvents()
        */
  +    protected List getInterceptedLogEvents()
  +    {
  +        return _appender.getEvents();
  +    }
  +
       protected void tearDown() throws Exception
       {
  -    	HiveMind.setDefault(null);
  -        HiveMind.setBrittle(false);
  +        HiveMind.setDefault(null);
  +
  +        if (_appender != null)
  +        {
  +            _appender = null;
  +
  +            Logger logger = LogManager.getLogger(_interceptedLoggerName);
  +            logger.setLevel(null);
  +            logger.setAdditivity(true);
  +            logger.removeAllAppenders();
  +        }
       }
   
       protected void unreachable()
  @@ -187,30 +233,65 @@
           return new URLResourceLocation(f.toURL());
       }
   
  +    /**
  +     * Digs down through a stack of ARE's to find the first non-ARE, or
  +     * the deepest ARE.
  +     */
  +
  +    protected Throwable findNestedException(ApplicationRuntimeException ex)
  +    {
  +        Throwable cause = ex.getRootCause();
  +
  +        if (cause == null || cause == ex)
  +            return ex;
  +
  +        if (cause instanceof ApplicationRuntimeException)
  +            return findNestedException((ApplicationRuntimeException) cause);
   
  -	/**
  -	 * Digs down through a stack of ARE's to find the first non-ARE, or
  -	 * the deepest ARE.
  -	 */
  -	
  -	protected Throwable findNestedException(ApplicationRuntimeException ex)
  -	{
  -		Throwable cause = ex.getRootCause();
  -	
  -		if (cause == null || cause == ex)
  -			return ex;
  -	
  -		if (cause instanceof ApplicationRuntimeException)
  -			return findNestedException((ApplicationRuntimeException)cause);
  -			
  -		return cause;
  -	}
  +        return cause;
  +    }
   
  +    /**
  +     * Checks to see if a specific event matches the name and message.
  +     */
       protected void checkLoggingEvent(String name, String message, List events, int index)
       {
           LoggingEvent e = (LoggingEvent) events.get(index);
  -    
  +
           assertEquals("Logger name", name, e.getLoggerName());
           assertEquals("Message", message, e.getMessage());
       }
  +
  +    protected void checkLoggingEvent(String name, String message)
  +    {
  +        checkLoggingEvent(name, message, getInterceptedLogEvents());
  +    }
  +
  +    /**
  +     * Checks to see if any LoggingEvent in the list of events matches the name and message.
  +     * @param name logger name to match
  +     * @param message substring to look for in the message
  +     * @param event list of LoggingEvent to search.
  +     */
  +    protected void checkLoggingEvent(String name, String message, List events)
  +    {
  +        int count = events.size();
  +
  +        for (int i = 0; i < count; i++)
  +        {
  +            LoggingEvent e = (LoggingEvent) events.get(i);
  +
  +            if (!e.getLoggerName().equals(name))
  +                continue;
  +
  +            String eventMessage = e.getMessage().toString();
  +
  +            if (eventMessage.indexOf(message) >= 0)
  +                return;
  +
  +        }
  +
  +        throw new AssertionFailedError("Could not find logging event: [" + name + "] " + message);
  +    }
  +
   }
  
  
  
  1.1                  jakarta-commons-sandbox/hivemind/src/test/hivemind/test/StoreAppender.java
  
  Index: StoreAppender.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package hivemind.test;
  
  import java.util.ArrayList;
  import java.util.List;
  
  import org.apache.log4j.AppenderSkeleton;
  import org.apache.log4j.spi.LoggingEvent;
  
  /**
   * Used to test logging provided by the {@link org.apache.commons.hivemind.impl.LoggingInterceptorFactory}.
   *
   * @author Howard Lewis Ship
   * @version $Id: StoreAppender.java,v 1.1 2003/07/02 15:40:39 hlship Exp $
   */
  public class StoreAppender extends AppenderSkeleton
  {
      private List _events = new ArrayList(0);
  
      /**
       * Returns any accumulated events since the last invocations of this method.
       * @return List of {@link LoggingEvent}.
       */
      public List getEvents()
      {
          List result = new ArrayList(_events);
  
          _events.clear();
  
          return result;
      }
  
      protected void append(LoggingEvent event)
      {
          _events.add(event);
      }
  
      /**
       * Does nothing.
       */
      public void close()
      {
      }
  
      /**
       * Returns false.
       */
      public boolean requiresLayout()
      {
          return false;
      }
  
  }
  
  
  
  1.8       +7 -0      jakarta-commons-sandbox/hivemind/src/xsl/hivemind.xsl
  
  Index: hivemind.xsl
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/xsl/hivemind.xsl,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- hivemind.xsl	1 Jul 2003 20:13:02 -0000	1.7
  +++ hivemind.xsl	2 Jul 2003 15:40:39 -0000	1.8
  @@ -274,6 +274,13 @@
   						<xsl:value-of select="@required"/>
   					</td>
   				</tr>
  +				<tr>
  +					<th>Overridable</th>
  +					<td>
  +						<xsl:if test="not(@overridable)">false</xsl:if>
  +						<xsl:value-of select="@overridable"/>
  +					</td>
  +				</tr>				
   				<xsl:if test="description">
   					<tr>
   						<td colspan="2" class="description">
  
  
  
  1.10      +53 -59    jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/TestServices.java
  
  Index: TestServices.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/TestServices.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TestServices.java	30 Jun 2003 23:04:45 -0000	1.9
  +++ TestServices.java	2 Jul 2003 15:40:40 -0000	1.10
  @@ -70,9 +70,6 @@
   import org.apache.commons.hivemind.Registry;
   import org.apache.commons.hivemind.impl.RegistryBuilder;
   import org.apache.commons.hivemind.parse.DescriptorParser;
  -import org.apache.log4j.Level;
  -import org.apache.log4j.LogManager;
  -import org.apache.log4j.Logger;
   import org.apache.tapestry.ApplicationRuntimeException;
   
   /**
  @@ -89,6 +86,14 @@
           super(name);
       }
   
  +    protected void tearDown() throws Exception
  +    {
  +        super.tearDown();
  +
  +        NameLookupHack._context = null;
  +        NameLookupHack._properties = null;
  +    }
  +
       public void testSimple() throws Exception
       {
           Registry r = buildRegistry("SimpleModule.xml");
  @@ -178,13 +183,7 @@
           b.processModule(_resolver, p.parse(getMasterModuleLocation()));
           b.processModule(_resolver, p.parse(getLocation("TestLogging.xml")));
   
  -        Logger logger = LogManager.getLogger("hivemind.test.services.Demo");
  -        logger.removeAllAppenders();
  -        logger.setLevel(Level.DEBUG);
  -        logger.setAdditivity(false);
  -
  -        StoreAppender a = new StoreAppender();
  -        logger.addAppender(a);
  +        interceptLogging("hivemind.test.services.Demo");
   
           Registry r = b.constructRegistry();
           DemoService s =
  @@ -192,7 +191,7 @@
   
           s.add(5, 3);
   
  -        List l = a.getEvents();
  +        List l = getInterceptedLogEvents();
           assertEquals(2, l.size());
   
           checkLoggingEvent("hivemind.test.services.Demo", "BEGIN add(5, 3)", l, 0);
  @@ -200,7 +199,7 @@
   
           s.noResult();
   
  -        l = a.getEvents();
  +        l = getInterceptedLogEvents();
           assertEquals(2, l.size());
   
           checkLoggingEvent("hivemind.test.services.Demo", "BEGIN noResult()", l, 0);
  @@ -216,7 +215,7 @@
               checkException(ex, "Failure in method alwaysFail.");
           }
   
  -        l = a.getEvents();
  +        l = getInterceptedLogEvents();
           assertEquals(2, l.size());
   
           checkLoggingEvent("hivemind.test.services.Demo", "BEGIN alwaysFail()", l, 0);
  @@ -263,9 +262,7 @@
           NameLookupHack._context = context;
   
           SimpleRemote object =
  -            (SimpleRemote) r.getService(
  -                "hivemind.test.services.SimpleRemote",
  -                SimpleRemote.class);
  +            (SimpleRemote) r.getService("hivemind.test.services.SimpleRemote", SimpleRemote.class);
   
           assertEquals(7, object.add(4, 3));
           // Exercise several code paths where objects are ready or cached.
  @@ -286,9 +283,7 @@
           NameLookupHack._context = context;
   
           SimpleRemote object =
  -            (SimpleRemote) r.getService(
  -                "hivemind.test.services.SimpleRemote",
  -                SimpleRemote.class);
  +            (SimpleRemote) r.getService("hivemind.test.services.SimpleRemote", SimpleRemote.class);
   
           try
           {
  @@ -305,47 +300,46 @@
               checkException(t, "Forced error: hivemind.test.services.Simple");
           }
       }
  -    
  -	public void testEJBProxyRemoteFailure() throws Exception
  -	{
  -		RegistryBuilder b = new RegistryBuilder();
  -		DescriptorParser p = new DescriptorParser();
  -		b.processModule(_resolver, p.parse(getMasterModuleLocation()));
  -		b.processModule(_resolver, p.parse(getLocation("EJBProxy.xml")));
  -		Registry r = b.constructRegistry();
  -
  -		SimpleHomeImpl home = new SimpleHomeImpl();
  -		home.setForceError(true);
  -		
  -		FakeContext context = new FakeContext();
  -		context.bind("hivemind.test.services.Simple", home);
  -		NameLookupHack._context = context;
  -
  -		NameLookupHack._context = context;
  -
  -		SimpleRemote object =
  -			(SimpleRemote) r.getService(
  -				"hivemind.test.services.SimpleRemote",
  -				SimpleRemote.class);
  -
  -		try
  -		{
  -
  -			object.add(4, 3);
  -			unreachable();
  -		}
  -		catch (RemoteException ex)
  -		{
  -			checkException(ex, "Forced error.");
  -		}
  -	}    
   
  -    protected void tearDown() throws Exception
  +    public void testEJBProxyRemoteFailure() throws Exception
       {
  -        super.tearDown();
  -        
  -        NameLookupHack._context = null;
  -        NameLookupHack._properties = null;
  +        RegistryBuilder b = new RegistryBuilder();
  +        DescriptorParser p = new DescriptorParser();
  +        b.processModule(_resolver, p.parse(getMasterModuleLocation()));
  +        b.processModule(_resolver, p.parse(getLocation("EJBProxy.xml")));
  +        Registry r = b.constructRegistry();
  +
  +        SimpleHomeImpl home = new SimpleHomeImpl();
  +        home.setForceError(true);
  +
  +        FakeContext context = new FakeContext();
  +        context.bind("hivemind.test.services.Simple", home);
  +        NameLookupHack._context = context;
  +
  +        NameLookupHack._context = context;
  +
  +        SimpleRemote object =
  +            (SimpleRemote) r.getService("hivemind.test.services.SimpleRemote", SimpleRemote.class);
  +
  +        try
  +        {
  +
  +            object.add(4, 3);
  +            unreachable();
  +        }
  +        catch (RemoteException ex)
  +        {
  +            checkException(ex, "Forced error.");
  +        }
       }
   
  +	public void testServiceOverride() throws Exception
  +	{
  +		Registry r = buildRegistry("ServiceOverride.xml");
  +		
  +		SimpleService s = (SimpleService)r.getService("hivemind.test.services.ServiceOverride", SimpleService.class);
  +		
  +		// The bad impl multiplies, not add.
  +		assertEquals(28, s.add(4, 7));
  +	}
   }
  
  
  
  1.1                  jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/ServiceOverride.xml
  
  Index: ServiceOverride.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!-- $Id: ServiceOverride.xml,v 1.1 2003/07/02 15:40:40 hlship Exp $ -->
  <module
  	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://jakarta.apache.org/commons/hivemind/schema/HiveMind_1.0.xsd"
  	id="hivemind.test.services" 
  	version="1.0.0">
  	<service id="ServiceOverride" interface="hivemind.test.services.SimpleService" overridable="true">
  	  <create-instance class="hivemind.test.services.impl.SimpleServiceImpl"/>
  	</service>
  	
  	<contribute-service service-id="hivemind.test.services.ServiceOverride">
  		<create-instance class="hivemind.test.services.impl.BaseSimpleServiceImpl"/>
  	</contribute-service>
  </module>
  
  
  1.12      +46 -62    jakarta-commons-sandbox/hivemind/src/test/hivemind/test/config/TestConfiguration.java
  
  Index: TestConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/config/TestConfiguration.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- TestConfiguration.java	1 Jul 2003 20:13:01 -0000	1.11
  +++ TestConfiguration.java	2 Jul 2003 15:40:41 -0000	1.12
  @@ -69,6 +69,7 @@
   import org.apache.commons.hivemind.Registry;
   import org.apache.commons.hivemind.impl.RegistryBuilder;
   import org.apache.commons.hivemind.parse.DescriptorParser;
  +import org.apache.log4j.spi.LoggingEvent;
   import org.apache.tapestry.ApplicationRuntimeException;
   import org.apache.tapestry.ILocation;
   import org.apache.tapestry.IResourceLocation;
  @@ -91,37 +92,40 @@
   
       public void testCheckRequired() throws Exception
       {
  -        try
  -        {
  -            HiveMind.setBrittle(true);
  +        interceptLogging();
   
  -            buildRegistry("CheckRequired.xml");
  +        Registry r = buildRegistry("CheckRequired.xml");
   
  +        checkLoggingEvent(
  +            "org.apache.commons.hivemind.impl.RegistryBuilder",
  +            "Configuration extension point hivemind.test.config.Required contains no contributions but expects exactly one contribution.");
  +
  +        try
  +        {
  +            r.getService("hivemind.test.config.Required", Object.class);
               unreachable();
           }
  -        catch (Exception ex)
  +        catch (ApplicationRuntimeException ex)
           {
               checkException(
                   ex,
  -                "Configuration extension point hivemind.test.config.Required contains no contributions but expects exactly one contribution.");
  +                "Service extension point hivemind.test.config.Required does not exist.");
           }
  +
       }
  +
       public void testCheckRequiredOver() throws Exception
       {
  -        try
  -        {
  -            HiveMind.setBrittle(true);
  +        interceptLogging();
  +        Registry r = buildRegistry("CheckRequiredOver.xml");
   
  -            buildRegistry("CheckRequiredOver.xml");
  +        checkLoggingEvent(
  +            "org.apache.commons.hivemind.impl.RegistryBuilder",
  +            "Configuration extension point hivemind.test.config.RequiredOver contains 3 contributions but expects exactly one contribution.");
   
  -            unreachable();
  -        }
  -        catch (Exception ex)
  -        {
  -            checkException(
  -                ex,
  -                "Configuration extension point hivemind.test.config.RequiredOver contains 3 contributions but expects exactly one contribution.");
  -        }
  +        List l = r.getConfiguration("hivemind.test.config.RequiredOver");
  +
  +        assertEquals(3, l.size());
       }
   
       public void testRequiredExact() throws Exception
  @@ -136,20 +140,17 @@
   
       public void testCheckOptional() throws Exception
       {
  -        try
  -        {
  -            HiveMind.setBrittle(true);
  +        interceptLogging();
   
  -            buildRegistry("CheckOptional.xml");
  +        Registry r = buildRegistry("CheckOptional.xml");
   
  -            unreachable();
  -        }
  -        catch (Exception ex)
  -        {
  -            checkException(
  -                ex,
  -                "Configuration extension point hivemind.test.config.CheckOptional contains 2 contributions but expects an optional contribution.");
  -        }
  +        checkLoggingEvent(
  +            "org.apache.commons.hivemind.impl.RegistryBuilder",
  +            "Configuration extension point hivemind.test.config.CheckOptional contains 2 contributions but expects an optional contribution.");
  +
  +        List l = r.getConfiguration("hivemind.test.config.CheckOptional");
  +
  +        assertEquals(2, l.size());
       }
   
       public void testOptional() throws Exception
  @@ -165,20 +166,17 @@
   
       public void testCheckOnePlus() throws Exception
       {
  -        try
  -        {
  -            HiveMind.setBrittle(true);
  +        interceptLogging();
   
  -            buildRegistry("CheckOnePlus.xml");
  +        Registry r = buildRegistry("CheckOnePlus.xml");
   
  -            unreachable();
  -        }
  -        catch (Exception ex)
  -        {
  -            checkException(
  -                ex,
  -                "Configuration extension point hivemind.test.config.CheckOnePlus contains no contributions but expects at least one contribution.");
  -        }
  +        checkLoggingEvent(
  +            "org.apache.commons.hivemind.impl.RegistryBuilder",
  +            "Configuration extension point hivemind.test.config.CheckOnePlus contains no contributions but expects at least one contribution.");
  +
  +        List l = r.getConfiguration("hivemind.test.config.CheckOnePlus");
  +
  +        assertEquals(0, l.size());
       }
   
       public void testOnePlus() throws Exception
  @@ -212,7 +210,6 @@
       {
           try
           {
  -            HiveMind.setBrittle(true);
   
               Registry r = buildRegistry("ConvertFail.xml");
   
  @@ -446,30 +443,17 @@
   
       public void testWrongElementType() throws Exception
       {
  -        HiveMind.setBrittle(true);
  +        interceptLogging();
   
           Registry r = buildRegistry("WrongElementType.xml");
   
  -        try
  -        {
  +        List l = r.getConfiguration("hivemind.test.config.Create");
   
  -            r.getConfiguration("hivemind.test.config.Create");
  -            unreachable();
  -        }
  -        catch (ApplicationRuntimeException ex)
  -        {
  -            Throwable t = findNestedException(ex);
  -
  -            checkException(
  -                t,
  -                "Module hivemind.test.config has contributed element hivemind.test.config.ConfigElement@");
  -            checkException(t, "to service extension point hivemind.test.config.Create");
  -            checkException(
  -                t,
  -                "The element may not be converted to the declared element type, "
  -                    + "org.apache.commons.hivemind.SymbolSource, and has been ignored.");
  -        }
  +        assertEquals(1, l.size());
   
  +        checkLoggingEvent(
  +            "org.apache.commons.hivemind.impl.ConfigurationExtensionPointImpl",
  +            "The element may not be converted to the declared element type, org.apache.commons.hivemind.SymbolSource, and has been ignored.");
       }
   
       /**
  
  
  
  1.3       +2 -1      jakarta-commons-sandbox/hivemind/src/test/hivemind/test/config/WrongElementType.xml
  
  Index: WrongElementType.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/config/WrongElementType.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WrongElementType.xml	30 Jun 2003 23:04:42 -0000	1.2
  +++ WrongElementType.xml	2 Jul 2003 15:40:41 -0000	1.3
  @@ -7,5 +7,6 @@
   	version="1.0.0">
     <configuration id="Create" element-type="org.apache.commons.hivemind.SymbolSource">
   		<create-instance class="hivemind.test.config.ConfigElement"/>
  +		<create-instance class="hivemind.test.external.MapSymbolSource"/>
     </configuration>
   </module>
  
  
  
  1.11      +29 -20    jakarta-commons-sandbox/hivemind/src/test/hivemind/test/parse/TestDescriptorParser.java
  
  Index: TestDescriptorParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/parse/TestDescriptorParser.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- TestDescriptorParser.java	1 Jul 2003 20:13:02 -0000	1.10
  +++ TestDescriptorParser.java	2 Jul 2003 15:40:43 -0000	1.11
  @@ -132,6 +132,7 @@
           assertEquals("Bar", s.getId());
           assertEquals("package.IBar", s.getInterfaceClassName());
           assertEquals(false, s.isRequired());
  +        assertEquals(false, s.isOverridable());
           assertNull(s.getDescription());
   
           s = d.getService("Foo");
  @@ -590,23 +591,31 @@
   
           assertEquals("foo/bar.baz", rd.getPath());
       }
  -    
  -	public void testSetResource() throws Exception
  -	{
  -		ModuleDescriptor d = parse("SetResource.xml");
  -		ConfigurationDescriptor cd = d.getConfiguration("Resource");
  -
  -		List l = cd.getProviders();
  -		assertEquals(1, l.size());
  -
  -		NewDescriptor nd = (NewDescriptor) l.get(0);
  -	
  -		l = nd.getConfigurators();
  -		assertEquals(1, l.size());
  -		
  -		ResourceDescriptor rd = (ResourceDescriptor) l.get(0);
  -
  -		assertEquals("foo", rd.getPropertyName());
  -		assertEquals("biff.blat", rd.getPath());		
  -	}    
  +
  +    public void testSetResource() throws Exception
  +    {
  +        ModuleDescriptor d = parse("SetResource.xml");
  +        ConfigurationDescriptor cd = d.getConfiguration("Resource");
  +
  +        List l = cd.getProviders();
  +        assertEquals(1, l.size());
  +
  +        NewDescriptor nd = (NewDescriptor) l.get(0);
  +
  +        l = nd.getConfigurators();
  +        assertEquals(1, l.size());
  +
  +        ResourceDescriptor rd = (ResourceDescriptor) l.get(0);
  +
  +        assertEquals("foo", rd.getPropertyName());
  +        assertEquals("biff.blat", rd.getPath());
  +    }
  +
  +    public void testOverridableService() throws Exception
  +    {
  +        ModuleDescriptor d = parse("OverridableService.xml");
  +        ServiceDescriptor sd = d.getService("Foo");
  +
  +        assertEquals(true, sd.isOverridable());
  +    }
   }
  
  
  
  1.1                  jakarta-commons-sandbox/hivemind/src/test/hivemind/test/parse/OverridableService.xml
  
  Index: OverridableService.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!-- $Id: OverridableService.xml,v 1.1 2003/07/02 15:40:43 hlship Exp $ -->
  <module
  	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://jakarta.apache.org/commons/hivemind/schema/HiveMind_1.0.xsd"	
  	id="hivemind.test.parse" 
  	version="1.0.0">
    <service id="Foo" interface="package.foo.Fubar" overridable="true">
  		<create-instance class="fie.fie.foe.Fum"/>
    </service>
  </module>
  
  
  1.7       +1 -26     jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/HiveMind.java
  
  Index: HiveMind.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/HiveMind.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- HiveMind.java	30 Jun 2003 23:04:30 -0000	1.6
  +++ HiveMind.java	2 Jul 2003 15:40:43 -0000	1.7
  @@ -97,8 +97,6 @@
           _bundle = ResourceBundle.getBundle(HiveMind.class.getName() + "Messages");
       }
   
  -    private static boolean _brittle = false;
  -
       private HiveMind()
       {
           // Prevent instantiation
  @@ -180,29 +178,6 @@
           int count = keys.size();
   
           return (String[]) keys.toArray(new String[count]);
  -    }
  -
  -    /**
  -     * Returns true if HiveMind is operating in "brittle" mode,
  -     * which is only used for testing.  In brittle mode,
  -     * runtime warnings (such as missing services and modules)
  -     * become actual exceptions.  By default, HiveMind
  -     * is in normal (non-brittle) mode.
  -     * 
  -     **/
  -
  -    public static boolean isBrittle()
  -    {
  -        return _brittle;
  -    }
  -
  -    /**
  -     * Used to activate the "brittle" mode for testing
  -     * purposes only.
  -     */
  -    public static void setBrittle(boolean brittle)
  -    {
  -        _brittle = brittle;
       }
   
       public static ApplicationRuntimeException createMissingServiceException(
  
  
  
  1.5       +7 -3      jakarta-commons-sandbox/hivemind/src/META-INF/hivemodule.xml
  
  Index: hivemodule.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/META-INF/hivemodule.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- hivemodule.xml	1 Jul 2003 11:28:53 -0000	1.4
  +++ hivemodule.xml	2 Jul 2003 15:40:43 -0000	1.5
  @@ -26,10 +26,14 @@
   	
   	<service id="NameLookup"
   			interface="org.apache.commons.hivemind.service.NameLookup"
  -			required="false">
  +			required="false"
  +			overridable="true">
   		<description>
   			A service which can perform name lookups of objects; typically an implementation based on JNDI is supplied.	
  -		</description>		
  +			The default implementation uses JNDI but may be overriden for other environments, or to override its
  +			configuration.
  +		</description>	
  +		<create-instance class="org.apache.commons.hivemind.service.impl.NameLookupImpl"/>	
   	</service>
   	
   	<service id="EJBProxyFactory"
  
  
  
  1.1                  jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/impl/BaseSimpleServiceImpl.java
  
  Index: BaseSimpleServiceImpl.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package hivemind.test.services.impl;
  
  import hivemind.test.services.SimpleService;
  
  /**
   * Used to test overriding of service implementations.  Multiplies the arguments
   * instead of adding them, so that we can detect that the implementation has
   * been overriden.
   *
   * @author Howard Lewis Ship
   * @version $Id: BaseSimpleServiceImpl.java,v 1.1 2003/07/02 15:40:43 hlship Exp $
   */
  public class BaseSimpleServiceImpl implements SimpleService
  {
  
  	/**
  	 * Multiplies the values!
  	 */
      public int add(int a, int b)
      {
          return a * b;
      }
  
  }
  
  
  
  1.5       +5 -2      jakarta-commons-sandbox/hivemind/src/test-data/TestConstructRegistry/testBasic.xml
  
  Index: testBasic.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test-data/TestConstructRegistry/testBasic.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- testBasic.xml	1 Jul 2003 11:28:53 -0000	1.4
  +++ testBasic.xml	2 Jul 2003 15:40:43 -0000	1.5
  @@ -23,10 +23,13 @@
           </service>
           <service id="org.apache.commons.hivemind.NameLookup"
               interface="org.apache.commons.hivemind.service.NameLookup"
  -            required="false" uid="6">
  +            overridable="true" required="false" uid="6">
               <description>    A service which can perform name lookups of
                   objects; typically an implementation based on JNDI is
  -                supplied.    </description>
  +                supplied.     The default implementation uses JNDI but
  +                may be overriden for other environments, or to override
  +                its    configuration.   </description>
  +            <create-instance class="org.apache.commons.hivemind.service.impl.NameLookupImpl"/>
           </service>
           <service id="org.apache.commons.hivemind.EJBProxyFactory"
               interface="org.apache.commons.hivemind.ServiceImplementationFactory" uid="7">
  
  
  
  1.5       +5 -2      jakarta-commons-sandbox/hivemind/src/test-data/TestConstructRegistry/testUptoDate.xml
  
  Index: testUptoDate.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test-data/TestConstructRegistry/testUptoDate.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- testUptoDate.xml	1 Jul 2003 11:28:53 -0000	1.4
  +++ testUptoDate.xml	2 Jul 2003 15:40:43 -0000	1.5
  @@ -23,10 +23,13 @@
           </service>
           <service id="org.apache.commons.hivemind.NameLookup"
               interface="org.apache.commons.hivemind.service.NameLookup"
  -            required="false" uid="6">
  +            overridable="true" required="false" uid="6">
               <description>    A service which can perform name lookups of
                   objects; typically an implementation based on JNDI is
  -                supplied.    </description>
  +                supplied.     The default implementation uses JNDI but
  +                may be overriden for other environments, or to override
  +                its    configuration.   </description>
  +            <create-instance class="org.apache.commons.hivemind.service.impl.NameLookupImpl"/>
           </service>
           <service id="org.apache.commons.hivemind.EJBProxyFactory"
               interface="org.apache.commons.hivemind.ServiceImplementationFactory" uid="7">
  
  
  
  1.8       +38 -27    jakarta-commons-sandbox/hivemind/src/test/hivemind/test/external/TestExternalParser.java
  
  Index: TestExternalParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/external/TestExternalParser.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TestExternalParser.java	30 Jun 2003 23:04:29 -0000	1.7
  +++ TestExternalParser.java	2 Jul 2003 15:40:43 -0000	1.8
  @@ -71,6 +71,7 @@
   import org.apache.commons.hivemind.parse.DescriptorParser;
   import org.apache.commons.hivemind.parse.ExternalParser;
   import org.apache.commons.hivemind.util.URLResourceLocation;
  +import org.apache.log4j.spi.LoggingEvent;
   import org.apache.tapestry.ApplicationRuntimeException;
   import org.apache.tapestry.IResourceLocation;
   import org.apache.tapestry.util.xml.DocumentParseException;
  @@ -253,6 +254,8 @@
   
       public void testXMLSymbols() throws Exception
       {
  +        interceptLogging();
  +
           RegistryBuilder b = new RegistryBuilder();
           DescriptorParser dp = new DescriptorParser();
   
  @@ -287,43 +290,51 @@
   
           assertEquals("${town}", e2.getContent());
   
  +        checkLoggingEvent(
  +            "org.apache.commons.hivemind.impl.RegistryImpl",
  +            "No value available for variable 'town'");
       }
  -    
  -	public void testSymbolSourceOrder() throws Exception
  -	{
  -		RegistryBuilder b = new RegistryBuilder();
  -		DescriptorParser dp = new DescriptorParser();
   
  -		b.processModule(_resolver, dp.parse(getMasterModuleLocation()));
  -		b.processModule(_resolver, dp.parse(getLocation("SymbolSourceOrder.xml")));
  +    public void testSymbolSourceOrder() throws Exception
  +    {
  +        interceptLogging();
  +
  +        RegistryBuilder b = new RegistryBuilder();
  +        DescriptorParser dp = new DescriptorParser();
   
  -		Registry r = b.constructRegistry();
  +        b.processModule(_resolver, dp.parse(getMasterModuleLocation()));
  +        b.processModule(_resolver, dp.parse(getLocation("SymbolSourceOrder.xml")));
   
  -		List elements = r.getConfiguration("hivemind.test.external.Elements");
  -		assertEquals(1, elements.size());
  +        Registry r = b.constructRegistry();
   
  -		Element e = (Element) elements.get(0);
  +        List elements = r.getConfiguration("hivemind.test.external.Elements");
  +        assertEquals(1, elements.size());
   
  -		assertEquals("family", e.getElementName());
  +        Element e = (Element) elements.get(0);
   
  -		Attribute a = (Attribute) e.getAttributes().get(0);
  -		assertEquals("husband", a.getName());
  -		assertEquals("Homer Simpson", a.getValue());
  +        assertEquals("family", e.getElementName());
   
  -		List l2 = e.getElements();
  -		Element e2 = (Element) l2.get(0);
  -		assertEquals("Wife: Wilma Flintstone", e2.getContent());
  +        Attribute a = (Attribute) e.getAttributes().get(0);
  +        assertEquals("husband", a.getName());
  +        assertEquals("Homer Simpson", a.getValue());
   
  -		e2 = (Element) l2.get(1);
  -		assertEquals("Barney Rubble", e2.getContent());
  +        List l2 = e.getElements();
  +        Element e2 = (Element) l2.get(0);
  +        assertEquals("Wife: Wilma Flintstone", e2.getContent());
   
  -		e2 = (Element) l2.get(2);
  -		assertEquals("Dino", e2.getContent());
  +        e2 = (Element) l2.get(1);
  +        assertEquals("Barney Rubble", e2.getContent());
   
  -		e2 = (Element) l2.get(3);
  -		// No value for this variable.
  +        e2 = (Element) l2.get(2);
  +        assertEquals("Dino", e2.getContent());
   
  -		assertEquals("${town}", e2.getContent());
  +        e2 = (Element) l2.get(3);
  +        // No value for this variable.
   
  -	}    
  +        assertEquals("${town}", e2.getContent());
  +        
  +		checkLoggingEvent(
  +			"org.apache.commons.hivemind.impl.RegistryImpl",
  +			"No value available for variable 'town'");
  +    }
   }
  
  
  

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


Mime
View raw message