Upgrade HST Spring Configuration

As part of the restructuring of HST for version 13, HST's Spring configuration has undergone significant changes. If your project-specific code relies on Spring beans managed by the HST core, you may need to make corresponding changes to your project.

Per-Site Spring Contexts

In version 13, each site web application has its own Spring context, separate from the other web applications' Spring contexts. Each web application's Spring context is initialized by the HST core, and each web application can then add Spring beans to that context, or override designated core beans. Additionally, the CMS/platform web application also has its own Spring context, which is guaranteed to be initialized before the Spring contexts of all site web applications, augmenting HST's core beans with platform-specific beans such as those required by the Channel Manager.

HST Core Spring Extension Points

There is a list of IDs of Spring beans managed by HST core and intended for API or SPI usage by project code. If your project code only depends on these beans, your code should be fine; you can still inject/override these beans through custom Spring configuration, or retrieve them by their old IDs, using HST's ComponentManager.

Dropped HST Core Spring Beans

Several Spring beans used before version 13 have been dropped without replacement. Except for the HstSiteMapMatcher and the HstLinkCreator, for which we describe an alternative access mechanism below, we consider it highly unlikely that your end project depends on any of them. If it does, and there is no obvious alternative to restore the old functionality on version 13, please get in touch with us to discuss potential solutions.

These are the IDs of the dropped Spring beans:

  • org.hippoecm.hst.configuration.channel.ChannelManager
  • org.hippoecm.hst.channelmanager.security.SecurityModel
  • jcrPathTemplateComposer
  • org.hippoecm.hst.core.container.HstComponentRegistry
  • org.hippoecm.hst.core.container.HstNavigationalStateCodec
  • org.hippoecm.hst.core.sitemapitemhandler.HstSiteMapItemHandlerFactory
  • org.hippoecm.hst.core.sitemapitemhandler.HstSiteMapItemHandlerRegistry
  • org.hippoecm.hst.core.internal.MountDecorator*
  • org.hippoecm.hst.core.request.HstSiteMapMatcher
  • hstEventsCollector
  • hstEventsDispatcher
  • org.hippoecm.hst.configuration.cache.HstNodeLoadingCache
  • org.hippoecm.hst.configuration.cache.HstConfigurationLoadingCache
  • org.hippoecm.hst.configuration.model.EventPathsInvalidator
  • org.hippoecm.hst.configuration.site.DelegatingHstSiteProvider
  • org.hippoecm.hst.core.linking.HstLinkCreator
  • org.hippoecm.hst.core.linking.locationResolvers
  • org.hippoecm.hst.core.linking.ResourceContainer.list
  • cmsHostRestRequestContextValve

*This bean has been renamed to org.hippoecm.hst.core.internal.PreviewDecorator, but is not meant for use by end projects anyway.

Retrieving HST's Link Creator and Sitemap Matcher

As described above, in version 13, it is no longer possible to inject org.hippoecm.hst.core.linking.HstLinkCreator or org.hippoecm.hst.core.request.HstSiteMapMatcher using Spring. These objects are now created in the CMS/platform web application rather than the site web application. If your project has Spring configuration like this:

<property name="linkCreator" ref="org.hippoecm.hst.core.linking.HstLinkCreator"/>
<property name="siteMapMatcher" ref="org.hippoecm.hst.core.request.HstSiteMapMatcher"/>

this will not work anymore, and you must remove that configuration. Likewise, if your project code programmatically retrieved these objects like this:

HstLinkCreator linkCreator = HstServices.getComponentManager().getComponent(HstLinkCreator.class.getName());

your code will not work anymore. Instead, you can retrieve the site's HstLinkCreator and HstSiteMapMatcher objects through the HST Model, as follows:

HstModelRegistry hstModelRegistry = HippoServiceRegistry.getService(HstModelRegistry.class);
HstModel hstModel = hstModelRegistry.getHstModel(contextPath);
HstLinkCreator linkCreator = hstModel.getHstLinkCreator();
HstSiteMapMatcher siteMapMatcher = hstModel.getHstSiteMapMatcher();

As of version 13.0.1, you can also retrieve the HST Model in your Spring configuration by injecting HstModelProvider as follows:

<property name="hstModelProvider" ref="org.hippoecm.hst.platform.HstModelProvider"/>

and then in your Spring bean, use

hstModelProvider.getHstModel().getHstLinkCreator();
hstModelProvider.getHstModel().getHstSiteMapMatcher();

The latter approach always uses the HST Model of the local site web application, while the former approach allows/requires you to specify a web application based on its context path.

During request processing, you can get these objects through the HstRequestContext:

RequestContextProvider.get().getHstLinkCreator();
RequestContextProvider.get().getSiteMapMatcher();

or if you have an HstRequest object:

hstRequest.getRequestContext().getHstLinkCreator();
hstRequest.getRequestContext().getSiteMapMatcher();
Did you find this page helpful?
How could this documentation serve you better?
On this page
    Did you find this page helpful?
    How could this documentation serve you better?

    We rely on cookies

    to optimize our communication and to enhance your customer experience. By clicking on the Accept and Close button, you agree to the collection of cookies. You can also adjust your preferences by clicking on Manage Preferences. For more information please see our Privacy policy.

    Manage cookies
    Accept & close

    Cookies preferences

    Accept & close
    Back