This metadata is stored on the Rule itself:
Rule rule = // ...
Context ruleContext = rule instanceof Context ? (Context) rule : null;
Object origin = ruleContext.get(RuleMetadata.ORIGIN);
On 02/04/2015 08:24 PM, Ondrej Zizka wrote:
Hi,
it seems that the metadata is a bit scattered around the place.
A) Some metadata are at rules themselves, e.g. as returned by
getExecuteAfter().
B) Some are sunken into the dark depth of ~.rewrite.Context, like
rewriteCtx.put(RuleMetadata.CATEGORY, DEFAULT_CATEGORY);
However when I try to retrieve this,
Object cat = event.getRewriteContext().get(RuleMetadata.CATEGORY);
I get null.
So I debugged and found the data stored in a weird data structure,
context.map[WindupRuleMetadata].providersToRules[?RuleProvider][?].contextMap
So I was trying to get it out,
WindupRuleMetadata wrm = (WindupRuleMetadata)
event.getRewriteContext().get(WindupRuleMetadata.class);
Assert.assertNotNull("event.getRewriteContext()[WindupRuleMetadata.class] is
not null", wrm);
for(WindupRuleProvider provider : wrm.getProviders())
{
if(provider.getClass().equals(TestMetadataAnnotationExecRuleProvider.class))
continue;
provider.get
}
But here I got lost as there seems to be no API for providersToRules.
1) How can I get to the metadata?
2) I suggest to review where and how the metadata are stored and unify
it a bit.
Thanks,
Ondra
PS: I admit that I didn't look much around for some working usages of
metadata as I am going to sleep, but CATEGORY seems not to be used anywhere.
_______________________________________________
windup-dev mailing list
windup-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/windup-dev