Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Business Components
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## oracle.jbo.common.ampool
Class PoolTester

    java.lang.Object
      |
      +--oracle.jbo.common.ampool.PoolTester

public class PoolTester
extends java.lang.Object

The PoolTester class provides a sample implementation and use of Application Module Pooling in LOCAL mode. This example uses the default implementation of Application Module Pooling.

View implementation of PoolTester

### Understanding the Sample Implementation

The sample implementation begins by defining the environment settings. This can be done directly (as is demonstrated in this example) or from a property file. In this example, the hashtable contains the properties to set up the environment to connect in LOCAL mode.

Create the pool `TestAMPool`. Since `PoolMgr` is a singleton object, use `PoolMgr.getInstance` to get it. Use `createPool` to create the pool. Notice that `createPool` requires the name of the pool, the name of the package that contains the Application Module, the connect string to the database, and env, the hashtable. The `createPool` method is overloaded—an alternative version takes an additional parameter that lets you override the default implementation of Application Module Pooling and specify your own.

Create a second pool, `SecondAMPool` that connects with the same environment variables, but to an Application Module in a different package.

`PoolMgr.getInstance().getPool("TestAMPool")` gets a handle to the pool to work with it.

Checkout three instances. Note that the classes `ApplicationPoolImpl` and `PoolMgr` contain other functions that you can use to traverse the pool content. The `ampool` package also contains a `PoolAdministrator` Web Bean that you can use to dump the contents of the pool.

Get a handle to the second pool, check out two instances, then check in one.

Use `removePool` to remove the Application Module Pool. This function calls `remove()` on all of the Application Module instances, including ones that are currently checked out and in use, and causes them to disconnect from the database and remove all of their View Objects.

The next part of the program defines a class, `CustomPool`, that ensures that no more than three instances are checked out of the pool at any time. In this case, the definition of the checkout method is overridden to check that no more than three instances are checked out. If more than three are checked out, an exception is thrown.

This custom pool class is then used in a program which attempts to create more than three instances. The `try-catch` loop is set up to start checking out instances and to catch exceptions. When an attempt is made to create the fourth instance, an exception is thrown.

Constructor Summary
`PoolTester()` Constructor

Method Summary
`void` | `doTest()`
`static void` | `main(java.lang.String[] args)` Provides a `main` for the PoolTester sample implementation of Application Module Pooling.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### PoolTester

    public PoolTester()

  Constructor

Method Detail

### doTest

    public void doTest()
                throws java.lang.Exception

### main

    public static void main(java.lang.String[] args)

  Provides a `main` for the PoolTester sample implementation of Application Module Pooling.
  Parameters:
    `args` - arguments to the PoolTester sample implementation.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Business Components
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD