Update: The plot thickens.
Sometimes when I'm importing my domain class in the rulesflow, it works, and
sometimes it does not.
This seems to be tied to the class loader that happens to be in the current
thread context. Sometimes it is
org.eclipse.core.runtime.internal.adaptor.ContextFinder and sometimes it is
another type. I don't know what class the 'other type' is because it
overrides Object's toString()and I was just doing
getClassLoader().toString(). I've changed it to
getClassLoader().getClass().getName() so I can see what the real object is
if it happens again
msully wrote:
So I'm playing with Drools in Equinox OSGi, and so far it's behaving quite
nicely - one bit of weirdness though.
What I'm trying to do:
I have a bundle with a 'flow manager' that listens for instances of
WorkItemHandler in the service broker (well, really my own subinterface
that has a getName method). It also listens for new bundles with a
META-INF/drools directory with *.rf files in them, and parses the .rf
files it finds there.
The Flow Manager is itself published as an OSGI Service with a 'perform'
method. It encapsulates all of its Drools calls within the perform method
though - they aren't exposed to clients.
My test involves a simple start->work item->end workflow.
I pass in an instance of a class "Tablex" that can be saved to hibernate.
I also pass in a String that has the table name, and an empty List to get
the results.
My .rf file tries to import Tablex. It declares the three values I
mention above, and maps them to the work item in the work item definition.
<p>
<imports>
<import name="my.pkg.Tablex" />
</imports>
...
<variable name="my.pkg.newrecord" >
<type
name="org.drools.process.core.datatype.impl.type.ObjectDataType"
className="my.pkg.Tablex"/>
</variable>
...
<workItem id="2" name="DBWorkItem" x="165"
y="374" width="80"
height="40" >
<work name="DBWorkItem" >
</work>
<mapping type="in" from="my.pkg.tablename"
to="my.pkg.tablename" />
<mapping type="in" from="my.pkg.newrecord"
to="my.pkg.newrecord"/>
<mapping type="in" from="my.pkg.outlist"
to="my.pkg.outlist"/>
</workItem>
</p>
In my manifest for my .rf file and for the flow manager (where the parsing
occurs) I Import-Package Tablex's package.
When my flow manager tries parsing the rule, it gives an error saying the
the import failed. BUT, everything still works, and my WorkItemHandler
works correctly (the WorkItemHandler imports Tablex itself, since it needs
to manipulate it).
If I declare my Tablex variable as a java.util.Object in the ruleflow then
I don't get the error and things also still work.
If I declare my Tablex as Tablex in the rule flow AND import it in the
class that does the parsing (it's already 'OSGI' imported to the parsing
bundle, but now I'm doing a plain old Java import on it) then everything
works fine with no error message.
Kind of a hybrid question but I figured I'd start with the Drools folks.
Any ideas would be appreciated.
Thanks,
Mike
--
View this message in context:
http://www.nabble.com/OSGI%2C-classloading%2C-and-imports-in-KnowledgeBui...
Sent from the drools - user mailing list archive at
Nabble.com.