Return-Path:
Delivered-To: apmail-jakarta-hivemind-cvs-archive@www.apache.org
Received: (qmail 52532 invoked from network); 31 Jan 2005 10:10:56 -0000
Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199)
by minotaur-2.apache.org with SMTP; 31 Jan 2005 10:10:56 -0000
Received: (qmail 30343 invoked by uid 500); 31 Jan 2005 10:10:56 -0000
Delivered-To: apmail-jakarta-hivemind-cvs-archive@jakarta.apache.org
Received: (qmail 30322 invoked by uid 500); 31 Jan 2005 10:10:56 -0000
Mailing-List: contact hivemind-cvs-help@jakarta.apache.org; run by ezmlm
Precedence: bulk
list-help:
list-unsubscribe:
list-post:
Reply-To: hivemind-dev@jakarta.apache.org
Delivered-To: mailing list hivemind-cvs@jakarta.apache.org
Received: (qmail 30307 invoked by uid 99); 31 Jan 2005 10:10:56 -0000
X-ASF-Spam-Status: No, hits=-9.8 required=10.0
tests=ALL_TRUSTED,NO_REAL_NAME
X-Spam-Check-By: apache.org
Received: from minotaur.apache.org (HELO minotaur.apache.org)
(209.237.227.194)
by apache.org (qpsmtpd/0.28) with SMTP; Mon, 31 Jan 2005 02:10:55 -0800
Received: (qmail 52498 invoked by uid 1870); 31 Jan 2005 10:10:54 -0000
Date: 31 Jan 2005 10:10:54 -0000
Message-ID: <20050131101054.52495.qmail@minotaur.apache.org>
From: knut@apache.org
To: jakarta-hivemind-cvs@apache.org
Subject: cvs commit:
jakarta-hivemind/framework/src/test/org/apache/hivemind/impl
TestSchemaProcessor.java
X-Virus-Checked: Checked
X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N
knut 2005/01/31 02:10:54
Modified: src/documentation/content/xdocs configurations.xml
descriptor.xml
framework/src/java/org/apache/hivemind/impl
SchemaProcessorImpl.java
framework/src/test/org/apache/hivemind/impl
TestSchemaProcessor.java
Log:
Use the translated attribute value as the key for mapped configurations.
Revision Changes Path
1.13 +3 -2 jakarta-hivemind/src/documentation/content/xdocs/configurations.xml
Index: configurations.xml
===================================================================
RCS file: /home/cvs/jakarta-hivemind/src/documentation/content/xdocs/configurations.xml,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- configurations.xml 5 Jan 2005 21:53:31 -0000 1.12
+++ configurations.xml 31 Jan 2005 10:10:54 -0000 1.13
@@ -158,10 +158,11 @@
As mentioned it is also possible to have the configuration contributions
injected as a Map. This requires the schema to define the attribute of
- the top-level elements which should be used as the key for the elements
+ the top-level elements which should be used as the key for the objects
in the map. This is specified using &_element;'s key-attribute
attribute. The identified key attribute is implicitly marked as
- required and unique.
+ required and unique. Further it is the translated
+ attribute value which is used as the key in the map.
The list / map of elements is always injected as an unmodifiable
collection. An empty list / map may be injected, but never
null
.
1.19 +4 -4 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.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- descriptor.xml 5 Jan 2005 21:53:31 -0000 1.18
+++ descriptor.xml 31 Jan 2005 10:10:54 -0000 1.19
@@ -292,10 +292,10 @@
key-attribute |
string |
no |
- The name of this element's &_attribute; which will be used as a unique key
- for configuration contributions corresponding to this element. The
- contributions can then be accessed in a Map using this key. The specified
- &_attribute; is implicitly marked as required and
+ | The name of this element's &_attribute; whose translated value will
+ be used as a unique key for configuration contributions corresponding to this
+ element. The contributions can then be accessed in a Map using this key. The
+ specified &_attribute; is implicitly marked as required and
unique. |
1.13 +10 -2 jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/SchemaProcessorImpl.java
Index: SchemaProcessorImpl.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/SchemaProcessorImpl.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- SchemaProcessorImpl.java 6 Jan 2005 01:45:12 -0000 1.12
+++ SchemaProcessorImpl.java 31 Jan 2005 10:10:54 -0000 1.13
@@ -26,6 +26,7 @@
import org.apache.hivemind.schema.Schema;
import org.apache.hivemind.schema.SchemaProcessor;
import org.apache.hivemind.schema.Translator;
+import org.apache.hivemind.util.PropertyUtils;
/**
* Used to assemble all the {@link org.apache.hivemind.Contribution}s contributed to an
@@ -93,9 +94,16 @@
if (_canElementsBeMapped)
{
- String key = peekElement().getAttributeValue(_activeElement.getKeyAttribute());
+ Element currentElement = peekElement();
- _mappedElements.put(key, element);
+ String keyAttribute = _activeElement.getKeyAttribute();
+
+ Translator t = getAttributeTranslator(keyAttribute);
+
+ Object finalValue = t.translate(getContributingModule(), Object.class, currentElement
+ .getAttributeValue(keyAttribute), currentElement.getLocation());
+
+ _mappedElements.put(finalValue, element);
}
}
1.10 +13 -1 jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/TestSchemaProcessor.java
Index: TestSchemaProcessor.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/TestSchemaProcessor.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- TestSchemaProcessor.java 6 Jan 2005 01:45:16 -0000 1.9
+++ TestSchemaProcessor.java 31 Jan 2005 10:10:54 -0000 1.10
@@ -23,6 +23,7 @@
import org.apache.hivemind.internal.Module;
import org.apache.hivemind.schema.SchemaProcessor;
+import org.apache.hivemind.schema.Translator;
import org.apache.hivemind.schema.impl.AttributeModelImpl;
import org.apache.hivemind.schema.impl.ElementModelImpl;
import org.apache.hivemind.schema.impl.SchemaImpl;
@@ -245,6 +246,7 @@
AttributeModelImpl am = new AttributeModelImpl();
am.setName("name");
+ am.setTranslator("cartoon");
em.addAttributeModel(am);
@@ -278,6 +280,16 @@
m.expandSymbols("fred", null);
control.setReturnValue("fred");
+ MockControl tControl = newControl(Translator.class);
+ Translator t = (Translator) tControl.getMock();
+
+ m.getTranslator("cartoon");
+ control.setReturnValue(t);
+
+ Object flintstoneKey = new Object();
+ t.translate(m, Object.class, "flintstone", element.getLocation());
+ tControl.setReturnValue(flintstoneKey);
+
replayControls();
p.process(elements, m);
@@ -285,7 +297,7 @@
Map map = p.getMappedElements();
assertEquals(1, map.size());
- StringHolder h = (StringHolder) map.get("flintstone");
+ StringHolder h = (StringHolder) map.get(flintstoneKey);
assertEquals("fred", h.getValue());
---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org