[
https://issues.jboss.org/browse/JBRULES-2993?page=com.atlassian.jira.plug...
]
Edson Tirelli commented on JBRULES-2993:
----------------------------------------
This problem is fixed, but please note:
Due to the need of supporting backward compatible metadata that could be written without
"", the current behavior is adopted:
1. The system will try to resolve the annotation value as an MVEL expression.
1.1. If it succeeds, the result value is returned.
1.2. If it does not succeed, the original content will pass-through as a String.
2. As of 5.2, the old non-quoted syntax for annotation values is deprecated. Needs
documentation.
3. As of 5.2, multi-valued annotations for rules are not supported yet, but this is a
desirable feature for 5.3
Examples:
{code:title=Bar.java|borderStyle=solid}
@Test
public void testRuleAnnotation() {
String drl = "package org.drools\n" +
"rule X\n" +
" @author(\"John Doe\")\n" +
" @output(Hello World!)\n" + // backward compatibility
" @value( 10 + 10 )\n" +
" @alt( \"Hello \"+\"World!\" )\n"
+
"when\n" +
" Person()\n" +
"then\n" +
"end";
KnowledgeBaseConfiguration conf =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
conf.setOption( EventProcessingOption.STREAM );
conf.setOption( MBeansOption.ENABLED );
KnowledgeBase kbase = loadKnowledgeBase( "kb1",
drl,
conf );
Rule rule = kbase.getRule( "org.drools",
"X" );
Assert.assertEquals( "John Doe",
rule.getMetaData().get( "author" ) );
Assert.assertEquals( "Hello World!",
rule.getMetaData().get( "output" ) );
Assert.assertEquals( 20,
((Number)rule.getMetaData().get( "value"
)).intValue() );
Assert.assertEquals( "Hello World!",
rule.getMetaData().get( "alt" ) );
}
{code}
Metadata escapes
----------------
Key: JBRULES-2993
URL:
https://issues.jboss.org/browse/JBRULES-2993
Project: Drools
Issue Type: Bug
Security Level: Public(Everyone can see)
Affects Versions: 5.2.0.M2
Reporter: Tomáš Schlosser
Assignee: Edson Tirelli
Fix For: 5.3.0.CR1
I have a rule:
package org.jboss.qa.drools.bugfixes
rule "hello world"
@output("\"Hello world!\"")
when
then
System.out.println("Hello world!");
end
And a piece of code:
System.out.println(getKnowledgeBase().getRule("org.jboss.qa.drools.bugfixes",
"hello world").getMetaData().get("output"));
and the result is:
""Hello world!""
while I expect same result as in 5.1:
"Hello world!"
--
This message is automatically generated by JIRA.
For more information on JIRA, see:
http://www.atlassian.com/software/jira