JBoss Drools - Infinite Recurrsion

March 8th, 2008

Drools, interesting name for a software isn’t it? Clever and catchy.

When JBoss changed their name from Drools to Rules Engine and back to Drools with the release of 4.0. I personally like this name. So anywayz, today I wanted to talk about something I’ve been struggling with. I’ve been using Drools 3.0.6 with FileNet Workflow system.  The rule I’ve implemented requires to modify certain value of an objects’ field within the working memory several times before spitting out the result.  With Drools 3.0.6, I’ve encountered infinite recurrsion when modifying the objects’ value.

I’ll step back for a bit and explain my situation.

The rule I have consists of multiple Agenda groups to control the rules flow.  Each agenda group contains its’ own activation group to fire one and only one rule from its’ group.  The salience is provided to control the execution order.  At any given point in the agenda groups, based on the business need, rules may need to modify the value of the fact and re-enter the working memory. The working memory does not automagically know of this changed values unless you implement the Property Change Listener.  So, in such case, after you set the value to an object, you must call modify(object); in the consequence (THEN) portion of the rule.

In the inner workings of the working memory, when Modify helper method is called, working memory will cancel any activated rule and re-enter the working memory.  Now, technically, you could set rules attribute, NO-LOOP to true and have the rule which called the Modify method not to be re-evaluated.  However, after looking at the audit log, I’ve noticed something interesting.  Everytime a Modify method is called from a rule, it does infact cancels any activated rule before re-entering the working memory. Once re-entered, the rule which called the Modify is infact not activated. However, if other rules call modify, it re-enters the working memory and reactivates any rules that matches.  NO-LOOP isn’t taken into account when reactived. 

I hope this explains my situation a bit.

Based on this, I’ve decided to come up with a “Hack”.  The business requirements I am using know when to end the rules evaluation.  If an incoming object contains certain values, rules engine should fired that rule and end the rules evaluation.  In FileNets’ term, it’s called “Dispatch Work Item”, as in send it to next step in the workflow process. 

I got lukcy in this sense.  So, in order to get rid of this, “POSSIBLE DEFECT” in drools, I implemented a very simple solution.  When the working memory is ready to Dispatch the incoming object, you “Retract” the object from the working memory.  The action of Retract cancels the entire activated list of rules.

If any of you “Droolers” encountered such behavior with Drools 3.0.6, please let me know of your solution.

 Happy Drooling!


Destination Wedding Invitation

February 18th, 2008

A new project was handed to us to come up with an invitation idea for a destination wedding for a friend of ours. We made the Save the Date card for them few months ago. They are having their wedding at Dreams Cancun, a wonderfully decorated resort in Cancun, Mexico. I’ve heard some other couple have done a unique destination wedding invitation where they created an invitation that looks like Airline ticket. The invitation resembled an airline ticket and was enclosed in airline folder which you get when you check in. Very cool idea!

For them we decided to go one step further. We are going to create invitation that specifically represents their fun loving personality as well as their wedding destination.  NO, we are not sending “PinYaTa” with invitaiton inside… although that would make an interesting invitation.

This invitation will be a Message in the Bottle. The message being the invitation. Pretty cool uh?
The invitations will be printed in high qulaity papers and we’ll burn the edges to make it more authentic.  Sands and empty sea shells will be stored in side along with beach scent.

We are in the process of purchasing the materials for this project. The final product will definately be unqiue to them. 

Stay tuned for the update on this project and yes folks, you’ve heard it here first, at AnJoeDesign~


Dave & Gina’s Wedding website is up

February 13th, 2008

It’s been a long journey but I’ve finally deployed the first version of Dave & Ginas’ wedding website. 

Dave & Gina

I’ve taken a different approach to this website during development. I wanted to try new way of displaying information with Flash. I’ve gotten comfortable using normal Flash usage so with this version, I’ve used external component and integrated music player. This is the first time I tried scene based flash movie.

External Component:

I’ve spent about two to three weeks trying to figure out book flip animation. I’ve gotten the basics from different sites but couldn’t get the actual thing to work. Finally I ran out of time so I ended up purchasing a book flip component from Flipping Book. These guys have really done their homework and created extremely flexible and useful flash component. If you are familiar with Flash, it’s very easy to implement.  I would highly recomment this site for anyone who wishes to add book flip animation to their website.

I’ve used this component as Photo scrap book and story book. It fits the context very well.

Music Player:

I’ve done previous Flash with background music but never adding a player with user selectable music player.  Tiago wrote a very informative blog about creating XML driven flash music player. If anyone is interested in adding fancy music player, I’d highly recommend this blog.

Dave & Gina selected five songs that represents them. The music player loads the music real time. It’s a slick implementation.

I still have lot of work left but it’s slowing down. I can’t say I’m proud of this site but I’m happy with it. The layout design could have used some work and inspiration.  Perhaps on my next release, I may play around with integrating Video. That’d be interesting.

Hope you guys would use these resources. I cerntainly found them extremely useful.


When your design goes wrong…

January 30th, 2008

I’ve recently finished up a Flash website for a bowling alley. I’m not good when it comes to design but I do ok. Every site I make, I see improvements and work towards filling the gap which existsed in the previous designs. The site which I completed and gotten approved for by the client with high remarks, has recently been replaced by another layout. He had the site up for 2 months. Check out what has become of the website for yourself. www.usbowlingva.com. Please keep in mind, the layout you see is NOT, NOT what I intended on. This was my original site which I delievered to him.

After I saw this, I called my client numerous times and with no luck of conversation, I’ve left a message:

“Hello, I’ve noticed that you’ve changed the design layout of your site fairly quickly. Please let me know if you have any questions or concerns regarding previous design.”

The client paid good money for it I’d like to make sure he gets what he paid for. Am I being a little bitch by leaving him such message? It hurts me to see the site take a turn for the worst. If its’ HTML only website he wants, I’d like to make it for him for free. I know I’m not the greatest designer in the world but I can make far better site than THAT!!!!!


Page Flip Part II

December 18th, 2007

Oh man, I am running out of time. I think I’ll hold off on this until I can figure it out. Since I do have a deadline to meet, I’ve decided to go with Flipping Book. It cost $25 for one website use and it comes with pretty good documentation.  I’d definately recommend this Flash Component if you need to use it.

It’s not over yet! I will figure this book flip out and share it with the world!!!!


Accessing Hibernate Table Mapping Document

December 4th, 2007

My current job decided to build web based database maintenance system using Struts and Hibernate. The table mapping document xml file, which I will refer to it as “table config file”, basically contains most of the information you’d want about your database. So instead of creating another configuration, I’ve decided to find out if there is a way to access them programmatically in Java. XML configuration elements that I was interested in was the column name and Javabean method name.  Here is an example of table config file:

<hibernate-mapping>
   <class name=”com.myPojo” table=”MY_TABLE_NAME”>
       <property name=”FirstName” type=”string” column=”FIRST_NAME”/>
       <property name=”LastName” type=”string” column=”LAST_NAME”/>
   </class>
</hibernate-mapping>

the property “name” attribute refers to your mapping POJO’s method. In my example above, myPojo.java will have getter and setter methods defined as “getFirstName(), setFirstName(), getLastName(), setLastName()”.

What I’m interested in is the value of name attribute and value of column attribute. Here are the Java code that will access the values

I’ve created a Configuration object called config by calling “new Configuration().configure();”

Value of “column” attribute:

  1. Get the PersistentClass object:
    PersistentClass pc = config.getClassMapping(myPojo.class.getName());

  2. Get the Table object from the PersistentClass object you just got:
    Table tbl = pc.getTable();

Once you have the table object, you can get the list of defined column names using this syntax:
Iterator it = tbl.getColumnIterator();

Value of “name” attribute:

  1. Get the Component object out using similar code syntax:
    Component cmp = config.getClassMapping(myPojo.class.getName()).getKey();

  2. Get the Property iterator:
    Iterator it = cmp.getPropertyIterator();

  3. You can access the value of name attribute by casting each items in the iteratory with Property calss.
    while (it.hasNext()) {
         ( (Property) it.next() ).getName();
    }

I know this is all that of a new information but I found this extremely helpful. I hope you guys find this info helpful as well.

As always, using Hibernate API documentation is awesome!

Happy coding guys.


Flash Page turn effect: Part 1

November 26th, 2007

The coveted page turn effect. I’ve always wanted to try it and my current project is going to allow me to do so. On my previous post, Bride, Groom and Website~!, I mentioned the O’Reilly website describing the page turn effect. I’ve been following the post and here is what I have so far.

Page Turn Practice sample 1

There are few things I had to twick around for this example

  • When you work on this, you will come across a state where page movie clips’ text layer will prematurely show while the page is turning. 
    If this happens to you, simply right click on the text panel and make sure your font isn’t using device font as anti alias option.
  • Understand the action script being used. (I am certainly trying to understand it myself so that I can manipulate it.
  • The original tutorial apparently only goes up to 5 pages and you can’t flip back page unless you are at the last page. (I am still trying to find the solution for this)
  • The auto turn is not part of the tutorial but the discussion board on the site seem to have a work around (I am still trying to find the solution to this as well)

On my next post, I will have something more advanced then the sample above and share the flash file for everyone to use.


Slow down

November 8th, 2007

Slow Down

Photo by Annie, San Francisco 2007 (Artesa Vinyard)


Wine under $20 - Bray Vineyards 2004 Sangiovese ($15)

November 4th, 2007

We found this wine from our vacation to the wine country past week. Bray Vineyards is one of many wineries closely located to eachother in Sacramento, about 75 miles northeast of San Francisco.  They have great wines under $20 which was a surprise to me. While Napa Valley was charging $20 just to go through the tasting, these guys were offering free wine tasting and great tasting wine under $20.

Their 2004 Sangiovese has become our newest favorite. Sangiovese is the grape that brings Chianti to life. It is the red-wine grape of Tuscany. A bit acidic but when combined with great cheese, the wine takes the taste buds to the next level. The bottle should be fused with air for atleast 20 min or so. Use decanter if you have it but if not, let it get happy a bit after opening the bottle.

This award winning wine from Shenandoah Valley CA takes our pick as wine of the week. We’ve enjoyed it so much that we ordered two additional bottles to be shipped to our hotel to take back home. Unfortunately, they do not ship to Virginia.

If you like this wine, I’d also recommend 2005 Brayzin Hussy Red, blend of Zinfandel and Saniovese. I asked how they came up with the name and they said “A Lot of drinking!”.


Random Thoughts about Web

November 4th, 2007

I read an article on Communication Arts magazine written by Patrick Coyne. He compiled various interviews with leading creative directors. There was a statement that triggered my train of thoughts. 

 “The Web has become center point of most campaigns because it’s a place to really emotionally connect with consumers” -Jason Zada

Isn’t it amazing? Marketers use web to “Emotionally” connect with consumers. They use it as medium to reach consumers. Ok. That makes totoal sense. To me, this statement means that marketers view web as representation of us, the consumers. When I read this phrase by Jason Zada, an image came to my head. The industry represented by one human, looking at the thousands of copy/pasted consumers with their heads as a computer monitor.  The concept is bi-directional. As consumers, we “Emotionally” connect with businesses through the web. Newspapers, T.V. Commercials, magazines have become secondary. I’d assume people spend about 60% of their day online through work and web enabled cell phones. That leaves 40% of day to be divided up for traveling (To and From work), dinner, tending to kids (Ok This is a bit extreme), watching T.V. or reading a newspaper.  No wonder marketers are using Web to “Emotionally” connect with consumers

The reason I decided to write this random post is this. I feel like a Robot. SiFi movies show emotionless robots finding emotion through interaction with humans. Don’t you find it odd that humans are finding emotion through a robot?