com.remedy.arsys.api
Class PoolingProxyManager
java.lang.Object
|
+--com.remedy.arsys.api.ProxyManager
|
+--com.remedy.arsys.api.PoolingProxyManager
- public class PoolingProxyManager
- extends ProxyManager
ProxyManager is a singleton factory class that provides clients with
Proxy instances. Proxies represent connections to AR System servers and
provide access to their server via the native AR System API. Proxies are
pooled by server. A client taking a proxy from the pool by calling
getProxy must return it to the pool when done
by calling releaseProxy and not hold
onto a reference to it.
Expired proxies in the pool will be released, terminating their
connection to their AR System server, and made available for garbage
collection.
Each server's ProxyPool is limited to maxPerServer number of
connections defined in setConnectionLimits.
The total number of connections is limited to
maxTotal defined in setConnectionLimits.
If allocating a new pool for a server would cause
maxTotal to be exceeded, a new pool is not allocated and an
exception is thrown.
|
Method Summary |
protected void |
finalize()
Clears up all the pools for all the servers. |
Proxy |
getProxy(ARServerUser context,
boolean usingContextProxy)
Get proxy for the AR System server specified by the context. |
void |
releaseProxy(Proxy proxy,
ARServerUser context,
boolean usingContextProxy)
Return a proxy to the pool for later reuse. |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
INITIAL_PROXIES_PER_SERVER
public static final int INITIAL_PROXIES_PER_SERVER
getProxy
public Proxy getProxy(ARServerUser context,
boolean usingContextProxy)
throws ARException
- Get proxy for the AR System server specified by the context. The caller
must return the proxy after use by calling
releaseProxy. The proxy holds one of a limited number of
connections to its associated server. The caller must not
hold a reference to the proxy after returning it.
- Overrides:
getProxy in class ProxyManager
- Throws:
ARException - if proxy is not returned
releaseProxy
public void releaseProxy(Proxy proxy,
ARServerUser context,
boolean usingContextProxy)
- Return a proxy to the pool for later reuse. The specified context is
used to determine which AR System server (and its connecton) is associated
with this proxy. The caller must not continue to hold a
reference to the proxy after returning it to the
ProxyManager so that
when it expires its connection can be terminated and it can be
garbage collected.
- Overrides:
releaseProxy in class ProxyManager
finalize
protected void finalize()
- Clears up all the pools for all the servers.
Basically, the
finalize method calls
the C API call ARTermination for all the connections.
- Overrides:
finalize in class java.lang.Object