Configuring the CRISP Addon

Overview

CRISP configuration is stored in the repository by default at /hippo:configuration/hippo:modules/crispregistry/hippo:moduleconfig.

Info:
Starting with brXM 12.6, you can change the CRISP repository configuration path by setting the crisp.moduleconfig.path property in /WEB-INF/hst-config.properties in your site web application. For example:

# Setting a custom CRISP configuration path.
crisp.moduleconfig.path = /crisp/site1/hippo:moduleconfig

The custom path /crisp/site1/hippo:moduleconfig might have the following structure:

/crisp: jcr:primaryType: nt:unstructured /site1: jcr:primaryType: nt:unstructured /hippo:moduleconfig: jcr:primaryType: crisp:moduleconfig /crisp:resourceresolvercontainer: jcr:primaryType: crisp:resourceresolvercontainer ...

You can configure CRISP for a resource space, such as demoProductCatalog, as shown below:

/hippo:moduleconfig: jcr:primaryType: crisp:moduleconfig /crisp:resourceresolvercontainer: jcr:primaryType: crisp:resourceresolvercontainer /demoProductCatalogs: jcr:primaryType: crisp:resourceresolver crisp:beandefinition: <!-- XML Bean definition here for the resource space, 'demoProductCatalogs'. --> crisp:propnames: [commerce.api.base.uri] crisp:propvalues: ['${example.commerce.api.base.uri}'] crisp:sitescopes: []

Info:
You can use variable interpolation in the crisp:propvalues property. These variables are resolved from the HST-2 Container Configuration. For example:

# HST-2 Container Configuration properties file example. e.g, conf/hst.properties
# ...
example.commerce.api.base.uri = http://localhost:8080/example-commerce/api/v1
# ...

Hint:
To restrict a ResourceResolver configuration to specific web applications, set the crisp:sitescopes property. Valid values are "platform" (for the platform application) and the names of delivery-tier applications as configured in the hcm-site.yaml files. For more information, see Manage Site-Specific Data.
If you do not set crisp:sitescopes or set it to an empty array, the configuration is available to all applications.

You can bootstrap these configurations or update them at runtime. Changes take effect immediately.

CRISP Configuration Node Structure

  • The CRISP module configuration node at /hippo:configuration/hippo:modules/crispregistry/hippo:moduleconfig must use the primary node type crisp:moduleconfig.
  • This node contains a single child node named crisp:resourceresolvercontainer (primary type: crisp:resourceresolvercontainer). This container holds zero or more child nodes, each representing a ResourceResolver for a resource space (primary type: crisp:resourceresolver).
  • Each ResourceResolver node can define the following properties:
    • crisp:propnames (multi-valued string): Names of configuration properties.
    • crisp:propvalues (multi-valued string): Values for the properties, supporting variable interpolation from HST-2 Container Configuration.
    • crisp:beandefinition (string): Spring Framework bean definition in XML format.
  • The crisp:beandefinition property defines a Spring bean for the ResourceResolver. The property values can be interpolated using the names and values defined in crisp:propnames and crisp:propvalues.
  • This structure allows administrators to manage configuration properties without directly editing the XML bean definition.

Adding a ResourceResolver Configuration for a New Resource Space

You can configure a ResourceResolver in the repository or directly in a CRISP API Addon's Spring Bean XML file (from version 12.6 onward).

  • If you configure a ResourceResolver in a delivery tier application's Spring Bean XML file (e.g., /site), it is only accessible within that application. It is not available to other applications such as /cms.

Adding a ResourceResolver in Repository Configuration

By default, /hippo:configuration/hippo:modules/crispregistry/hippo:moduleconfig/crisp:resourceresolvercontainer does not contain any ResourceResolver configuration. You can add nodes for your backend services as needed.

For example, to add a new resource space named demoProductCatalogs, create a node at /hippo:configuration/hippo:modules/crispregistry/hippo:moduleconfig/crisp:resourceresolvercontainer/demoProductCatalogs. The following examples show the configuration in System View XML format.

brXM 16:

<?xml version="1.0" encoding="UTF-8"?> <sv:node sv:name="demoProductCatalogs" xmlns:sv="http://www.jcp.org/jcr/sv/1.0"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>crisp:resourceresolver</sv:value> </sv:property> <sv:property sv:name="crisp:beandefinition" sv:type="String"> <sv:value><![CDATA[<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd"> <bean parent="abstractCrispSimpleJacksonRestTemplateResourceResolver" class="org.onehippo.cms7.crisp.core.resource.jackson.SimpleJacksonRestTemplateResourceResolver"> <property name="cacheEnabled" value="${cache.enabled}" /> <property name="baseUri" value="${commerce.api.base.uri}" /> <property name="restTemplate"> <bean class="org.springframework.web.client.RestTemplate"> <property name="requestFactory" ref="org.springframework.http.client.ClientHttpRequestFactory" /> </bean> </property> <property name="resourceLinkResolver"> <bean class="org.onehippo.cms7.crisp.core.resource.FreemarkerTemplateResourceLinkResolver"> <property name="templateSource"> <value>http://www.example.com/products/${(preview == "true")?then("staging", "current")}/sku/${resource.valueMap['SKU']!"unknown"}/overview.html</value> </property> </bean> </property> <property name="resourceDataCache"> <bean class="org.onehippo.cms7.crisp.core.resource.SpringResourceDataCache"> <constructor-arg> <bean class="org.springframework.cache.caffeine.CaffeineCache" factory-bean="caffeineCacheInstanceFactory" factory-method="createSpringCacheInstance"> <constructor-arg value="demomarketoCache" /> <constructor-arg value="initialCapacity=10,maximumSize=1000,expireAfterWrite=100s,expireAfterAccess=100s" /> </bean> </constructor-arg> </bean> </property> </bean> </beans> ]]></sv:value> </sv:property> <sv:property sv:multiple="true" sv:name="crisp:propnames" sv:type="String"> <sv:value>cache.enabled</sv:value> <sv:value>commerce.api.base.uri</sv:value> </sv:property> <sv:property sv:multiple="true" sv:name="crisp:propvalues" sv:type="String"> <sv:value>true<sv:value> <sv:value>http://localhost:8080/example-commerce/api/v1</sv:value> </sv:property> </sv:node>

brXM 14 & 15:

<?xml version="1.0" encoding="UTF-8"?> <sv:node sv:name="demoProductCatalogs" xmlns:sv="http://www.jcp.org/jcr/sv/1.0"> <sv:property sv:name="jcr:primaryType" sv:type="Name"> <sv:value>crisp:resourceresolver</sv:value> </sv:property> <sv:property sv:name="crisp:beandefinition" sv:type="String"> <sv:value><![CDATA[<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd"> <bean parent="abstractCrispSimpleJacksonRestTemplateResourceResolver" class="org.onehippo.cms7.crisp.core.resource.jackson.SimpleJacksonRestTemplateResourceResolver"> <property name="cacheEnabled" value="${cache.enabled}" /> <property name="baseUri" value="${commerce.api.base.uri}" /> <property name="restTemplate"> <bean class="org.springframework.web.client.RestTemplate"> <property name="requestFactory" ref="org.springframework.http.client.ClientHttpRequestFactory" /> </bean> </property> <property name="resourceLinkResolver"> <bean class="org.onehippo.cms7.crisp.core.resource.FreemarkerTemplateResourceLinkResolver"> <property name="templateSource"> <value>http://www.example.com/products/${(preview == "true")?then("staging", "current")}/sku/${resource.valueMap['SKU']!"unknown"}/overview.html</value> </property> </bean> </property> <property name="resourceDataCache"> <bean class="org.onehippo.cms7.crisp.core.resource.SpringResourceDataCache"> <constructor-arg> <bean class="org.springframework.cache.ehcache.EhCacheCache"> <constructor-arg> <bean parent="abstractCrispResourceEhCache"> <property name="cacheName" value="demoProductCatalogsCache" /> <property name="maxEntriesLocalHeap" value="1000" /> <property name="maxEntriesLocalDisk" value="0" /> <property name="timeToLiveSeconds" value="60" /> <property name="timeToIdleSeconds" value="60" /> </bean> </constructor-arg> </bean> </constructor-arg> </bean> </property> </bean> </beans> ]]></sv:value> </sv:property> <sv:property sv:multiple="true" sv:name="crisp:propnames" sv:type="String"> <sv:value>cache.enabled</sv:value> <sv:value>commerce.api.base.uri</sv:value> </sv:property> <sv:property sv:multiple="true" sv:name="crisp:propvalues" sv:type="String"> <sv:value>true<sv:value> <sv:value>http://localhost:8080/example-commerce/api/v1</sv:value> </sv:property> </sv:node>

This configuration creates a ResourceResolver node named demoProductCatalogs. This name is used as the resource space when invoking the ResourceServiceBroker API.

Adding a ResourceResolver in Spring Bean Assembly

Starting with brXM 12.6, you can define a ResourceResolver bean directly in a CRISP API Addon's Spring Bean XML file. This approach is only available to the delivery tier web application where the bean is defined.

To configure this, define a ResourceResolver bean with an ID matching the desired resource space name. For example, to create a ResourceResolver for demoProductCatalogs, add the following to a CRISP API Addon's Spring assembly XML file (for example, site/components/src/main/resources/META-INF/hst-assembly/addon/crisp/overrides/custom-resource-resolvers.xml):

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd"> <bean id="demoProductCatalogs" parent="abstractCrispSimpleRestTemplateResourceResolver" class="org.onehippo.cms7.crisp.core.resource.jdom.SimpleJdomRestTemplateResourceResolver"> <!-- SNIP --> </bean> </beans>

You can define multiple ResourceResolver beans in the same XML file, as long as each bean ID is unique. These beans are only available to the delivery tier web application where they are defined.

ResourceResolver Bean Definition

When you configure a ResourceResolver using the crisp:beandefinition property, CRISP Core creates a child ApplicationContext from the XML configuration. It registers a bean of type org.onehippo.cms7.crisp.api.resource.ResourceResolver for the resource space, using the node name as the resource space name. You do not need to specify an id attribute for the bean definition.

The crisp:beandefinition property can use variables defined by the crisp:propnames and crisp:propvalues properties. This enables management tools to expose configuration parameters without requiring direct edits to the XML bean definition.

In the example above, the bean uses the class org.onehippo.cms7.crisp.core.resource.jackson.SimpleJacksonRestTemplateResourceResolver, which provides generic support for JSON-based REST APIs. The bean also inherits from abstractCrispSimpleJacksonRestTemplateResourceResolver, which includes common features provided by the CRISP module library. It is recommended to inherit from the provided abstract bean definitions when possible.

Default abstract bean definitions include:

<!-- SNIP --> <!-- Basic HTTP Client Enabled Abstract Base Bean Definition --> <bean id="abstractCrispHttpRequestResourceResolver" abstract="true"> <property name="clientHttpRequestFactory" ref="org.springframework.http.client.ClientHttpRequestFactory" /> </bean> <!-- SNIP --> <!-- Basic JSON Supporting (Jackson Library based) HTTP Client Enabled Abstract Base Bean Definition --> <bean id="abstractCrispSimpleJacksonRestTemplateResourceResolver" abstract="true" parent="abstractCrispHttpRequestResourceResolver"> <property name="cacheEnabled" value="true" /> </bean> <!-- SNIP -->

Configuring the HTTP Connection Pool

CRISP API uses a default HTTP connection pool with a maximum of 600 total connections and 200 connections per route. These defaults are suitable for most use cases.

To customize the connection pool settings, add an XML file to site/components/src/main/resources/META-INF/hst-assembly/addon/crisp/overrides/ (for example, custom-crisp-http-client.xml):

<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <!-- Customizing the default CRISP HttpClientBuilderFactoryBean with custom settings. --> <bean id="crispHttpClientBuilder" class="org.onehippo.cms7.crisp.core.support.httpclient.DefaultHttpClientBuilderFactoryBean"> <property name="useSystemProperties" value="true" /> <property name="maxConnTotal" value="400" /> <property name="maxConnPerRoute" value="200" /> <property name="connectionTimeMillisToLive" value="3600000" /> </bean> </beans>

The following table describes each property:

PropertyDescriptionDefault Value
useSystemPropertiesIf set to true, uses HttpClientBuilder.useSystemProperties(). This allows system properties to be passed when initializing HttpClient.true
maxConnTotalMaximum total HTTP connections.600
maxConnPerRouteMaximum HTTP connections per route.200
connectionTimeMillisToLiveTime to live (in milliseconds) for each HTTP connection. If not positive, connections never expire.-1
Share Feedback
Page: /build/crisp-api/introduction-config/configuring-crisp-addon
Section: Build
Category *