AR System Java API

com.bmc.arsys.api
Class ProxyManager

java.lang.Object
  extended by com.bmc.arsys.api.ProxyManager
Direct Known Subclasses:
DefaultProxyManager

public abstract class ProxyManager
extends Object

ProxyManager is a factory class that provides clients with Proxy instances. It is an abstract class that provides the interface used by clients. It is implemented by two concrete subclasses, DefaultProxyManager and PoolingProxyManager. Neither subclass has a public constructor (they are package-scoped) so clients cannot access their services directly. For that, they must call the public static method getProxyManager of ProxyManager.

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 calling getProxy does not know whether proxies are being pooled or not, so it must return it to the ProxyManager when done by calling releaseProxy and not hold on to a reference to it. If proxies are being pooled this will return the proxy to the pool without terminating its connection. Otherwise, returning it will automatically terminiate its connection and make the proxy available for garbage collection.

The default ProxyManager returned by getProxyManager does not pool connections. Pooling can be initiated by by calling setUseConnectionPooling with argument true. Pooling can be stopped at any time by calling this method with argument false. When pooling is stopped, all connections in the pool will be terminated.


Nested Class Summary
static class ProxyManager.PoolInfo
           
 
Constructor Summary
ProxyManager()
           
 
Method Summary
static ProxyManager.PoolInfo[] getPoolInformation()
           
abstract  com.bmc.arsys.api.Proxy getProxy(ARServerUser context)
          Get proxy for the AR Server specified by the context.
static ProxyManager getProxyManager()
          Get the current ProxyManager instance.
static Map<String,com.bmc.arsys.api.session.ARServerContext> getServerContextMap()
           
static boolean isUseConnectionPooling()
           
abstract  void releaseProxy(com.bmc.arsys.api.Proxy proxy, ARServerUser context)
          Return a proxy for possible later reuse.
static void setConnectionLimits(int maxPerServer)
          Configure limits on proxy pool sizes per server when connection pooling is used.
static void setUseConnectionPooling(boolean usePooling)
          Whether proxies are pooled or not is dynamically configurable.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ProxyManager

public ProxyManager()
Method Detail

getProxyManager

public static ProxyManager getProxyManager()
Get the current ProxyManager instance.


setConnectionLimits

public static void setConnectionLimits(int maxPerServer)
Configure limits on proxy pool sizes per server when connection pooling is used. The maxPerServer parameter decide the number of connections per server that the program can talk to. Calling this method over writes the configured value.

Parameters:
maxPerServer - Maximum number of proxy connections per server

setUseConnectionPooling

public static void setUseConnectionPooling(boolean usePooling)
Whether proxies are pooled or not is dynamically configurable. This method enables switching between policies. When pooling is turned off, the underlying connection pool is cleared, terminiating each connection. Thereafter, each use of a proxy in a call to the AR System server will result in a new connection being established and being terminated upon completion of the call. A proxy that was taken from a pool and released after the pool has been cleared will have its connection terminated.

Parameters:
usePooling, - default value is true

isUseConnectionPooling

public static boolean isUseConnectionPooling()
Returns:
the useConnectionPooling

getPoolInformation

public static ProxyManager.PoolInfo[] getPoolInformation()

getProxy

public abstract com.bmc.arsys.api.Proxy getProxy(ARServerUser context)
                                          throws ARException
Get proxy for the AR Server specified by the context. The caller must return the proxy after use by calling returnProxy. 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. In nested Java API calls, only the first call requests proxy from the pool and stores that proxy in ServerUser. All the following calls use the proxy from ServerUser.

Throws:
ARException - if proxy not returned

releaseProxy

public abstract void releaseProxy(com.bmc.arsys.api.Proxy proxy,
                                  ARServerUser context)
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. In nested Java API calls, only the first call should release proxy and set proxy in ServerUser to be null.


getServerContextMap

public static Map<String,com.bmc.arsys.api.session.ARServerContext> getServerContextMap()
Returns:
the synchoronized ARServerContext Map

AR System Java API

? Copyright 2006, 2007 BMC Software, Inc.