Java RMI/EJB Tutorial - Borland Technical Publications

Java RMI/EJB Tutorial - Borland Technical Publications Java RMI/EJB Tutorial - Borland Technical Publications

techpubs.borland.com
from techpubs.borland.com More from this publisher
13.11.2014 Views

Java RMI/EJB Tutorial SilkPerformer 2007 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.08.2007 1

<strong>Java</strong> <strong>RMI</strong>/<strong>EJB</strong> <strong>Tutorial</strong><br />

SilkPerformer 2007<br />

Introduction<br />

This presentation offers an overview of how to<br />

record and replay <strong>Java</strong> <strong>RMI</strong> and <strong>EJB</strong> virtual users.<br />

It also shows example use of the sample <strong>RMI</strong><br />

application (Product Manager) that ships with<br />

SilkPerformer.<br />

2 13.08.2007<br />

1


What to Record/Replay<br />

Record and replay the client<br />

• A virtual user is a simulated client application<br />

<strong>RMI</strong>/<strong>EJB</strong> Client<br />

Applications<br />

Server/<br />

Server farm<br />

3 13.08.2007<br />

Preparation: Create a Project<br />

Choose project type <strong>Java</strong> / <strong>Java</strong> <strong>RMI</strong>/<strong>EJB</strong> (recording)<br />

4 13.08.2007<br />

2


Preparation: Profile Settings<br />

Select a <strong>Java</strong> JDK (version 1.2 or higher)<br />

• For use internally by the recorder<br />

• Used for replay via SilkPerformer <strong>Java</strong> Framework<br />

Add the Classpath elements that are required by the<br />

recorded application<br />

• The classpath is not required for recording. It is required for:<br />

• Compiling the recorded script<br />

• Replay<br />

5 13.08.2007<br />

Preparation: Profile Settings<br />

Choose a JDK<br />

Define the classpath<br />

<strong>Java</strong> options<br />

6 13.08.2007<br />

3


Preparation: Profile Settings<br />

Set the record log level to Debug<br />

• When contacting technical support, send exported projects with<br />

Debug logging enabled<br />

Set log level to Debug<br />

7 13.08.2007<br />

Preparation: Application Profile<br />

Define an application profile for the application you want<br />

to record<br />

Enter the path to the executable / startup script (.exe,<br />

.bat, or .cmd)<br />

Enter the name of the executable<br />

that hosts the <strong>Java</strong> VM<br />

(e.g., java.exe or javaw.exe)<br />

Select Custom Application<br />

Select the <strong>Java</strong> APIs that are to be<br />

recorded<br />

Add a new application profile<br />

8 13.08.2007<br />

4


Preparation: Application Profile for IBM JVM<br />

Recording IBM‘s <strong>Java</strong> virtual machine requires additional<br />

settings<br />

Edit <strong>Java</strong> Settings<br />

Select Manual<br />

9 13.08.2007<br />

Preparation: Startup Script for IBM JVM<br />

Recording IBM‘s <strong>Java</strong> virtual machine also requires a<br />

customized startup script<br />

Original startup script<br />

Customized copy<br />

of startup script<br />

Insert call to<br />

perfPrepare<strong>Java</strong>Recording.cmd<br />

(adjust SilkPerformer‘s home directory if<br />

necessary)<br />

Add the command line parameter<br />

%PERFREC_OPTIONS%<br />

10 13.08.2007<br />

5


Recording<br />

Click the Model Script workflow button<br />

• Launch the application<br />

• Perform the actions that are to be recorded<br />

11 13.08.2007<br />

Recording<br />

When you are done:<br />

• Stop recording<br />

• Save the script<br />

Recorded <strong>Java</strong><br />

source code<br />

Overview log<br />

12 13.08.2007<br />

6


Recorded Result<br />

x.java<br />

• The <strong>Java</strong> source file that contains the recorded actions<br />

• This file can be compiled from within the SilkPerformer<br />

Workbench<br />

• The file is compiled automatically<br />

• The classpath must be specified correctly (<strong>Java</strong> Profile Settings)<br />

x.bdf<br />

• BDL stub code that launches the <strong>Java</strong> virtual user<br />

13 13.08.2007<br />

Testing Applets<br />

Recording Applets<br />

• Use Sun <strong>Java</strong> VM in the browser (not Microsoft)<br />

Replay<br />

• Remove the recorded API calls:<br />

<strong>Java</strong>SetOption(JAVA_CLASSPATH and<br />

<strong>Java</strong>SetOption(JAVA_CMDLINE_OPTIONS from the BDL script<br />

• Obtain JAR and CLASS files from the server; copy these files to the local<br />

machine; enter the classpath in <strong>Java</strong> Profile Settings.<br />

• Use recorded comments in the recorded <strong>Java</strong> source code to find JAR and<br />

class files<br />

// ###ClassPath###<br />

// ###Applet CodeBase###<br />

// ###Applet parameters queried by the Applet###<br />

// codebase=…<br />

// archive=…<br />

// code=…<br />

14 13.08.2007<br />

7


Example: Product Manager<br />

• The <strong>RMI</strong> sample application that ships with SilkPerformer is<br />

called Product Manager.<br />

• To launch Product Manager, go to:<br />

C:\<strong>Borland</strong>\SilkPerformer/Sample Applications/<strong>Java</strong><br />

Samples/Product Manager<br />

15 13.08.2007<br />

Example: Create a Project<br />

Project type: <strong>Java</strong> / <strong>Java</strong> <strong>RMI</strong>/<strong>EJB</strong> (recording)<br />

16 13.08.2007<br />

8


Example: Application Profile<br />

Modify the existing<br />

Internet Explorer<br />

application profile<br />

• Deselect Web<br />

• Select <strong>Java</strong> <strong>RMI</strong><br />

• Select <strong>Java</strong> JNDI<br />

• This is required because<br />

this sample uses JNDI for<br />

the bootstrapping of<br />

remote object references<br />

17 13.08.2007<br />

Example: Profile Settings<br />

Specify script generation details at<br />

Profile Settings / Record / Script / <strong>Java</strong><br />

18 13.08.2007<br />

9


Example: Profile Settings<br />

Specify <strong>Java</strong> Settings<br />

• Add ProductManager.jar from the SilkPerformer samples<br />

directory<br />

19 13.08.2007<br />

Example: Start Servers<br />

Start the <strong>RMI</strong> and LDAP<br />

servers<br />

• Open the Product Manager<br />

sample HTML page and<br />

follow the instructions:<br />

• Step 1: Start the<br />

LDAP database<br />

• Step 2: Start JNDI<br />

name server<br />

• Step 3: Start <strong>RMI</strong><br />

over IIOP server<br />

20 13.08.2007<br />

10


Example: Model Script<br />

Open the Model Script dialog<br />

Enter the location of the <strong>RMI</strong> sample application HTML page<br />

Click the ProductManager – DemoVersion.htm link to launch the applet<br />

• The applet loads and the recorder begins recording the JNDI and <strong>RMI</strong> activities of<br />

the applet.<br />

• Perform searches for products; change products; add new products, etc.<br />

21 13.08.2007<br />

Example: Save the Recorded Script<br />

Save the recorded<br />

script<br />

• Specify a valid <strong>Java</strong><br />

identifier<br />

22 13.08.2007<br />

11


Example: Recorded BDL Script<br />

Comment out (or delete) the recorded API calls:<br />

• <strong>Java</strong>SetOption(JAVA_CLASSPATH<br />

• <strong>Java</strong>SetOption(JAVA_CMDLINE_OPTIONS<br />

23 13.08.2007<br />

Example: Recorded <strong>Java</strong> Script<br />

24 13.08.2007<br />

12


Example: Replay Script<br />

Continue with SilkPerformer‘s workflow:<br />

• Run a TryScript<br />

• Customize the script<br />

• Identify the baseline<br />

25 13.08.2007<br />

13

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!