Newsletter sign-up
View all newsletters

Sign up for our technology specific newsletters.

Enterprise Java
Email Address:

Develop n-tier applications using J2EE

An introduction to the Java 2 Platform, Enterprise Edition specification by way of BEA's WebLogic Server

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone

Page 4 of 7

Another database feature frequently required in enterprise applications is support for transactions. A transaction is a group of statements that should be treated as a single statement to ensure data integrity. JDBC uses the auto-commit transaction mode by default. This can be overridden using the setAutoCommit() method of the Connection class.

Now that we have a sense of JDBC, let's turn our attention to JNDI.

Java Naming and Directory Interface (JNDI)

The JNDI API is used to access naming and directory services. As such, it provides a consistent model for accessing and manipulating such enterprise-wide resources as DNS, LDAP, local filesystems, or objects in an application server.

In JNDI, every node in a directory structure is called a context. Every JNDI name is relative to a context; there is no notion of an absolute name. An application can obtain its first context using the InitialContext class:

Context ctx = new InitialContext();


From this initial context, the application can traverse the directory tree to locate the desired resources or objects. For example, assume that you have deployed an EJB within WebLogic Server and bound the home interface to the name myApp.myEJB. A client of this EJB, after obtaining an initial context, could then locate the home interface using:

MyEJBHome home = ctx.lookup( "myApp.myEJB" );


Once you have a reference to the acquired object -- in this case, the home interface of the EJB -- it is then possible to invoke methods on it. We will discuss this further in the section below entitled "Enterprise Java Beans."

The above discussion of JNDI is just the tip of the iceberg. In addition to looking up objects in a context, JNDI also provides methods to:

  • Insert, or bind, an object into a context. This is effectively what you do when you deploy an EJB.
  • Remove an object from a context.
  • List all objects within a context.
  • Create and delete subcontexts.


Next, let's turn our attention to EJBs.

Enterprise Java Beans (EJB)

One of the J2EE technologies to receive a great deal of media attention is EJBs. They provide a framework for developing and deploying distributed business logic to clients, thereby significantly easing the development of scalable, highly complex enterprise applications. The EJB specification defines how and when EJB components should interact with their container. It is the responsibility of the container to provide for common services, such as directory services, transaction management, security, resource pooling, and fault tolerance.

The EJBs specification defines three fundamental types of bean:

  • Stateless session beans: These provide a single-use service, do not maintain any state, do not survive server crashes, and are relatively short lived. For example, a stateless session bean may be used to perform temperature conversion.
  • Stateful session bean: These provide a conversational interaction with the client and, as such, store state on the behalf of the client. An online shopping cart is a classic example of a stateful session bean. Stateful session beans do not survive server crashes, are also relatively short lived, and each instance can be used only by a single thread.
  • Entity beans: These provide a representation of persistent data -- typically stored in a database -- and can therefore survive a server crash. Multiple clients can use EJBs that represent the same data. An example of an entity EJB: a customer's account information.


In spite of their differences, all EJBs have much in common. They all possess a home interface that defines how a client can create and destroy the EJB; a remote interface that defines the methods a client can invoke on the bean; and a bean class that implements the main business logic.

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Comments (11)
Login
Forgot your account info?

Discounted Louis VuittonBy Anonymous on November 7, 2009, 10:00 pm Discounted Louis Vuitton Handbags,Purse & Wallets Online Shop - Compare our prices to other distributors, Louis Vuitton Louis Vuitton Louis Vuitton Beaubourg Louis...

Reply | Read entire comment

noBy free online games on October 31, 2009, 6:08 pmno

Reply | Read entire comment

replica bagsBy replica handbags on October 30, 2009, 9:29 pmYour comments on this question are pertinent replica bags .And people always do things like and they don't know what they replica handbags are doing at the same...

Reply | Read entire comment

3erBy qast on October 30, 2009, 2:14 pmThank to admin..Post ; share to facebook.. My sites ; film izle müzik dinle free porn sex shop lazer epilasyon program indir lig tv arama thanks.

Reply | Read entire comment

louis vuitton Sale louisBy Anonymous on October 27, 2009, 5:06 amlouis vuitton Sale louis vuitton bags louis vuitton discounted louis vuitton ...

Reply | Read entire comment

View all comments

Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a JavaWorld account? Log in here. Register now for a free account.
Resources
  • JavaWorld resources
  • Other resources