Javaton

Friday, April 28, 2006

Free Maven 2 Book

A free book about Maven is available from Margere.

The good think is that the book does not mess with the legacy Maven 1 that differs very much from Maven 2.

Besides the first introductory chapters I found very useful chapter 4 that address the topic of building J2EE applications with maven. The chapters also provides many examples of using the profiling options of Maven2 with the cargo plugin, for deploying and testing J2EE applications into J2EE applications servers.

Unfortunately, the cargo plugin does not support JOnAS my favorite application server.

Tuesday, April 18, 2006

Java Generics - Stay away

The well known Bruce Eckel, has a nice article that criticizes the implementation of generics in java 5.

Personally, I totaly agree with the conclusion of Eckel that

"So generics are really autoboxing"
There is not a serious advantage by adopting java generics over simple interfaces.

spring-oxm - Why do we have to use another abstraction layer?

Java is known for its wealth of options when it comes to choose an API to manipulate XML, and XML Schema.

This wealth is both a bless and a curse. For sure, it is very good to have many options to choose from, since each API - JDOM, DOM4J, Xerces, JAXB, XMLBeans, Castor, Jixb, Aegis and many more – has its own merits and drawbacks.

But at the same time, this plethora is a nightmare for the one who has to take the decision which to choose.

Hopefully, to the rescue, comes a new API developed under the umbrella of spring framework the spring-oxm.

Spring Object-to-XML is a very small library that acts as a mediate between your program and the code that actually manipulates XML using a particular API.

Someone could argue “Why do we have to use another abstraction layer?”. Actually, you don’t have. Yet again, spring-oxm offers the same benefits as spring-dao, or commons-logging offer:

  • Independence from actual implementation. Your main code establishes a contract with spring-oxm and not any particular XML API
  • Ease to compare different implementation. Write your tests against spring-oxm, and just provide two different implementations.
  • Low risk choice. Are you disappointed by one XML API? Go ahead a choose another. The rest of your application does not have to change.

Just to summarize, if you are confused about which XML API to choose adopt spring-oxm to minimize your headaches. You can find introductory material here.

Saturday, April 15, 2006

Google Calendar - First impression

Google Calendar is very impressive, but there are some minor pitfalls:

  • It does not yet support import of Outlook CSV files that contain non Latin characters. I tried to upload my Greek calendar using UTF8, Cp1253 and ISO-8858-7 encodings, but Google Calendar messes always the encoding.
  • It does not yet support Greek user interface.
  • It does not contain Greek holydays. Though I found and successfully imported a Greek Orthodox, and Greek Holidays calendar.
Besides these minor problems I found the new service of Google very promissing.

Firefox - Share your bookmarks across many computers

For those who use many computers and want to keep their bookmarks synchronized, there is the Foxmarks extension for Firefox.
It uses WebDAV in order to keep in sync your bookmarks across multiple computers.

Configuring Springframework, Hibernate and MyFaces

Recently I discorved a fantastic enty at Rick Hightower blog on how to configure Spring Framework, Hibernate3, and MyFaces.

Friday, April 14, 2006

Oracle Database XE - Installation

Today, I installed Oracle Database XE on my old Windows XP laptop. According to Oracle:
Oracle Database 10g Express Edition (Oracle Database XE) is an entry-level, small-footprint database based on the Oracle Database 10g Release 2 code base that's free to develop, deploy, and distribute; fast to download; and simple to administer.

To my surprise, the installation process was very straightforward. The only weird thing is that the installer does not provide an option to change the default port (8080) of the servlet engine that comes with the product and hosts its administration program. This is very annoying since this port is also the default port of Tomcat. Hopefully, the installer will prompt you for choosing another port if during the installation the 8080 is occupied. So, start you Tomcat before installing Oracle Express.

I managed to connect to Oracle Express, using TOAD and JDBC using the thin driver of the Enterprise RDBMS 10g.

JAXB 2 - Validate against XML Schema

Recently, java.net announced the availability of JAXB 2 RI. Although there is a short tutorial that aims to introduce JAXB the part that reffers to the validation of XML against XML Schema reffers to JAXB 1.
The tutorial states that in order to validate xml the following option should be set:
unmarshaller.setValidating(true);
In JAXB 2 this method is deprecated and throws a UnsupportedOperationException when called.

So, here is how you validate against XML Schema using JAXB2:

import javax.xml.*;
import javax.xml.validation.*;
..
// Get a schema factory for XML Schema
SchemaFactory schemaFactory =
SchemaFactory
.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);

// In this example we use two xsd files
Source schemas = new Source[]{
new StreamSource(new File("schema1.xsd")),
new StreamSource(new File("schema2.xsd"))
};

// Obtain schema
Schema schema = schemaFactory.newSchema(schemas);

// Enable schema validation
unmarshaller.setSchema(schema);