Thoughts about java, ruby, agile and other every developer stuff.

Saturday, February 24, 2007

The saga about Hibernete.

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: ,

Tuesday, February 20, 2007

WJUG 5

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.

Sunday, February 18, 2007

Flex2 on the board

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.


Friday, February 16, 2007

Seam or not to seam

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: ,

Thursday, February 15, 2007

Django tutorial finished

Yep it's finished.
In my opinion django is worth knowing. It's easy as RoR, but you always have control about what's going on.

You must watch out about python syntax it's sometimes not obvious that you have one space extra and code doesn't work.

Last part of tutorial was about forms it normal, I think.

I'm going sleep now. Today I challenge with performance.

I think I won, becouse I really do so many improvements, but Lucene index is about 1Gb and performance still don't satisfied me.

Tomorrow I'm going to won this battle.

Wednesday, February 14, 2007

Django 3rd day

Now Django has no chance. After admin panel my expectation are very high.

But once again I was wrong.

Today tutorial 4, I didn't achieve tutorial 4 because i play basketball and I've got appointment tomorrow about 7 a.m.

OK, URL managing, in my opinion it's better than RoR because you have full control about it. For example

(r'^polls/(?P<poll_id>\d+)/$', 'mysite.polls.views.detail'),


Means that django all URL that matches regular expression

r'^polls/(?P<poll_id>\d+)/$'


Sends to module mysite.polls.views and call detail() function like

detail(request=<httprequest>, poll_id='23')


Next, tutorial shows how to write views, template. Finally it shows us a shortcuts. Yeah the functions from django.shortcuts boosts developing speed.

The last part of tutorial before me, and I'm thinking about topic of application to write, yet another blog is too easy for django and it's admin module. So please suggest me something.

Regards
Pedro


Technorati Tags: ,

Django admin rulez

Holly dolly

After I generate django project there was so little files. All Ruby on Rails
script directory is in manege.py, setting in settings.py quit simple.
Four files, it amazing.

Today I've got some time to look at tutorial2. And I don't believe it, just can believe, the django admin application is marvelous. I don't know what to say, it's perfect. Even RoR ajax_scaffold is nothing special compared to django admin.
I Can't even write here what I saw. Definitely everyone should see this. Great Job.

And to be honest this confusion was before I read about templates and css possibilities.

What is certain, I follow tutorial3, and definitely I wrote some application in django. Tomorrow I will fighting with bottlenecks, so I'm going to rest to be prepared.


Technorati Tags: ,

Sunday, February 11, 2007

Django first meeting ;)

Ok I finished bootstrap meeting. It's time to look at django framework. Some years ago I try python, and I think it's worth knowing. Let's see django.

Django requires python 2.3+ so I check my machine.

pedro@pedrowaty: ~ -V
Python 2.4.4

Bingo. Let's follow installation instruction, get django tarball.

pedro@pedrowaty: ~ wget http://www.djangoproject.com/download/0.95.1/tarball/
tar xzvf Django-0.95.1.tar.gz
cd Django-0.95.1
sudo python setup.py install

Also I read that this don't work with python 2.5, luckily I’ve got 2.4.4 ;)

Next I followed this instruction

I follow this tutorial 1 and what can I say? It's easy as RoR. So the trip just begin, I couldn't do my test app with this framework because of my home-life. But I’m sure the next meeting is coming as quick as possible.

Friday, February 09, 2007

Mavenization Idea

Finally, we did it. Our project was gained maven nature. The process of conversation is NOT so simple, as I thought when I started. I share my experiences during this migration.

Mavenize your project structure

It is possible to make maven work with your actual project structure, but as I know now, the first maven rule is "Don't fight with maven”.

When structure is mavenized your entire project looks the same way, and of course you find resources there where you suppose too.

Move your webapp part to src/main/webapp. In this directory you should have all the stuff going to web archive.

The hardest is how to separate java files which should be in src/main/java and java resources such properties, validations, and other stuff which should be in src/main/resources. In our company we have a tool which makes this for us. You can write yours, or use shell utils such as find, awk, and grep.

Next move all your ant stuff (properties, libraries) exclude build.xml to src/test/deprecated. Finally you should have clear maven Standard Directory Layout. For further information visit maven SDL site.

Useful tools

Without tools you are naked ;). When you want make maven SDL you must use tools. Of course when you don't want keep your versions control history you can do it just by deleting all files, moving them to SDL structure.

find - your first friend with -exec parameter.
sed & awk - sometimes we must rename path (for example sed 's/main/test/' in.file >out.file)
grep - it's always useful

When you work on windows, my suggestion is : if you don't have cygwin, install it. Build generate.sh file with UNIX tools, which generate for you bat files. Run it in windows command shell and go for coffee brake.

Keep your build.xml alive

The most important task is modifying build.xml file to work with new file structure. When you do this, you can switch to maven structure when all your team is on the lunch. Second maybe more important, if you want have time to make another step, prepare good how to switch work from previous structure to maven way. IT'S THE MOST IMPORTANT. And remember it must be easy and complete. Test it, and at least one another person should test it.

Write your pom

Its easy part, write task from beginning to end, and don’t forget to tell someone to test it, because you may have special setting, which won't work in another environment. Once you finish and check that pom.xml makes everything as build.xml. You should once again write proper documentation how to replace old task the new one. Makes profiles with filters.

Watch out, maven doesn't recognize that you filtering filter. In this case he hangs on resource:resource phase depends on configuration.
And it is not obvious to catch this. So be careful.

Finally kill deprecated

At least after all this steps, you can kill deprecated directory. First libs I think, next the rest. Ok one thing if you run in trouble I suggest use -X option. Than you should live long and peacefully.

Pedro

Tuesday, February 06, 2007

Strange, I survived

This day is the most nervous day in my life. First mavenization started, after commit we realized that where are some web-guys. which have problems to run tomcat and other stuff, so we want rollback and than SVN refuse to cooperate with us.

I fight with time seeking another solutions. As it was not enough, our product manager arrived. And this day my presentation starts at 6 pm. Nightmare!!!.

Suddenly I looked outside the window, and to my surprise the sun goes out of the clouds. Michal comes back, and said that we don't rollback. So I think to myself maybe this day is not so bad.

My Ruby on Rails presentation on wjug meeting close ruby and java worlds, I hope so. Maybe one day we stand together on the 'right' side, we'll see. And maybe we make our conference.

Next post mavenization is nearly ready, today I'm to tired to post it.

Pedro

Friday, February 02, 2007

Mavenization Holded


Eh, life isn't fair. Two minutes before final commit mavenization was canceled, so I must put on hold my mavenization post. Next time Gadget next time.

On the other hand I prepare for wjug presentation on Tuesday; it's about ruby on rails. I'm afraid a little because java vs. ruby evangelism. In my opinion java programmer can teach so much from ruby ones, and maybe in java 7 or 8 we see some ruby like syntax.

I will talk about Ruby, Rails and of course new template engine HAML, it’s beautiful, and I think another posts counting keystroke are coming.

See you.