3.3.3 Setting up the schema cache
To use the schema cache functionality, you must decide a schema document for cache in advance and set up a schema cache. Therefore, set up the following property file appropriately:
-
Schema definition file
-
User-defined file (usrconf.properties) of the J2EE server
The above mentioned file corresponds to the Java property file. Therefore, for basic syntax rules, follow the rules used in the Java property file. Note that for details about the syntax rules of the property files, see Javadoc of the java.util.Properties class.
This subsection described the property files.
- Organization of this subsection
(1) Schema definition file
You can define the following items in a schema definition file:
-
Schema document to cache
-
Cache format
-
Location on a disk in which the schema cache is saved
You can specify any file name and save location for the schema definition file.
The following schema documents will be cached:
-
Schema documents directly specified in the schema definition file
-
Schema documents that are referenced directly or indirectly from the schema documents that are defined directly in the schema definition file, with the following elements:
-
import element
-
include element
-
redefine element
-
The following table lists the properties that you can code in a schema definition file. If you specify any other property, that property will be ignored.
No. |
Property name |
Specified value |
---|---|---|
1 |
schema_path |
Specifies an absolute path that indicates a directory where the schema document exists. |
2 |
diskcache_path |
Specifies an absolute path that indicates a directory where the disk cache is saved. |
3 |
schema_xxx (xxx is any character string that has more than one character) |
Specifies a relative path that indicates a file of the schema document to be cached and the disk cache specifier. You can omit the disk cache specifier. For the disk cache specifier, code D at the end of the relative path of the schema document. The schema document cache specified by the disk cache specifier is created on the disk. If there is no coding of the disk cache specifier, a cache is created in the memory. A space or a tab that is connected to the file name and the disk cache will be ignored. |
Use a forward slash (/) as a delimiter in a path specified for each property, in Windows and UNIX. Using a forward slash (/) at the end of an absolute path for the directory name is optional.
If the same property name is specified more than once, the last specified value of the property will be valid.
The following are the examples of schema definition files:
- In Windows
shema_path=C:/usr/app/xmlparser/schemafiles diskcache_path=C:/usr/app/xmlparser schema_01=schema/type1.xsd schema_02=schema/type2.xsd,D
- In UNIX
shema_path=/usr/app/xmlparser/schemafiles diskcache_path=/usr/app/xmlparser schema_01=schema/type1.xsd schema_02=schema/type2.xsd,D
When schema_01=schema/type1.xsd is specified, the disk cache specifier has not been coded, so cache of the schema document will be performed in the memory.
When schema_02=schema/type2.xsd,D is specified, the disk cache specifier has been coded, and therefore, the schema document is cached on the disk.
The following are the operations for specifying the schema definition files:
-
You must specify the schema_path property and the diskcache_path property.
If any one of the above two properties is not specified, a warning message (KECX09503-W) indicating that the required property is not specified will output to an error file, and schema validation is executed without using the schema cache.
-
Even if the same directory is specified in the diskcache_path property on multiple J2EE servers, the disk cache is managed independently on each server.
A directory having the name same as that of the J2EE server is created in the directory specified in the diskcache_path property, and a cache file is created in the directory. When the disk cache is deleted, the cache file for each created subdirectory will be deleted.
-
When the specified of the diskcache_path property is not an absolute path, the warning message (KECX09507-W) is output to an error file, and schema validation is executed without using the schema cache.
-
When you cannot access to a directory that is specified in the diskcache_path property, the warning message (KECX09505-W) indicating that the directory for saving the disk cache cannot be accessed will output to an error file, and schema validation is executed without using the schema cache.
-
When the specified value of the schema_path property is not an absolute path, the warning message (KECX09508-W) is output to the error file, and schema validation is executed without using the schema cache.
-
When the specified value of the schema_xxx property is not a relative path, the warning message (KECX09509-W) is output to an error file, and the specification of the schema_xxx property will be ignored.
-
When an attempt to write grammar objects in a file fails while creating a disk cache, the warning message (KECX09511-W) is output to an error file. A parser validates the schema using the schema document and not the cache for which an attempt to write the grammar objects has failed.
-
When the same schema document is specified with multiple schema_xxx properties, only one cache corresponding to the schema document is created. In such cases, if the disk cache specifier is specified to any of the properties among all the properties, a cache will be created on the disk. If the disk cache specifier is not specified to any of the properties, the cache will be created in the memory.
For details about the precautions related to the schema definition files, see the subsection 6.18.3 Precautions related to schema definition files.
(2) J2EE server user-defined file
The user-defined file (usrconf.properties) of the J2EE server defines a class, to be initialized when the J2EE server starts, and a system property to be set up.
For details about the user-defined files of J2EE servers, see 2. Files Used in J2EE Servers in the uCosminexus Application Server Definition Reference Guide.
The following table lists the properties coded in the user-defined file of the J2EE server, when the schema cache functionality is used.
No. |
Property name |
Specified value |
---|---|---|
1 |
ejbserver.application.InitTermProcessClasses |
Specifies the initialization and termination class of the J2EE extended container. Specify com.cosminexus.jaxp.impl.parsers.util.XMLGrammarCaching that is required to set up a schema cache, using the schema cache functionality. |
2 |
com.cosminexus.jaxp.grammar_caching.preload |
Specifies whether to use the schema cache functionality or not. You can specify either ON or OFF. The default value is OFF. If you specify ON, the schema cache functionality can be used. The XML parser executes the schema validation using the schema cache. If you specify OFF, the schema cache functionality cannot be used. The XML parser executes the schema validation without using the schema cache. Note that this property controls all the schema cache functionality. You must specify ON to use the schema cache functionality for J2EE server. If you specify OFF, the schema cache functionality will not be enabled after the J2EE server starts. |
3 |
com.cosminexus.jaxp.grammar_caching.config |
Specifies an absolute path of the schema definition file. |
You can use the schema cache functionality only when corresponding to all the following conditions:
-
Specifies the ejbserver.application.InitTermProcessClasses property.
-
Specifies ON in the com.cosminexus.jaxp.grammar_caching.preload property.
-
Specifies the com.cosminexus.jaxp.grammar_caching.config property.
The following is an example of the user-defined files for J2EE servers:
# Specifies the class to be initialized when Cosminexus starts ejbserver.application.InitTermProcessClasses=com.cosminexus.jaxp.impl.parsers.util.XMLGrammarCaching # Enables the cache functionality com.cosminexus.jaxp.grammar_caching.preload=ON # Absolute path of schema definition file defined in the schema document to be maintained in the cache com.cosminexus.jaxp.grammar_caching.config=C:/usr/app/xmlparser/config.properties
The following are the operations for specifying the user-defined files for J2EE servers:
-
When the following value is specified in the com.cosminexus.jaxp.grammar_caching.preload property, OFF must be specified:
-
A value other than ON or OFF is specified
-
A property is not specified
-
-
When you cannot access the schema definition file specified in the com.cosminexus.jaxp.grammar_caching.config property, even if ON is specified in the com.cosminexus.jaxp.grammar_caching.preload property, you cannot use the schema cache functionality (warning message KECX09504-W)