Joseph,
Concerning the KieSession, here is the response :
What is the difference if I create a session on KieContainer vs KieBase
(Global, Local List ...) ?
there shouldn't be any difference. the possibility of creating a session
from a KieContainer is just a shortcut. under the hood it retrieves the
KieBase in which that KieSession has been defined (or build it if you're
using it for the first time) and then creates the KieSession from there
Regards,
On Fri, Jan 24, 2014 at 8:38 AM, Charles Moulliard <ch007m(a)gmail.com> wrote:
Hi Joseph,
1. I need to rebuild the rules on the fly, so I was using examples from
the IncrementalCompilationTest.java
<
https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test...
>
to accomplish that task. However, those tests don't use a classpath
container... can I still rebuild a KieModule via runtime code when running
in a classpathContainer?
>> My example uses this META-INF/kmodules.xml file to let the
KieContainer to scan and discover the resources (.drl, pacjkages) when we
call
KieContainer kcont = ks.newKieClasspathContainer(getClass().getClassLoader());
KieBase kbase = kcont.getKieBase("sampleKBase");
As you have mentioned in your email, this is a static approach as we load the resources
before to create a KieSession and fire the rules.
To be able to do increment, the approach that you mention is the way to go. I have also
created an example where the KieModule is created using a programming approach -->
*https://github.com/cmoulliard/droolsjbpm-osgi-examples/blob/master/simple-external-resource/src/main/java/org/drools/example/osgi/FetchExternalResourceOsgiActivator.java
<
https://github.com/cmoulliard/droolsjbpm-osgi-examples/blob/master/simple...;.
That should not be difficult to adapt it to support increment*
2. Your example code calls .newKieSession() on a kbase object as opposed
to
a kContainer object. Is there a reason why? If I create a new KieSession
from a kbase vs. kContainer, will I still be able to rebuild the kjar
dynamically in the code and keep using the same stateful session?
I need that Mario Fusco or Marc Proctor confirm what I will say here (or
somebody) else but I suspect that if you create a session on the
KieContainer level and not on the KieBase could allow you to support
increment as this unit test show you (
https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test...)
without having to recreate a new session (stateless)
3. It looks like I'll have to wait until Drools 6.1.0 to get the parameter
to specify a classloader when creating the container? I see you just added
that recently. I've tried using
Thread.currentThread().setContextClassLoader(...) but can't seem to make
that work with Drools 6.0.1 in Karaf 2.3.3 because then
RuleBaseConfiguration sets the classloader and uses it to try resolving
org.drools.core.conflict.DepthConflictResolver, which it can't do because
it's no longer using the OSGi classloader.
>> I have no ideas if my modifications will be merged with 6.0.x release.
Mario Fusco should be able to provide a response
Regards,
On Thu, Jan 23, 2014 at 6:01 PM, jhusby <husby024(a)umn.edu> wrote:
> I actually looked through your example project yesterday; very helpful!!!
> However, there are a few things I'm not sure are compatible with what I'm
> trying to do.
>
> 1. I need to rebuild the rules on the fly, so I was using examples from
> the IncrementalCompilationTest.java
> <
>
https://github.com/droolsjbpm/drools/blob/master/drools-compiler/src/test...
> >
> to accomplish that task. However, those tests don't use a classpath
> container... can I still rebuild a KieModule via runtime code when running
> in a classpathContainer?
>
> 2. Your example code calls .newKieSession() on a kbase object as opposed
> to
> a kContainer object. Is there a reason why? If I create a new KieSession
> from a kbase vs. kContainer, will I still be able to rebuild the kjar
> dynamically in the code and keep using the same stateful session?
>
> 3. It looks like I'll have to wait until Drools 6.1.0 to get the
> parameter
> to specify a classloader when creating the container? I see you just
> added
> that recently. I've tried using
> Thread.currentThread().setContextClassLoader(...) but can't seem to make
> that work with Drools 6.0.1 in Karaf 2.3.3 because then
> RuleBaseConfiguration sets the classloader and uses it to try resolving
> org.drools.core.conflict.DepthConflictResolver, which it can't do because
> it's no longer using the OSGi classloader.
>
> Thank you,
>
> Joseph
>
>
> Charles Moulliard-2 wrote
> > Hi Joseph,
> >
> > I propose that you have a look to this example which is currently
> working
> > on Karaf -
https://github.com/cmoulliard/droolsjbpm-osgi-examples(simple
> > =
> > OSGI BundleActivator + KieSession + Drools Rules)
> >
> > Regards,
> >
> > Charles
>
>
>
>
>
> --
> View this message in context:
>
http://drools.46999.n3.nabble.com/kContainer-newKieSession-fails-in-Apach...
> Sent from the Drools: User forum mailing list archive at
Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>
--
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :
http://cmoulliard.github.io
--
Charles Moulliard
Apache Committer / Architect @RedHat
Twitter : @cmoulliard | Blog :