Saturday, December 27, 2008

Configuring OpenXava with MySql


Recently I started learning OpenXava and I wanted to configure OpenXava with MySQL. Lack of documentation on OpenXava 3.1 and all of them were configured to HSQL database, took me a long time to configure it to MySQL. So I thought of sharing my findings with others.

The intention of this post is not to give a step by step guide for OpenXava (which I’ll do in some other post) but to mention the changes you have to do in OpneXava project configuration files to work it with MySQL.

If you are new to OpeanXava please go through the reference manual and have a basic knowledge first.
http://openxava.wikispaces.com/reference_en

Ok, let’s get in to the business now.

Installs

1) MySQL database (ex. MySQL 5.0.24)
2) MySQL connector J (ex. mysql-connector-java-5.1.7-bin.jar)
3) OpenXava 3.1


Steps to follow


1) Create a new project (ex. Academy) according to the steps mentioned in the OpenXava reference guide.

2) Go to MySQL console and create a new database ex. academydb



3) Place MySQL connector jar into {OpenXavaBase}/tomcat/common/lib


4) Open the context.xml file in {OpenXavaBase}/tomcat/conf folder. Insert the following lines into the file.


name : name of the data source, use the default name OpeanXava gives. (Since I created the project as Academy, the default datasource name given is AcademyDS.
username: username of the MySQL database
password: password for the MySQL database
driverClassName: com.mysql.jdbc.Driver in this case
url: you have to point to the database you have creates. (ex. academydb)


5) Go to the project folder’s build.xml (Academy/build.xml) and change updateSchema target as follows. You have to change the value of the schema.path to point to the MySQL connector jar.



6) Go to persistence.xml (Academy/persistence/META-INF/persistence.xml)
Change the default persistence unit as follows



And change the junit persistence unit as follows




7) Go to hibernate.cfg.xml (Academy/persistence/hibernate.cfg.xml) and change the hibernate.dialect to org.hibernate.dialect.MySQLDialect as follows


That’s it, and now when you run updateSchema target, it will create the tables in MySQL and once you deploy the application, that will access the MySQL to retrieve and save data. (Assumed that you have written the relevant entity classes)

Sunday, June 1, 2008

Identifying Classes and Objects from a Requirement Spec. - Presentation

CRC Cards

Class Responsibility Collaborator (CRC cards) are a brainstorming tool used in the design of object-oriented software. They were proposed by Ward Cunningham and Kent Beck. There original purpose was to teach programmers the object-oriented paradigm.

Why uses CRC cards?

  • They are portable... No computers are required so they can be used anywhere. Even away from the office.
  • They allow the participants to experience firsthand how the system will work. No computer tool can replace the interaction that happens by physically picking up the cards and playing the role of that object...
  • They are a useful tool for teaching people the object-oriented paradigm.


What is a CRC CARD?


Nothing more than a blank card of 6 X 4 inches. In that card, you can draw a table something like this

By reading the spec you will come across nouns. For each nouns that you feel that can be a class, allocate a card and write the class name on top. Then reading further you will find the thing that can be done or has to be done by that class. Those are the responsibilities. Write down those responsibilities in the relevant cards. There are other classes that this class will communicate or this class should know that “there is a class like this”. Those are called collaborators. Write class names of the collaborators under the collaborator column.