*DISCLAIMER: PLEASE NOTICE THAT THIS IS NOT RECOMMENDED, AND IN ANY CASE
SHOULD BE DONE WITH ***EXTREME*** CARE.*
This said, you need to create a KnowledgeBase passing a
RuleBaseConfiguration.
Take a look at RuleBaseConfiguration.getComponentFactory(), which returns a
ReteooComponentFactory.
This class controls the sub-factories used to build parts of the RETE
network. In particular, you will
need to hack the NodeFactory (guess what it does :))
So, in reverse order:
- Create a KnowledgeBase using a custom configuration
/KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase( rbc );/
- When you create the configuration, do not use the interface, but the
actual implementation
/RuleBaseConfiguration rbc = (RuleBaseConfiguration)
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();/
- Set a custom NodeFactory in the configuration
/rbc.getComponentFactory().setNodeFactoryProvider( myNodeFactory );/
- The nodefactory should extend the appropriate methods and returned
customized nodes.
For example, to hack the alpha nodes:
/org.drools.reteoo.builder.NodeFactory myNodeFactory = new
DefaultNodeFactory() {
public AlphaNode buildAlphaNode(int id, AlphaNodeFieldConstraint
constraint, ObjectSource objectSource, BuildContext context) {
return new MyAlphaNode( /* args from super constructor here */ );
}
};/
- Your custom nodes should add the desired behaviour. For example, the
custom AlphaNode
could override the "assertObject" method
( see :
https://github.com/droolsjbpm/drools/blob/master/drools-core/src/main/jav...
)
/
...
if ( isAllowed(...) ) {
...
} else {
// not present in the original
// here, a particular object failed to satisfy a given constraint
}
/
--
View this message in context:
http://drools.46999.n3.nabble.com/modify-and-update-is-not-working-in-the...
Sent from the Drools: User forum mailing list archive at
Nabble.com.