Chapter 5: Using the EAServer Samples  Java Pet Store

Chapter 5: Using the EAServer Samples

Samples in the EAServer installation

In addition to the CORBA Java and EJB tutorials in this book, the EAServer installation includes many optional Java and C++ samples.


Java samples

Your EAServer installation includes the following Java samples.


Using JavaServer Pages and EJB components

The MyPortfolio sample demonstrates the use of JavaServer Pages (JSPs) and EJB components. The application simulates an online stock trading service. A Web application runs JSPs to provide the user interface. The JSPs call EJB session beans for client session management, and the session beans call EJB entity beans to manage data in the back-end database.

The MyPortfolio files are in the directory sample/MyPortfolio. The file readme.html describes how to install and run the application in EAServer.


Using EJB CMP entity beans

EAServer includes a sample EJB 2.0 CMP entity bean, in the installation subdirectory html/classes/Sample/cmp20sample. The sample defines two components to demonstrate the use of container managed persistence for entity beans, including EJB-QL queries for finder and select methods. This sample also shows the use of local interfaces to call the entity bean from a session bean. For instructions on deploying and running the sample, see the readme.txt file included with the source files.


Using message-driven beans and JMS

This sample shows how to run message-driven beans (MDBs) and use the Java Message Service (JMS) in EAServer. JMS is a standard API for asynchronous messaging in Java. MDBs are EJB 2.0 components that respond to messages published in the message service. For information on using JMS and creating MDBs, see Chapter 31, “Using the Message Service,” in the EAServer Programmer’s Guide.

The file html/classes/MDBSample.jar contains all the files you need to deploy and run the sample, as well as the source code. Follow the instructions below to deploy the MDB and run the sample client. When you import the JAR file, EAServer Manager creates and configures the MDB component and also extracts the source files to the html/classes/Sample/MDBSample directory in your installation.

StepsImporting the JAR file, installing the MDB, and running the JMS client

  1. If the message service is not running, configure and start it as described in Chapter 8, “Setting up the Message Service,” in the EAServer System Administration Guide.

  2. Using EAServer Manager, import the MDBSample JAR file:

    1. Highlight the Packages folder.

    2. Choose File | Deploy | Jaguar JAR.

    3. In the Specify JAR File dialog box, click Browse and select the /html/classes/MDBSample.jar file.

    4. Click OK.

  3. Install the MDB component:

    1. Highlight the Jaguar | Installed Packages folder.

    2. Choose File | Install Package.

    3. In the Package wizard, click Install an Existing Package.

    4. In the list of packages, highlight MDBSample, then click OK.

  4. Restart the server.

  5. At a command prompt, run the JMS client:On Windows:

    %JAGUAR%\html\classes\Sample\MDBSample\run.bat
    

    On UNIX:

    $JAGUAR/html/classes/Sample/MDBSample/run.sh
    

    The console window displays the program status.

When you run the JMS client, it sends a message to the message queue myQueue; the MDB listens on this queue. When the MDB receives the message, it sends the message to the queue yourQueue, and the client receives the message from yourQueue. The message queues are created automatically when you run the JMS client.


Using SSL in Java clients

Clients can use SSL to enhance the security of their connection to EAServer. You can also configure servers to require that clients provide an SSL certificate when connecting to EAServer. For information on configuring EAServer to use SSL, see Chapter 13, “Security Configuration Tasks,” in the EAServer Security Administration and Programming Guide.

EAServer provides samples to demonstrate SSL connectivity from standalone Java clients and Java applets:


Using custom authentication

EAServer allows you to plug in your own service to implement user authentication for component and Web application access. A sample Java implementation is provided in the directory html/classes/Sample/AuthServiceDemo. The file readme.html in this directory describes how to install and run the sample authentication service.


Using the Java Authentication and Authorization API

The Java Authentication and Authorization Service (JAAS) API provides a framework and standard programming interface for authenticating users and assigning privileges. To comply with EJB 2.0 specification, EAServer supports JAAS for user authentication in standalone EJB client applications, and for authenticating resource access to J2EE connectors.

EAServer contains a sample JAAS login module in the html/classes/Sample/JAAS directory, with setup instructions provided in the readme.txt file.

For more information on JAAS, see Chapter 11, “Using the JAAS API,” in the EAServer Security Administration and Programming Guide.


Using CORBA components and clients

This sample shows how to use the basic predefined datatypes in CORBA component calls, and includes a Java client and a Java component. The client source is in html/classes/Sample/Intro. Instructions for running the sample are in the file readme.html in this directory.


Systems management

EAServer supports programmatic systems management via the Java Management Extensions (JMX) agent management framework. For information on the systems management samples included with EAServer, see Chapter 13, “Using Systems Management,” in the EAServer System Administration Guide


C++ samples

In addition to the C++ tutorial in this book, your EAServer installation includes the following C++ samples.


Using SSL in C++ clients

Clients can use SSL to enhance the security of their connection to EAServer. You can also configure servers to require that clients provide an SSL certificate when connecting to EAServer. For information on configuring EAServer to use SSL, see Chapter 13, “Security Configuration Tasks,” in the EAServer Security Administration and Programming Guide.

Sample C++ clients that use SSL are provided in the Sample/ClientSSL directory. The file readme.txt describes how to build and run the clients.


Using custom authentication services

EAServer allows you to plug in your own service to implement user authentication for component and Web application access. A sample C++ implementation is provided in the Sample/AuthServiceDemo directory. The file readme.txt in this directory describes how to build, install, and run the sample authentication service.


Inspecting client SSL credentials

EAServer components can inspect the calling client’s SSL credentials using the CtsSecurity::UserCredentials interface. A sample C++ component demonstrating this feature is provided in the Sample/SecurityDemo directory.

For information on building, installing, and running the component, see the file readme.html in the directory html/classes/Sample/SecurityDemo.





Copyright © 2005. Sybase Inc. All rights reserved. Java Pet Store