website link

demo eclipse video:
http://www.mirror.in.th./osarchive/eclipse/technology/phoenix/demos/install-ve/install-ve.html

http://sourceforge.net/projects/easyeclipse/files/

all plugin updatesite:
http://eclipse-plugins.2y.net/eclipse/plugins.jsp;jsessionid=60179A11877482E70B290590C1B30146?category=Code+Generation

appfuse updatesite
https://appfusegenerator.dev.java.net/

spring- Hibernate integration sample application

http://docs.huihoo.com/spring/Lightweight-Applications-with-Spring-Hibernate-and-Java-EE-5.pdf



adobe Flex3 demo
http://livedocs.adobe.com/flex/3/html/index.html
http://learn.adobe.com/wiki/display/Flex/Download+Projects

Appfuse 2.0 Review

Appfuse 2.0 Review

AppFuse is an open source project and application that uses open source tools built on the Java platform to help you develop
web applications quickly and efficiently.

What is AppFuse?

AppFuse is an application for “kickstarting” J2EE web application development. It consists of a set of libraries, jsp’s, templates and several build scripts. Running the ant new target in the AppFuse root directory will prompt for a few parameters of the target application, like database and package names. AppFuse then generates and copies a deployable web application that can serve as a starting point for further application development.

How well does AppFuse work in practice?

To find out how well AppFuse really works, I followed the QuickStart Guide, the Creating new DAOs and Objects in AppFuse, the Creating new Managers, the Creating Spring Controllers and JSPs and the Adding Validation and List Screen tutorials. I then tried to port the generated code to another RDBMS (Cloudscape 10.1). I also had a go at replacing the default two column page design with a three column design.

These are my findings.

Strengths

* Short startup time - I had a deployable, database driven, tested, 3-Tier J2EE application supporting authentication, authorization, logging, click through tracing etc. in less than 3 hours. Even taken into account that I already had a complete Java environment installed on my machine (JDK, Eclipse, MySQL, Ant), this is fast … very fast.
* Choose between IBatis and Hibernate - for persistence, AppFuse lets you chose between a DAO layer implemented using IBatis or Hibernate.
* Choose between Spring MVC, Tapestry, Webwork orJSF - for the Web Tier, you can chose between two Component based (Tapestry and JSF) or two Request based web frameworks (Spring MVC, Webwork).
* Support for Test Driven Development- apart from DAO, Manager and Web classes, AppFuse also generates Test Cases and the ant targets to run them, either individually or in logical groups (test-dao, test-web, etc.).
* Build script - the Ant build script consists of 1200 lines and 65 targets and covers everything from dropping, creating and populating the database to deploying to Tomcat and fixing CRLF for Unix Machines.
* Integration with Sitemesh - the JSP’s are build up using the the Sitemesh templating library, providing for clean separation between content and layout directives. Compared to for instance Tiles, Sitemesh is more powerfull and flexible.
* Released under the Apache License - it lets us freely use the software for company internal and commercial purposes and does not require us to submit changes that we make to the software back to the Apache Software Foundation.
* Documentation and community support - the tutorials and JavaDoc are quite good, and there is an active developer community using the software.

Weaknesses

* MySQL only - the generated code is targeted at the MySQL database system. AppFuse does not support other RDBMS out of the box - manual adaptations of the generated code are necessary to achieve this.
* No clean dependency management - AppFuse relies on ant build scripts and properties files to configure its (50+) dependencies. Usage of a tool like Ivy, a simple to use but powerfull dependency manager would be nice instead.
* Heavy reliance on XDoclet for code generation - this leads to code that belongs in the Integration Layer (i.e. Hibernate mapping definitions and column names) being part of the Domain Layer.
* Large build scripts - although they do provide a lot of functionality, the large build scripts are difficult to understand and maintain. It is also not always clear what the different targets do and how they depend on each other.
* Usage of Business Keys as PKs - in general, when using Hibernate, it is a best practice to use Surrogate Keys as PKs for database tables representing Business Objects (”User”, “Car” etc.). AppFuse ignores this and uses the Business Keys as PKs.
* Small committer base - it is unclear to me how large the developer base is that actively maintains and develops the AppFuse project. This is something to investigate when planning any long running projects.


In a typical web application, it is common to have a login screen, registration screen, content storage in database, security and most importantly testing.

When building a Java web application, we might start adding one jar file after another to implement a particular user story.

For example, if i want to have ACEGI security for my web app, I might download ACEGI jar, map and configure it in web.xml and security.xml files.

What if, there exists a toolkit that already provides these common features to us. ?
For instance...

ACEGI security
Hibernate integration
AJAX templates
Switchable CSS framework
Unit test
Layout reuse
PDF support
Excel support and so on...



Installing Appfuse is easy for people who have basic knowledge of Maven 2. We took the Spring MVC Basic archetype of Appfuse, as the team already had good expertise on Spring/Hibernate/Junit.

The Spring MVC Basic archetype was made with excellent set of framework and libraries, some of them include Hibernate, JUnit, Spring MVC,DisplayTag, DWR and so on. The good thing is, its also supports most of commonly used databases.

It took very short time to add a new spring-mvc jsp page, a spring controller and the related test cases.
It took hardly no time to add our own language extension for internationalization, because Appfuse comes with ready made templates.

At one point, we wanted to extend the user registration form, spring controller and the database. I was able to do it with the help of documentation provided on the Appfuse website.

It takes a while to understand the whole structure of the project, but I dont feel it wasted my time on learning it's structure.
Heavily based on many external jars files so you never know when they will become obsolete.One can also argue that is not the problem of Appfuse but the individual package. We faced some compatibility issues on using the jars but later we managed to correct them using our pom.xml

I strongly recommend to the spring developers to look in to the Appfuse application before you start developing your own set of common features and requirements for your web application.
This helps you not to re-invent wheel and saves time and effort.

The mailing list/user community is very active in answering the queries. The Appfuse team is also very active in keeping their application at par with new changes in the technology.
Apart from Spring MVC archetype, Appfuse also has its archetype for JSF, Struts and Tapestry. Checkout Appfuse website for more info about online demos, tutorials and release roadmap.


http://appfuse.org/display/APF/Home

http://appfuse.org/display/APF/Demos+and+Videos

Conclusion
AppFuse does what it promises to do, which is always nice: it kick starts a J2EE project in a very short period of time. In my opinion, this makes it a very good tool for Consultants that are assigned to small to medium sized, Proof of Concept like projects. Here AppFuse really shines and should be used to its full extent, meaning including all XDoclet code generation features and ant targets.

For larger projects, that will be running over longer periods of time, that have to integrate with other RDBMS like Oracle and need a clean dependency management, AppFuse can serve as a starting point. In that case though, one really has to invest the time to refactor the generated code.

Hibernate 3.0

What is Hibernate?
Hibernate 3.0, the latest Open Source persistence technology
at the heart of J2EE EJB 3.0 is available for download from Hibernet.org.The Hibernate 3.0 core is 68,549 lines of Java code together with 27,948 lines of unit tests, all freely available under the LGPL, and has been in development for well over a year. Hibernate maps the Java classes to the database tables. It also provides the data query and retrieval facilities that significantly reduces the development time. Hibernate is not the best solutions for data centric applications that only uses the stored-procedures to implement the business logic in database. It is most useful with object-oriented domain modes and business logic in the Java-based middle-tier. Hibernate allows transparent persistence that enables the applications to switch any database. Hibernate can be used in Java Swing applications, Java Servlet-based applications, or J2EE applications using EJB session beans.

Features of Hibernate

* Hibernate 3.0 provides three full-featured query facilities: Hibernate Query Language, the newly enhanced Hibernate Criteria Query API, and enhanced support for queries expressed in the native SQL dialect of the database.

* Filters for working with temporal (historical), regional or permissioned data.

* Enhanced Criteria query API: with full support for projection/aggregation and subselects.

* Runtime performance monitoring: via JMX or local Java API, including a second-level cache browser.

* Eclipse support, including a suite of Eclipse plug-ins for working with Hibernate 3.0, including mapping editor, interactive query prototyping, schema reverse engineering tool.

* Hibernate is Free under LGPL: Hibernate can be used to develop/package and distribute the applications for free.

* Hibernate is Scalable: Hibernate is very performant and due to its dual-layer architecture can be used in the clustered environments.

* Less Development Time: Hibernate reduces the development timings as it supports inheritance, polymorphism, composition and the Java Collection framework.

* Automatic Key Generation: Hibernate supports the automatic generation of primary key for your.

* JDK 1.5 Enhancements: The new JDK has been released as a preview earlier this year and we expect a slow migration to the new 1.5 platform throughout 2004. While Hibernate3 still runs perfectly with JDK 1.2, Hibernate3 will make use of some new JDK features. JSR 175 annotations, for example, are a perfect fit for Hibernate metadata and we will embrace them aggressively. We will also support Java generics, which basically boils down to allowing type safe collections.


* Hibernate XML binding enables data to be represented as XML and POJOs interchangeably.

Detailed features are available at http://www.hibernate.org/About/RoadMap.

In this lesson you will learn the architecture of Hibernate. The following diagram describes the high level
architecture of hibernate:

Hibernate architecture has three main components:

* Connection Management

Hibernate Connection management service provide efficient management of the database connections. Database connection is the most expensive part of interacting with the database as it requires a lot of resources of open and close the database connection.

* Transaction management:

Transaction management service provide the ability to the user to execute more than one database statements at a time.

* Object relational mapping:

Object relational mapping is technique of mapping the data representation from an object model to a relational data model. This part of the hibernate is used to select, insert, update and delete the records form the underlying table. When we pass an object to a Session.save() method, Hibernate reads the state of the variables of that object and executes the necessary query.

Hibernate is very good tool as far as object relational mapping is concern, but in terms of connection management and transaction management, it is lacking in performance and capabilities. So usually hibernate is being used with other connection management and transaction management tools. For example apache DBCP is used for connection pooling with the Hibernate.

Hibernate provides a lot of flexibility in use. It is called "Lite" architecture when we only uses the object relational mapping component. While in "Full Cream" architecture all the three component Object Relational mapping, Connection Management and Transaction Management) are used.

Writing First Hibernate Code

In this section I will show you how to create a simple program to insert record in MySQL database. You can run this program from Eclipse or from command prompt as well. I am assuming that you are familiar with MySQL and Eclipse environment.

Configuring Hibernate
In this application
Hibernate provided connection pooling and transaction management is used for simplicity. Hibernate uses the hibernate.cfg.xml to create the connection pool and setup required environment.

Here is the code:


"-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">





com.mysql.jdbc.Driver



jdbc:mysql://localhost/hibernatetutorial

root

10
true
org.hibernate.dialect.MySQLDialect
update





In the above configuration file we specified to use the "hibernatetutorial" which is running on localhost and the user of the database is root with no password. The dialect property is org.hibernate.dialect.MySQLDialect which tells the Hibernate that we are using MySQL Database. Hibernate supports many database. With the use of the Hibernate (Object/Relational Mapping and Transparent Object Persistence for Java and SQL Databases), we can use the following databases dialect type property:

* DB2 - org.hibernate.dialect.DB2Dialect
* HypersonicSQL - org.hibernate.dialect.HSQLDialect
* Informix - org.hibernate.dialect.InformixDialect
* Ingres - org.hibernate.dialect.IngresDialect
* Interbase - org.hibernate.dialect.InterbaseDialect
* Pointbase - org.hibernate.dialect.PointbaseDialect
* PostgreSQL - org.hibernate.dialect.PostgreSQLDialect
* Mckoi SQL - org.hibernate.dialect.MckoiDialect
* Microsoft SQL Server - org.hibernate.dialect.SQLServerDialect
* MySQL - org.hibernate.dialect.MySQLDialect
* Oracle (any version) - org.hibernate.dialect.OracleDialect
* Oracle 9 - org.hibernate.dialect.Oracle9Dialect
* Progress - org.hibernate.dialect.ProgressDialect
* FrontBase - org.hibernate.dialect.FrontbaseDialect
* SAP DB - org.hibernate.dialect.SAPDBDialect
* Sybase - org.hibernate.dialect.SybaseDialect
* Sybase Anywhere - org.hibernate.dialect.SybaseAnywhereDialect

The property is the mapping for our contact table.

Writing First Persistence Class
Hibernate uses the Plain Old Java Objects (POJOs) classes to map to the database table. We can configure the variables to map to the database column. Here is the code for Contact.java:
package roseindia.tutorial.hibernate;

/**
* @author Deepak Kumar
*
* Java Class to map to the datbase Contact Table
*/
public class Contact {
private String firstName;
private String lastName;
private String email;
private long id;

/**
* @return Email
*/
public String getEmail() {
return email;
}

/**
* @return First Name
*/
public String getFirstName() {
return firstName;
}

/**
* @return Last name
*/
public String getLastName() {
return lastName;
}

/**
* @param string Sets the Email
*/
public void setEmail(String string) {
email = string;
}

/**
* @param string Sets the First Name
*/
public void setFirstName(String string) {
firstName = string;
}

/**
* @param string sets the Last Name
*/
public void setLastName(String string) {
lastName = string;
}

/**
* @return ID Returns ID
*/
public long getId() {
return id;
}

/**
* @param l Sets the ID
*/
public void setId(long l) {
id = l;
}

}

Mapping the Contact Object to the Database Contact table
The file contact.hbm.xml is used to map Contact Object to the Contact table in the database. Here is the code for contact.hbm.xml:

"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">



















Setting Up MySQL Database
In the configuration file(hibernate.cfg.xml) we have specified to use hibernatetutorial database running on localhost. So, create the databse ("hibernatetutorial") on the MySQL server running on localhost.

Developing Code to Test Hibernate example
Now we are ready to write a program to insert the data into database. We should first understand about the Hibernate's Session. Hibernate Session is the main runtime interface
between a Java application and Hibernate. First we are required to get the Hibernate Session.SessionFactory allows application to create the Hibernate Sesssion by reading the configuration from hibernate.cfg.xml file. Then the save method on session object is used to save the contact information to the database:

session.save(contact)

Here is the code of FirstExample.java


package roseindia.tutorial.hibernate;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;


/**
* @author Deepak Kumar
*
* http://www.roseindia.net
* Hibernate example to inset data into Contact table
*/
public class FirstExample {
public static void main(String[] args) {
Session session = null;

try{
// This step will read hibernate.cfg.xml

and prepare hibernate for use
SessionFactory sessionFactory = new

Configuration().configure().buildSessionFactory();
session =sessionFactory.openSession();
//Create new instance of Contact and set

values in it by reading them from form object
System.out.println("Inserting Record");
Contact contact = new Contact();
contact.setId(3);
contact.setFirstName("Deepak");
contact.setLastName("Kumar");
contact.setEmail("deepak_38@yahoo.com");
session.save(contact);
System.out.println("Done");
}catch(Exception e){
System.out.println(e.getMessage());
}finally{
// Actual contact insertion will happen at this step
session.flush();
session.close();

}

}

http://www.roseindia.net/struts/hibernate-spring/index.shtml
}

MVC Architecture

The main aim of the MVC architecture is to separate the business logic and application data from the presentation data to the user.

M --->in MVC stands for the MODEL
V --->in MVC stands for the VIEW
C --->in MVC stands for the CONTROLLER

Here are the reasons why we should use the MVC design pattern
.

1. They are resuable : When the problems recurs, there is no need to invent a new solution, we just have to follow the pattern and adapt it as necessary.
2. They are expressive: By using the MVC design pattern our application becomes more expressive.

1). Model: The model object knows about all the data that need to be displayed. It is model who is aware about all the operations that can be applied to transform that object. It only represents the data of an application. The model represents enterprise data and the business rules that govern access to and updates of this data. Model is not aware about the presentation data and how that data will be displayed

2). View : The view represents the presentation of the application. The view object refers to the model. It uses the query methods of the model to obtain the contents and renders it. The view is not dependent on the application logic. It remains same if there is any modification in the business logic. In other words, we can say that it is the responsibility of the of the view's to maintain the consistency in its presentation when the model changes.

3). Controller: Whenever the user sends a request for something then it always go through the controller. The controller is responsible for intercepting the requests from view and passes it to the model for the appropriate action. After the action has been taken on the data, the controller is responsible for directing the appropriate view to the user. In GUIs, the views and the controllers often work very closely together.

Difference between Model 1 and Model 2 architecture:

Features of MVC1:

1. Html or jsp files are used to code the presentation. To retrieve the data JavaBean can be used.
2. In mvc1 archictecture all the view, control elements are implemented using Servlets or Jsp.
3. In MVC1 there is tight coupling between page and model as data access is usually done using Custom tag or through java bean call.

Features of MVC2:

1. The MVC2 architecture removes the page centric property of MVC1 architecture by separating Presentation, control logic and the application state.
2. In MVC2 architecture there is only one controller which receives all the request for the application and is responsible for taking appropriate action in response to each request.