Class Global
- All Implemented Interfaces:
AutoCloseable
Unlock Chilkat and configure library-wide defaults, diagnostics, and async behavior.
Chilkat.Global is the Chilkat class for library-wide
initialization, licensing, default behavior, diagnostics, and thread-pool
control. Its most important method is UnlockBundle, which should
be called once at application startup before using other Chilkat classes. It
also provides settings for DNS caching, ANSI code page behavior, NTLM
version, IPv6 preference, verbose TLS logging, async task execution,
thread-pool limits, thread-pool logging, and special PKCS#7 encoding
behavior.
Library unlocking
Call UnlockBundle once during application startup to unlock
Chilkat components for use throughout the process.
Global defaults
Configure process-wide defaults such as ANSI code page handling, DNS caching behavior, IPv6 preference, and NTLM version selection.
Diagnostics and logging
Enable additional diagnostic behavior such as verbose TLS logging and thread-pool logging when troubleshooting difficult runtime issues.
Async thread pool
Control the limits and behavior of Chilkat's internal thread pool used by asynchronous task-based methods.
Network-related behavior
Adjust DNS and IP-version preferences that can affect how Chilkat classes resolve names and establish network connections.
Compatibility options
Set specialized process-wide options for interoperability scenarios, such as special PKCS#7 encoding behavior.
Common pattern:
Create a Chilkat.Global object at application startup, call
UnlockBundle once, then set any process-wide defaults before
creating and using other Chilkat objects. Treat these settings as
application-wide configuration, not per-object state.
For an extended overview, see Global Class Overview.
</section>
Instances hold a native Chilkat object: close them with ChilkatObject.close() (try-with-resources) when
done; an unclosed instance is freed when it becomes unreachable.
- See Also:
- Online reference
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidThis function clears the Chilkat in-memory DNS cache, which stores hostname-to-IP address mappings to avoid repeated DNS lookups.voidCalled to stop and finalize all threads in the thread pool, and causes the thread pool thread to exit.intThe default ANSI code page is determined at runtime based on the computer where the application happens to be running.booleanIf set totrue, thenQorBencoded strings can be passed in any string argument to any Chilkat method, and Chilkat will automatically decode the string before using it.intSelects the default NTLM protocol version to use for NTLM authentication for HTTP, POP3, IMAP, SMTP, and HTTP proxies.booleanSets the default value of the Utf8 property for each Chilkat class.intIf DNS caching is enabled, this is the time-to-live (in seconds) for a cached DNS lookup.booleanControls whether DNS domain lookups (to resolve to IP addresses) are cached in memory.intThe maximum number of thread pool threads.booleanIftrue, then use IPv6 over IPv4 when both are supported for a particular domain.If set, indicates the path of a log file to be used by the thread pool thread and each of the pool worker threads for logging async activity.This is a catch-all property to be used for uncommon needs.intIndicates the unlocked status for the last call to UnlockBundle.booleanThis property should typically be left at the default value offalse.booleanIf set totrue, then causes extremely verbose logging (in LastErrorText) all TLS connections in any Chilkat class.voidsetAnsiCodePage(int value)Sets theAnsiCodePageproperty; seegetAnsiCodePage().voidsetAutoQBDecode(boolean value)Sets theAutoQBDecodeproperty; seegetAutoQBDecode().voidsetDefaultNtlmVersion(int value)Sets theDefaultNtlmVersionproperty; seegetDefaultNtlmVersion().voidsetDefaultUtf8(boolean value)Sets theDefaultUtf8property; seegetDefaultUtf8().voidsetDnsTimeToLive(int value)Sets theDnsTimeToLiveproperty; seegetDnsTimeToLive().voidsetEnableDnsCaching(boolean value)Sets theEnableDnsCachingproperty; seegetEnableDnsCaching().voidsetMaxThreads(int value)Sets theMaxThreadsproperty; seegetMaxThreads().voidsetPreferIpv6(boolean value)Sets thePreferIpv6property; seegetPreferIpv6().voidsetThreadPoolLogPath(String value)Sets theThreadPoolLogPathproperty; seegetThreadPoolLogPath().voidsetUncommonOptions(String value)Sets theUncommonOptionsproperty; seegetUncommonOptions().voidsetUsePkcsConstructedEncoding(boolean value)Sets theUsePkcsConstructedEncodingproperty; seegetUsePkcsConstructedEncoding().voidsetVerboseTls(boolean value)Sets theVerboseTlsproperty; seegetVerboseTls().voidthreadPoolLogLine(String str)Logs a line to the thread pool log file.voidunlockBundle(String bundleUnlockCode)Unlocks the entire Chilkat API for all classes.Methods inherited from class com.chilkatsoft.chilkat2.ChilkatObject
close, getDebugLogFilePath, getLastErrorHtml, getLastErrorText, getLastErrorXml, getLastMethodSuccess, getVerboseLogging, getVersion, isClosed, setDebugLogFilePath, setLastMethodSuccess, setVerboseLogging, toString
-
Constructor Details
-
Global
public Global()Creates a newGlobalobject.
-
-
Method Details
-
getAnsiCodePage
public int getAnsiCodePage()The default ANSI code page is determined at runtime based on the computer where the application happens to be running. For example, the ANSI code page for an application running on a Japanese computer is likely to be Shift_JIS (code page 932), whereas on a US-English computer it would be iso-8859-1 (or Windows-1252 which is essentially a superset of iso-8859-1).If there is a desire for the Chilkat library to use a specific ANSI code page regardless of locale, then this property should be set to the desired code page. The default value of this property is the ANSI code page of the local computer.
- Returns:
- the value of the
AnsiCodePageproperty
-
setAnsiCodePage
public void setAnsiCodePage(int value)Sets theAnsiCodePageproperty; seegetAnsiCodePage().- Parameters:
value- the new value
-
getAutoQBDecode
public boolean getAutoQBDecode()If set totrue, thenQorBencoded strings can be passed in any string argument to any Chilkat method, and Chilkat will automatically decode the string before using it. This is meant to be a convenient way to use non-usascii literal strings in your source code. See the links below for an example and for a discussion about non-usascii literal strings.- Returns:
- the value of the
AutoQBDecodeproperty
-
setAutoQBDecode
public void setAutoQBDecode(boolean value)Sets theAutoQBDecodeproperty; seegetAutoQBDecode().- Parameters:
value- the new value
-
getDefaultNtlmVersion
public int getDefaultNtlmVersion()Selects the default NTLM protocol version to use for NTLM authentication for HTTP, POP3, IMAP, SMTP, and HTTP proxies. The default value is 2. This property may optionally be set to 1.- Returns:
- the value of the
DefaultNtlmVersionproperty
-
setDefaultNtlmVersion
public void setDefaultNtlmVersion(int value)Sets theDefaultNtlmVersionproperty; seegetDefaultNtlmVersion().- Parameters:
value- the new value
-
getDefaultUtf8
public boolean getDefaultUtf8()Sets the default value of the Utf8 property for each Chilkat class.In Chilkat v11.0.0 and later, the default value is
true. Before v11.0.0, it wasfalse.- Returns:
- the value of the
DefaultUtf8property
-
setDefaultUtf8
public void setDefaultUtf8(boolean value)Sets theDefaultUtf8property; seegetDefaultUtf8().- Parameters:
value- the new value
-
getDnsTimeToLive
public int getDnsTimeToLive()If DNS caching is enabled, this is the time-to-live (in seconds) for a cached DNS lookup. A DNS lookup result older than this expiration time is discarded, and causes a new DNS lookup to occur. A value of 0 indicates an infinite time-to-live. The default value of this property is 0.- Returns:
- the value of the
DnsTimeToLiveproperty
-
setDnsTimeToLive
public void setDnsTimeToLive(int value)Sets theDnsTimeToLiveproperty; seegetDnsTimeToLive().- Parameters:
value- the new value
-
getEnableDnsCaching
public boolean getEnableDnsCaching()Controls whether DNS domain lookups (to resolve to IP addresses) are cached in memory. The default value isfalse, meaning that DNS caching is disabled.- Returns:
- the value of the
EnableDnsCachingproperty
-
setEnableDnsCaching
public void setEnableDnsCaching(boolean value)Sets theEnableDnsCachingproperty; seegetEnableDnsCaching().- Parameters:
value- the new value
-
getMaxThreads
public int getMaxThreads()The maximum number of thread pool threads. The default value is 100. The maximum value is 500. Note: Asynchronous worker threads are created on as needed up to the maximum.- Returns:
- the value of the
MaxThreadsproperty
-
setMaxThreads
public void setMaxThreads(int value)Sets theMaxThreadsproperty; seegetMaxThreads().- Parameters:
value- the new value
-
getPreferIpv6
public boolean getPreferIpv6()Iftrue, then use IPv6 over IPv4 when both are supported for a particular domain. The default value of this property isfalse, which will choose IPv4 over IPv6.Note: Setting this property has the effect of also setting the default value of the PreferIpv6 property for other classes.
- Returns:
- the value of the
PreferIpv6property
-
setPreferIpv6
public void setPreferIpv6(boolean value)Sets thePreferIpv6property; seegetPreferIpv6().- Parameters:
value- the new value
-
getThreadPoolLogPath
If set, indicates the path of a log file to be used by the thread pool thread and each of the pool worker threads for logging async activity. Chilkat always appends to the log file. If the log file already exists, then new information will be appended.- Returns:
- the value of the
ThreadPoolLogPathproperty
-
setThreadPoolLogPath
Sets theThreadPoolLogPathproperty; seegetThreadPoolLogPath().- Parameters:
value- the new value (notnull)
-
getUncommonOptions
This is a catch-all property to be used for uncommon needs. This property defaults to the empty string, and should typically remain empty.- Returns:
- the value of the
UncommonOptionsproperty
-
setUncommonOptions
Sets theUncommonOptionsproperty; seegetUncommonOptions().- Parameters:
value- the new value (notnull)
-
getUnlockStatus
public int getUnlockStatus()Indicates the unlocked status for the last call to UnlockBundle. The possible values are:- Not unlocked. (Still in locked state.)
- Unlocked with in fully-functional trial mode.
- Unlocked using a valid purchased unlock code.
Note: If UnlockBundle is called with a purchased unlock code, the UnlockStatus is correctly set to the value 2. This value is intentionally sticky. If a subsequent and redundant call to UnlockBundle happens, it is effectively a
No-Opbecause the library is already unlocked. The UnlockStatus will not change.If however, if the 1st call resulted in UnlockStatus = 1, and THEN the unlock method is called again with a purchased unlock code, the UnlockStatus should change from 1 to 2.
- Returns:
- the value of the
UnlockStatusproperty (read-only)
-
getUsePkcsConstructedEncoding
public boolean getUsePkcsConstructedEncoding()This property should typically be left at the default value offalse. If set totrue, then Chilkat will use a constructed ASN.1 encoding for PCKS7 data. (This is an internal implementation option that normally does not matter, and should not matter. Some PKCS7 receiving systems might be picky, and this option can be used to satisfy this requirement.)- Returns:
- the value of the
UsePkcsConstructedEncodingproperty
-
setUsePkcsConstructedEncoding
public void setUsePkcsConstructedEncoding(boolean value)Sets theUsePkcsConstructedEncodingproperty; seegetUsePkcsConstructedEncoding().- Parameters:
value- the new value
-
getVerboseTls
public boolean getVerboseTls()If set totrue, then causes extremely verbose logging (in LastErrorText) all TLS connections in any Chilkat class. This property should only be used for troubleshooting TLS problems. The default value isfalse.Note: This property only has effect on Chilkat objects not yet created. Set the property first, then instantiate the Chilkat object.
- Returns:
- the value of the
VerboseTlsproperty
-
setVerboseTls
public void setVerboseTls(boolean value)Sets theVerboseTlsproperty; seegetVerboseTls().- Parameters:
value- the new value
-
dnsClearCache
public void dnsClearCache()This function clears the Chilkat in-memory DNS cache, which stores hostname-to-IP address mappings to avoid repeated DNS lookups.Note:
- The DNS cache is shared across all Chilkat objects, so clearing it will impact all such objects.
-
Chilkat's DNS caching respects the TTL (time to live) of DNS records. If the TTL has expired since
the initial lookup, Chilkat will perform a new DNS query and update the cache with the latest IP
address.
- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
finalizeThreadPool
public void finalizeThreadPool()Called to stop and finalize all threads in the thread pool, and causes the thread pool thread to exit.The following behaviors exist in v9.5.0.64 and later:
- All remaining asynchronous tasks are automatically canceled.
- Restores the thread pool to it's pristine state where no background threads are running.
It is a good idea to call this method at the very end of a program, just before it exits. This is especially true for programs written in VBScript, VB6, FoxPro, and PowerBuilder.
- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
threadPoolLogLine
Logs a line to the thread pool log file.- Parameters:
str- thestrargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
unlockBundle
Unlocks the entire Chilkat API for all classes. This should be called once at the beginning of a program. Once unlocked, objects of any Chilkat class may be instantiated and used. To unlock in fully-functional 30-day trial mode, pass any string, such asHello, inbundleUnlockCode. If a license is purchased, then replace theHellowith the purchased unlock code.After calling UnlockBundle once, the instance of the CLASS_NAME object may be discarded/deleted (assuming the programming language requires explicit deletes). Multiple calls to UnlockBundle are harmless. If the Chilkat API is already unlocked, the duplicate calls to UnlockBundle are no-ops.
Important: Unlocking sets a flag in memory to indicate the unlocked status. There are no licensing files, and there is no communication with any Chilkat servers. This means your application, script, etc. must call UnlockBundle once at the start each time it runs. The good thing is that your application can run on any computer -- there are no licensing files to worry about. Also: If an application forgets to call UnlockBundle, Chilkat will automatically unlock in trial mode, and this will eventually fail when the trial runs out. If you purchased a license, it is very important to make sure you call UnlockBundle with the purchased unlock code.
- Parameters:
bundleUnlockCode- thebundleUnlockCodeargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-