Custom Resource Containers

This page describes how you can inject custom resource containers into your HST2 website. We consider a resource container a node that can contain one or more binary blobs.

By default, the CMS ships with two resource containers, namely 'hippogallery:exampleImageSet' and 'hippogallery:exampleAssetSet'. In case of the container exampleImageSet, the node contains two binary blobs, 'hippogallery:thumbnail' and 'hippogallery:picture'. For example you have the node in jcr like:


Now, the default binary the HST2 shows should be 'hippogallery:picture' (the real picture). So, instead of having a undesirable ugly link like


the HST2 out-of-the-box shows the 'hippogallery:picture' when the link is:


This works with the help of default built in org.hippoecm.hst.core.linking.ResourceContainer's. The default available implementations are HippoGalleryImageSetContainer and HippoGalleryAssetSet. They both extend from the general AbstractResourceContainer, which you might reuse if you want to add your own custom resource container. The HippoGalleryImageSetContainer looks like:

public class HippoGalleryImageSetContainer extends AbstractResourceContainer {
    public String getNodeType() {
        return "hippogallery:imageset";

Adding a custom Resource Container.

Now Assume, you have a custom image set, that looks like:


Now by default, if you do not add any custom resource container, then if myimageset.jpg is of type 'mygallery:imageset' the url


resolves to the mygallery:thumbnail. Also links /binaries/content/gallery/mysite/myimageset.jpg/myimageset.jpg/mygallery:original etcetera will work out-of-the-box, because the HST2 ships also with a fallback DefaultResourceContainer, which works on everything extending from 'hippo:document'.

But, what if you want to have the following links:

      --> mygallery:original

      --> mygallery:medium

      --> mygallery:small

      --> mygallery:thumbnail

This is possible by merely adding a very simple class extending AbstractResourceContainer, and add a piece of spring configuration. More advanced/exotic usecases can be easily achieved by overriding some AbstractResourceContainer methods. You can also take a look at the demosite at /src/main/java/META-INF/hst-assembly/overrides/customResourceContainers.xml and the DemositeResourceContainer.

Back to our example, we can achieve the links described above by adding the following spring config to your hst-assembly/overrides:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns=""

    <bean id="customResourceContainers"
          <property name="sourceList">
                  <bean class=
                      <property name="primaryItem" value="mygallery:original"/>
                      <property name="mappings">
                        <bean class=
                          <property name="sourceMap">
                            <map key-type=
                              "java.lang.String" value-type="java.lang.String">
                              <entry key="mygallery:thumbnail"
                              <entry key="mygallery:medium" value="medium"/>
                              <entry key="mygallery:small" value="small"/>


public class MyGalleryResourceContainer extends AbstractResourceContainer {
    public String getNodeType() {
        return "mygallery:imageset";

That's it.

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?