bea.jolt.pool.servlet
Class ServletSessionPool

java.lang.Object
  bea.jolt.pool.Factory
      bea.jolt.pool.SessionPool
          bea.jolt.pool.servlet.ServletSessionPool

public class ServletSessionPool
extends SessionPool

This class provides a session pool for use in a Java servlet. A session pool represents one or more connections (sessions) to a BEA Tuxedo system. This class provides call methods that accept input parameters for a BEA Tuxedo service as a javax.servlet.http.HttpServletRequest object.

Refer to the base class SessionPool for information about session pools in general.


Method Summary
 ServletResult call(java.lang.String name, javax.servlet.http.HttpServletRequest request)
          Invokes a BEA Tuxedo service without an explicit transaction.
 ServletResult call(java.lang.String name, javax.servlet.http.HttpServletRequest request, Transaction tran)
          Invokes a BEA Tuxedo service.
 
Methods inherited from class bea.jolt.pool.SessionPool
call, getAppAddr, getConnection, getFailOverAddr, getMaxConnections, getMinConn, getPoolName, getSecurityContextClass, getUser, isKeepAlive, isSuspended, propagateSecurityContext, setKeepAlive, setMaxConnections, startTransaction
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

call

public ServletResult call(java.lang.String name,
                          javax.servlet.http.HttpServletRequest request)
                   throws SessionPoolException,
                          ApplicationException,
                          ServiceException,
                          TransactionException
Invokes a BEA Tuxedo service without an explicit transaction. When used under an explicit transaction model (i.e. current Jolt transaction model), this is a convenience method and is equivalent to using the call(name, request, tran) method with tran set to null. The BEA Tuxedo service to be invoked is specified in the parameter name. Input parameters for the BEA Tuxedo service are passed to this method as a javax.servlet.http.HttpServletRequest object request. The names of the parameters in request must match the names of the BEA Tuxedo service input parameters. For HttpServletRequest parameters, the paramter names are the HTML form field names. Any HttpServletRequest parameter names that do not match the BEA Tuxedo service parameter names are ignored.

To represent BEA Tuxedo parameters with multiple occurrences, the name of a form field should have "_<index>" appended to it. Note that index numbers start at 0 (zero), so the first occurrence is represented by index 0 (zero). To indicate the first and second occurrences of a service parameter named "ACCOUNT_ID", sample HTML form fields could be written as follows:

 <FORM ACTION=myservlet METHOD=POST>
 ...
 <INPUT TYPE=TEXT NAME=ACCOUNT_ID_0>
 <INPUT TYPE=TEXT NAME=ACCOUNT_ID_1>
 ...
 </FORM>
 

If the session pool is suspended or if no connections are available, this method throws a SessionPoolException.

Specific exceptions are thrown to indicate error conditions. If an application error occurs, this method throws an ApplicationException. The return from the getResult method on ApplicationException can be cast to ServletResult, as below:

 // Assume ServletSessionPool (pool) has been initialized, and
 // request is a HttpServletRequest
 try
 {
    pool.call ("MY_SERVICE", request);
 }
 catch (ApplicationException e)
 {
	// Get the ServletResult
	ServletResult result = (ServletResult) e.getResult();
	// Access application data in result
	out.println("Application code is " + result.getApplicationCode());
	...
 }
 catch ... // Handle other exceptions
 ...
 }
 

Parameters:
name - Name of the BEA Tuxedo service to call
request - HttpServletRequest object
Returns:
A ServletResult object
Throws:
SessionPoolException
ApplicationException
ServiceException
TransactionException
See Also:
call(java.lang.String, javax.servlet.http.HttpServletRequest, bea.jolt.pool.Transaction), SessionPool.call(java.lang.String, bea.jolt.pool.DataSet, bea.jolt.pool.Transaction)

call

public ServletResult call(java.lang.String name,
                          javax.servlet.http.HttpServletRequest request,
                          Transaction tran)
                   throws SessionPoolException,
                          ApplicationException,
                          ServiceException,
                          TransactionException
Invokes a BEA Tuxedo service. The name of the BEA Tuxedo service to be invoked is specified in the parameter name. Input parameters for the BEA Tuxedo service are passed to this method as a javax.servlet.http.HttpServletRequest object request. The names of the members in request must match the names of the BEA Tuxedo service parameters. For input parameters, member names are the names of the HTML form field. Any members with names that do not match the BEA Tuxedo service parameter names are ignored.

To represent BEA Tuxedo parameters with multiple occurrences, the name of a member should have "_<index>" appended to it. Note that index numbers start at zero, so the first occurrence is represented by index zero (0). To indicate the first and second occurrences of a parameter named "ACCOUNT_ID", the member names should be "ACCOUNT_ID_0" and "ACCOUNT_ID_1" respectively.

To invoke multiple services in a transaction, create a Transaction object (see startTransaction()) and pass the Transaction object as the parameter to this method. If this service is not part of a transaction this parameter should be null.

If the session pool is suspended or if no connections are available, this method throws a SessionPoolException.

Parameters:
tran - Transaction object, or null if no transaction
Returns:
A Result object, or null
Throws:
SessionPoolException
ApplicationException
ServiceException
TransactionException
See Also:
call(java.lang.String, javax.servlet.http.HttpServletRequest), SessionPool.call(java.lang.String, bea.jolt.pool.DataSet, bea.jolt.pool.Transaction), SessionPool.startTransaction(int)