Using a JCO Client for Several Portal
Requests
When you have a pool entry instance you can get an instance of the JCO client. If you want to use a JCO client in more than one portal request, the pool entries can be stored in static instance. When you work with static pool entries, you have to check if a HTTP session timeout has occurred. If a HTTP session timeout occurred, the JCO client service has deleted the pool entry (with method delete())so you have to create a new connection again.
The following example stores pool entries in a static. The key in this map is defined by the user ID and session ID.

The isTimeoutOccurred() method has to called before the JCO client is used.
public class JCOComponent extends AbstractPortalComponent |
· The access to the static map that holds all pool entries is synchronized.
We do not known how many threads execute the doContent() method at a time. Even the same user can execute the method within different threads. Therefore the table must be kept in a consistent state.
· The Portal Runtime (PRT) can release portal components when memory is needed.
Consider this if using stateful components. The PRT calls the portal component method destroy() to release a component. This method can be used also to manage the open connections, for example, to release stored pool entries.
· The execution of the client call is synchronized.
JCO clients are not thread safe and when the same user enters doContent() from several threads, the access to his client must be synchronized.
· Pool entries are not released.
Pool entries are released by the JCO client servicewhen a HTTP session timeout occurs or by the Java VM finalizer. The method finalize() of the class JCOClientPoolEntry calls the release() method itself. This will take place when iView is not referenced by the PRT anymore, because it was released from the PRT or the portal was shut down. The garbage collector finalizes the whole iView including the hash map.
When a HTTP session timeout occurs the delete() method is called - so the JCO client is only disconnected; in case of finalize the release() method is called - so the JCO client is disconnected and is returned to the pool.