Davide,

 

Thanks for your responses and for re-opening the JIRA.

 

Although I get warnings about accessing FieldDefinition and AnnotationDefinition due to restriction on the drools-core-5.4.0.Final.jar library, it does work to cast FactField to FieldDefinition and use its methods to access the AnnotationDefinitions.

 

Regarding your other suggestion, I was able to use Java reflection to get the FactType annotations (factType.getFactClass().getAnnotations()). However, I was not able to use Java reflection to obtain the field annotations. I successfully used factType.getFactClass().getDeclaredFields() to get the Fields. But then using field.getClass().getAnnotations() on each Field did not return any annotations. Using the debugger, I can see that the factType.definedClass.declaredFields.referent[0].annotations variable is not null and is null for referent[1] and referent[2] where each referent is a Field. I do not know how to interpret the contents of the Field’s annotations variable, but at least it is not null for the first Field which seems correct since I have a DRL field annotation on the first field and not on the next 2.

 

Thanks again for your help.

Phil

 

From: Davide Sottara [via Drools] [mailto:[hidden email]]
Sent: Thursday, August 23, 2012 1:29 PM
To: Courtney, Phil
Subject: Re: Accessing FactField Metadata

 

Phil,
also consider that getDefinedClass().getAnnotations() will give you the >>JAVA<< annotations.
Any custom Drools metadata which is not mapped into a java annotation (e.g. @role) will not
be visible from there.


If you reply to this email, your message will be added to the discussion below:

click here.
NAML



View this message in context: RE: Accessing FactField Metadata
Sent from the Drools: User forum mailing list archive at Nabble.com.