Вы находитесь на странице: 1из 13

Java RMI/EJB Tutorial

SilkPerformer 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.

2 13.02.2008

1
What to Record/Replay

™ Record and replay the client


ƒ A virtual user is a simulated client application

RMI/EJB Client
Applications

Server/
Server farm

3 13.02.2008

Preparation: Create a Project

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

4 13.02.2008

2
Preparation: Profile Settings

™ Select a Java JDK (version 1.2 or higher)


ƒ For use internally by the recorder
ƒ Used for replay via SilkPerformer Java Framework
™ Add the Classpath elements that are required by the
recorded application
ƒ The classpath is not required for recording. It is required for:
ƒ Compiling the recorded script
ƒ Replay

5 13.02.2008

Preparation: Profile Settings


Choose a JDK Define the classpath

Java options

6 13.02.2008

3
Preparation: Profile Settings

™ Set the record log level to Debug


ƒ When contacting technical support, send exported projects with
Debug logging enabled

Set log level to Debug

7 13.02.2008

Preparation: Application Profile

™ Define an application profile for the application you want


to record
Enter the path to the executable / startup script (.exe, Enter the name of the executable
.bat, or .cmd) that hosts the Java VM
(e.g., java.exe or javaw.exe)

Select Custom Application

Select the Java APIs that are to be


recorded

Add a new application profile

8 13.02.2008

4
Preparation: Application Profile for IBM JVM
™ Recording IBM‘s Java virtual machine requires additional
settings

Edit Java Settings Select Manual

9 13.02.2008

Preparation: Startup Script for IBM JVM


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

Original startup script

Customized copy Insert call to


of startup script perfPrepareJavaRecording.cmd
(adjust SilkPerformer‘s home directory if
necessary)

Add the command line parameter


%PERFREC_OPTIONS%

10 13.02.2008

5
Recording

™ Click the Model Script workflow button


ƒ Launch the application
ƒ Perform the actions that are to be recorded

11 13.02.2008

Recording

Recorded Java

™ When you are done: source code

ƒ Stop recording
ƒ Save the script
Overview log

12 13.02.2008

6
Recorded Result

™ x.java
ƒ The Java source file that contains the recorded actions
ƒ This file can be compiled from within the SilkPerformer
Workbench
ƒ The file is compiled automatically
ƒ The classpath must be specified correctly (Java Profile Settings)
™ x.bdf
ƒ BDL stub code that launches the Java virtual user

13 13.02.2008

Testing Applets

™ Recording Applets
ƒ Use Sun Java VM in the browser (not Microsoft)
™ Replay
ƒ Remove the recorded API calls:
JavaSetOption(JAVA_CLASSPATH and
JavaSetOption(JAVA_CMDLINE_OPTIONS from the BDL script
ƒ Obtain 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=…

14 13.02.2008

7
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

15 13.02.2008

Example: Create a Project

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

16 13.02.2008

8
Example: Application Profile

™ Modify the existing


Internet Explorer
application profile
ƒ Deselect Web
ƒ Select Java RMI
ƒ Select Java JNDI
ƒ This is required because
this sample uses JNDI for
the bootstrapping of
remote object references

17 13.02.2008

Example: Profile Settings

™ Specify script generation details at


Profile Settings / Record / Script / Java

18 13.02.2008

9
Example: Profile Settings

™ Specify Java Settings


ƒ Add ProductManager.jar from the SilkPerformer samples
directory

19 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 database
ƒ Step 2: Start JNDI
name server
ƒ Step 3: Start RMI
over IIOP server

20 13.02.2008

10
Example: Model Script

™Open the Model Script dialog


™Enter the location of the RMI sample application HTML page
™Click 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.

21 13.02.2008

Example: Save the Recorded Script

™ Save the recorded


script
ƒ Specify a valid Java
identifier

22 13.02.2008

11
Example: Recorded BDL Script

™Comment out (or delete) the recorded API calls:


ƒ JavaSetOption(JAVA_CLASSPATH
ƒ JavaSetOption(JAVA_CMDLINE_OPTIONS

23 13.02.2008

Example: Recorded Java Script

24 13.02.2008

12
Example: Replay Script

™ Continue with SilkPerformer‘s workflow:


ƒ Run a TryScript
ƒ Customize the script
ƒ Identify the baseline

25 13.02.2008

13

Вам также может понравиться