13
1 Java RMI/EJB Tutorial SilkPerformer 2008 2 13.02.2008 Introduction This presentation offers an overview of how to record and replay Java RMI and EJB virtual users. It also shows example use of the sample RMI application (Product Manager) that ships with SilkPerformer.

Java RMI EJB Tutorial

Embed Size (px)

Citation preview

Page 1: Java RMI EJB Tutorial

1

Java RMI/EJB TutorialSilkPerformer 2008

2 13.02.2008

Introduction

This presentation offers an overview of how to record and replay Java RMI and EJB virtual users.

It also shows example use of the sample RMI application (Product Manager) that ships with SilkPerformer.

Page 2: Java RMI EJB Tutorial

2

3 13.02.2008

What to Record/Replay

Record and replay the clientA virtual user is a simulated client application

Server/Server farm

RMI/EJB ClientApplications

4 13.02.2008

Preparation: Create a Project

Choose project type Java / Java RMI/EJB (recording)

Page 3: Java RMI EJB Tutorial

3

5 13.02.2008

Preparation: Profile Settings

Select a Java JDK (version 1.2 or higher)For use internally by the recorderUsed for replay via SilkPerformer Java Framework

Add the Classpath elements that are required by therecorded application

The classpath is not required for recording. It is required for:Compiling the recorded scriptReplay

6 13.02.2008

Preparation: Profile Settings

Java options

Choose a JDK Define the classpath

Page 4: Java RMI EJB Tutorial

4

7 13.02.2008

Preparation: Profile Settings

Set the record log level to DebugWhen contacting technical support, send exported projects with Debug logging enabled

Set log level to Debug

8 13.02.2008

Preparation: Application Profile

Define an application profile for the application you wantto record

Add a new application profile

Enter the path to the executable / startup script (.exe, .bat, or .cmd)

Enter the name of the executablethat hosts the Java VM

(e.g., java.exe or javaw.exe)

Select Custom Application

Select the Java APIs that are to berecorded

Page 5: Java RMI EJB Tutorial

5

9 13.02.2008

Recording IBM‘s Java virtual machine requires additional settings

Preparation: Application Profile for IBM JVM

Edit Java Settings Select Manual

10 13.02.2008

Preparation: Startup Script for IBM JVM

Recording IBM‘s Java virtual machine also requires a customized startup script

Original startup script

Insert call to perfPrepareJavaRecording.cmd

(adjust SilkPerformer‘s home directory if necessary)

Add the command line parameter %PERFREC_OPTIONS%

Customized copy of startup script

Page 6: Java RMI EJB Tutorial

6

11 13.02.2008

Recording

Click the Model Script workflow buttonLaunch the applicationPerform the actions that are to be recorded

12 13.02.2008

Recording

When you are done:Stop recordingSave the script

Overview log

Recorded Java source code

Page 7: Java RMI EJB Tutorial

7

13 13.02.2008

Recorded Result

x.javaThe Java source file that contains the recorded actionsThis file can be compiled from within the SilkPerformer Workbench

The file is compiled automaticallyThe classpath must be specified correctly (Java Profile Settings)

x.bdfBDL stub code that launches the Java virtual user

14 13.02.2008

Testing Applets

Recording AppletsUse Sun Java VM in the browser (not Microsoft)

ReplayRemove the recorded API calls:JavaSetOption(JAVA_CLASSPATH and JavaSetOption(JAVA_CMDLINE_OPTIONS from the BDL scriptObtain JAR and CLASS files from the server; copy these files to the local machine; enter the classpath in Java Profile Settings.

Use recorded comments in the recorded Java source code to find JAR and class files

// ###ClassPath###// ###Applet CodeBase###// ###Applet parameters queried by the Applet###

// codebase=…// archive=…// code=…

Page 8: Java RMI EJB Tutorial

8

15 13.02.2008

Example: Product Manager

The RMI sample application that ships with SilkPerformer is called Product Manager.To launch Product Manager, go to: C:\Borland\SilkPerformer/Sample Applications/Java Samples/Product Manager

16 13.02.2008

Example: Create a Project

Project type: Java / Java RMI/EJB (recording)

Page 9: Java RMI EJB Tutorial

9

17 13.02.2008

Example: Application Profile

Modify the existing Internet Explorer application profile

Deselect WebSelect Java RMISelect Java JNDI

This is required because this sample uses JNDI for the bootstrapping of remote object references

18 13.02.2008

Example: Profile Settings

Specify script generation details at Profile Settings / Record / Script / Java

Page 10: Java RMI EJB Tutorial

10

19 13.02.2008

Example: Profile Settings

Specify Java SettingsAdd ProductManager.jar from the SilkPerformer samples directory

20 13.02.2008

Example: Start Servers

Start the RMI and LDAP servers

Open the Product Manager sample HTML page and follow the instructions:

Step 1: Start the LDAP databaseStep 2: Start JNDI name serverStep 3: Start RMI over IIOP server

Page 11: Java RMI EJB Tutorial

11

21 13.02.2008

Example: Model Script

Open the Model Script dialogEnter the location of the RMI sample application HTML pageClick the ProductManager – DemoVersion.htm link to launch the applet

The applet loads and the recorder begins recording the JNDI and RMI activities of the applet.Perform searches for products; change products; add new products, etc.

22 13.02.2008

Example: Save the Recorded Script

Save the recorded script

Specify a valid Java identifier

Page 12: Java RMI EJB Tutorial

12

23 13.02.2008

Example: Recorded BDL Script

Comment out (or delete) the recorded API calls:JavaSetOption(JAVA_CLASSPATHJavaSetOption(JAVA_CMDLINE_OPTIONS

24 13.02.2008

Example: Recorded Java Script

Page 13: Java RMI EJB Tutorial

13

25 13.02.2008

Example: Replay Script

Continue with SilkPerformer‘s workflow:Run a TryScriptCustomize the scriptIdentify the baseline