Top
首页 > 老文章 > 正文

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
发布时间:2006-03-10 04:07        来源:        作者:

Table of Contents

Tutorial.

Preface

About the Authors

Acknowledgments

Disclaimer

Introduction

Prerequisites for this tutorial

Tools required for this tutorial

Case Study Overview


Chapter 1.

Configuration of ECLIPSE using JBOSS and LOMBOZ

Install Eclipse

Install JBOSS

Creating Database Schema

Install Lomboz

Lomboz Configuration

Configure JBOSS to run from within Eclipse

Test your configuration


Chapter 2.

Overview Of J2EE Technology and Concepts

J2EE Components

J2EE Clients

Web Components

Business Components

Enterprise Information System Tier

J2EE Containers


Packaging

J2EE Platform Roles

Distributed Architecture in J2EE

Java Naming Directory Interface (JNDI) Architecture


Chapter 3.

Creating a Stateless Session Bean

Tasks

Create J2EE Project

Create StoreAccess Stateless Bean

Setup DAO

Create StoreAccess's DAO Interface

Add Business Method

Implement DAO Interface

Add Callback Method

Deploy StoreAccess Bean

Create your Test Client

Test your Client


Chapter 4.

Creating a Stateful Session Bean

Tasks

Create StoreAccessState Stateful Bean

Create StoreAccessSate's DAO Interface

Add Business Method

Add Callback Method


Implement DAO Interface

Deploy StoreAccessState Bean

Create your Test Client

Test your Client


Chapter 5.

Creating a BMP Entity Bean

Tasks

Create Customer BMP Entity Bean

Create Customer's DAO Interface

Add Finder Methods

Add Business Methods

Implement Customer's DAO Interface :

Deploy Customer Bean

Add Create Method in StoreAccess

Add Business Method in StoreAccess

Create your Test Client


Test your Client

Exercise


Chapter 6.

Creating a CMP Entity Bean

Tasks

Create Item CMP Entity Bean

Implement ejbCreate Method

Add Finder Methods

Add Business Methods

Add Callback Methods

Deploy Item Bean

Add Business Method in StoreAccess


Create your Test Client

Test your Client

Exercise


Chapter 7.

Creating a Message Driven Bean

Tasks

Create RequestItems MDB Bean

Create Immutable Value Object RequestItem

Implement onMessage Method

Deploy RequestItems Bean

Create Test Client


Test your Client

Exercise


Chapter 8.

Creating Web Clients

Create AccessController Servlet

Implement init method

Implement methods doGet and doPost

Deploy AccessController Servlet

Test your Servlet

Create JSP Page

Add Html and JSP Tags

Deploy Module OnlineStore

Test your JSP Page


Chapter 9.

Creating Web Services

Web Services Standards

Web Services In Java

Installing AXIS

Configuring AXIS with JBOSS

Create the Web Service

Deploy the Web Service

Create Web Service Test Client

Test your Client

Create and Test Web Client

Create and Test VB.Net Client

Create and Test Perl Client


Feedback

Feedback






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.

加载更多

专题访谈

合作站点
stat