Friday, September 30, 2005

Photos from a beautiful Calabria

A friend of mine has published a very nice photo set on Focus, an italian magazine.

The subject is a beautiful Calabria which I want to share with you .... here are some links:


http://www.focus.it/community/contr_new.asp?ID=10005


http://www.focus.it/community/contr_new.asp?ID=10009


http://www.focus.it/community/contr_new.asp?ID=10011


And my preferred one:



Take a look and if you want give them a vote!

Congratulations, Mario!

Thursday, September 29, 2005

An AJAX office suite

Yes, I say, everyone wants AJAX.

Yes, I say, AJAX usefulness in rich web application development is true: just in these days, for compatibility reasons, I turned off AJAX support from the web project I'm working on, which previously was AJAX-enabled, and I REALLY NOTICE the difference.

And yes, AJAX is very appealing for many developers (like me).

But my mind could never imagine this:



I'm a bit skeptical ... making an office suite is not a joke, in particular if you use javascript ... moreover, I have doubts also about its usefulness over standard office suites and pen drives for storing documents and bringing them around ... but may be interesting!

My best wishes to the development team (hoping will grown) .... have a good luck!

Tuesday, September 20, 2005

Unit testing DAO classes in the Spring Framework

One of the major claims of the Spring framework is its non-intrusiveness, which, among other things, permits to unit test all classes managed by the Spring container.

So, it is natural that I felt very surprised when yesterday my unit test failed two times while testing a DAO class, based on Hibernate and implemented with the HibernateDaoSupport class provided by Spring.

The first time, my unit test failed because I instantiated my DAO object directly through the no-arg constructor: no one set the Hibernate SessionFactory (normally injected by the Spring container), so this was the problem.
I solved the problem creating a SessionFactory into my unit test, and setting it into the DAO object, as I were the Spring container.

Big surprise, the unit test failed a second time, screaming for no TransactionManager found ... but there was no method for setting such a thing in the DAO object!

So, is the unit testability of Spring managed objects only valid for THAT objects NOT using DAO templates?

The answer is no, you can unit test also them.
In the case of Hibernate, simply create and set by yourself a SessionFactory, like said before, and avoid using Session objects directly into your DAO code.
Just use the template facilities, like the getHibernateTemplate().find(...) methods, or, if you must directly use Query or Criteria APIs, encapsulate the access to the Session in the HibernateCallback class provided by Spring, which automatically manages the session and its transactions.

More and more powerful, more and more lightweight.

Monday, September 19, 2005

Takk...



Simply beautiful.
No other words than these, because no human word can describe what art and creation are.

Friday, September 09, 2005

.... and come back.

There's always a come back, wherever you go you'll always end up coming back to same place, maybe this is our destiny, maybe this is our damnation, maybe our salvation.
It's like the sea ... what if the sea didn't come back towards earth?

So, this is my "come back".

I'm in Rome since Monday, but I've been very busy until today ...
First, my Linux box with Fedora Core 3 started going crazy .... maybe it wanted to stay on holiday? .... no, I must say this, maybe it didn't like some hazardous upgrades, but this is what I most like of Linux, having all the control ... even with the risk of messing up something.
So I had to reinstall Linux, in the form of SuSE Professional 9.3, restore my backups, recreate my development environment, and so on.
Then, I had to take a look at a lot of new mails and news (still in progress)....
And, last but not least, I had to realign myself with the interrupted work ....

Wow ..... very busy.
And I must say that, even if it still needs a lot of work for personalisation, my new SuSE Linux box looks very well and comfortable ..... take a look at this:



I have a lot of ideas and news that I want to share with you ..... as always, I hope to have the time for writing about them, too!

But I'll have.
I'll have.

Friday, August 19, 2005

Going away ....

Tomorrow I'll leave Rome, being away for two weeks.

I'll come back home, my, home, in Messina, Sicily, enjoying my family, my girlfriend, my friends, plus a lot of sun, sea and ... relax.
The right energy for continuing the already started work, and starting new exciting projects ...

I have a lot of ideas .... but they will wait for September.

Now, farewell.

And good night.

Monday, August 15, 2005

Time Out of Joint

"The time is out of joint. O, cursed spite,
That ever I was born to set it right!"

Hamlet, William Shakespeare


When I first read this, suddenly Hermann Hesse's "Steppenwolf" novel came to my mind.

This beautiful (and meaningful) novel talks about the crisis of a 48 year old man, Harry Haller, his conflicts with a world that he views as populated by people living meaningless lives, his frail belief in a "personal" world where knowledge and art are the only worthy things, and his difficult path towards a different (and more real) vision of life.

In the first pages, so, Harry is described as one of that few men who, born in a "wrong" time, like between two different eras, are able to feel all the contradictions and sufferings of their time and world.
A man born in a time out of joint, this makes me think.

But now, seeing what every day happens in our world, today, 15 August 2005, yesterday and tomorrow, I wonder if does really exist a "right" time, opposed to a "wrong" one ...
And I think that maybe it is always wrong, always "out of joint", and never, never, right.
And that only a few persons can feel this, living all the contradictions and sufferings of this condition and consciousness ... like Hamlet, like Harry.

Because there's no hope for the time to be right.

Thursday, August 04, 2005

Native support for binding "complex" properties in Cocoon Forms

This is a good news for all those Cocoon guys.

Cocoon Forms has now a "native" support for "complex" properties and JXPath factories.
Simply implement your JXPath factory, as shown in my previous post, and configure it in you binding, without adding any other class.

Take a look at this XML snippet showing a binding example:


<fb:context xmlns:fb="http://apache.org/cocoon/forms/1.0#binding"
path="/">

<fb:value id="name" path="name"/>
<fb:value id="surname" path="surname"/>

<fb:context path="residence" factory="com.example.AddressFactory">
<fb:value id="street" path="street"/>
</fb:context>

</fb:context>

As you can see, you must configure your factory class inside a "factory" attribute of an enclosing context element;
enclosed binding elements will automatically use this factory.

For using this new feature, you have to checkout the Cocoon revision 227024 or later, from:

http://svn.apache.org/repos/asf/cocoon/branches/BRANCH_2_1_X/

It is in development, but is almost stable.

Have a nice Cocoon coding!

Saturday, July 30, 2005

A strategy for binding "complex" properties in Cocoon Forms

First, a short introduction about the problem context.

Cocoon Forms provides a binding framework for both loading object properties into form widgets and saving form values into object properties.
This is done through the association of every form widget you want to bind, with a JXPath expression leading to a particular object property.
This is an XML snippet showing a binding example:

<fb:value id="name" path="name"/>
<fb:value id="street" path="address/street"/>

We associate the value of the "name" widget with the "name" property of some object passed by Cocoon control flow, and the "street" widget value with the "street" property contained by the object "address" property.
For bigger clarity, this is a code snippet for the object used in our binding example:

public class Person {
private String name;
...
private Address address;
...
}

And this is its Address property:

public class Address {
private String street;
...
}

The address property is a sort of "complex", or "composite", property.

The problem arises when you want to save form values into a Person object just created, which has a null address property: this will throw a JXPathException because the JXPath context used by Cocoon doesn't know how to create the address property.
So, the following binding:

<fb:value id="street" path="address/street"/>

Will not work.
And, like it, the binding of every complex property with a default null value.

Solutions?

A first one could be to set the address property to a new Address into the Person constructor or in Cocoon control flow, but this is very poor, because requires you to change the business code, or hack the control flow.

A better solution is to use JXPath factories and Cocoon custom binding.
Let me explain my idea.

First of all, create a JXPath factory for making Address objects; this is very simple:

public class AddressFactory extends AbstractFactory {

public boolean createObject(JXPathContext context, Pointer pointer, Object parent,
String name, int index) {

pointer.setValue(new Address());

return true;
}
}

The factory must be set in the JXPath context object, which will use the createObject() method for creating null properties, like "address" in our example (for additional details see the JXPath User Guide and its javadoc).

The question is: how to do that in Cocoon?
The answer is, you can guess it, in custom binding.

First, configure it:

<fb:custom id="street" path="." builderclass="com.example.JXPathConfiguratorFactory" factorymethod="makeConfigurator">
<fb:config relative="address/street" factory="com.example.AddressFactory"/>
</fb:custom>

JXPathConfiguratorFactory is the factory which will make JXPathConfigurator objects through its method "makeConfigurator".
It must be configured, through the "fb:config" element, with two attributes:

  1. The JXPath expression relative to the "path" attribute. In our example this is called "relative".
  2. The fully qualified class name of the JXPath factory (previously shown) to use, here called "factory".

Important: why do we need two different "path" and "relative" attributes?
The reason is that if you set the JXPath expression in the "path" attribute of the "fb:custom" element, Cocoon will try to create the path BEFORE calling the custom binding, causing the well known JXPathException.
So, we must set the "path" attribute to the current context path (which should be existent), and the "relative" path to the desired JXPath expression.

Finally, write the JXPathConfiguratorFactory, as you usually do, and the JXPathConfigurator:

public class JXPathConfigurator extends AbstractCustomBinding {

private Element config;

...

protected void doSave(Widget widget, JXPathContext context) throws Exception {

JXPathContext configContext = JXPathContext.newContext(config);
String relative = (String) configContext.getValue("@relative");
String factory = (String) configContext.getValue("@factory");

context.setFactory((org.apache.commons.jxpath.AbstractFactory) Class.forName(factory).newInstance());

context.createPathAndSetValue(relative,widget.getValue());
}
}

It will simply set the factory into the JXPathContext object, create the null property and set the widget value!

I think that this solution has mainly three advantages:

  1. Non-invasiveness : it doesn't require you to change business code or control flow, but only your binding configuration file.
  2. Reusable : AddressFactory can be used whenever you need a property of type "Address", and the JXPathConfigurator can be used with every JXPath factory.
  3. Simple.

I'd like to know your opinion and ideas.

And, as usual ... have a good coding!

Sunday, July 24, 2005

Me and AJAX

AJAX, Asynchronous Javascript And XML, is one of those acronyms you have surely read of in some web sites like TheServerSide or XML.com.
It is one of those technologies which rises a great hype, with everyone talking and talking about it.
However, I must admit, I've never read much about it, being too much absorbed by other technologies and ideas, and being a strong supporter of server-side code against client-side javascript.
So, as soon as I've seen its capabilities, I've suddenly got surprised.

How have I encountered it?

A few days ago, as usual, I was working with Cocoon Forms when, testing a form made by my colleague Ugo Cei, I noticed its great responsiveness in combo box dynamic loading and data validation. So, I started browsing the code and while talking with Ugo I've discovered that the high responsiveness was due to AJAX automatic support in Cocoon Forms.
This got my interest, in particular when I discovered that many services like Google Suggest are driven by AJAX.

"Amazing!" I said. "This is great!"

However, after a few hours, my anti-javascript nature began to threat me and my new friend, AJAX... I started to doubt about its support and behavior in different browsers like IE or Mozilla, and so about its real usefulness in production environments.

This led me to further documenting, reading a bunch of good articles which let me understand how AJAX really works: and well, I must say, my anti-javascript nature, this time, was wrong.

So, how does it work?

I'll do a very short description, because you can find a longer (and better) one in the good articles cited at the end of this post.

All the magic lies into a particular javascript object: XMLHttpRequest.
This object lets you, from javascript code, sending an asynchronous request to the server the containing page come from, and receiving an XML document which will be processed by a callback javascript function when the asynchronous request gets completed.
Asynchronous means that the client doesn't wait for the server response, and the web page remains responsive. Moreover, the server doesn't send the whole page, but only an XML document containing the information requested by the client, which will be processed by the callback function, updating data without page reloading.
Here is a step-by-step summary:

  1. The web page editor associates a javascript function to an event of an HTML control, say a combo box which, once selected, must fill a text field.
  2. This function, called when the user selects some item into the combo box, creates the XMLHttpRequest object which makes an asynchronous request to the server, sending the value of the selected item and then suddenly returning.
  3. Meanwhile, the server-side code makes some business logic and sends back the data, formatted in an XML document.
  4. When this asynchronous request/response completes, the callback function takes the XML data from the XMLHttpRequest object and processes it, through the javascript DOM binding, updating the text field.
  5. All updates gets suddenly displayed.

What about my previous doubts?

The XMLHttpRequest object, invented by Microsoft (I've always said that Microsoft guys are able to do something good, in particular when working in rooms with windows closed, in order to keep away from noises and bugs), is still not standard, but implemented by all major browsers, from IE to Mozilla. So, interoperability should not be a problem, and if you want to be safe, you can implement a sort of fallback behavior, like Cocoon does.
Moreover, all the business logic lies server-side (as it MUST be): client side javascript simply makes view processing.

And the advantages?

You can answer by yourself.
Thanks to AJAX, you gain a more responsive interface, which can make the web a sort of new experience, with new
applications like Google Suggest.

Now the links moment:

http://www.adaptivepath.com/publications/essays/archives/000385print.php
https://bpcatalog.dev.java.net/nonav/ajax/index.html
http://www.xml.com/pub/a/2005/02/09/xml-http-request.html

And, if Google has AJAX, why should we not?

Try clicking the "In-line view syndication titles ..." link on the bottom of the sidebar...

Saturday, July 23, 2005

Montag WS-I Basic Profile Compliance

This is the first great goal : Montag web services are officially compliant to the WS-I Basic Profile 1.1 recommendations.

It took me an hard work to code and test services WSDLs and all the related stuff in order to achieve this ... but it was very worthwhile and now I feel happy for this result.

Moreover, for this piece of good work I must thank Alex Saloustros for his precious .Net testing, and David Law for his testings about WS-I Basic Profile Compliance.

Congratulations, boys!

Wednesday, July 20, 2005

Talking about Montag

Montag is my main effort into the Open Source Community.

It is a SOAP Web Services system for interacting with Native XML Databases, but here I don't want to talk about what it is, and what is not ... for this, you can take a look at its web site.
I'd rather want to take a look at its future.

Montag 0.8 will have, first of all, a consistent core code refactoring and rewriting, in order to support new features and better accommodate future changes.
The new features released for the next version will be:
  • New services and full document/literal style for all services, based on WS-I Basic Profile.
  • New authorization system based on per-service permissions, different from the Unix-like permission system implemented by many Native XML Databases.
  • New authentication system using WS-Security UsernameTokenProfile.
  • Support for specific non-XML:DB Native XML Databases, like Berkeley DB XML.
All these changes and features are already in development or will start soon to be, but will obviously require a considerable amount of time to be completely developed.
So, prior to the 0.8 final version, a certain number of binary development snapshots will be released, in order to give "fresh meat" to Montag users and to test new features.
They will not be documented, except for some news announcement, but will be supported in the mailing list.

Stay tuned.
Montag's story continues.

Sunday, July 17, 2005

It is sunday, it is late evening and tomorrow a new week begins.

On Monday 11 July I've joined Pro-Netics, in Rome, where I will work with great technologies and great minds.



It promises to be a very interesting job and a very exciting experience.
I hope to talk more about it later.

But now ... Shakespeare's Hamlet waits for me.

Good night.

(nice dreams)
Hello all.

It took me a long time to start a blog, but now ... here I am.

What about this blog?

I'll talk mainly about Computer Science, which is my work and my main interest, but also about music and literature, which are my passion, and about every other thing will make sense for me.
Hoping I will find the time!

The play begins.

Welcome.