站内搜索: 请输入搜索关键词

当前页面: 开发资料首页J2EE 专题Tutorial for building J2EE Applications using JBOSS and ECLIPSE

Tutorial for building J2EE Applications using JBOSS and ECLIPSE

摘要: Tutorial for building J2EE Applications using JBOSS and ECLIPSE

Table of Contents

<table borderColor=#2323dc cellSpacing=0 cellPadding=2 rules=cols width="100%" border=1> <tr vAlign=top> <th width="26%" rowSpan=8>

Tutorial.

</th> <th width="60%">

Preface

</th> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

About the Authors

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Acknowledgments

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Disclaimer

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Introduction

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Prerequisites for this tutorial

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Tools required for this tutorial

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Case Study Overview


</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="26%" rowSpan=8>

Chapter 1.

</td> <td width="60%">

Configuration of ECLIPSE using JBOSS and LOMBOZ

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Install Eclipse

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Install JBOSS

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Creating Database Schema

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Install Lomboz

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Lomboz Configuration

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Configure JBOSS to run from within Eclipse

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Test your configuration


</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="26%" rowSpan=11>

Chapter 2.

</td> <td width="60%">

Overview Of J2EE Technology and Concepts

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

J2EE Components

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

J2EE Clients

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Web Components

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Business Components

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Enterprise Information System Tier

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

J2EE Containers

</td> <td width="14%">


</td></tr> <tr vAlign=top> <td width="60%">

Packaging

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

J2EE Platform Roles

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Distributed Architecture in J2EE

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Java Naming Directory Interface (JNDI) Architecture


</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="26%" rowSpan=12>

Chapter 3.

</td> <td width="60%">

Creating a Stateless Session Bean

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Tasks

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Create J2EE Project

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Create StoreAccess Stateless Bean

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Setup DAO

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Create StoreAccess's DAO Interface

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Add Business Method

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Implement DAO Interface

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Add Callback Method

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Deploy StoreAccess Bean

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Create your Test Client

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Test your Client


</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="26%" rowSpan=10>

Chapter 4.

</td> <td width="60%">

Creating a Stateful Session Bean

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Tasks

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Create StoreAccessState Stateful Bean

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Create StoreAccessSate's DAO Interface

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Add Business Method

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Add Callback Method

</td> <td width="14%">


</td></tr> <tr vAlign=top> <td width="60%">

Implement DAO Interface

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Deploy StoreAccessState Bean

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Create your Test Client

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Test your Client


</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="26%" rowSpan=13>

Chapter 5.

</td> <td width="60%">

Creating a BMP Entity Bean

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Tasks

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Create Customer BMP Entity Bean

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Create Customer's DAO Interface

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Add Finder Methods

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Add Business Methods

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Implement Customer's DAO Interface :

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Deploy Customer Bean

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Add Create Method in StoreAccess

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Add Business Method in StoreAccess

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Create your Test Client

</td> <td width="14%">


</td></tr> <tr vAlign=top> <td width="60%">

Test your Client

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Exercise


</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="26%" rowSpan=12>

Chapter 6.

</td> <td width="60%">

Creating a CMP Entity Bean

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Tasks

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Create Item CMP Entity Bean

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Implement ejbCreate Method

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Add Finder Methods

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Add Business Methods

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Add Callback Methods

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Deploy Item Bean

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Add Business Method in StoreAccess

</td> <td width="14%">


</td></tr> <tr vAlign=top> <td width="60%">

Create your Test Client

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Test your Client

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Exercise


</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="26%" rowSpan=9>

Chapter 7.

</td> <td width="60%">

Creating a Message Driven Bean

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Tasks

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Create RequestItems MDB Bean

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Create Immutable Value Object RequestItem

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Implement onMessage Method

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Deploy RequestItems Bean

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Create Test Client

</td> <td width="14%">


</td></tr> <tr vAlign=top> <td width="60%">

Test your Client

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Exercise


</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="26%" rowSpan=10>

Chapter 8.

</td> <td width="60%">

Creating Web Clients

</td> <td width="14%"></td></tr> <tr vAlign=top> <td width="60%">

Create AccessController Servlet

</td> <td width="14%" rowSpan=9></td></tr> <tr> <td vAlign=top width="60%">

Implement init method

</td></tr> <tr> <td vAlign=top width="60%">

Implement methods doGet and doPost

</td></tr> <tr> <td vAlign=top width="60%">

Deploy AccessController Servlet

</td></tr> <tr> <td vAlign=top width="60%">

Test your Servlet

</td></tr> <tr> <td vAlign=top width="60%">

Create JSP Page

</td></tr> <tr> <td vAlign=top width="60%">

Add Html and JSP Tags

</td></tr> <tr> <td vAlign=top width="60%">

Deploy Module OnlineStore

</td></tr> <tr> <td vAlign=top width="60%">

Test your JSP Page


</td></tr> <tr vAlign=top> <td width="26%" rowSpan=12>

Chapter 9.

</td> <td width="60%">

Creating Web Services

</td> <td width="14%" rowSpan=12></td></tr> <tr> <td vAlign=top width="60%">

Web Services Standards

</td></tr> <tr> <td vAlign=top width="60%">

Web Services In Java

</td></tr> <tr> <td vAlign=top width="60%">

Installing AXIS

</td></tr> <tr> <td vAlign=top width="60%">

Configuring AXIS with JBOSS

</td></tr> <tr> <td vAlign=top width="60%">

Create the Web Service

</td></tr> <tr> <td vAlign=top width="60%">

Deploy the Web Service

</td></tr> <tr> <td vAlign=top width="60%">

Create Web Service Test Client

</td></tr> <tr> <td vAlign=top width="60%">

Test your Client

</td></tr> <tr> <td vAlign=top width="60%">

Create and Test Web Client

</td></tr> <tr> <td vAlign=top width="60%">

Create and Test VB.Net Client

</td></tr> <tr> <td vAlign=top width="60%">

Create and Test Perl Client


</td></tr> <tr vAlign=top> <td width="26%">

Feedback

</td> <td width="60%">

Feedback

</td> <td width="14%">


</td></tr></table>





Preface.

This tutorial is about building Java 2 Platform, Enterprise Edition (J2EE) components using Eclipse as an Integrated Development Environment (IDE) and JBOSS as the Application Server. Tutorial covers step-by-step development of J2EE components, starting from setting up Eclipse, JBOSS and Lomboz. Lomboz uses Xdoclet (Attribute Oriented Programming) for rapid development of J2EE components. Importantly, all of the tools used in this tutorial can be downloaded free of charge, so there should be nothing stopping you!

Eclipse provides an excellent IDE, with features like refactoring and debugging. JBOSS is integrated within Eclipse using JBOSS plug-in. Lomboz is another plug-in used for building J2EE components, which provides wizards for bean creation, method creation, deployment of bean, test client creation etc. JBOSS is an integrated application server with convenient built-in components such as the Hypersonic Database and Jetty as the Web Engine. This bundling of all the key components of a J2EE environment assists beginners in learning how to develop J2EE applications. Having gained some skills and confidence, beginners can move on to tools provided by other vendors.

One of the problems J2EE developers face is that of synchronizing their code with J2EE's deployment descriptors. As development of components progresses, developers have to keep updating deployment descriptors, a generally tedious activity which can lead to other mistakes, instead of this devoting time to the business logic of the application. Xdoclet generates these interfaces and helper classes along with deployment descriptors, by parsing source files. These files are generated from templates that use the information provided in the source code and its JavaDoc tags. XDoclet allows developers to concentrate on only one Java source file per component, that is, concentrate on the business logic of the application, and the rest is done by Xdoclet.

For so many years developers have been looking for some sort of a tool which speeds up this process of development and deployment, and Xdoclet is certainly a step in that direction. Hopefully you'll find that Xdoclet makes development and deployment rapid and easy. So explore the power of Xdoclet, Eclipse and JBOSS!



About the Authors.

Glen McCallum.

Glen joined TUSC in 1990. He has extensive experience in software development for the telecommunications industry, including C, C++, Perl and Java. Outside of TUSC, Glen continues to fiddle with such technologies as he thinks are “cool”. This includes TCP/IP networking, security, cryptography, VPNs, digital video capture, Bluetooth, PDAs and J2EE, all on Linux. His wife and two young sons complete a “pure Linux” household.

Vishal Sharma.

Vishal was born in 1976 in India. He studied mechanical engineering, graduating in 1998. After working in that field for 6 months, he came to Australia and obtained a Master's degree in Computer Science. Since graduating from RMIT Melbourne in 2001 he first worked as a software engineer in Mcom Solutions developing communication protocols. Vishal joined TUSC in 2002 and has enjoyed a varied diet of different projects since then. Most recently he has been involved in building multi-tiered Web applications for the telecommunications industry, with a particular focus on J2EE technology.



Acknowledgments.

We'd like to thank some particular TUSC people: Rod Bower, Telecommunications Business Unit Manager, Sebastian Bellofiore, Delivery Manager and Marcia Abbott, Business Improvement Manager for their support and help in this initiative, and of course our colleagues for their collaboration; Simon Shields, Andrew Hendry and Ray Walford.

Vishal wishes to thank Glen McCallum for his guidance, inspiration and invaluable support in bringing this to you all.



Disclaimer.

TUSC MAKES NO WARRANTY OF ANY KIND WITH REGARD TO THIS MATERIAL INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OR SUITABILITY FOR A PARTICULAR PURPOSE.

TUSC shall not be liable for errors contained herein or for incidental consequential damages in connection with the supply of, performance of, or use of this material.

This document contains proprietary information which is protected by copyright.

All rights are reserved. No parts of this document may be photocopied, reproduced or translated to another language without the prior written permission of TUSC.

© Copyright 2003 TUSC Computer Systems Pty. Ltd.



Introduction.

Prerequisites for this tutorial.

Before you start this tutorial, you should ideally have a working knowledge of Java technology, XML, J2EE technology and some exposure to SQL, JDBC concepts, and Xdoclet (Attribute Oriented Programming). Even if you are new to a lot of this then don't panic – just expect to do a bit more learning along the way!

All the examples covered in this tutorial were developed on RedHat Linux 8.0, Sun Microsystem's JDK (j2sdk1.4.1_02), using Eclipse 2.1 as the IDE, and Lomboz 2.1_02 plugin for Eclipse. JBOSS-3.2.1 is being used as an application server to deploy applications. Jetty is used as the web server and Hypersonic SQL as the database, both of which are integrated in the JBOSS application server.

Tools required for this tutorial.

You will need a current version of Java Development Kit (JDK) or Java Runtime Environment (JRE) - at least JDK 1.3 onwards. Eclipse 2.1 is required as an Integrated Development Environment (IDE) along with the Eclipse plug-in Lomboz 2.1_02 for J2EE applications development and JBOSS integration.

JBOSS-3.2.1 is being used as an application server to deploy applications, together with its embedded Jetty web server and Hypersonic SQL database as noted above.

Case Study Overview.

For this tutorial we are using a case study similar to Inventory, rather than using any complex scenario or going into strict database design, as our aim is to learn how to design and develop various J2EE components using this new revolutionary approach of Attribute Oriented Programming with the help of these tools.

We have a database schema called 'MyStore' which is composed of five tables.

Table Supplier records details of those suppliers (many) who sell different materials to MyStore as request is sent to these suppliers from MyStore manager as need arises.

Table Manager records details of managers who run MyStore, currently there is only one manager.

Table Customer records details of those customers (many) who have bought some items at least once.

Table Items maintains an inventory of available/non-available items (many).

Table StoreAccess records the authentication details of all customers, suppliers and manager for on-line access of MyStore.

The MyStore Database is shown in the figure below.




To access data from the database and do business operations, we will create various J2EE components including Session, Entity and Message-driven Enterprise Java Bean components along with Web clients using Servlets and JSP pages.

Figure below presents an overview of the MyStore application's architecture.




Note : In the case of Web clients, a request is sent by Servlets/JSP (Java Server Pages) to beans using RMI (Remote Method Invocation). Stateless, Stateful and Bean Managed Persistence (BMP) Entity Beans access data from the database using Data Access Objects (DAO), which are wrappers for Java Database Connectivity (JDBC) code, while Container Managed Persistence (CMP) Entity Beans don't require a DAO, as the container manages communication between the Beans and the database, which is a very powerful feature. Finally, in the case of Java clients requests are made via Java middleware technology (RMI, CORBA, Java Messaging) to Entity Beans.

All beans together with their public behaviors/methods which will be implemented during the course of this tutorial are shown below. StoreAccessBean is a Session facade bean, which exposes its interface to the Presentation Tier, while encapsulating the complex business interactions with Customer, Manager, Item and Suppler Entity beans.


MyStore customers, suppliers and manager login into the system using the StoreAccess stateless session bean. Once authenticated, they request information about MyStore's inventory, manager details, customer details and supplier details using the various interfaces available in the StoreAccess bean, which invokes methods on the remaining beans, from where the information is requested. RequestItems and DeliverItems are Message Driven Beans which listen for messages from a JMS producer and transfer messages to appropriate beans.

Now lets start this tutorial, with setting up the environment in chapter 1.



↑返回目录
前一篇: Tutorial for building J2EE Applications using JBOSS and ECLIPSE -1
后一篇: Quest JProbe最佳实践指南--------分析Weblogic J2EE应用性能