Tuesday, June 30, 2009

Struts Action Classes

An Action Class performs a role of an adapter between the contents of an incoming HTTP request and the corresponding business logic that should be executed to process this request. Different kinds of actions in Struts are:

  • ForwardAction
  • IncludeAction
  • DispatchAction
  • LookupDispatchAction
  • SwitchAction
DispatchAction in Struts

The DispatchAction class is used to group related actions into one class. Using this class, We can have a method for each logical action compared than a single execute method. The DispatchAction dispatches to one of the logical actions represented by the methods. It picks a method to invoke based on an incoming request parameter. The value of the incoming parameter is the name of the method that the DispatchAction will invoke.

Struts ForwardAction

The ForwardAction class is useful when you’re trying to integrate Struts into an existing application that uses Servlets to perform business logic functions. You can use this class to take advantage of the Struts controller and its functionality, without having to rewrite the existing Servlets. Use ForwardAction to forward a request to another resource in your application, such as a Servlet that already does business logic processing or even another JSP page. By using this predefined action, you don’t have to write your own Action class. You just have to set up the struts-configfile properly to use ForwardAction.

IncludeAction in Struts

The IncludeAction class is useful when you want to integrate Struts into an application that uses Servlets. Use the IncludeAction class to include another resource in the response to the request being processed.

Struts LookupDispatchAction

The LookupDispatchAction is a subclass of DispatchAction. It does a reverse lookup on the resource bundle to get the key and then gets the method whose name is associated with the key into the Resource Bundle. LookupDispatchAction is useful if the method name in the Action is not driven by its name in the front end, but by the Locale independent key into the resource bundle. Since the key is always the same, the LookupDispatchAction shields your application from the side effects of I18N.

SwitchAction in Struts

The SwitchAction class provides a means to switch from a resource in one module to another resource in a different module. SwitchAction is useful only if you have multiple modules in your Struts application. The SwitchAction class can be used as is, without extending.

Read more...

Thursday, June 25, 2009

(EJB) Entity Beans in brief

What is an Entity Bean?

An Entity bean represents a business object in a persistent storage mechanism. An entity bean typically represents a table in a relational database and each instance represents a row in the table. Entity bean differs from session bean by persistence, shared access, relationship and primary key. There are two types of entity beans available.

  • Container Managed Persistence (CMP)
  • Bean Managed Persistence (BMP)
CMP / Container Managed Persistence

A The term container-managed persistence means that the EJB container handles all database access required by the entity bean. The bean's code contains no database access (SQL) calls. As a result, the bean's code is not tied to a specific persistent storage mechanism (database). Because of this flexibility, even if you redeploy the same entity bean on different J2EE servers that use different databases, you won't need to modify or recompile the bean's code. So, your entity beans are more portable.

BMP / Bean Managed Persistence

A Bean managed persistence (BMP) occurs when the bean manages its persistence. Here the bean will handle all the database access. So the bean's code contains the necessary SQLs calls. So it is not much portable compared to CMP. Because when we are changing the database we need to rewrite the SQL for supporting the new database.

Read more...

Tuesday, June 23, 2009

Stateless Session Beans

A Stateless session beans are of equal value for all instances of the bean. Session bean will execute a client request and return a result without saving any client specific state. This means the container can assign any bean to any client, making it very scalable. Stateless session beans does not retain client specific state from one method invocation to the next.

Bean instance can be reassigned to serve a method invocation from another client once current method invocation is done. Value of instance variables of a bean instance is not preserved between calls. Container transparently reuses bean instances to serve different clients. Load-balancing & Failover is easier since no state needs to be preserved. High scalability since a client call can be Served by any EJB server in a clustered architecture.

A stateless session bean is an enterprise bean that provides a stateless service to the client. Conceptually, the business methods on a stateless session bean are similar to procedural applications or static methods; there is no instance state, so all the data needed to execute the method is provided by the method arguments. The stateless session bean is an EJB component that implements the javax.ejb.SessionBean interface and is deployed with the declarative attribute "stateless".

Stateless session beans
are called "stateless" because they do not maintain conversational state specific to a client session. In other words, the instance fields in a stateless session bean do not maintain data relative to a client session. This makes stateless session beans very lightweight and fast, but also limits their behavior. Typically an application requires less number of stateless beans compared to stateful beans.

Read more...

Monday, June 22, 2009

Stateful Session Beans

A Stateful session bean maintain the state of the conversation between the client and itself. When the client invokes a method on the bean the instance variables of the bean may contain a state but only for the duration of the invocation.

Stateful session bean will retain client specific state (session state) from one method invocation to the next, her bean instances are to be maintained for each client. A stateful session bean is an enterprise bean (EJB component) that acts as a server-side extension of the client that uses it. The stateful session bean is created by a client and will work for only that client until the client connection is dropped or the bean is explicitly removed.

A stateful session bean is an enterprise bean (EJB component) that acts as a server-side extension of the client that uses it. The stateful session bean is created by a client and will work for only that client until the client connection is dropped or the bean is explicitly removed. Stateful session beans are usually developed to act as agents for the client, managing the interaction of other beans and performing work on behalf of the client application.

The stateful session bean is EJB component that implements the javax.ejb.SessionBean interface and is deployed with the declarative attribute "stateful". Stateful session beans are called "stateful" because they maintain a conversational state with the client. In other words, they have state or instance fields that can be initialized and changed by the client with each method invocation. The bean can use the conversational state as it process business methods invoked by the client.

Read more...

Sunday, June 21, 2009

Java Garbage Collection

Garbage Collection in Java

Java has built-in facility to re-claim unwanted memory, this is known as garbage collection. Garbage collector plays its role if there is any memory defficiency. Usually an object no longer referenced, for example when you assign with null, it could be ready for garbage collection. In java all objects are created in heap memory, whereas primitive type and object reference are placed in stack memory. Object class has defined finalize() method that is called by the garbage collector on an object when garbage collection determines that there are no more references to the object.


The purpose of Java Garbage Collection is to identify and discard objects that are no longer needed by a program so that their resources can be reclaimed and reused. A Java object is subject to garbage collection when it becomes unreachable to the program in which it is used. Garbage collection is also called automatic memory management as JVM automatically removes the unused variables/objects (value is null) from the memory.


Every class inherits finalize() method from java.lang.Object, the finalize() method is called by garbage collector when it determines no more references to the object exists. In Java, it is good idea to explicitly assign null into a variable when no more in use. In Java on calling System.gc() and Runtime.gc(), JVM tries to recycle the unused objects, but there is no guarantee when all the objects will garbage collected. Java Garbage collection is an automatic process and can't be forced.

Java Garbage Collection program

class GC
{

public static void main(String args[]){
MyObj obj = new MyObj();
obj=null;
System.gc();
}
}

class MyObj
{

public MyOb(){
System.out.println("Object created");
}

protected void finalize()
{

System.out.println("Garbage collector in action");
}
}
Garbage collection will start immediately upon request of System.gc(). Garbage collection does not guarantee that a program will not run out of memory. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection.

Read more...

Friday, June 19, 2009

Java Internationalization (II8N)

Internationalization (I18N) in Java

Java Internationalization (I18N) is the process of designing an application so that it can be adapted to different languages and regions, without requiring engineering changes. This model is to support many languages but only two of them, English (ASCII) and another one, at the same time. One have to specify the 'another' language,usually by LANG environmental variable. The above I18N-L10N model can be regarded as a part of this I18N model. gettextization is categorized into I18N model.

I18N is needed in the following places.

  • Displaying characters for the end users' native languages.
  • Inputing characters for the end users' native languages.
  • Handling files written in popular encodings [1] that are used for the end users' native languages.
  • Using characters from the end users' native languages for file names and other items.
  • Printing out characters from the end users' native languages.
  • Displaying messages by the program in the end users' native languages.
  • Formatting input and output of numbers, dates, money, etc., in a way that obeys customs of the end users' native cultures.
  • Classifying and sorting characters, in a way that obey customs of the end users' native cultures.
  • Using typesetting and hyphenation rules appropriate for the end users' native languages.

Java Internationalization (I18N) can be done with some handy modifications in our existing application. We have to know the two Internationalization (I18N) components that are packaged with the Struts Framework. The first of these components, which is managed by the application Controller, is a Message class that references a resource bundle containing Locale-dependent strings.

The second Internationalization (I18N) component is a JSP custom tag, <bean:message /> , Which is used in the View layer to present the actual strings managed by the Controller.


Java Internationalization (I18N) is a set of simple Java properties files. Each file contains a key/value pair for each message that you expect your application to present, in the language appropriate for the requesting client.

Locale objects are only identifiers. After defining a Locale, you pass it to other objects that perform useful tasks, such as formatting dates and numbers. These objects are called locale-sensitive, because their behavior varies according to Locale. A ResourceBundle is an example of a locale-sensitive object.

Internationalization Sample Program

import java.util.*

public class I18NCode
{
public static void main(String args{})
{

String language;
String country;

if (args.length != 2)
{

language = new String("en");
country = new String("US");

}else{

language = new String(args[0]);
country = new String(ars[1]);
}

Locale currentLocale;
ResourseBundle messages;

currentLocale = new Locale(language, country);
messages = ResourseBundle.getBundle("MessagesBundle", currentLocale);

System.out.println(messages.getString("Hai");
System.out.println(messages.getString("How are");
System.out.println(messages.getString("You");

}
run this program in the following way:

java I18NCode en US
(or)

java I18NCode fr FR

Read more...

Thursday, June 18, 2009

JSP Tags

Tags in JSP

JSP is a serverside technology to make content generation a simple appear. A Java Server Page can contain Java program fragments that instantiate and execute Java classes, but these occur inside an HTML template file and are primarily used to generate dynamic content.
Some of the JSP functionality can be achieved on the client, using JavaScript. The power of JSP is that it is server-based and provides a framework for Web application development.

JSP contains the following tags

  • Declaration tag
  • Expression tag
  • Directive Tag
  • Scriptlet tag
Declaration tag ( <%! %> )

A declaration tag declares one or more variables or methods for use later in the JSP source file. A declaration tag must contain at least one complete declarative statement. You can declare any number of variables or methods within one declaration tag, as long as they are separated by semicolons. The declaration tag must be valid in the scripting language used in the JSP file.

This tag allows the developer to declare variables or methods. Before the declaration you must have
<%! At the end of the declaration, the developer must have %> Code placed in this tag must end in a semicolon ( ; ). Declarations do not generate output so are used with JSP expressions or scriptlets.
<%!
private int counter = 0 ;
private String get Account ( int accountNo) ;
%>
Expression tag ( <%= %>)

An expression tag contains a scripting language expression that is evaluated, converted to a String, and inserted where the expression appears in the JSP file. Because the value of an expression is converted to a String, you can use an expression within text in a JSP file.

This tag allows the developer to embed any Java expression and is short for out.println(). A semicolon ( ; ) does not appear at the end of the code inside the tag. Example to show the current date and time
Date : <%= new java.util.Date() %>
Directive tag ( <%@ directive … %>)

A JSP directive tag gives special information about the page to the JSP Engine.

There are three main types of directives:
  • page – processing information for this page.
  • Include – files to be included.
  • Tag library – tag library to be used in this page.
Directives do not produce any visible output when the page is requested but change the way the JSP Engine processes the page.

Scriptlet tag ( <% … %> )

A scriptlet tag can contain any number of language statements, variable or method declarations, or expressions that are valid in the page scripting language. We can declare variables or methods to use later in the file. Write expressions valid in the page scripting language. Use any of the JSP implicit objects or any object declared with a tag. You must write plain text, HTML-encoded text, or other JSP tags outside the scriptlet. Scriptlets are executed at request time, when the JSP engine processes the client request.

If the scriptlet produces output, the output is stored in the out object, from which you can display it. Between <% and %> tags, any valid Java code is called a Scriptlet. This code can access any variable or bean declared. For example, to print a variable.
<%
String username = “visualbuilder” ;
out.println ( username ) ;
%>

Read more...

Wednesday, June 17, 2009

JDBC Drivers Types

JDBC Drivers are set of classes and interfaces which implements JDBC specification. There are mainly four type of JDBC drivers registered under SUN.

Type 1 - JDBC-ODBC Bridge Driver

Driver which converts JDBC calls into ODBC calls and interact with the ODBC driver is called as DBC-ODBC Bridge Driver. A JDBC-ODBC bridge provides JDBC API access via one or more ODBC drivers, in many cases native database client code must be loaded on each client machine which uses this type of driver. Hence, this kind of driver is generally most appropriate when automatic installation and downloading of a Java technology application is not important.

Type 2 - Native API Partly Java Driver

Driver which converts JDBC call into database specific native call is called as type 2 driver. A native-API partly Java technology-enabled driver converts JDBC calls into calls on the client API for Oracle, Sybase, Informix, DB2, or other DBMS. Note that, like the bridge driver, this style of driver requires that some binary code be loaded on each client machine.

Type 3 - Network protocol Pure Java Driver

Driver which converts JDBC call into server specific newtwork call and interacts with the server driver is called as Network protocol Driver. A net-protocol fully Java technology-enabled driver translates JDBC API calls into a DBMS-independent net protocol which is then translated to a DBMS protocol by a server. This net server middleware is able to connect all of its Java technology-based clients to many different databases. The specific protocol used depends on the vendor.

In general, this is the most flexible JDBC API alternative. It is likely that all vendors of this solution will provide products suitable for Intranet use. In order for these products to also support Internet access they must handle the additional requirements for security, access through firewalls, etc., that the Web imposes. Several vendors are adding JDBC technology-based drivers to their existing database middleware products.

Type 4 - Native Protocol pure Java Driver

Driver which converts JDBC call into database specific native call is called as type 4 driver. A native-protocol fully Java technology-enabled driver converts JDBC technology calls into the network protocol used by DBMS directly. This allows a direct call from the client machine to the DBMS server and is a practical solution for Intranet access. Since many of these protocols are proprietary the database vendors themselves will be the primary source for this style of driver. Several database vendors have these in progress.

Read more...

Tuesday, June 16, 2009

EJB Session Beans

Session Beans in EJB

Session beans are Java components that run in either stand-alone EJB containers or EJB containers that are part of standard Java Platform, Enterprise Edition (Java EE) application servers. A Session bean represents a single client inside the J2EE server. To access the application deployed in the server the client invokes methods on the session bean. The session bean performs the task shielding the client from the complexity of the business logic.

These Java components are typically used to model a particular user task or use case, such as entering customer information or implementing a process that maintains a conversation state with a client application. Session beans can hold the business logic for many types of applications, such as human resources, order entry, and expense reporting applications.

Session bean components implement the javax.ejb.SessionBean interface. Session beans can act as agents modeling workflow or provide access to special transient business services. Session beans do not normally represent persistent business concepts.

Types of Session Beans:

There are two types of session beans, namely: Stateful and Stateless session beans.
Stateful session beans maintain conversational state when used by a client. Conversational state is not written to a database, it’s state that is kept in memory while a client uses a session.Maintaining conversational state allows a client to carry on a conversation with an enterprise bean.

Stateless session beans do not maintain any conversational state. Each method is completely independent and uses only data passed in its parameters.
A session bean corresponds to a client server session. The session bean is created when a client requests some query on the database and exists as long as the client server session exists.

Read more...

Monday, June 15, 2009

Hybrid Server Pages beyond JSP

Hybrid Server Pages beyond the Java Server Pages

JSP combined HTML and Java in one source text but did not go far enough. Hybrid Java Language (HJL) is the next step in the same direction. HJL supports code reuse in the form of widgets written in same Hybrid Java Pages. Generated Java code gets built into a natural pages and components framework wrapped around Servlet API.

Hybrid Java Language incorporates Java and HTML operators into a single formal grammar.We may consider the language as consisting of three parts – subset of Java, subset of HTML and all the rest. The latter serves for code factorization and reuse as well as for ‘gluing’ Java and HTML. Widgets are the units of code reuse.

The Hybrid Java Pages code of an application is provided as a set of .page files (one per Web page) and a set of .widget files. A widget may define named attributes and/or named slots (or one anonymous slot). A slot is somewhat similar to the position between opening and closing a ‘library tag’. The code inHybrid Java Pages slots has Java context of the point of call of the widget, so widgets are transparent for Java context (same as HTML elements are by the way).

The rest of the .widget file is just ARBITRARY Hybrid Java Pages code – no other programming support or configuration is necessary to define a widget.

Technology suggests a very natural framework that includes application, page and widget data persistent in the scope of HTTP session. Developer defines such data as members of ‘code-behind’ classes, which may contain handlers of those states called by the framework with a proper dispatching in case of widgets.

Compiler resolves the identifiers used in widgets and pages against Java definitions in Java blocks, definitions of widget attributes, in instances of widgets and page state classes. Widgets may send signals to parent and page.

Read more...

Sunday, June 14, 2009

Struts Framework in Brief

Jakarta Struts is open source implementation of MVC 2 (Model-View-Controller) pattern for the development of web based applications. Jakarta Struts is robust architecture and can be used for the development of application of any size. Struts framework makes it much easier to design scalable, reliable Web applications with Java. Struts is a Web-based user interface framework also an open source framework. It is a matured and proven framework, which has been used in many J2EE projects.

Struts framework was created by Craig R. McClanahan and donated to the Apache Software Foundation in 2000. The Project now has several committers, and many developers are contributing to overall to the framework.

Struts is a open source framework which make building of the web applications easier based on the java Servlet and JavaServer pages technologies. The core of the Struts framework is a flexible control layer based on standard technologies like Java Servlets, JavaBeans, ResourceBundles, and XML, as well as various Jakarta Commons packages. Struts encourages application architectures based on the Model 2 approach (MVC 2), a variation of the classic Model-View-Controller (MVC) design paradigm.

Struts frames work is based on three components.

Model: A model represents an application’s data and contains the busuiness logic for accessing and manipulating that data. Any data that is part of the persistent state of the application should reside in the model objects. The business objects update the application state. ActionForm bean represents the Model state at a session or request level, and not at a persistent level. Model services are accessed by the controller for either querying or effecting a change in the model state. The model notifies the view when a state change occurs in the model. The JSP file reads information from the ActionForm bean using JSP tags. Components like business logic /business processes and data are the part of model.

The business logic updates the state of the model and helps control the flow of the application. With Struts this is done with an Action class as a thin wrapper to the actual business logic.

View: The view is responsible for rendering the state of the model. The presentation semantics are encapsulated within the view, therefore model data can be adapted for several different kinds of clients.The view modifies itself when a change in the model is communicated to the view. A view forwards user input to the controller.The view is simply a JSP file. There is no flow logic, no business logic, and no model information just tags. Tags are one of the things that make Struts unique compared to other frameworks like Velocity. HTML, JSP are the view components.

Controller: The controller is responsible for intercepting and translating user input into actions to be performed by the model. The controller is responsible for selecting the next view based on user input and the outcome of model operations.The Controller receives the request from the browser, and makes the decision where to send the request. With Struts, the Controller is a command design pattern implemented as a servlet. The struts-config.xml file configures the Controller. Action Servlet of Struts is part of Controller components which works as front controller to handle all the requests.

Struts provides its own Controller component and integrates with other technologies to provide the Model and the View. For the Model, Struts can interact with standard data access technologies, like JDBC and EJB, as well as most any third-party packages, like Hibernate, iBATIS, or Object Relational Bridge. For the View, Struts works well with JavaServer Pages, including JSTL and JSF, as well as Velocity Templates, XSLT, and other presentation systems.

Struts is a set of cooperating classes, servlets, and JSP tags that make up a reusable MVC 2 design. This definition implies that Struts is a framework, rather than a library, but Struts also contains an extensive tag library and utility classes that work independently of the framework.

Developing web application using struts frame work is fairly complex, but it eases things after it is setup. It encourages software development following the MVC design pattern. Many web applications are JSP-only or Servlets-only. With JSP and Servlets, Java code is embedded in the HTML code and the Java code calls println methods to generate the HTML code respectively. Both approaches have their advantages and drawbacks. Struts gathers their strengths to get the best of their association.

Read more...

Friday, June 12, 2009

Model View Controller (MVC) Design Pattern

Model-View-Controller (MVC) is a design pattern put together to help control change. MVC decouples interface from business logic and data. The MVC (Model-View-Controller) architecture the client request is first intercepted by a servlet referred as controller servlet, this servlet handles the initial processing of the request and determines which JSP page to display next. Here the controller servlet is the single point of entry, there is a clear sepration of business logic, presentation output and request processing.

MCV architecture is a way of decomposing an application into three parts:

Model : The model contains the core of the application's functionality. The model encapsulates the state of the application. Sometimes the only functionality it contains is state. It knows nothing about the view or controller.The model maintains the state and data that the application represents.

View: The view provides the presentation of the model. It is the look of the application. The view can access the model getters, but it has no knowledge of the setters. In addition, it knows nothing about the controller. The view should be notified when changes to the model occur.The view allows the display of information about the model to the user.

Controller: The controller reacts to the user input. It creates and sets the model.The controller allows the user to manipulate the application.

MVC Design Pattern comprised of two models.
  • MVC Model 1 is a Page Centric Architechure
  • MVC Model 2 is a Serlet Centric Architechure
Struts frame work extensively makes use of MVC 2 Architecture

MVC was originally applied in the graphical user interaction model of input, processing and output. In Struts, the view is handled by JSPs and presentation components, the model is represented by Java Beans and the controller uses Servlets to perform its action.

Read more...

Testing phases

Development Projects follows the following Testing phases

  • Unit tests can be done using JUnit or any other tools by Developers
  • System tests (ST)or Functional tests will be carried out by Business Analysts or Testers
  • System Integration tests (SIT) or Component Integration Testing (CIT) will be done by Business Analysts, Testers, Developers etc
  • Regression tests will be carried out by Business Analysts and Testers
  • Performance Testing (PT) or Stress Volume Tests or Toad tests will be carried out by Technical Testing team
  • User acceptance tests (UAT) will be done completely by end users

Read more...

Tuesday, June 9, 2009

Hibernate Vs JDBC

Hibernate is better than JDBC because of the following reasons

Support for Query Language:
JDBC supports only native Structured Query Language (SQL). Developer has to find out the
efficient way to access database, i.e to select effective query from a number of queries to perform same task. Hibernate provides a powerful query language Hibernate Query Language
(independent from type of database) that is expressed in a familiar SQL like syntax and includes full support for polymorphic queries. Hibernate also supports native SQL statements. It also selects an effective way to perform a database manipulation task for an application.

Database Dependent Code:
Application using JDBC to handle persistent data (database tables) having database specific code in large amount. The code written to map table data to application objects and vice versa is actually to map table fields to object properties. As table changed or database changed then it’s essential to change object structure as well as to change code written to map table-to-object/object-to-table. Hibernate provides this mapping itself. The actual mapping between tables and application objects is done in XML files. If there is change in Database or in any table then the only need to change XML file properties.

Maintenance Cost :
With JDBC, it is developer’s responsibility to handle JDBC result set and convert it to Java objects through code to use this persistent data in application. So with JDBC, mapping between Java objects and database tables is done manually. Hibernate reduces lines of code by maintaining object-table mapping itself and returns result to application in form of Java objects. It relieves programmer from manual handling of persistent data, hence reducing the development time and maintenance cost.

Optimize Performance:
Caching is retention of data, usually in application to reduce disk access. Hibernate, with
Transparent Persistence, cache is set to application work space. Relational tuples are moved to this cache as a result of query. It improves performance if client application reads same data many times for same write. Automatic Transparent Persistence allows the developer to concentrate more on business logic rather than this application code. With JDBC, caching is maintained by hand-coding.

Relational Persistence for JAVA:
Working with both Object-Oriented software and Relational Database is complicated task with
JDBC because there is mismatch between how data is represented in objects versus relational
database. So with JDBC, developer has to write code to map an object model's data representation to a relational data model and its corresponding database schema. Hibernate is flexible and powerful ORM solution to map Java classes to database tables. Hibernate itself takes care of this mapping using XML files so developer does not need to write code for this.

Transparent Persistence:
The automatic mapping of Java objects with database tables and vice versa is called Transparent Persistence. Hibernate provides transparent persistence and developer does not need to write code explicitly to map database tables tuples to application objects during interaction with RDBMS. With JDBC this conversion is to be taken care of by the developer manually with lines of code.

Automatic Versioning and Time Stamping:
By database versioning one can be assured that the changes done by one person is not being roll backed by another one unintentionally. Hibernate enables developer to define version type field to application, due to this defined field Hibernate updates version field of database table every time relational tuple is updated in form of Java class object to that table. So if two users retrieve same tuple and then modify it and one user save this modified tuple to database, version is automatically updated for this tuple by Hibernate. When other user tries to save updated tuple to database then it does not allow to save it because this user does not has updated data. In JDBC there is no check that always every user has updated data. This check has to be added by the developer.

Open-Source, Zero-Cost Product License:
Hibernate is an open source and free to use for both development and production deployments.

Enterprise-Class Reliability and Scalability:
Hibernate scales well in any environment, no matter if use it in-house Intranet that serves hundreds of users or for mission-critical applications that serve hundreds of thousands. JDBC can not be scaled easily.

Read more...

Saturday, June 6, 2009

What is Hibernate ?

Hibernate is an Object-Relational Mapping (ORM) solution for JAVA. It is a powerful, high performance object/relational persistence and query service. It allows us to develop persistent classes following object-oriented principles including association, inheritance and polymorphism.

Hibernate is a solution or object relational mapping and a persistence management
solution. Hibernate provides a solution to map database tables to a classI It copies the database data to a class. In the other direction it supports to save objects to the databaseI In this process the object is trans ormed to one or more tables. Saving data to a storage is called persistence and the copying of tables to objects and vice versa is called object relational mapping.

Hibernate itself opens connection to database, converts HQL (Hibernate Query Language) statements to database specific statement, receives result set, then performs mapping of these database specific data to Java objects which are directly used by Java application.

Hibernate uses the database specification from Hibernate Properties file. Automatic mapping is performed on the basis of the properties defined in hbm XML file defined for particular Java object.

Read more...

Hibernate Object States

Hibernate defines and supports the following object states

Transient - an object is transient if it has just been instantiated using the new operator, and it is not associated with a Hibernate Session. It has no persistent representation in the database and no identifier value has been assigned. Transient instances will be destroyed by the garbage collector if the application doesn't hold a reference anymore. Use the Hibernate Session to make an object persistent (and let Hibernate take care of the SQL statements that need to be executed for this transition.

Persistent - a persistent instance has a representation in the database and an identifier value. It might just have been saved or loaded, however, it is by definition in the scope of a Session. Hibernate will detect any changes made to an object in persistent state and synchronize the state with the database when the unit of work completes. Developers don't execute manual UPDATE statements, or DELETE statements when an object should be made transient.

Detached - a detached instance is an object that has been persistent, but its Session has been closed. The reference to the object is still valid, of course, and the detached instance might even be modified in this state. A detached instance can be reattached to a new Session at a later point in time, making it (and all the modifications) persistent again. This feature enables a programming model for long running units of work that require user think-time. We call them application transactions, i.e. a unit of work from the point of view of the user.

Read more...

Wednesday, June 3, 2009

Java Messaging Service (JMS)

The Java Messaging Service (JMS) is a standard API for accessing enterprise messaging systems.

JMS is an enterprise messaging system, also referred to as message-oriented middleware (MOM), enables applications to communicate with one another through the exchange of messages. A message is a request, report, and/or event that contains information needed to coordinate communication between different applications.

A message provides a level of abstraction, allowing you to separate the details about the destination system from the application code.

JMS (Java Messaging Service) Features

  • Enables Java applications sharing a messaging system to exchange messages.
  • Simplifies application development by providing a standard interface for creating, sending, and receiving messages.
  • JMS specification describes a common way for Java programs to create, send, receive and read distributed enterprise messages.
  • Loosely coupled communication
  • Asynchronous messaging
  • Reliable delivery where a message is guaranteed to be delivered once and only once

MOM Stands for Message Oriented Middleware. MOMA (Message Oriented Middleware Association) promotes MOM as a middleware solution in distributed computing applications.

MOM mainly addresses the following issues
  • Asynchronous communication between objects available on locations on the network
  • Fault tolerance feature in Distributed Application Development

Read more...
Blog Widget by LinkWithin

JS-Kit Comments

  © Blogger template Newspaper III by Ourblogtemplates.com 2008

Back to TOP