19 Using Cache Configuration Override
xml-override
attribute in the root element of cache configuration. The root element is
referred to as the "base" cache configuration file whose elements you can now override by
placing the override file in the classpath or a module path. If the specified XML override
file is found on the classpath or a module path, Coherence loads the file at runtime and
overrides the base configuration based on each module’s specific requirements.
This chapter includes the following topics:
- Specifying the xml-override Attribute
Based on thexml-override
attribute you specify, Coherence loads thecache-config-override.xml
file and applies when it is found on the classpath or a module path of the application when you do not specify thecoherence.cacheconfig.override
system property. - Use Cases for Overriding Coherence Cache Configuration
The use cases in this section describe the different scenarios for overriding Coherence cache configuration.
Parent topic: Using Caches
Specifying the xml-override Attribute
xml-override
attribute you
specify, Coherence loads the cache-config-override.xml
file and
applies when it is found on the classpath or a module path of the application when you
do not specify the coherence.cacheconfig.override
system
property. If you specify coherence.cacheconfig.override
,
Coherence loads the XML override pointed by this system property and applies it at
runtime.
xml-override
attribute
specified:<cache-config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.oracle.com/coherence/coherence-cache-config"
xsi:schemaLocation="http://xmlns.oracle.com/coherence/coherence-cache-config coherence-cache-config.xsd"
xml-override="{coherence.cacheconfig.override cache-config-override.xml}">
....
</cache-config>
Parent topic: Using Cache Configuration Override
Use Cases for Overriding Coherence Cache Configuration
The use cases in this section describe the different scenarios for overriding Coherence cache configuration.
- Cache configuration override has
caching-scheme-mapping
/cache-mapping
that already exists in the base cache configuration with the samecache-name
In this case, the
cache-mapping
element withincaching-scheme-mapping
is overridden from the override file, as shown in the following example:- Base
XML
<cache-mapping> <cache-name>my-cache-*</cache-name> <scheme-name>my-cache-scheme-parent</scheme-name> </cache-mapping>
- Override
XML
<cache-mapping> <cache-name>my-cache-*</cache-name> <scheme-name>my-cache-scheme-override</scheme-name> </cache-mapping>
- The effective
<caching-scheme-mapping>
element after the application of the XML override to the base XML<caching-scheme-mapping> <cache-mapping> <cache-name>my-cache-*</cache-name> <scheme-name>my-cache-scheme-override</scheme-name> </cache-mapping> </caching-scheme-mapping>
- Base
XML
- Cache configuration override has
caching-scheme-mapping
/cache-mapping
that does not exist in the base cache configurationIn this case, the new
<cache-mapping>
element from the override file prepends to the other elements withincaching-scheme-mapping
, as shown in the following example:- Base
XML
<cache-mapping> <cache-name>my-cache-*</cache-name> <scheme-name>my-cache-scheme-parent</scheme-name> </cache-mapping>
- Override
XML
<cache-mapping> <cache-name>my-cache-override</cache-name> <scheme-name>my-cache-scheme-override</scheme-name> </cache-mapping>
- The effective
<caching-scheme-mapping>
element after the application of the XML override to the base XML<caching-scheme-mapping> <cache-mapping> <cache-name>my-cache-override</cache-name> <scheme-name>my-cache-scheme-override</scheme-name> </cache-mapping> <cache-mapping> <cache-name>my-cache-*</cache-name> <scheme-name>my-cache-scheme-parent</scheme-name> </cache-mapping> </caching-scheme-mapping>
- Base
XML
- Cache configuration override has
caching-scheme
with the samescheme-name
that exists in the base configuration fileOnly a
caching-scheme
with the givenscheme-name
is merged with the relevant content from the override file, as shown in the following example:- Base
XML
<caching-schemes> <distributed-scheme> <scheme-name>my-cache-scheme</scheme-name> <service-name>MyCache</service-name> <backing-map-scheme> <local-scheme> <unit-calculator>BINARY</unit-calculator> </local-scheme> </backing-map-scheme> <partitioned-quorum-policy-scheme> <write-quorum>3</write-quorum> </partitioned-quorum-policy-scheme> <autostart>true</autostart> </distributed-scheme> <distributed-scheme> <scheme-name>my-cache-scheme-two</scheme-name> <service-name>MyCache2</service-name> </distributed-scheme> <caching-schemes>
- Override
XML
<caching-schemes> <distributed-scheme> <scheme-name>my-cache-scheme</scheme-name> <partitioned-quorum-policy-scheme> <write-quorum>1</write-quorum> </partitioned-quorum-policy-scheme> </distributed-scheme> </caching-schemes>
- The effective
<caching-schemes>
element after the application of the XML override<caching-schemes> <distributed-scheme> <scheme-name>my-cache-scheme</scheme-name> <service-name>MyCache</service-name> <backing-map-scheme> <local-scheme> <unit-calculator>BINARY</unit-calculator> </local-scheme> </backing-map-scheme> <partitioned-quorum-policy-scheme> <write-quorum>1</write-quorum> </partitioned-quorum-policy-scheme> <autostart>true</autostart> </distributed-scheme> <distributed-scheme> <scheme-name>my-cache-scheme-two</scheme-name> <service-name>MyCache2</service-name> </distributed-scheme> <caching-schemes>
- Base
XML
- Cache configuration override with
caching-schemes
without anyscheme-name
All types of that
caching-scheme
is modified with the relevant content from the override file, as shown in the following example:- Base
XML
<caching-schemes> <distributed-scheme> <scheme-name>my-cache-scheme</scheme-name> <service-name>MyCache</service-name> <backing-map-scheme> <local-scheme> <unit-calculator>BINARY</unit-calculator> </local-scheme> </backing-map-scheme> <partitioned-quorum-policy-scheme> <write-quorum>3</write-quorum> </partitioned-quorum-policy-scheme> <autostart>true</autostart> </distributed-scheme> <distributed-scheme> <scheme-name>my-cache-scheme-two</scheme-name> <service-name>MyCache2</service-name> </distributed-scheme> <caching-schemes>
- Override
XML
<caching-schemes> <distributed-scheme> <partitioned-quorum-policy-scheme> <write-quorum>1</write-quorum> </partitioned-quorum-policy-scheme> </distributed-scheme> </caching-schemes>
- The effective
<caching-schemes>
element after the application of the XML override<caching-schemes> <distributed-scheme> <scheme-name>my-cache-scheme</scheme-name> <service-name>MyCache</service-name> <backing-map-scheme> <local-scheme> <unit-calculator>BINARY</unit-calculator> </local-scheme> </backing-map-scheme> <partitioned-quorum-policy-scheme> <write-quorum>1</write-quorum> </partitioned-quorum-policy-scheme> <autostart>true</autostart> </distributed-scheme> <distributed-scheme> <scheme-name>my-cache-scheme-two</scheme-name> <service-name>MyCache2</service-name> <partitioned-quorum-policy-scheme> <write-quorum>1</write-quorum> </partitioned-quorum-policy-scheme> </distributed-scheme> <caching-schemes>
- Base
XML
Parent topic: Using Cache Configuration Override