And what will happen to any FactType objects out there? Or the Class<?>
objects derived from them? Will it be safe to continue to use the object
returned by KnowledgeAgent.getKnowledgeBase() which is documented to return
a "cached KnowledgeBase"?

Whoa!
-W



2011/2/14 Mark Proctor <[email protected]>

>  On 14/02/2011 18:10, Edson Tirelli wrote:
>
>
>     The current version of Drools does not support dynamic changes in "type
> declarations" and I don't see this changing anytime soon. The reason is that
> not only the actual fact would require changes, but the actual knowledge
> base would require changes as several nodes might be referencing the old
> class.
>
>     So, to update a fact type you need to recreate the knowledge base.
> This is the same, BTW, than changing one of your fact classes in your
> application jars... you need to recompile the knowledge base or you will end
> up with class cast exceptions, sooner or later.
>
> Longer term there are two ways to achieve this
> 1) type declarations can only be modified if there is no data on them and
> the existing rules are still valid after the change, i.e. it will not effect
> the current state.
>
> 2) If ther eare existing facts a migration script must be provided that
> handles the mapping as all beans would need to be copied to the new type
> declaration.
>
> Mark
>
>
>      Edson
>
> 2011/2/14 delete <[email protected]>
>
>>
>> Hi.
>> I have such declaration of type
>> declare Contact
>>  firstName : String
>> end
>>
>> then I want to add new property to this type. so the  next version is
>> declare Contact
>>  firstName : String
>>  newField : String
>> end
>>
>> this type declaration is in separate drl file.
>> then I add this new type to current KnowledgeBase.
>> but when I execute knowledgeBase.getFactType("test.package", "Contact");
>> I get old version of Contact.
>>
>> During debugging I found the place where is should be upgraded in the
>> KnowledgeBase.
>> org.drools.common.AbstractRuleBase.mergePackage
>> there is
>> // merge the type declarations
>>        if ( newPkg.getTypeDeclarations() != null ) {
>>            // add type declarations
>>            for ( TypeDeclaration type :
>> newPkg.getTypeDeclarations().values() ) {
>>                // @TODO should we allow overrides? only if the class is
>> not
>> in use.
>>                if ( !pkg.getTypeDeclarations().containsKey(
>> type.getTypeName() ) ) {
>>                    // add to package list of type declarations
>>                    pkg.addTypeDeclaration( type );
>>                }
>>            }
>>        }
>>
>> so according this comments it's not possible to upgrade Type on the fly.
>>
>> Am I missing something?
>> Does someone had such problems or know the workaround.
>>
>> Thanks in advance,
>> Yuriy
>>
>> --
>> View this message in context:
>> http://drools-java-rules-engine.46999.n3.nabble.com/Type-Declaration-upgrade-tp2491975p2491975.html
>> Sent from the Drools - User mailing list archive at Nabble.com.
>> _______________________________________________
>> rules-users mailing list
>> [email protected]
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
>
>
> --
>   Edson Tirelli
>   JBoss Drools Core Development
>   JBoss by Red Hat @ www.jboss.com
>
>
> _______________________________________________
> rules-users mailing 
> [email protected]https://lists.jboss.org/mailman/listinfo/rules-users
>
>
>
> _______________________________________________
> rules-users mailing list
> [email protected]
> https://lists.jboss.org/mailman/listinfo/rules-users
>
>
_______________________________________________
rules-users mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/rules-users

Reply via email to