com.remedy.arsys.api
Class DefaultProxyManager
java.lang.Object
com.remedy.arsys.api.ProxyManager
com.remedy.arsys.api.DefaultProxyManager
- public class DefaultProxyManager
- extends ProxyManager
DefaultProxyManager 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
optionally 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.
Here the DefaultProxyManager simply instantiates Proxy on request and terminates
its connection when a client releases it. Because a connection is maintained until the proxy
has been releasd, clients should not hold references to a proxy for extended times; an AR System
server license is also consumed while the connection is active. Behavior is undefined when holding
a reference to a released proxy and calling methods on it. Such practice will also prevent the proxy
from being garbage collected.
The default ProxyManager returned by getProxyManager does
not pool connections. The system property
ProxyManager class can be set to the
name of an alternative class that uses another policy. Specifically,
the API provides PoolingProxyManager
if pooling of connections is desired.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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.
- Specified by:
getProxy in class ProxyManager
- Throws:
ARException - because logging in
Proxy.ARSetLogging failed in the server
releaseProxy
public void releaseProxy(Proxy proxy,
ARServerUser context,
boolean usingContextProxy)
- Return a proxy for possible later reuse. Whether it can be later
reused depends on whether the specific
ProxyManager being used pools
connections or not. The specified context is used to determine which
AR System server (and its connection) 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.
- Specified by:
releaseProxy in class ProxyManager