JBoss-IDE 1.2.2 Tutorial 1

zhaozj2021-02-16  52

JBoss-IDE 1.2.2 Tutorial 1:

Preface:

JBoss-IDE is a Plugin in Eclipse, which supports the Eclipse 2.1.x series and Eclipse 3.0.x series, first download and install Eclipse (www.eclipse.org).

Introduction:

The main purpose of this tutorial is to demonstrate how to use JBoss-IDE / Eclipse to develop J2EE's application project. The example is in J2EE's project with a session (session) EJB and a servlet to calculate Fibonacchi Nupers (Fibonacci, an integer number, wherein each number is equal to two sums of sum).

Several tutorials are separated:

l Project: This part will show the current preparation of the development item (source and the path to establish)

l EJB: This will show how to write EJB with XDoclet's Javadoc tags.

l Generate an EJB profile: This displays how to set up the XDoclet generation setting to generate all files related to EJB

l Servlet and Web-App: How to display the servlet how to use the XDoclet's Javadoc label

l Generate a servlet profile: This displays how to set up the XDoclet generating setting to generate all files related to web

l J2EE Application Project: This part shows how new legacy files

l Package: This part shows how to encapsulate J2EE applications

l JBoss setting: How to display how to set up JBoss in Eclipse

l Deploy: How to deploy J2EE application items

l Insect: This shows how to set the breakpoint in a deployed project

demand:

To run the instance of this tutorial, you must:

l Java Development Kit 1.3.0 or above version (JDK is for start JBoss 3.x)

l Eclipse 2.1.0 (http://www.eclipse.org) or above

l JBoss Server 3.0.x or 3.2.x

You also need some knowledge to develop and demonstrate in Eclipse. See more information in the Eclipse's web page.

project:

This part will show the current preparation of the development, we will add a source of data clips, enter the library, and setup paths.

Add a Java project in Eclipse. Name Enter 'Tutorial'.

Added a source data clip 'src'. The preset output data is clipped to 'bin', then press 'Finish'.

In Package Explorer, you should see this picture:

Copying two files in JBoss's data sheets in the root of the project:

l Javax.Servlet.jar (in JBoss Server / Default / LIB)

l JBoss-j2ee.jar (in the server / default / lib in JBoss)

We need to put these two JAR files in the establishment path, right-click the item to select 'Properties' -> 'Java Build Path' -> 'Add Jars ...', choose these two JAR files, press 'OK':

After the setting is set, you should see this figure:

EJB:

The next step is to add an EJB. In order to simplify the program, it will be a newly incremented session, and other types of EJB is also easy to write.

Add a Java Class. Package Fill in 'Fibobean'. Press 'Add ...' plus 'sessionBean' Interface. Select 'Constructors from Superclass' and 'Inherited Abstract Methods'.

After the record is set, you should see this picture: Open 'Fibobobean.java' file. We have to add a 'EJBCREATE' method without parameters to define a session bean in the uncleary state.

Public void ejbcreate () throws createException {

}

Add a method of calculating the Fibonacci number, Compute, returns a Double column.

Public Double [] compute (int number) {

IF (Number <0) {

Throw New EjBexception ("argument shouth be posacy");

}

Double [] suite = new double [number 1];

Suite [0] = 0;

IF (Number == 0) {

Return suite;

}

Suite

[1]

= 1;

For (int i = 2; i <= number; i ) {

Suite [i] = suite [i - 1] suite [i - 2];

}

Return suite;

}

The next step is to add EJB XDoclet's Javadoc-related label. Enter '@ejb' on the segment of Java's editing window Javadoc and press 'Ctrl Space' (author press: The author is using a Chinese job system, while switching China / English The input key group is 'ctrl space', so this feature is not too feasible, and my solution is to enter '@' and then wait for the automatic completion code function.), You will see the window of the automatic completion function. pop up:

After selecting 'Stateless Session EJB', complete the tag of the xdoclet, as follows:

*

* @ ejb.bean name = "fibo"

* Display-name = "FIBO EJB"

* Description = "EJB That Computes Fibonacci Suite"

* View-type = "remote"

* JNDI-NAME = "EJB / TUTORALIAL / FIBO"

* /

Public Class Fibobean Implements SessionBean {

The XDoclet label code of 'EJBCREATE' method is as follows:

/ **

* DEFAULT CREATE METHOD

* @Throws CreateException

* @ ejb.create-method

* /

Public void ejbcreate () throws createException {

The xdoclet label code for the 'Compute' method is as follows:

/ **

* @Param Number

* @Return

*

* @ ejb.interface-method view-type = "remote"

* /

Public Double [] compute (int number) {

转载请注明原文地址:https://www.9cbs.com/read-21981.html

New Post(0)