ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzamy_5.4.0.1/50/program/jndicchp.htm

125 lines
7.6 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=utf-8">
<LINK rel="stylesheet" type="text/css" href="../../../rzahg/ic.css">
<title>JNDI cache properties</title>
</head>
<BODY>
<!-- Java sync-link -->
<SCRIPT LANGUAGE="Javascript" SRC="../../../rzahg/synch.js" TYPE="text/javascript"></SCRIPT>
<h6><a name="jndicchp"></a>JNDI cache properties</h6>
<p>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.</p>
<p>You can set properties in these ways:</p>
<ul>
<li><strong>Through the command line:</strong> To set properties through the command line, enter the actual string value as indicated in this example:
<pre>
java -Dcom.ibm.websphere.naming.jndicache.maxentrylife=1440 MyProgram
</pre>
</li>
<li><strong>In a file:</strong> To set properties in a file, create a text file listing the properties. For example:
<pre>
...
com.ibm.websphere.naming.jndicache.cacheobject=none
...
</pre>
</li>
<li><strong>Within a program:</strong> To set properties in a Java program, use the following <strong>PROPS.JNDI_CACHE*</strong> Java constants, defined in the com.ibm.websphere.naming.PROPS class:
<pre>
import com.ibm.websphere.naming.PROPS;
...
public static final String JNDI_CACHE_OBJECT =
&quot;com.ibm.websphere.naming.jndicache.cacheobject&quot;;
public static final String JNDI_CACHE_OBJECT_NONE = &quot;none&quot;;
public static final String JNDI_CACHE_OBJECT_POPULATED = &quot;populated&quot;;
public static final String JNDI_CACHE_OBJECT_CLEARED = &quot;cleared&quot;;
public static final String JNDI_CACHE_OBJECT_DEFAULT = JNDI_CACHE_OBJECT_POPULATED;
public static final String JNDI_CACHE_NAME =
&quot;com.ibm.websphere.naming.jndicache.cachename&quot;;
public static final String JNDI_CACHE_NAME_DEFAULT = &quot;providerURL&quot;;
public static final String JNDI_CACHE_MAX_LIFE =
&quot;com.ibm.websphere.naming.jndicache.maxcachelife&quot;;
public static final int JNDI_CACHE_MAX_LIFE_DEFAULT = 0;
public static final String JNDI_CACHE_MAX_ENTRY_LIFE =
&quot;com.ibm.websphere.naming.jndicache.maxentrylife&quot;;
public static final int JNDI_CACHE_MAX_ENTRY_LIFE_DEFAULT = 0;
</pre>
To set a property in your program, enter the following:
<pre>
env.put(PROPS.JNDI_CACHE_OBJECT, PROPS.JNDI_CACHE_OBJECT_NONE).
// Sets a property to a value
</pre>
</li>
</ul>
<p>Cache properties are evaluated when an InitialContext instance is created. The resulting cache association, including <a href="#cacheobjnone">&quot;none&quot;</a>, cannot be changed. The &quot;max life&quot; cache properties affect the individual cache's behavior. If the cache already exists, cache behavior is updated according to the new &quot;max life&quot; property settings. If no &quot;max life&quot; properties exist in the environment, the cache assumes default &quot;max life&quot; settings, regardless of the previous settings. The various cache properties are described below. All property values must be String values.</p>
<ul>
<li><strong>com.ibm.websphere.naming.jndicache.cacheobject</strong>
<p>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.</p>
<ul>
<li><strong>&quot;populated&quot;</strong> (default): Use a cache with the specified <a href="#cachename">name</a>. If the cache already exists, leave existing cache entries in cache; otherwise, create a new cache.</li>
<li><strong>&quot;cleared&quot;</strong>: Use a cache with the specified <a href="#cachename">name</a>. If the cache already exists, clear all cache entries from cache; otherwise, create a new cache.</li>
<li><a NAME="cacheobjnone"></a><strong>&quot;none&quot;</strong>: Do not cache. If this option is specified, the cache <a href="#cachename">name</a> is irrelevant. Therefore, this option will not disable a cache that is already associated with other InitialContext instances. The InitialContext being instantiated will not be associated with any cache.</li>
</ul>
<p><strong>Note:</strong> You must include the quotation marks when specifying any of the above property values.</p>
</li>
<li><a NAME="cachename"></a><strong>com.ibm.websphere.naming.jndicache.cachename</strong>
<p>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.</p>
<ul>
<li><strong>&quot;providerURL&quot;</strong> (default): Use the value for java.naming.provider.url property as the cache name. The default provider URL is &quot;iiop:///&quot;. URLs are normalized by stripping off everything after the port. For example, &quot;iiop://server1:2809&quot; and &quot;iiop://server1:2809/com/ibm/initCtx&quot; are normalized to the same cache name.</li>
<li><strong><em>any_string</em></strong>: Use the specified string as the cache name. Any arbitrary string with a value other than &quot;providerURL&quot; can be used as a cache name.</li>
</ul>
<p><strong>Note:</strong> You must include the quotation marks when specifying any of the above property values.</p>
</li>
<li><a NAME="maxcachelife"></a><strong>com.ibm.websphere.naming.jndicache.maxcachelife</strong>
<p>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 &quot;cleared&quot;. This property enables a JNDI client to set the maximum life of a cache as follows:</p>
<ul>
<li><strong>&quot;0&quot;</strong> (default): Make the cache lifetime unlimited.</li>
<li><strong><em>positive_integer</em></strong>: Set the maximum lifetime of the cache, in minutes, to the specified value. When the maximum cache lifetime is reached, the cache is cleared before another cache operation is performed. The cache is repopulated as bind, rebind, and lookup operations are performed.</li>
</ul>
<p><strong>Note:</strong> You must include the quotation marks when specifying any of the above property values.</p>
</li>
<li><a NAME="maxentrylife"></a><strong>com.ibm.websphere.naming.jndicache.maxentrylife</strong>
<p>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 &quot;cleared&quot;. This property enables a JNDI client to set the maximum lifetime of individual cache entries as follows:</p>
<ul>
<li><strong>&quot;0&quot;</strong> (default): Lifetime of cache entries is unlimited.</li>
<li><strong><em>positive_integer</em></strong>: Set the maximum lifetime of individual cache entries, in minutes, to the specified value. When the maximum lifetime for an entry is reached, the next attempt to read the entry from the cache will cause the entry to be refreshed.</li>
</ul>
<p><strong>Note:</strong> You must include the quotation marks when specifying any of the above property values.</p>
</li>
</ul>
</body>
</html>