Develop n-tier applications using J2EE
An introduction to the Java 2 Platform, Enterprise Edition specification by way of BEA's WebLogic Server
By Steven Gould, JavaWorld.com, 12/01/00
- 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
Resources
- "JDBC Drivers in the Wild," Nitin Nanda (JavaWorld, July 7, 2000) explains how to deploy, use, and benchmark JDBC driver types 1, 2, 3, and 4
http://www.javaworld.com/jw-07-2000/jw-0707-jdbc.html
- "XML Document Processing in Java Using XPath and XSLT," André Tost (JavaWorld, September 8, 2000)
http://www.javaworld.com/javaworld/jw-09-2000/jw-0908-xpath.html
- "Programming XML in Java, Part 1," Mark Johnson (JavaWorld, March 2000) looks at how to use SAX to process XML documents in Java
http://www.javaworld.com/javaworld/jw-03-2000/jw-03-xmlsax.html
- For more JavaWorld articles covering JDBC, visit the Java Database Connectivity (JDBC) section of our Topical Index
http://www.javaworld.com/javaworld/topicalindex/jw-ti-jdbc.html
- JavaWorld's Topical Index also offers extensive articles on EJBs
http://www.javaworld.com/javaworld/topicalindex/jw-ti-ejb.html
- JavaWorld's Topical Index offers a lot of information on XML as well
http://www.javaworld.com/javaworld/topicalindex/jw-ti-javaxml.html
- For answers to your pressing J2EE questions, check out the JavaWorld Server-Side Java discussion
http://forums.itworld.com/webx?14@@.ee6bdcf
- Sign up for the JavaWorld This Week free weekly email newsletter and keep up with what's new at JavaWorld
http://www.idg.net/jw-subscribe
- Professional Java XML Programming with Servlets and JSP, Alexander Nakhimovsky and Tom Myers (Wrox Press, 1999) provides good coverage of XML and related topics and their relation
to Java
http://www.amazon.com/exec/obidos/ASIN/1861002858/qid=974496697/sr=1-3/107-1103713-5842922
- Sun's J2EE page contains the latest information and updates to the J2EE specifications
http://www.javasoft.com/j2ee
- You'll also want to check out Sun's J2EE documentation, FAQs, and developer guides
http://java.sun.com/j2ee/docs.html
- The WebLogic Server Website offers extensive documentation on installing, configuring, and administering WebLogic Server,
and on using it as a development platform. It should be the first place you look for help with any WebLogic-related questions
you have
http://www.weblogic.com
- The HttpServlet API documentation at Java.sun.com offers more information on Java servlets
http://java.sun.com/products/servlet/2.2/javadoc/javax/servlet/http/HttpServlet.html
- Sun's Java Developer Connection -- a must for every Java developer -- contains reservoirs of technical documentation, FAQs,
whitepapers, and more
http://developer.java.sun.com/developer
- Developing Java Enterprise Applications, Stephen Ashbury and Scott R. Weiner (John Wiley and Sons, 1999) covers much of the same material as this article but in significantly
more depth
http://www.amazon.com/exec/obidos/ASIN/0471327565/o/qid=974165631/sr=8-2/ref=aps_sr_b_1_2/104-2442186-0189510
- "Java Database Connectivity," Carol Sliwa (Computerworld, December 13, 1999) discusses the pros and cons of the four types of JDBC driver, and covers when you would use each
http://www.computerworld.com/cwi/story/0,1199,NAV47-68-85-98_STO43545,00.html
- Sun's Java.sun.com Website offers a complete list of JNDI service providers
http://java.sun.com/products/jndi/serviceproviders.html
- "The JNDI tutorialBuilding Directory-Enabled Java Applications," Rosanna Lee (Java.sun.com, May 1, 2000)
http://java.sun.com/products/jndi/tutorial/index.html
- Visit Sun's Java-XML page for news on the latest developments surrounding the combination of Java and XML
http://java.sun.com/xml
- The XML Zone at IBM's developerWorks
http://www.ibm.com/developer/xml/
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