Archive for February, 2007

Choosing the right cache

Wednesday, February 28th, 2007

My friend Piotr asks me about cache. Truly I can’t suggest him any cache. So I decided to compare cache libraries.

Nomination in alphabetical order:

Cache4j

Cache4j is very simple cache. Its have three cache algorithms LFU, LRU, FIFO. It’s fast and small. There is no English documentation (there is Russian one). There’s no JMX. Configuration is simple (algorithm, idle time, max memory, time to live). In my opinion if you search simple cache maybe WhirlyCache be better one. For enterprise this one is unusable. Last version 0.4 from 2006.03.09 says for itself.

EhCache

Once oscache losing power, ehcache is stronger. Last version is from 26 February 2007. Once again “2007 February 26″. There is JMX support for statistic and for configuration. Great! Ehcache has many configuration options, good performance. It has also very good site documentation, works with hibernate. It’s good choice. Keep going

JCS (Java Caching System)

Ok, Jakarta project. Last distro was 5 months ago, not so bad. Version 1.2.9.2. Many configuration options, documentation is ok. This cache allows plugin. In distro we have memory, disk, lateral and remote plugin. No JMX but we have admin servlet. In my opinion we can forget about this cache mechanism now.

JBossCache

This one as Ehcache is also alive. Last version (2.0.0.ALPHA2) was released on 2007 January. Good professional support. There is perfect documentation. It is extremely configurable, it has
JMX support and there is POGO caching by annotation and AOP. In my opinion this is very good choice.

JCache

On the beginning it’s not so good. Last version 1.0-beta6 released two year ago. Let’s see performance page. Faster than hashmap, it’s amazing, but after that of course 2005 so it’s tested on java 1.4 (1.4.2_05-b04). What else, we see great milestones. For example in 1.2 there will be JMX support. Ok I think that this is enough, another dead cache system.

OSCache

This one includes jsp tag library for caching regions of web pages. As a cache it’s rather slow. No JMX, and last version 2.3.2 from 07.23.2006, that’s minus. I think opensymphony are too busy (webwork and struts integration). It’s ok, but a little bit old.

ShiftOne

Good cache system. We achieve FIFO, LRU, LFU algorithms. What is very important we have JMX with some statistics and also hibernate integration. From JMX you can get some statistics. But as many cache systems last update was three years ago, it’s not so bad because of version 2.0, but you know world are changing.

SwarmCache

The most deadly project I have ever seen. In news section we read that 1.0RC2 was released at 10.25.2003. The one interesting think is that this cache is distributed. In my opinion it is scrap, no stable release for three and half a year.

WhirlyCache

It’s very simple, fast in memory cache. It has a plugin for hibernate. It has plugin mechanism and one very interesting feature Cacheable key interface, which allows you to use as function hook on remove, store and retrieve action. Maybe it is not for enterprise but it is ok form home use. It’s nearly dead project, version 1.0.1 released on May 2006.

In my opinion for serious use we should consider JBossCache or Ehcahe. For home made simple caches I suggest you WhirlyCache. If I forget about some cache system please post comment.

Regards

Technorati Tags: ,

The saga about Hibernete.

Saturday, February 24th, 2007

I’ve borrowed book about hibernate. So naturally i want share my experiences with You.

Today we focused on JMX and Hibernate.

Hibernate has two MBean. HibernateServiceMBean which allows you to modify hibernate settings and StatisticsServiceMBean which expose hibernate statistics.

Using jconsole you can change settings, for example you can tell hibernate to write queries to console (very usefull), enabling and disabling cache, setting JDBC parameters, and even changing database access parameters. It is possible to change on the fly all parameters you can set in hibernate.cfg.xml config file.

The second MBean allows you to find out about statistic. So you know about cache hits, entities and collections operations such as fetch, load, remove etc. You can turn on statistic gathering or when you finish you can turn it off.

When you are seeking ORM problems in your application this two MBean are extremely helpful.

I’ve got so much post as drafts, and have no time to finished them. So for now I suggest you to try this MBeans with your application by adding -Dcom.sun.management.jmxromote and running jconsole.

Good luck.

Technorati Tags: ,

WJUG 5

Tuesday, February 20th, 2007

Five Warsaw Java User Group meeting is the past.

Jacek shows us Seam. I found it very attractive. Last week I’ve try seam. It’s worth trying.
JBoss guys close java EE world to new trends such RoR or Django. Their also add few nice features.

Ok it’s late, and the seam’s posts will come.

Flex2 on the board

Sunday, February 18th, 2007

Today my family went to kids-play. The children has unimaginable power. My wife is sleeping now, and I’m nearly sleeping too.

Introduction to Flex

Flex is based on adobe flash technology. Flex applications consist of MXML and ActionScript source files. For easy development you can try for 30 days Flex Builder. Flex Builder is built on Eclipse so everyone who use eclipse is familiar with. There are also Flex Data Service (integration with EJB, Hibernte, JMS and other data sources) and Flex Charting (charts).

The one hour ride on Flex.

Creating application is easy part. You have graphical designer where you layout components. It’s very similar to Swing application building. There is also event-listener mechanism. All properties You can set by properties editor, it’s very comfortable.

The heart of every application is MXML file. This is a normal XML file, which flex can convert on the fly to swf. The flex builder has very good mxml editor, it provides hints and auto-completes your code. Builder has a very good debuger, so you can easy debug your code to find out what’s going on.

You can create customer components and reuse it whenever you need. I think that you can find useful components on the web.

And finally flex has many WebService/XML integration. It’s very easy to create application connection to WS. For example, this code is a flex blogger reader from tutorial. This application connect to flex blog, read last post and shows them in table view.

The code:

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml”
layout=”absolute” creationComplete=”feeder.send()”>
<mx:HTTPService
id=”feeder”
url=”http://weblogs.macromedia.com/mchotin/index.xml”
useProxy=”false”/>
<mx:Panel title=”{feeder.lastResult.rss.channel.title}” x=”10″ y=”10″ width=”475″ height=”400″ layout=”absolute” >
<mx:DataGrid x=”20″ y=”20″ id=”posts” width=”400″
dataProvider=”{feeder.lastResult.rss.channel.item}“>
<mx:columns>
<mx:DataGridColumn headerText=”Posts” dataField=”title”/>
<mx:DataGridColumn headerText=”Date” dataField=”pubDate” width=”150″/>
</mx:columns>
</mx:DataGrid>
<mx:TextArea x=”20″ y=”175″ width=”400″ htmlText=”{posts.selectedItem.description}”/>
<mx:LinkButton x=”20″ y=”225″ label=”Read Full Post”
click=”navigateToURL(new URLRequest(posts.selectedItem.link));”/>
</mx:Panel>
</mx:Application>

The HTTPService object is responsible for getting posts. It simple get HTML page. Next we can access DOM objects. In our example rss.channel.title and channel.item (this one is a collection). It’s very easy.

Summary of Flex

+ Rich user interface
+ Eliminate page loads
- Depends on Adobe Flash 9
- Flex Builder is not free, building without builder is not easy than.

Seam or not to seam

Friday, February 16th, 2007

Today is a titan worker day. Karwer and I have killed nearly all tasks in 1.9.2.

For long time I waited for Seam exploration. I read Jacek fights with seam and application servers. He provides simple seam 5 minutes tutorial startup.

1. Get JEMS Installer 1.2.0.GA.
2. Get JBoss Seam 1.1.6.GA.
3. Install JBoss AS 4.0.5.GA with EJB 3.0

java -jar ./jems-installer-1.2.0.GA.jar -installGroup ejb3 installpath=

4. Unzip seam.
5. Run seam setup
6. create project seam


7. Run JBoss AS and you’re done.

After that you have:

* project structure with ant build.xml
* EJB 3.0
* TestNG with JBoss Embeddable EJB3
* JSF template
* Database (HSQL) integration
* You have simple login form (which works)

Directory structure, I’m disappointed, because it’s no maven like. You have netbeans project, if you use eclipse or idea you have got a problem. It’s ant, so you have 32M lib directory.

I think than seam wants to show that he can generate more than RoR (by the way, django way ;) ).

So seam guys suggested use netbeans, no problem. Downloaded, installed and … everything is fine. Netbeans is better and better. Maybe it’s time to look closer on it. We’ll see. I going back to seam.

Technorati Tags: ,

about me

My name is Sebastian Pietrowski. I've finished Warsaw University as Master degree. I started my journey with Java 1.1 with Thread and JDBC programing in 1998 as I worked for merlin.pl. In 1999 I've passed Java Programer Certificate for Java 1.2, and was solution architect of merlin.pl infrastructure when we was moving from pl/sql to J2EE. It was great performance optimization with 10 times more req/sec than in requirements and 85 times faster as original solution.

Currently I work as Expert Software Development Java at F.Hoffmann-La Roche. The company was founded in 1896 and today, Roche employs over 80.000 people. After work I'm involved in activities related to Scala/Lift, Ruby/Rails/Merb, Python/Django. This is because I try to be pragmatic also I'm focused on application performance and tuning with success in my daily work.

My Yoda's motto: Do, or do not. There is no try.