JNDI clients can use several properties to control cache behavior. These properties can be set in the Java virtual machine system environment or in the environment Hashtable that is passed to the InitialContext constructor.
You can set properties in these ways:
java -Dcom.ibm.websphere.naming.jndicache.maxentrylife=1440 MyProgram
... com.ibm.websphere.naming.jndicache.cacheobject=none ...
import com.ibm.websphere.naming.PROPS; ... public static final String JNDI_CACHE_OBJECT = "com.ibm.websphere.naming.jndicache.cacheobject"; public static final String JNDI_CACHE_OBJECT_NONE = "none"; public static final String JNDI_CACHE_OBJECT_POPULATED = "populated"; public static final String JNDI_CACHE_OBJECT_CLEARED = "cleared"; public static final String JNDI_CACHE_OBJECT_DEFAULT = JNDI_CACHE_OBJECT_POPULATED; public static final String JNDI_CACHE_NAME = "com.ibm.websphere.naming.jndicache.cachename"; public static final String JNDI_CACHE_NAME_DEFAULT = "providerURL"; public static final String JNDI_CACHE_MAX_LIFE = "com.ibm.websphere.naming.jndicache.maxcachelife"; public static final int JNDI_CACHE_MAX_LIFE_DEFAULT = 0; public static final String JNDI_CACHE_MAX_ENTRY_LIFE = "com.ibm.websphere.naming.jndicache.maxentrylife"; public static final int JNDI_CACHE_MAX_ENTRY_LIFE_DEFAULT = 0;To set a property in your program, enter the following:
env.put(PROPS.JNDI_CACHE_OBJECT, PROPS.JNDI_CACHE_OBJECT_NONE). // Sets a property to a value
Cache properties are evaluated when an InitialContext instance is created. The resulting cache association, including "none", cannot be changed. The "max life" cache properties affect the individual cache's behavior. If the cache already exists, cache behavior is updated according to the new "max life" property settings. If no "max life" properties exist in the environment, the cache assumes default "max life" settings, regardless of the previous settings. The various cache properties are described below. All property values must be String values.
Caching is turned on or off with this property. Additionally, an existing cache can be cleared. The valid values for this property and the resulting cache behavior are listed below.
Note: You must include the quotation marks when specifying any of the above property values.
It is possible to create multiple InitialContext instances, each operating on the namespace of a different name service provider. By default, objects from each service provider are cached separately, since they each involve independent namespaces and name collisions could occur if they used the same cache. The provider URL specified when the initial context is created serves as the default cache name. With this property, a JNDI client can specify a cache name other than the provider URL. The valid option for cache names are listed below.
Note: You must include the quotation marks when specifying any of the above property values.
By default, cached objects remain in the cache for the life of the process or until cleared with the com.ibm.websphere.naming.jndicache.cacheobject property set to "cleared". This property enables a JNDI client to set the maximum life of a cache as follows:
Note: You must include the quotation marks when specifying any of the above property values.
By default, cached objects remain in the cache for the life of the process or until cleared with the com.ibm.websphere.naming.jndicache.cacheobject property set to "cleared". This property enables a JNDI client to set the maximum lifetime of individual cache entries as follows:
Note: You must include the quotation marks when specifying any of the above property values.