hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahue...@apache.org
Subject svn commit: r463185 - in /hivemind/branches/branch-2-0-annot: framework/src/java/org/apache/hivemind/impl/ framework/src/java/org/apache/hivemind/service/impl/ framework/src/java/org/apache/hivemind/util/ library/src/java/org/apache/hivemind/lib/chain/...
Date Thu, 12 Oct 2006 10:49:23 GMT
Author: ahuegen
Date: Thu Oct 12 03:49:22 2006
New Revision: 463185

URL: http://svn.apache.org/viewvc?view=rev&rev=463185
Log:
Backward compatibility mode for unique elements 

Added:
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/util/UniqueHashMap.java
Modified:
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java
    hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/service/impl/DefaultsSymbolSource.java
    hivemind/branches/branch-2-0-annot/library/src/java/org/apache/hivemind/lib/chain/ChainFactory.java
    hivemind/branches/branch-2-0-annot/library/src/java/org/apache/hivemind/lib/factory/BeanFactoryBuilder.java
    hivemind/branches/branch-2-0-annot/library/src/java/org/apache/hivemind/lib/factory/BeanFactoryParameter.java
    hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/chain/TestChainBuilder.java
    hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/factory/TestBeanFactoryImpl.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SchemaElement.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SchemaProcessorImpl.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleDescriptorProcessor.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/Schema.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/impl/SchemaImpl.java
    hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/rules/InvokeParentRule.java
    hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/config/TestUniqueElementAttribute.java
    hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestSchemaProcessor.java

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java?view=diff&rev=463185&r1=463184&r2=463185
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java
(original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/impl/CoreServicesProvider.java
Thu Oct 12 03:49:22 2006
@@ -2,9 +2,11 @@
 
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
+import java.util.Map;
 
 import org.apache.hivemind.ErrorHandler;
 import org.apache.hivemind.HiveMind;
@@ -140,7 +142,7 @@
             public Object constructCoreServiceImplementation(ImplementationConstructionContext
context)
             {
                 DefaultsSymbolSource result = new DefaultsSymbolSource();
-                result.setDefaults((List) context.getConfiguration(configurationId));
+                result.setDefaults(((Map) context.getConfiguration(configurationId)).values());
                 result.initializeService();
                 return result;
             }
@@ -150,8 +152,8 @@
         // Configuration point for setting defaults for symbol values.
 
         helper.addConfigurationPoint(configurationId, 
-                new CreateClassConfigurationConstructor(md.getLocation(), ArrayList.class.getName()),

-                List.class.getName());
+                new CreateClassConfigurationConstructor(md.getLocation(), HashMap.class.getName()),

+                Map.class.getName());
     }
 
     /**

Modified: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/service/impl/DefaultsSymbolSource.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/service/impl/DefaultsSymbolSource.java?view=diff&rev=463185&r1=463184&r2=463185
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/service/impl/DefaultsSymbolSource.java
(original)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/service/impl/DefaultsSymbolSource.java
Thu Oct 12 03:49:22 2006
@@ -14,6 +14,8 @@
 
 package org.apache.hivemind.service.impl;
 
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -51,8 +53,8 @@
         }
     }
 
-    public void setDefaults(List list)
+    public void setDefaults(Collection defaults)
     {
-        _defaults = list;
+        _defaults = new ArrayList(defaults);
     }
 }

Added: hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/util/UniqueHashMap.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/util/UniqueHashMap.java?view=auto&rev=463185
==============================================================================
--- hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/util/UniqueHashMap.java
(added)
+++ hivemind/branches/branch-2-0-annot/framework/src/java/org/apache/hivemind/util/UniqueHashMap.java
Thu Oct 12 03:49:22 2006
@@ -0,0 +1,24 @@
+package org.apache.hivemind.util;
+
+import java.util.HashMap;
+
+import org.apache.hivemind.ApplicationRuntimeException;
+
+/**
+ * Specialized map that guarantees uniqueness of key values.
+ * 
+ * @author Achim Huegen
+ */
+public class UniqueHashMap extends HashMap
+{
+
+    public Object put(Object key, Object value)
+    {
+        if (containsKey(key)) {
+            // TODO annotations: Exception-Handling
+            throw new ApplicationRuntimeException("Key '" + key + "' already contained in
map");
+        }
+        return super.put(key, value);
+    }
+
+}

Modified: hivemind/branches/branch-2-0-annot/library/src/java/org/apache/hivemind/lib/chain/ChainFactory.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/library/src/java/org/apache/hivemind/lib/chain/ChainFactory.java?view=diff&rev=463185&r1=463184&r2=463185
==============================================================================
--- hivemind/branches/branch-2-0-annot/library/src/java/org/apache/hivemind/lib/chain/ChainFactory.java
(original)
+++ hivemind/branches/branch-2-0-annot/library/src/java/org/apache/hivemind/lib/chain/ChainFactory.java
Thu Oct 12 03:49:22 2006
@@ -17,6 +17,7 @@
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.hivemind.ServiceImplementationFactory;
 import org.apache.hivemind.ServiceImplementationFactoryParameters;
@@ -35,11 +36,11 @@
     public Object createCoreServiceImplementation(
             ServiceImplementationFactoryParameters factoryParameters)
     {
-        List contributions = (List) factoryParameters.getFirstParameter();
+        Map contributions = (Map) factoryParameters.getFirstParameter();
 
         Orderer orderer = new Orderer(factoryParameters.getErrorLog(), "command");
 
-        Iterator i = contributions.iterator();
+        Iterator i = contributions.values().iterator();
         while (i.hasNext())
         {
             ChainContribution cc = (ChainContribution) i.next();

Modified: hivemind/branches/branch-2-0-annot/library/src/java/org/apache/hivemind/lib/factory/BeanFactoryBuilder.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/library/src/java/org/apache/hivemind/lib/factory/BeanFactoryBuilder.java?view=diff&rev=463185&r1=463184&r2=463185
==============================================================================
--- hivemind/branches/branch-2-0-annot/library/src/java/org/apache/hivemind/lib/factory/BeanFactoryBuilder.java
(original)
+++ hivemind/branches/branch-2-0-annot/library/src/java/org/apache/hivemind/lib/factory/BeanFactoryBuilder.java
Thu Oct 12 03:49:22 2006
@@ -31,6 +31,6 @@
         BeanFactoryParameter p = (BeanFactoryParameter) factoryParameters.getFirstParameter();
 
         return new BeanFactoryImpl(factoryParameters.getErrorLog(), p.getVendClass(), p
-                .getContributions(), p.getDefaultCacheable());
+                .getContributionsList(), p.getDefaultCacheable());
     }
 }

Modified: hivemind/branches/branch-2-0-annot/library/src/java/org/apache/hivemind/lib/factory/BeanFactoryParameter.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/library/src/java/org/apache/hivemind/lib/factory/BeanFactoryParameter.java?view=diff&rev=463185&r1=463184&r2=463185
==============================================================================
--- hivemind/branches/branch-2-0-annot/library/src/java/org/apache/hivemind/lib/factory/BeanFactoryParameter.java
(original)
+++ hivemind/branches/branch-2-0-annot/library/src/java/org/apache/hivemind/lib/factory/BeanFactoryParameter.java
Thu Oct 12 03:49:22 2006
@@ -14,7 +14,9 @@
 
 package org.apache.hivemind.lib.factory;
 
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 /**
  * Parameter object passed to {@link org.apache.hivemind.lib.factory.BeanFactoryBuilder}.
@@ -31,7 +33,7 @@
      * The contributions to the list (assigned from the companion
      * configuration point).
      */
-    public List getContributions()
+    public List getContributionsList()
     {
         return _contributions;
     }
@@ -55,9 +57,14 @@
         return _vendClass;
     }
 
-    public void setContributions(List list)
+    public void setContributions(Map contributions)
     {
-        _contributions = list;
+        _contributions = new ArrayList(contributions.values());
+    }
+
+    public void setContributionsList(List contributions)
+    {
+        _contributions = contributions;
     }
 
     public void setDefaultCacheable(boolean b)

Modified: hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/chain/TestChainBuilder.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/chain/TestChainBuilder.java?view=diff&rev=463185&r1=463184&r2=463185
==============================================================================
--- hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/chain/TestChainBuilder.java
(original)
+++ hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/chain/TestChainBuilder.java
Thu Oct 12 03:49:22 2006
@@ -24,7 +24,6 @@
 import org.apache.hivemind.service.ClassFab;
 import org.apache.hivemind.service.MethodFab;
 import org.apache.hivemind.service.MethodSignature;
-import org.apache.hivemind.test.HiveMindTestCase;
 import org.apache.hivemind.xml.XmlTestCase;
 import org.easymock.MockControl;
 

Modified: hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/factory/TestBeanFactoryImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/factory/TestBeanFactoryImpl.java?view=diff&rev=463185&r1=463184&r2=463185
==============================================================================
--- hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/factory/TestBeanFactoryImpl.java
(original)
+++ hivemind/branches/branch-2-0-annot/library/src/test/org/apache/hivemind/lib/factory/TestBeanFactoryImpl.java
Thu Oct 12 03:49:22 2006
@@ -190,7 +190,7 @@
 
         List l = Collections.singletonList(build("integer", Integer.class));
 
-        p.setContributions(l);
+        p.setContributionsList(l);
 
         MockControl fpc = newControl(ServiceImplementationFactoryParameters.class);
         ServiceImplementationFactoryParameters fp = (ServiceImplementationFactoryParameters)
fpc

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SchemaElement.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SchemaElement.java?view=diff&rev=463185&r1=463184&r2=463185
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SchemaElement.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SchemaElement.java
Thu Oct 12 03:49:22 2006
@@ -25,7 +25,6 @@
 import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.hivemind.Attribute;
 import org.apache.hivemind.Element;
-import org.apache.hivemind.Location;
 import org.apache.hivemind.schema.AttributeModel;
 import org.apache.hivemind.schema.ElementModel;
 import org.apache.hivemind.schema.Rule;
@@ -147,8 +146,6 @@
             if (!_knownAttributes.contains(name))
                 errors.add(XmlImplMessages.unknownAttribute(name));
 
-            checkUniquness(name, a.getValue(), element.getLocation(), errors);
-
             required.remove(name);
         }
 
@@ -181,36 +178,6 @@
         throw new ApplicationRuntimeException(buffer.toString(), element.getLocation(), null);
     }
 
-    private void checkUniquness(String name, String value, Location location, List errors)
-    {
-        Map valuesMap = (Map) _attributeValues.get(name);
-
-        // If null, then not checking on uniqueness.
-
-        if (valuesMap == null)
-            return;
-
-        Object translatedValue = getAttributeTranslator(name).translate(
-                _processor.getContributingModule(),
-                Object.class,
-                value,
-                location);
-
-        Location prior = (Location) valuesMap.get(translatedValue);
-
-        if (prior == null)
-        {
-            valuesMap.put(translatedValue, location);
-            return;
-        }
-
-        // A conflict.
-
-        errors.add(XmlImplMessages.uniqueAttributeConstraintBroken(
-                name,
-                translatedValue.toString(),
-                prior));
-    }
 
     void fireBegin(Element element)
     {

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SchemaProcessorImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SchemaProcessorImpl.java?view=diff&rev=463185&r1=463184&r2=463185
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SchemaProcessorImpl.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/SchemaProcessorImpl.java
Thu Oct 12 03:49:22 2006
@@ -16,13 +16,16 @@
 
 import java.util.ArrayList;
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.hivemind.ApplicationRuntimeException;
 import org.apache.hivemind.Element;
 import org.apache.hivemind.ErrorLog;
 import org.apache.hivemind.TranslatorManager;
 import org.apache.hivemind.internal.Module;
+import org.apache.hivemind.schema.AttributeModel;
 import org.apache.hivemind.schema.ElementModel;
 import org.apache.hivemind.schema.Schema;
 import org.apache.hivemind.schema.SchemaProcessor;
@@ -98,6 +101,17 @@
             Element currentElement = peekElement();
             String keyAttribute = _activeElement.getModel().getKeyAttribute();
 
+            if (keyAttribute == null) {
+                // check for unique attribute
+                for (Iterator j = _activeElement.getModel().getAttributeModels().iterator();
j.hasNext();)
+                {
+                    AttributeModel attributeModel = (AttributeModel) j.next();
+    
+                    if (attributeModel.isUnique())
+                        keyAttribute = attributeModel.getName();
+                }
+            }
+
             String expandedKey = getContributingModule().expandSymbols(
                     currentElement.getAttributeValue(keyAttribute),
                     currentElement.getLocation());
@@ -110,7 +124,6 @@
                     expandedKey,
                     currentElement.getLocation());
             
-            // SchemaProcessorImpl ensures that the root container is a Map
             Map container = (Map) _stack.get(0);
             container.put(finalValue, element);
 
@@ -216,6 +229,11 @@
         }
         Defense.notNull(contributingModule, "Contributing module");
         
+        if (_canElementsBeMapped && !(container instanceof Map)) {
+            throw new ApplicationRuntimeException("Schema root class is expected to be assignable
to " +
+                    "'java.util.Map' because key-attribute or unique attribute is used in
the schema. ");
+        }
+
         // Move the container to the stack as top level element
         push(container);
 

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleDescriptorProcessor.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleDescriptorProcessor.java?view=diff&rev=463185&r1=463184&r2=463185
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleDescriptorProcessor.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/impl/XmlModuleDescriptorProcessor.java
Thu Oct 12 03:49:22 2006
@@ -36,6 +36,7 @@
 import org.apache.hivemind.schema.Schema;
 import org.apache.hivemind.schema.impl.SchemaImpl;
 import org.apache.hivemind.util.IdUtils;
+import org.apache.hivemind.util.UniqueHashMap;
 
 /**
  * Adds the modules held by instances of {@link org.apache.hivemind.parse.ModuleDescriptor}
@@ -267,7 +268,8 @@
             // be resolved and processed later
             if (cpd.getContributionsSchema() != null) {
                 // TODO: compare container class name and rootElementClassName
-                if (HashMap.class.getName().equals(cpd.getContributionsSchema().getRootElementClassName()))
{
+                if (HashMap.class.getName().equals(cpd.getContributionsSchema().getRootElementClassName())
+                    || UniqueHashMap.class.getName().equals(cpd.getContributionsSchema().getRootElementClassName()))
{
                     configurationPoint.setContainerClassName(Map.class.getName());
                 }
 
@@ -358,7 +360,8 @@
                     xmlNature.setSchema(schema);
                     XmlConfigurationConstructor constructor = (XmlConfigurationConstructor)
point.getConstructor();
 
-                    if (HashMap.class.getName().equals(schema.getRootElementClassName()))
{
+                    if (HashMap.class.getName().equals(schema.getRootElementClassName())
+                       || UniqueHashMap.class.getName().equals(schema.getRootElementClassName()))
{
                         point.setContainerClassName(Map.class.getName());
                     }
                     // store the root-element-classname in the constructor

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/Schema.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/Schema.java?view=diff&rev=463185&r1=463184&r2=463185
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/Schema.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/Schema.java
Thu Oct 12 03:49:22 2006
@@ -50,8 +50,8 @@
 
     /**
      * Returns true if Elements conforming to this Schema can be indexed using a key. For
this to be
-     * true every {@link #getElementModel() top-level ElementModel} must define a non-null
-     * {@link ElementModel#getKeyAttribute() key attribute}.
+     * true one {@link #getElementModel() top-level ElementModel} must define a non-null
+     * {@link ElementModel#getKeyAttribute() key attribute} or a unique attribute.
      * 
      * @since 1.1
      */

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/impl/SchemaImpl.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/impl/SchemaImpl.java?view=diff&rev=463185&r1=463184&r2=463185
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/impl/SchemaImpl.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/impl/SchemaImpl.java
Thu Oct 12 03:49:22 2006
@@ -26,6 +26,7 @@
 import org.apache.hivemind.schema.AttributeModel;
 import org.apache.hivemind.schema.ElementModel;
 import org.apache.hivemind.schema.Schema;
+import org.apache.hivemind.util.UniqueHashMap;
 
 /**
  * Implementation of {@link org.apache.hivemind.schema.Schema}.
@@ -105,6 +106,9 @@
         return _shareableElementModels;
     }
 
+    /**
+     * @see org.apache.hivemind.schema.Schema#canInstancesBeKeyed()
+     */
     public boolean canInstancesBeKeyed()
     {
         boolean emptyModel = _elementModels == null || _elementModels.isEmpty();
@@ -112,15 +116,53 @@
         if (emptyModel)
             return false;
 
+        boolean result = false;
         for (Iterator i = _elementModels.iterator(); i.hasNext();)
         {
             ElementModel model = (ElementModel) i.next();
 
-            if (model.getKeyAttribute() == null)
-                return false;
+            if (model.getKeyAttribute() != null)
+                result = true;
+            
+            // check for unique attribute
+            for (Iterator j = model.getAttributeModels().iterator(); j.hasNext();)
+            {
+                AttributeModel attributeModel = (AttributeModel) j.next();
+
+                if (attributeModel.isUnique())
+                    result = true;
+            }
         }
 
-        return true;
+        return result;
+    }
+    
+    /**
+     * @return  true if instances are keyed and the key is unique (attribute unique="true"
used)
+     */
+    public boolean isKeyUnique()
+    {
+        boolean emptyModel = _elementModels == null || _elementModels.isEmpty();
+
+        if (emptyModel)
+            return false;
+
+        boolean result = false;
+        for (Iterator i = _elementModels.iterator(); i.hasNext();)
+        {
+            ElementModel model = (ElementModel) i.next();
+
+            // check for unique attribute
+            for (Iterator j = model.getAttributeModels().iterator(); j.hasNext();)
+            {
+                AttributeModel attributeModel = (AttributeModel) j.next();
+
+                if (attributeModel.isUnique())
+                    result = true;
+            }
+        }
+
+        return result;
     }
     
     /**
@@ -186,8 +228,13 @@
     {
         // if one element of the schema has defined a key-attribute, then use a map 
         // in that case {@link InvokeParentRule} does the rest to handle element addition
correctly
-        if (canInstancesBeKeyed())
-            return HashMap.class.getName();
+        if (canInstancesBeKeyed()) {
+            if (isKeyUnique()) {
+                return UniqueHashMap.class.getName();
+            } else {
+                return HashMap.class.getName();
+            }
+        }
         else return ArrayList.class.getName();
     }
 

Modified: hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/rules/InvokeParentRule.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/rules/InvokeParentRule.java?view=diff&rev=463185&r1=463184&r2=463185
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/rules/InvokeParentRule.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/java/org/apache/hivemind/schema/rules/InvokeParentRule.java
Thu Oct 12 03:49:22 2006
@@ -14,6 +14,7 @@
 
 package org.apache.hivemind.schema.rules;
 
+import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.util.List;
 
@@ -80,7 +81,13 @@
 
             m.invoke(parent, parameters);
         }
-        catch (Exception ex)
+        catch (InvocationTargetException ex) {
+            throw new ApplicationRuntimeException(RulesMessages.errorInvokingMethod(
+                    _methodName,
+                    parent,
+                    getLocation(),
+                    ex.getTargetException()), getLocation(), ex.getTargetException());
+        } catch (Exception ex)
         {
             throw new ApplicationRuntimeException(RulesMessages.errorInvokingMethod(
                     _methodName,

Modified: hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/config/TestUniqueElementAttribute.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/config/TestUniqueElementAttribute.java?view=diff&rev=463185&r1=463184&r2=463185
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/config/TestUniqueElementAttribute.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/test/hivemind/test/config/TestUniqueElementAttribute.java
Thu Oct 12 03:49:22 2006
@@ -14,13 +14,13 @@
 
 package hivemind.test.config;
 
-import hivemind.test.FrameworkTestCase;
-import org.apache.hivemind.Registry;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.hivemind.ApplicationRuntimeException;
+import org.apache.hivemind.Registry;
 import org.apache.hivemind.xml.XmlTestCase;
 
-import java.util.List;
-
 /** Test for checking the uniqueness of element attributes.
  */
 public class TestUniqueElementAttribute extends XmlTestCase
@@ -34,7 +34,7 @@
             buildFrameworkRegistry(
                 new String[] { "UniqueAttributeDefinition.xml", "UniqueAttributeBroken.xml"
});
 
-        List elements = (List) r.getConfiguration("hivemind.test.parse.MyExtensionPoint");
+        Map elements = (Map) r.getConfiguration("hivemind.test.parse.MyExtensionPoint");
 
         try
         {
@@ -47,7 +47,7 @@
         {
             assertExceptionSubstring(
                 ex,
-                "Value for attribute 'unique' ('jeje') duplicates a prior instance at");
+                "already contained in map");
         }
 
     }

Modified: hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestSchemaProcessor.java
URL: http://svn.apache.org/viewvc/hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestSchemaProcessor.java?view=diff&rev=463185&r1=463184&r2=463185
==============================================================================
--- hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestSchemaProcessor.java
(original)
+++ hivemind/branches/branch-2-0-annot/xml/src/test/org/apache/hivemind/impl/TestSchemaProcessor.java
Thu Oct 12 03:49:22 2006
@@ -404,24 +404,31 @@
         m1.expandSymbols("flintstone", location1);
         control1.setReturnValue("flintstone");
         
+        m1.expandSymbols("flintstone", location1);
+        control1.setReturnValue("flintstone");
+
+        String flintstoneKeyModule1 = "m1.flintstone";
+        t1.translate(m1, String.class, "flintstone", element1.getLocation());
+        tControl1.setReturnValue(flintstoneKeyModule1);
+
+        t1.translate(m1, Object.class, "flintstone", element1.getLocation());
+        tControl1.setReturnValue(flintstoneKeyModule1);
+
         m2.resolveType("StringHolderImpl");
         control2.setReturnValue(StringHolderImpl.class);
         
         m2.expandSymbols("flintstone", location2);
         control2.setReturnValue("flintstone");
         
+        m2.expandSymbols("flintstone", location2);
+        control2.setReturnValue("flintstone");
+
         tm.getTranslator("qualified-id");
         tmControl.setReturnValue(t1);
 
-        String flintstoneKeyModule1 = "m1.flintstone";
-        t1.translate(m1, Object.class, "flintstone", element1.getLocation());
-        tControl1.setReturnValue(flintstoneKeyModule1);
         tm.getTranslator("qualified-id");
         tmControl.setReturnValue(t1);
 
-        t1.translate(m1, String.class, "flintstone", element1.getLocation());
-        tControl1.setReturnValue(flintstoneKeyModule1);
-
         MockControl tControl2 = newControl(Translator.class);
         Translator t2 = (Translator) tControl2.getMock();
 
@@ -429,25 +436,26 @@
         tmControl.setReturnValue(t2);
 
         String flintstoneKeyModule2 = "m2.flintstone";
+        t2.translate(m2, String.class, "flintstone", element2.getLocation());
+        tControl2.setReturnValue(flintstoneKeyModule2);
+
         t2.translate(m2, Object.class, "flintstone", element2.getLocation());
         tControl2.setReturnValue(flintstoneKeyModule2);
 
         tm.getTranslator("qualified-id");
         tmControl.setReturnValue(t2);
 
-        t2.translate(m2, String.class, "flintstone", element2.getLocation());
-        tControl2.setReturnValue(flintstoneKeyModule2);
 
         replayControls();
 
-        List dest = new ArrayList();
+        Map dest = new HashMap();
         p.process(dest, elements1, m1, tm);
         p.process(dest, elements2, m2, tm);
 
         assertEquals(2, dest.size());
 
         Set keys = new TreeSet();
-        for (Iterator iter = dest.iterator(); iter.hasNext();)
+        for (Iterator iter = dest.values().iterator(); iter.hasNext();)
         {
             StringHolderImpl element = (StringHolderImpl) iter.next();
             keys.add(element.getValue());



Mime
View raw message