Yes, this was a misunderstanding. Using .package as an extension with
the idea of so describing a file that only contains declared types is
unusual - such a file is also written in the DRL language (and I'd
give it the extension .drl, too).
It is the KnowledgeBuilder that needs to know about all the types it
encounters in rules. Try passing the DRL files containing the declared
types to the builder before you compile any rules. It should not
matter whether you load previously compiled packages with these types
followed by newly compiled packages using the same types into the
KnowledgeBase.
-W
On 13/09/2012, Paul Ryan <pryan(a)infotrustgroup.com> wrote:
Wolfgang,
Ok maybe I'm misunderstanding what .package is indented for. Yes I
understand how to deserialize a binary serialization of a KnowledgePackage.
Let me explain the problem and what I'm trying to solve.
The case is that we have rules spread out between many files (not known
until run time, these are then serialized and cached based on run keys and
reused). Note too that these files have a precedence order from a
programming perspective, not from a run perspective. The problem is in
adding declared types to be used by these rule sets at a lower level rule
(e.g. one that is more generic and more core). Then we put in a set of
specialization rules that also need to use this declared type, sometimes
this works but sometimes this won't compile because it says the type is not
declared. In eclipse we found that if we put a .package file with the
declared type in it then this specialization rule set compiles however we
can't figure out how to propagate this into the runtime KnowledgeBase. It
sounds like what your saying is that I made a wrong assumption. Is this kind
of thing not possible? Is there a different mechanism for these generic
types besides having them as pre-compiled java POJO's?
Example Rules Source:
I have a blah.drl like the following
package com.x
rule "A Thing"
when
then
Blah blah = new Blah();
blah.setX("123");
blah.setY("321");
System.out.println("X is " + blah.getX());
System.out.println("Y is " + blah.getY());
end
and I have a blah.package like the following
package com.x
declare Blah
x : String
y : String
end
Thanks,
-- Paul Ryan
On Sep 13, 2012, at 12:05 AM, Wolfgang Laun
<wolfgang.laun@gmail.com<mailto:wolfgang.laun@gmail.com>> wrote:
You have serialized a Collection of KnowledgePackage, so I trust you
know how to do the reverse. Then, you simple call
kBase.addKnowledgePackages( packages )
-W
On 12/09/2012, Paul Ryan
<pryan@infotrustgroup.com<mailto:pryan@infotrustgroup.com>> wrote:
I guess I should also mention that by default we are using the expert API's
so primarily we're creating the knowledge packages using a
KnowledgeBuilder.
Again thanks for any light you can shed on getting files with the extension
.package loaded into the knowledge base.
-- Paul Ryan
On Sep 11, 2012, at 4:59 PM, Paul Ryan
<pryan@infotrustgroup.com<mailto:pryan@infotrustgroup.com>> wrote:
So drools will respect files with a .package extension as a place for
declared types, functions, etc. when used with these in the class path.
How can a import these into a KnowledgePackage/KnowledgeBase so they can
get compiled along with stuff when this is not in the class path at
startup? My use case is such that these are not in the same space and
can't be loaded at startup time in most cases.
Any help is greatly appreciated,
-- Paul Ryan
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org<mailto:rules-users@lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org<mailto:rules-users@lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org<mailto:rules-users@lists.jboss.org>
https://lists.jboss.org/mailman/listinfo/rules-users