BEA Logo BEA Tuxedo Release 8.0

  BEA Home  |  Events  |  Solutions  |  Partners  |  Products  |  Services  |  Download  |  Developer Center  |  WebSUPPORT

 

   Tuxedo Documentation   |   Using BEA Jolt with BEA WebLogic Server   |   Local Topics   |   Previous Topic   |   Next Topic   |   Contents

 


Using a Servlet Session Pool

The reference to the named ServletSessionPool from the pool manager represents a pool of sessions (or connections) to the Jolt Server in Tuxedo. The size of this pool and the Tuxedo system to which it connects are abstracted from the application code and are defined in the WebLogic config.xml configuration file. When you initiate a request, the SessionPool uses the least-busy connection available.

Calling a Tuxedo Service

A Jolt request usually consists of a single call to a Tuxedo service using the call() method of the SessionPool. You supply the name of the Tuxedo service and a set of parameters to the call() method, and it returns a set of results from the Tuxedo service. It is possible to make multiple calls within a single transaction, which allows a servlet to comply with transactional demands of a Tuxedo application or preserve integrity between databases. This transaction is described in more detail in Using a Transaction.

Sending a ServletDataSet

The ServletSessionPool provides overloaded call() methods for use inside an HTTP servlet. These methods accept their input parameters in terms of an HttpServletRequest object, and therefore can conveniently be passed the same HttpServletRequest object that was passed into your HTTP servlet's doPost() or doGet() methods. However, in this instance, you must ensure that the names of the HTTP posted name=value pairs correspond to those expected by the Tuxedo service. The ordering is not important, because the data is ultimately converted into a Java Hashtable. Other non-related data in the HttpServletRequest will not disrupt the Tuxedo service.

A Tuxedo service is invoked from within an HTTP servlet with the following method:

    ssPool.call("serviceName", request);

where ssPool is a reference to a ServletSessionPool, "serviceName" is the name of the Tuxedo service you wish to call, and the request argument is the HttpServletRequest object associated with the servlet.

The ServletSessionPool.call() method internally converts the HttpServletRequest into a ServletDataSet, which can be submitted to a regular SessionPool.

Adding Parameters to the Dataset

You may wish to add extra data to the parameter set before calling the Tuxedo service. For example, you may need to add a parameter representing the date and time of the request. You would not expect to receive this parameter from the FORM data in the HttpServletRequest. Instead, add it in the servlet, then submit the augmented data set to the Tuxedo service. The following example illustrates this procedure:

  // Create a new dataset
  ServletDataSet dataset = new ServletDataSet();
  // Import the HttpServletRequest into the dataset.
  dataset.importRequest(request);
  // Insert an extra parameter into the dataset.
  dataset.setValue("REQUEST_TIME", (new Date()).toString());
  // Send the dataset to the named service.
  ssPool.call("service_name", dataset, null);

This code example demonstrates the manual conversion of the HttpServletRequest object into a ServletDataSet object. In this new format you can add extra parameters using the setValue() method. The new value is associated with a key, represented by a string. Next, the call() method that is inherited from the SessionPool is invoked. This method accepts the ServletDataSet class, but requires an extra argument for use with transactions. Supply null for this last parameter, indicating that you are not using a transaction to group multiple session calls. SeeUsing a Transaction for more details.

 

back to top previous page next page