You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Ivanhoe Abrahams <iv...@gmail.com> on 2010/01/03 18:02:06 UTC

Modularization question, fragments.

Hi all

I have been playing around with Drools 5.0.1 running as a service in
Felix/Karaf.
I finally got it working using a very simple HelloWorld drools example (BTW
this is also my first stab at using Drools, so I'm no expert on that
framework).

What I ended up with was.
1. A bundle that starts/initializes the Drools service and exposes a method
which allows clients to call the Rules engine service.
2. A domain Model bundle
3. A fragment bundle which imports the exported packages from the domain
model bundle, as well as supplying the .drl file (which is the rules
engines' rule base)
4. A client bundle which imports the exported packages from the model
bundle.

The client then creates a model object, and calls the Drools service bundle
to execute the simple test.
The Service bundle is also the fragment-host for the fragment bundle. So in
that way it knows about the domain model, without explicitly declaring a
dependency on it.

So my question is. Does the above seem right?
I have seen a couple of posts where the use of fragments are discouraged.
But I am not sure how to cleanly achieve  the above scenario without
fragments.

Also what bugs me about my solution above is that, since the Drools rules
engine does some bytecode enhancement. I eventually had to add import
package statements to the bundle which contains the domain model. This just
seems wrong because my Service bundle already imports packages from the
underlying rules engine.

So basically the question is, are there better ways to achieve above
modularization.
How does one write a service, which needs to operate on some domain model,
but without knowing what those domain models will be beforehand.

Thankyou in advance
Ivanhoe

Re: Modularization question, fragments.

Posted by Ivanhoe Abrahams <iv...@gmail.com>.
Thanks Stuart

I am still a bit new to OSGI, I dont get much time to play around with it,
so I hope the complexities of classloading in an OSGI environment does not
overwhelm me, nevertheless the article seems quite well written, I will have
a more in depth look into it

Thanks again

Ivanhoe


On Sun, Jan 3, 2010 at 6:17 PM, Stuart McCulloch <mc...@gmail.com> wrote:

> 2010/1/4 Ivanhoe Abrahams <iv...@gmail.com>
>
> > Hi all
> >
> > I have been playing around with Drools 5.0.1 running as a service in
> > Felix/Karaf.
> > I finally got it working using a very simple HelloWorld drools example
> (BTW
> > this is also my first stab at using Drools, so I'm no expert on that
> > framework).
> >
> > What I ended up with was.
> > 1. A bundle that starts/initializes the Drools service and exposes a
> method
> > which allows clients to call the Rules engine service.
> > 2. A domain Model bundle
> > 3. A fragment bundle which imports the exported packages from the domain
> > model bundle, as well as supplying the .drl file (which is the rules
> > engines' rule base)
> > 4. A client bundle which imports the exported packages from the model
> > bundle.
> >
> > The client then creates a model object, and calls the Drools service
> bundle
> > to execute the simple test.
> > The Service bundle is also the fragment-host for the fragment bundle. So
> in
> > that way it knows about the domain model, without explicitly declaring a
> > dependency on it.
> >
> > So my question is. Does the above seem right?
> > I have seen a couple of posts where the use of fragments are discouraged.
> > But I am not sure how to cleanly achieve  the above scenario without
> > fragments.
> >
> > Also what bugs me about my solution above is that, since the Drools rules
> > engine does some bytecode enhancement. I eventually had to add import
> > package statements to the bundle which contains the domain model. This
> just
> > seems wrong because my Service bundle already imports packages from the
> > underlying rules engine.
> >
>
> FYI, this article discusses bytecode enhancement in OSGi
>
>   http://www.infoq.com/articles/code-generation-with-osgi
>
> which might provide some hints or alternative solutions
>
> So basically the question is, are there better ways to achieve above
> > modularization.
> > How does one write a service, which needs to operate on some domain
> model,
> > but without knowing what those domain models will be beforehand.
> >
> > Thankyou in advance
> > Ivanhoe
> >
>
> --
> Cheers, Stuart
>

Re: Modularization question, fragments.

Posted by Stuart McCulloch <mc...@gmail.com>.
2010/1/4 Ivanhoe Abrahams <iv...@gmail.com>

> Hi all
>
> I have been playing around with Drools 5.0.1 running as a service in
> Felix/Karaf.
> I finally got it working using a very simple HelloWorld drools example (BTW
> this is also my first stab at using Drools, so I'm no expert on that
> framework).
>
> What I ended up with was.
> 1. A bundle that starts/initializes the Drools service and exposes a method
> which allows clients to call the Rules engine service.
> 2. A domain Model bundle
> 3. A fragment bundle which imports the exported packages from the domain
> model bundle, as well as supplying the .drl file (which is the rules
> engines' rule base)
> 4. A client bundle which imports the exported packages from the model
> bundle.
>
> The client then creates a model object, and calls the Drools service bundle
> to execute the simple test.
> The Service bundle is also the fragment-host for the fragment bundle. So in
> that way it knows about the domain model, without explicitly declaring a
> dependency on it.
>
> So my question is. Does the above seem right?
> I have seen a couple of posts where the use of fragments are discouraged.
> But I am not sure how to cleanly achieve  the above scenario without
> fragments.
>
> Also what bugs me about my solution above is that, since the Drools rules
> engine does some bytecode enhancement. I eventually had to add import
> package statements to the bundle which contains the domain model. This just
> seems wrong because my Service bundle already imports packages from the
> underlying rules engine.
>

FYI, this article discusses bytecode enhancement in OSGi

   http://www.infoq.com/articles/code-generation-with-osgi

which might provide some hints or alternative solutions

So basically the question is, are there better ways to achieve above
> modularization.
> How does one write a service, which needs to operate on some domain model,
> but without knowing what those domain models will be beforehand.
>
> Thankyou in advance
> Ivanhoe
>

-- 
Cheers, Stuart