Hi,
what you are trying to do is potentially very dangerous. When you declare a
type, Drools (re)creates a class on the fly whenever the package is compiled
to be added to a knowledge base.
Adding a field and reloading the class implies that any previously
instantiated object (or even
rule pattern!) will no longer be compatible with the new instances.
So, I wonder if you must do it online at all... can't you just go and modify
the declared model?
Moreover, the way you are trying to apply the modifications to the
ClassDefinition is wrong.
Indeed you have added a field definition to the definition, but the engine
will not be aware of
this change by simply inserting the definition in some session.
You should either use very low level APIs to "patch" the knowledgebase or
pass a Resource containing
the updated definition to the knowledge agent.
But again, I would not recommend it unless you absolutely must do it
--
View this message in context:
http://drools.46999.n3.nabble.com/Dynamic-Fact-field-Generation-in-Declar...
Sent from the Drools: User forum mailing list archive at
Nabble.com.