You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hivemind.apache.org by kn...@apache.org on 2005/05/25 11:55:23 UTC
cvs commit: jakarta-hivemind/framework/src/java/org/apache/hivemind/parse DescriptorParser.java
knut 2005/05/25 02:55:23
Modified: framework/src/test/hivemind/test/parse
TestDescriptorParser.java
src/documentation/content/xdocs links.ent rules.xml
src/documentation/content HiveMind-QuickReference.doc
. status.xml
framework/src/java/org/apache/hivemind/ant
RegistrySerializer.java
framework/src/java/org/apache/hivemind/parse
DescriptorParser.java
Added: framework/src/test/hivemind/test/parse PushContentRule.xml
framework/src/test/hivemind/test/rules
TestPushContentRule.java
framework/src/java/org/apache/hivemind/schema/rules
PushContentRule.java
Log:
Added <push-content> rule (fixes HIVEMIND-126).
Revision Changes Path
1.35 +18 -0 jakarta-hivemind/framework/src/test/hivemind/test/parse/TestDescriptorParser.java
Index: TestDescriptorParser.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/test/hivemind/test/parse/TestDescriptorParser.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- TestDescriptorParser.java 29 Apr 2005 07:40:57 -0000 1.34
+++ TestDescriptorParser.java 25 May 2005 09:55:23 -0000 1.35
@@ -45,6 +45,7 @@
import org.apache.hivemind.schema.rules.CreateObjectRule;
import org.apache.hivemind.schema.rules.InvokeParentRule;
import org.apache.hivemind.schema.rules.PushAttributeRule;
+import org.apache.hivemind.schema.rules.PushContentRule;
import org.apache.hivemind.schema.rules.ReadAttributeRule;
import org.apache.hivemind.schema.rules.ReadContentRule;
import org.apache.hivemind.schema.rules.SetModuleRule;
@@ -532,6 +533,23 @@
}
/** @since 1.1 */
+ public void testPushContentRule() throws Exception
+ {
+ ModuleDescriptor md = parse("PushContentRule.xml");
+
+ List points = md.getConfigurationPoints();
+ ConfigurationPointDescriptor cpd = (ConfigurationPointDescriptor) points.get(0);
+ Schema s = cpd.getContributionsSchema();
+ List l = s.getElementModel();
+
+ ElementModel em = (ElementModel) l.get(0);
+
+ List rules = em.getRules();
+
+ PushContentRule rule = (PushContentRule) rules.get(0);
+ }
+
+ /** @since 1.1 */
public void testPrivateServicePoint() throws Exception
{
ModuleDescriptor md = parse("PrivateServicePoint.xml");
1.1 jakarta-hivemind/framework/src/test/hivemind/test/parse/PushContentRule.xml
Index: PushContentRule.xml
===================================================================
<?xml version="1.0"?>
<!--
Copyright 2004, 2005 The Apache Software Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<module id="hivemind.test.parse" version="1.0.0">
<configuration-point id="Config">
<schema>
<element name="frankfurt">
<rules>
<push-content/>
</rules>
</element>
</schema>
</configuration-point>
</module>
1.26 +3 -0 jakarta-hivemind/src/documentation/content/xdocs/links.ent
Index: links.ent
===================================================================
RCS file: /home/cvs/jakarta-hivemind/src/documentation/content/xdocs/links.ent,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- links.ent 28 Feb 2005 12:42:01 -0000 1.25
+++ links.ent 25 May 2005 09:55:23 -0000 1.26
@@ -137,6 +137,9 @@
<!ENTITY _push-attribute '<push-attribute>'>
<!ENTITY push-attribute '<link href="&projectroot;rules.html#push-attribute">&_push-attribute;</link>'>
+<!ENTITY _push-content '<push-content>'>
+<!ENTITY push-content '<link href="&projectroot;rules.html#push-content">&_push-content;</link>'>
+
<!-- Entities for common services and configurations. -->
<!ENTITY object-reference '<link href="site:hivemind.ObjectProviders">object reference</link>'>
1.11 +7 -0 jakarta-hivemind/src/documentation/content/xdocs/rules.xml
Index: rules.xml
===================================================================
RCS file: /home/cvs/jakarta-hivemind/src/documentation/content/xdocs/rules.xml,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- rules.xml 19 Feb 2005 17:57:40 -0000 1.10
+++ rules.xml 25 May 2005 09:55:23 -0000 1.11
@@ -164,6 +164,13 @@
</table>
</section>
<section>
+ <title>push-content</title>
+ <p>The &_push-content; rule reads the content, converts it with the content
+ translator, and pushes the result onto the stack. It will typically be
+ combined with a &invoke-parent; to get the pushed value added to the
+ configuration point elements (or to some parent object).</p>
+ </section>
+ <section>
<title>read-attribute</title>
<p>The &_read-attribute; rule reads an attribute from the current
element, optionally translates it (from a string to some other type),
1.3 +554 -80 jakarta-hivemind/src/documentation/content/HiveMind-QuickReference.doc
<<Binary file>>
1.1 jakarta-hivemind/framework/src/test/hivemind/test/rules/TestPushContentRule.java
Index: TestPushContentRule.java
===================================================================
// Copyright 2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package hivemind.test.rules;
import org.apache.hivemind.impl.ElementImpl;
import org.apache.hivemind.internal.Module;
import org.apache.hivemind.schema.SchemaProcessor;
import org.apache.hivemind.schema.rules.NullTranslator;
import org.apache.hivemind.schema.rules.PushContentRule;
import org.apache.hivemind.test.HiveMindTestCase;
import org.easymock.MockControl;
public class TestPushContentRule extends HiveMindTestCase
{
public void testPushContentRule()
{
MockControl control = newControl(SchemaProcessor.class);
ElementImpl element = new ElementImpl();
element.setElementName("myelement");
element.setContent("${flintstone}");
PushContentRule rule = new PushContentRule();
SchemaProcessor mockProcessor = (SchemaProcessor) control.getMock();
mockProcessor.getContentTranslator();
control.setReturnValue(new NullTranslator());
mockProcessor.getContributingModule();
MockControl moduleControl = newControl(Module.class);
Module mockModule = (Module) moduleControl.getMock();
control.setReturnValue(mockModule, 2);
mockModule.expandSymbols("${flintstone}", element.getLocation());
moduleControl.setReturnValue("FLINTSTONE");
mockProcessor.push("FLINTSTONE");
mockProcessor.pop();
control.setReturnValue("FLINTSTONE");
replayControls();
rule.begin(mockProcessor, element);
rule.end(mockProcessor, element);
verifyControls();
}
}
1.140 +1 -0 jakarta-hivemind/status.xml
Index: status.xml
===================================================================
RCS file: /home/cvs/jakarta-hivemind/status.xml,v
retrieving revision 1.139
retrieving revision 1.140
diff -u -r1.139 -r1.140
--- status.xml 18 May 2005 21:26:44 -0000 1.139
+++ status.xml 25 May 2005 09:55:23 -0000 1.140
@@ -43,6 +43,7 @@
<action type="update" dev="HLS" due-to="Vjeran Marcinko"> Much improved CSS for HiveDoc. </action>
<action type="fix" dev="HLS" fixes-bug="HIVEMIND-119"> Distribution .zip doesn't contain project directory </action>
<action type="add" dev="HLS"> Show counts of configuration points, service points and schemas in HiveDoc. </action>
+ <action type="add" dev="KW" fixes-bug="HIVEMIND-126" due-to="Richard Hensley"> New <push-content> rule added. </action>
</release>
<release version="1.1-beta-1" date="Apr 29 2005">
<action type="fix" dev="JC" fixes-bug="HIVEMIND-108" >Bean services could not be autowired into other services.</action>
1.1 jakarta-hivemind/framework/src/java/org/apache/hivemind/schema/rules/PushContentRule.java
Index: PushContentRule.java
===================================================================
// Copyright 2005 The Apache Software Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package org.apache.hivemind.schema.rules;
import org.apache.hivemind.Element;
import org.apache.hivemind.schema.Rule;
import org.apache.hivemind.schema.SchemaProcessor;
import org.apache.hivemind.schema.Translator;
/**
* A rule that reads the element's content, passes it through the content translator, then pushes
* the result onto the processor stack.
*
* @since 1.1
* @author Knut Wannheden
*/
public class PushContentRule extends BaseRule implements Rule
{
/**
* Uses the content translator to convert the element content into an object and pushes that
* object onto the processor stack.
*/
public void begin(SchemaProcessor processor, Element element)
{
Translator t = processor.getContentTranslator();
String value = RuleUtils.processText(processor, element, element.getContent());
Object finalValue = t.translate(
processor.getContributingModule(),
Object.class,
value,
element.getLocation());
processor.push(finalValue);
}
/**
* Invokes {@link SchemaProcessor#pop()}.
*/
public void end(SchemaProcessor processor, Element element)
{
processor.pop();
}
}
1.14 +6 -0 jakarta-hivemind/framework/src/java/org/apache/hivemind/ant/RegistrySerializer.java
Index: RegistrySerializer.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/ant/RegistrySerializer.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- RegistrySerializer.java 29 Apr 2005 07:40:56 -0000 1.13
+++ RegistrySerializer.java 25 May 2005 09:55:23 -0000 1.14
@@ -55,6 +55,7 @@
import org.apache.hivemind.schema.rules.CreateObjectRule;
import org.apache.hivemind.schema.rules.InvokeParentRule;
import org.apache.hivemind.schema.rules.PushAttributeRule;
+import org.apache.hivemind.schema.rules.PushContentRule;
import org.apache.hivemind.schema.rules.ReadAttributeRule;
import org.apache.hivemind.schema.rules.ReadContentRule;
import org.apache.hivemind.schema.rules.SetModuleRule;
@@ -578,6 +579,11 @@
rule.setAttribute("attribute", par.getAttributeName());
}
+ else if (r instanceof PushContentRule)
+ {
+ PushContentRule pcr = (PushContentRule) r;
+ rule = _document.createElement("push-content");
+ }
else if (r instanceof ReadAttributeRule)
{
ReadAttributeRule rar = (ReadAttributeRule) r;
1.52 +20 -0 jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/DescriptorParser.java
Index: DescriptorParser.java
===================================================================
RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/DescriptorParser.java,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- DescriptorParser.java 29 Apr 2005 07:40:57 -0000 1.51
+++ DescriptorParser.java 25 May 2005 09:55:23 -0000 1.52
@@ -42,6 +42,7 @@
import org.apache.hivemind.schema.rules.CreateObjectRule;
import org.apache.hivemind.schema.rules.InvokeParentRule;
import org.apache.hivemind.schema.rules.PushAttributeRule;
+import org.apache.hivemind.schema.rules.PushContentRule;
import org.apache.hivemind.schema.rules.ReadAttributeRule;
import org.apache.hivemind.schema.rules.ReadContentRule;
import org.apache.hivemind.schema.rules.SetModuleRule;
@@ -497,6 +498,12 @@
return;
}
+ if (elementName.equals("push-content"))
+ {
+ enterPushContent(elementName);
+ return;
+ }
+
if (elementName.equals("set-parent"))
{
enterSetParent(elementName);
@@ -1137,6 +1144,19 @@
elementModel.addRule(rule);
}
+ private void enterPushContent(String elementName)
+ {
+ ElementModelImpl elementModel = (ElementModelImpl) peekObject();
+
+ PushContentRule rule = new PushContentRule();
+
+ push(elementName, rule, STATE_NO_CONTENT);
+
+ checkAttributes();
+
+ elementModel.addRule(rule);
+ }
+
private void enterSubModule(String elementName)
{
ModuleDescriptor md = (ModuleDescriptor) peekObject();
---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org