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"?<br>
<br>Whoa!<br>-W<br><br><br><br><div class="gmail_quote">2011/2/14 Mark Proctor <span dir="ltr"><<a href="mailto:mproctor@codehaus.org">mproctor@codehaus.org</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div text="#000000" bgcolor="#ffffff">
On 14/02/2011 18:10, Edson Tirelli wrote:
<blockquote type="cite">
<div><br>
</div>
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.
<div>
<br>
</div>
<div> 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.</div>
</blockquote>
Longer term there are two ways to achieve this<br>
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.<br>
<br>
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.<br>
<br>
Mark<br>
<blockquote type="cite">
<div><br>
</div>
<div> Edson<br>
<br>
<div class="gmail_quote">2011/2/14 delete <span dir="ltr"><<a href="mailto:boyun.yuriy@gmail.com" target="_blank">boyun.yuriy@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
Hi.<br>
I have such declaration of type<br>
declare Contact<br>
firstName : String<br>
end<br>
<br>
then I want to add new property to this type. so the next
version is<br>
declare Contact<br>
firstName : String<br>
newField : String<br>
end<br>
<br>
this type declaration is in separate drl file.<br>
then I add this new type to current KnowledgeBase.<br>
but when I execute knowledgeBase.getFactType("test.package",
"Contact");<br>
I get old version of Contact.<br>
<br>
During debugging I found the place where is should be
upgraded in the<br>
KnowledgeBase.<br>
org.drools.common.AbstractRuleBase.mergePackage<br>
there is<br>
// merge the type declarations<br>
if ( newPkg.getTypeDeclarations() != null ) {<br>
// add type declarations<br>
for ( TypeDeclaration type :<br>
newPkg.getTypeDeclarations().values() ) {<br>
// @TODO should we allow overrides? only if
the class is not<br>
in use.<br>
if ( !pkg.getTypeDeclarations().containsKey(<br>
type.getTypeName() ) ) {<br>
// add to package list of type
declarations<br>
pkg.addTypeDeclaration( type );<br>
}<br>
}<br>
}<br>
<br>
so according this comments it's not possible to upgrade Type
on the fly.<br>
<br>
Am I missing something?<br>
Does someone had such problems or know the workaround.<br>
<br>
Thanks in advance,<br>
Yuriy<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://drools-java-rules-engine.46999.n3.nabble.com/Type-Declaration-upgrade-tp2491975p2491975.html" target="_blank">http://drools-java-rules-engine.46999.n3.nabble.com/Type-Declaration-upgrade-tp2491975p2491975.html</a><br>
Sent from the Drools - User mailing list archive at
Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</font></blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
Edson Tirelli<br>
JBoss Drools Core Development<br>
JBoss by Red Hat @ <a href="http://www.jboss.com" target="_blank">www.jboss.com</a><br>
</div>
<pre><fieldset></fieldset>
_______________________________________________
rules-users mailing list
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a>
</pre>
</blockquote>
<br>
</div>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br>