JBuilder9.0 + Weblogic7.0 actual articles session bean

zhaozj2021-02-16  50

JBUILDER9 WebLogic7 actual articles

Session bean

Author: Huang Kai E_mail: hk_sz@163.com

The application of the second session bean

First, create an EJBS

1. Select File / New in the menu bar.

2. Click the Enterprise subpage;

3. Select EJB Module and click OK to appear EJB Module window;

4. Enter Math after NAME;

5. Change Version to EJB 2.0 Compliant;

6. Click OK. EJB is designed in the document window.

7. On the right MATH subpage, click the first Create EJB icon, then find and click Session Bean;

8. Enter Mathejb after Bean Name;

9. Move the mouse to Mathejb, press right-click, pop up the menu;

10. Select Add / Method, then a session box appears, you can set the properties of this method on the above;

11. Enter the add name after Method Name;

12. Enter int after return type;

13. Interfaces Select Remote;

14. Right-click Add, select View Bean Source in the pop-up menu;

15. At this time, the source code of EJB is displayed, and the ADD method is as follows:

Public Int Add (int Num1, int Num2) {

Int results = Num1 Num2;

Return Result;

}

16. Find the Mathejb.java file in the / MathSample package, double-click to open it;

17.

Public int add () throws remoteexception;

Replace with:

Public Int Add (int Num1, int Num2) throws RemoteException;

18. Expand the MATH module in the engineering window;

19. Double-click Mathejb, change home jndi name: content to EJB / MATHEJB in the General sub page of the document window;

20.File / Save All;

21.math module Right-click to open the menu, select Make to compile EJB Classes;

Next we test whether this bean works fine.

Second, create a client to test this bean

JBuilder provides us with a test client.

1. Select File / New in the menu bar.

2. Click the Enterprise subpage;

3. Select EJB Test Client and click OK to appear EJB Test Client Window;

4. Click Next to confirm that the content after EJB NAME is Mathejb;

5. Only choose Generate Main Function, then click Finish;

6. Select MathejbTestClient1 subpages in the document window, please confirm if the code segment contains this sentence:

Object ref = context.lookup ("ejb / mathejb");

7. Confirm that the URL is:

String URL = "T3: // localhost: 7001";

8. Add:

Try {

Mathejbhome home = client.getHome (); mathejb test = home.create ();

System.out.println ("Result IS:" Test.Add (12, 12));

}

Catch (Exception E) {

System.out.println (E.TOString ());

9.SAVE ALL;

Note: The following steps are not necessary, you can directly start WEBLOGIC, but you must only start one.

Third, configure Server

1. Select Run / Configurations in the menu bar.

2. Select the RUN page;

3. Click New;

4. Enter a server after NAME;

5. Select Server in TYPE;

6. Click OK.

Fourth, deployment and operation

1. Select Perform Server by Run Projest in the Toolbar to start WebLogic;

2. Then find the math.jar under the MATH module in the engineering window, right-click open the menu, select DeployOptions for "Math.jar" / Deploy to deploy it in WebLogic;

3. Find MathejbTestClient1.java in the engineering window, right-click to open the menu, click Run Use "MathejbTestClient1";

4. In the information window, we can see:

Result IS: 24

OK, I successfully made the first session bean.

Remember: WebLogic can be used, the port must be 7001, if not, "String Url =" T3: // localhost: 7001 ";" changed to your corresponding port.

My article is the first Auro Forum (www.newer.com.cn/bbs) and programmers forum (www.9cbs.net), welcome to reprint, but please keep the author and the name of the revision, thank you.

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

New Post(0)