Fairy Tale of the Fruit Tree
This is a reprint of a fantasy authored by Yutaka Kachi and translated by Mikiko Kachi. Originally from http://www.catch.jp/openoffice/whats_oss/index_en.html.
I am reprinting it because it is only available through PDF. I want to share it and make it easier to read and comment on. I found it in 2005 and saved the PDF. I found the the file this morning and thought it would be good to share and discuss.
Long long time ago, there was a tree in a field of grass near a village. One day, this tree bore a lot of delicious fruit.
The fruit were very delicious. So villagers soon harvested all of the fruits.
There was no end to the number of people who cut branch of this tree and take them home.
Because of this, the tree died in a few years.
In the village, there was a clever merchant. He grafted the tree before the tree died.
And he fertilized the tree, cut off branch when it’s too much. He took care of the tree for a long time.
Then the tree bore fruit. He sold it and made big money.
He was a real worrier. He fenced around the tree and was always watching the tree.
This merchant was not just an worrier, but also a hard worker.
His effort made the fruit more delicious and a lot of people bought it.Some people delivered it to busy villagers, and some people made jam from the fruits and sold it.
The merchant monopolized the fruit tree.
When someone said to him “ there are many worm holes ” , he heard nothing of it and said “ It’s cheap so you can’t complain that.”
When someone asked him “ do you use any harmful fertilizer?”
he said “ it’s company secret” and wouldn’t answer that question.When someone offered him “ I’d like to buy branch”, he said “ I don’t want to have competitors” and rejected the offer.
More and more people started to sell the fruit and more and more people bought it.
Then the merchant increased the price and made a big profit.
In this village, there was a young man who really loved this fruit. When the merchant increased price of the fruit, he couldn’t afford it any more because he was very poor.
So, he got interested in another tree near the village. This tree also bore a lot of fruit, but its taste was not so good and no one had cared for it. The young man started taking care of it with his friends.
Therefore, the tree bore more fruit than they could eat. So they put up a sign board that said “ Free”. There were some people who take the fruit away although they didn’t take care of the tree, but the young man didn’t mind at all.
The young men kept making effort for years to improve taste of the fruit as much as possible. Some people who took the fruit said “ I will help you”, “I will help you too because we don’t want to kill this tree like the first one” and helped doing time-consuming works.
The more people helped, the more people took the fruit. When the fruit run short, the people grafted the tree to grow more. They put up “ Free” sign boards on new trees also.
Some people delivered the fruit, and some people made jam from the fruit. They were very cooperative and sometimes they pay for agricultural equipment, fertilizer and inviting specialists to get advise.
So they reduced warm holes, improved the taste of the fruit, and their fruit became much more popular.
Years later, many fruit trees were planted around the village and bore a lot of delicious fruit.
The villagers started delivering the young men’s fruit together to far-off town. In that town, many people said “I’ve never had such a delicious fruit !” and the fruit became popular. It sold like hot cakes.And not only the young man but also his friends and villagers all became happy.
By the way, what happened to the merchant who monopolized the fruit tree?
His business was also going well. For only a short while he had a fewer customers, but he expanded his business by hiring many people, shipping the fruits to far-off town, buying up fruit trees which had grown in other villages, etc.
There was no difference between the young man and the merchant in terms of making delicious fruit.
This is a great, simple explanation of how open source works and why the model it is successful. Growing a fruit tree is relatively easy compared to writing software, but as software development tools get easier to use, and more people learn to write code, it was and is inevitable that the number of open source tools and the quality of those tools will increase.
There are two more PDFs that talk around open source licensing at http://www.catch.jp/openoffice/whats_oss/index_en.html.

Anonymous 2:49 pm on May 24, 2008 Permalink
Thanks.
Anonymous 2:49 pm on May 24, 2008 Permalink
thanks a lot! code is better than 1000 blog post!
Mike 2:50 pm on May 24, 2008 Permalink
Too true. I hate going to software blogs and seeing nothing but paragraph after paragraph. I want to see code that I can copy and paste, that has comments in it so that I can follow it.
Glad I could help. Cheers.
cookie 2:51 pm on May 24, 2008 Permalink
Hi Mike,
Kudos on the great explanations and examples.
I am a newbie to Spring (as well as Java
). I have a question regarding OpenSessionInViewInterceptor/ Filter.
I have a Spring app that only selective controllers requires open sessions. Can I selectively “hook-up” the interceptor to those controllers?
Thanks a lot.
YS
Anonymous 2:51 pm on May 24, 2008 Permalink
For those of you using the Persistence API, there is also an EntityManager version:
org.springframework.orm.jpa.support.OpenEntityManagerInViewInterceptor
Thanks for your example, Chris
PS I would put an example – but seems the comments box does not allow it
weggyboy 2:52 pm on May 24, 2008 Permalink
Nice Post, but it only works for views, doesn´t it?
I was trying to change some entries after the proposed changes and found out, that the write operations are not allowed with the default session setting for the openViewInSession filter.
After searching for a solution I´ve found that:
import org.springframework.orm.hibernate3.support.OpenSessionInViewFilter;
import org.hibernate.*;
import org.springframework.dao.*;
public class SessionFilter extends OpenSessionInViewFilter {/*
* The default mode is FlushMode.NEVER
*
* @see org.springframework.orm.hibernate.support.OpenSessionInViewFilter#getSession(net.sf.hibernate.SessionFactory)
*/
protected Session getSession(SessionFactory sessionFactory)
throws DataAccessResourceFailureException {
Session session = super.getSession(sessionFactory);
session.setFlushMode(FlushMode.COMMIT);
return session;
}
/**
* we do an explicit flush here just in case we do not have an automated flush
*/
protected void closeSession(Session session, SessionFactory factory) {
session.flush();
super.closeSession(session, factory);
}
}
Now it works as wished!
delta one 2:53 pm on May 24, 2008 Permalink
Excellent example!
Dan Allen 3:21 pm on May 24, 2008 Permalink
You should read Spring in Seam, Part 3 (http://www.javaworld.com/javaworld/jw-05-2008/jw-05-spring-seam3.html) and chapters 8 and 9 of Seam in Action to discover why this Spring filter/interceptor is essential a huge *hack*. The persistence manager (Hibernate Session/JPA EntityManager) was designed to be extended across a series of requests, not be relegated to a single request or worse service layer call. LazyInitializationExceptions happen because the persistence manager is scoped incorrectly.
David Newcomb 12:28 pm on October 12, 2009 Permalink
Your xml for urlMapping is incomplete! No value is set for:
and the property is closed. What is it supposed to be?
David Newcomb 12:29 pm on October 12, 2009 Permalink
Your xml for urlMapping is incomplete! No value is set for:
property name=”mappings”
and the “property” is not closed. What is it supposed to be?
David Newcomb 1:51 pm on October 12, 2009 Permalink
Also urlMapping doesn’t work if you are using annotations.
If you are using annotations you should probably go for the OpenSessionInViewFilter otherwise there is a rats nest of other support classes you need. Just spent the day reading all about it and I have lost the will to live
Mike 9:25 am on October 13, 2009 Permalink
@David Newcomb – The post isn’t really about how to set mappings. But you’ll want something like
which maps a request URI to a controller. Here are some examples…
http://www.google.com/search?q=SimpleUrlHandlerMapping+example
Pieno 7:52 am on July 11, 2010 Permalink
In Spring 3 you can use the tag to use the OpenSessionInViewInterceptor. There is an example on my blog: http://www.pieno.be/content/2010/opensessioninviewinterceptor-example-spring-3-web-mvc