Archive for April, 2008

Steven Colbert… Don’t try to beat Koreans.. We OWN YOU!

Tuesday, April 29th, 2008

Need I say More?

We RULE… That’s right… No matter how GAY Rain might be… We still Win

hahahahaha

I actually checked out the 1ist of the 100 most influential people of the year pole
and Steven Colbert is number 2, trailing “Rain” by about 190000 votes.
NOT BAD…

Here is something to think about…

The most influential people in our lives these days are Entertainers…. Hum… 

Drools 3.0.6 - Serialize compiled Rules

Friday, April 25th, 2008

I’ve finally figured a way to serialize the compiled rules for real time deployment. I’ve been struggling with serialization using Drools 3.0.6 for a while now. I’ve been told that many of bugs surrounding compiled rule object serialization has been fixed for later versions of Drools. Matter a fact, the process of serializtion completely changed from Drools 4.x and above.

For those of you still using Drools 3.0.6, (I wouldn’t be surprised If I am the only one) here is a sample way of going about it.

First, serializing RuleBase object is still out in Drools 3.0.6. It still complains about a class that doesn’t exists with release of Drools 3.

Way to go about it is to serialize the package. I’ve experienced class loader issues when serializing Package objects for prior releases of Drools, specifically Drools 3.0.5 and below. Drools 3.0.6 seem to have fixed these class loader issues.

When you compile rules, DRL or DRL/DSL, it produces a package object. These packages are added to RuleBase object through RuleBaseFacotry and finally, an instance of working memory is created. Out of the three step process, compiling the rules is the most memory intensive.  So serializing packages is where you will save most time and enhance performance. 

Before you start writing codes, be sure all your rules related java objects implements java.io.Serialize. But I’m sure you knew that already. =)

Using Eclipse IDE with Drools plugin, compile the rules and serialize the packages to Direcotry of your liking. Here is an example:

FileInputStream fsDrl = new FileInputStream(”myDrl.drl”);
FileInputStream fsDsl = new FileInputStream(”myDsl.dsl”);

Reader drl = new InputStreamReader(fsDrl);
Reader dsl = new InputStreamReader(fsDsl);

PackageBuilder buildPkg = new PackageBuilder();
buildPkg.addPackageFromDrl(drl, dsl);

Package pkg = buildPkg.getPackage();

The above code will give you the compiled package object of DRL and DSL. You can proceed on to serializing this package object using standard java serialize process. Here is an example:

File pkgFile = new File(”myPkgOut.out”); //the file name can be anything of your choice.
FileOutputStream fOut = new FileOutputStream(pkgFile);
ObjectOutputStream objOut = new ObjectOutputStream(fOut);
objOut.writeObject(pkg);
objOut.flush();
objOut.close();

Simple isn’t it? Reading in the serialized package is can be accomplished by using FileInputStream and ObjectInputStream available in standard Java.

Hope this helps anyone Drooling~

Trapped in the elevator for 41 hours!

Tuesday, April 22nd, 2008

HOLLY Crap!, Can you imagin being in the elevator for 41 hours?
By YOUR SELF?

I don’t know what I’d do if that was me.

Another free movie/T.V. show site~

Friday, April 18th, 2008

http://www.surfthechannel.com/

Yes… My coworker points out to me it’s Illegal, but who cares! The movies you see here maybe a bit off. I’m talking about Hand cam versions… Cool site.

 

Do you Hulu?

Friday, April 18th, 2008

www.hulu.com

One of my favorite site to watch movies and tv shows. Love this site. It can get a bit slow but who CARES! It’s Legal and it’s FREE!

Human Tetris…

Thursday, April 17th, 2008

I tell ya… I feel like Japanese folks have done everything and they are running out of ideas for T.V. shows… HUMAn TETRIS???? Who thinks of things like this?

Drools 3.0.6 - API compiler gone crazy.

Monday, April 14th, 2008

I’ve become very friendly with Drools 3.0.6. So friendly that I am beginning to have fights about eachothers faults.
This one is the newest one I found.

Long story short, I implemented usage of DSL with DRL.  This method made it easier on the non-technical people to read the rule files.  Syntactically, DRL needs to identify a proper DSL in order to work properly.  When I say “proper”, I mean existing file. Check out this example:

package rule.sample.anjoe

import anjoe.test.pojo1;

expander anjoeDsl.dsl

Above is the first three lines in my DRL file.  The “expander” keyword identifies which dsl mapping file is used for this DRL. Have you ever tried to put wrong DSL file name as the expander value? The Eclipse IDE will immidiately tell you that there is an error.  But what about when compiling the rules using the API in online application environment?

The standard java code is used to read in the DRL and DSL files from the file location using Reader object. You create new PackageBuilder object and call addPackageFromDRL method with two parameters; DrlReader and DslReader. As far as compiler is concerned, both DRL and DSL files needs to be valid without any errors.  If errors exists, like wrong DSL file name as expander value, the method call should fail. RIGHT? apparently NOT!!!!

When compiling the rules through JAVA API, as long as you pass in proper DRL and DSL reader object into the addPackageFromDRL method, it compiles and everything is honkie-dorie~

In Eclipse IDE, this is a no no for built in IDE rules compiler will bitch at you right away.

Has anyone come across this? Shoot me an email. joe@anjoedesign.com