Sunday, September 30, 2007

about MySQL4.1.22

My sakai is running on MySql4.1.22.
Here are some tips worth of memorizing:

-2. Unzip mysql4.1.22 package to a proper directory, say "/opt/mysql4.1.22", which equals to {MySQL_HOME}

-1.set ${MySQL_HOME} into ${PATH};

0. run "${MySQL_HOME}/configure" first;

1.(*** !!!that's it!!! ***) About socket error "ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)"
-- if this occurs, no need to do anything but kill the process "mysqld", and wait until no mysql processes are running;

2. set "root" user if you didn't -- using command "mysql -u root password mysqlpwd1";

3. run mysql.

Thursday, September 20, 2007

Equals and HashCode

Java's Collections and Relational database (and thus Hibernate) relies heavily on being able to distinguish objects in a unified way. In Relational database's this is done with primary keys, in Java we have equals() and hashCode() methods on the objects. This page tries to discuss the best strategies for implementation of equals() and hashcode() in your persistent classes.
Why are equals() and hashcode() important
Normally, most Java objects provide a built-in equals() and hashCode() based on the object's identity; so each new() object will be different from all others.
This is generally what you want in ordinary Java programming. And if all your objects are in memory, this is a fine model. Hibernate's whole job, of course, is to move your objects out of memory. But Hibernate works hard to prevent you from having to worry about this.
Hibernate uses the Hibernate session to manage this uniqueness. When you create an object with new(), and then save it into a session, Hibernate now knows that whenever you query for an object and find that particular object, Hibernate should return you that instance of the object. And Hibernate will do just that.
However, once you close the Hibernate session, all bets are off. If you keep holding onto an object that you either created or loaded in a Hibernate session that you have now closed, Hibernate has no way to know about those objects. So if you open another session and query for "the same" object, Hibernate will return you a new instance. Hence, if you keep collections of objects around between sessions, you will start to experience odd behavior (duplicate objects in collections, mainly).
The general contract is: if you want to store an object in a List, Map or a Set then it is an requirement that equals and hashCode are implemented so they obey the standard contract as specified in the documentation.

to read more, please refer to [http://www.hibernate.org/109.html]

Wednesday, September 19, 2007

hierarchy of properties files

In fact, Maven has a hierarchy of properties files which you can use to customize a build for a specific project or a specific user. Maven reads properties from the following sources, in the order shown:

${basedir}/project.properties
This file is a sibling to both maven.xml and project.xml. This file customizes behavior for a particular project.

${basedir}/build.properties
This file is also a sibling to maven.xml and project.xml, but this file is used to customize a specific project's build for a specific user. If you need to change the value of a property for your own build environment but you don't want to affect the properties of other users, add a build.properties file to ${basedir}. Values defined in this file will override values defined in project.properties. build.properties should not be checked into source control; this file is for an individual user to tailor the behavior of a specific project.

${user.home}/build.properties
Your home directory can contain a build.properties file which contains user-specific properties to be used on all projects. This is the proper file in which to configure properties for a proxy server or a remote repository. Properties defined in this file are read for every project, and they supersede the values set in the previous two files.

System properties (specified with the -D flag)
Setting the value of a property on the command line supersedes all other configuration files. This is the final stop for properties.

Thursday, September 13, 2007

Using 3rd party plugins in maven

tomcat-plugin can be download from
http://www.codeczar.com/maven.

I did this manually, because when I ran the command
"maven-DartifactId=maven-tomcat-plugin -DgroupId=codeczar-tomcat -Dversion=1.2.1plugin:download"
what downloaded was just a broken file named"maven-tomcat-plugin-1.2.1.jar"(28kb).
[or, google the jar file to find the correct repository]

Maven 1.0.2 Structure

A project that uses the WAR plug-in contains three source trees:




src/main

Contains the runtime Java sources.



src/test

Contains the JUnit tests for unit testing the Java code found in src/main. Note that these unit tests are performed in isolation (i.e., without a running container). They are not functional tests.




src/webapp

Contains all the web application resources (HTML files, JSP files, configuration files, etc.). For the web subproject you have only a WEB-INF/web.xml file, which maps the Servlet to a web context.

Sunday, September 2, 2007

Check back on my project~

These 2 weeks were spent on my project, a web-based calender combined with ToDo list.
The component's are prepared. The next job will be to connect them together, and inject them into Spring-Hibernate framework.
Hope that I can handle this, as soon as possible.
Time, my biggest barrier...

Using an Eclipse plugin for Maven

There are two ways to use Maven and Eclipse:
1. Eclipse as the editor, and Maven command line for commands, or
2. Using an Eclipse plugin for Maven
Use the first one if you're much more comfortable with using the command line for your maven executions, but would like to take advantage of eclipse' features ( code complete, refactoring, etc ). Use the second one if you want eclipse to handle all these things - creation to editing to execution.

To do so, you must install an eclipse plugin for maven. For example, to install the m2eclipse plugin, go to

Help > Software Updates > Find and Install > Search for new features to install.

Then from there, clicked on the "New Remote Site" button and enter a name ( i.e m2eclipse ) and the url "http://m2eclipse.codehaus.org/". Then just click "next" till you reach "finish".

Maven, not just another build tool

In the Maven world, a project product (jar, war, ...) is called an artifact. Every project generates one and only one primary artifact (secondary artifacts will be covered in more advanced trails). An artifact is always identified by two ids:

groupId It identifies your project as a whole (it will make more sense when you start using multi-modules build) and should be unique. Maven enforces a naming schema following the Java package name rules. Hence, the groupId has to start by at least a domain name you control followed by any subgroups you want. For further informations, look at The package names in the Java language. [characters restrictions]
An example: org.apache.maven

artifactId It identifies precisely the current project inside the group identified by the groupId. [characters restrictions]
An example: groupdId: org.apache.maven.doxia, artifactId: doxia

and a version:

version: The version number allows you to distinguish your different project releases. There are two kinds of versions depending of the release type it is associated with:
Official releases : 1.0, 2.2, ...
Specific releases (nightly build or snapshots) : 1.0-SNAPSHOT, 2.1.2-SNAPSHOT [characters restrictions]

Having precise naming formats allows Maven to manage efficiently for you the dependencies and the plugins your project depends upon. We'll see what that means in the next lessons.
REF::http://docs.codehaus.org/display/MAVENUSER/Maven%2C+not+just+another+build+tool