Fork me on GitHub

How to install the properties plugin

Prerequisites

These instruction assumes that you have an HST project based on the HST archetype, i.e. a Maven multiproject consisting of at least three submodules: cms, site and content.

Maven 2 repository

Add this repository to your root pom.xml (if it has not already been defined in a parent pom):

<repository>
  <id>hippo-forge</id>
  <name>Bloomreach Forge maven 2 repository.</name>
  <url>http://maven.onehippo.com/maven2-forge/</url>
  <snapshots>
    <enabled>false</enabled>
  </snapshots>
  <releases>
    <updatePolicy>never</updatePolicy>
  </releases>
  <layout>default</layout>
</repository>

Installation in CMS/Repository

  1. Add this dependency to the pom.xml of your cms (or cms-dependencies) module:

    <dependency>
      <groupId>org.onehippo.forge</groupId>
      <artifactId>properties-addon-repository</artifactId>
      <version>7.0.0</version>
    </dependency>
  2. Rebuild your project. After startup, you should have the Properties document type available.

Installation in HST site

  1. Add this dependency to the pom.xml of your site/components module:

    <dependency>
      <groupId>org.onehippo.forge</groupId>
      <artifactId>properties-hst-client</artifactId>
      <version>7.0.0</version>
    </dependency>
  2. The properties component contains a manager object that provides an API by which to retrieve properties documents from repository. To create such a manager, add this part to the Spring configuration file (create the file if it does not exist): site/src/main/resources/META-INF/hst-assembly/overrides/propertiesManager.xml

    <bean id="org.onehippo.forge.properties.api.PropertiesManager"
        class="org.onehippo.forge.properties.impl.CachingPropertiesManagerImpl">
      <property name="defaultDocumentLocation"
                value="construction/labels"/>
      <property name="defaultDocumentName"
                value="common"/>
    </bean>

    Please see the properties-demo project on how to set up the accompanying PropertiesEventListener that invalidates that cache. You need to add something like

      <bean id="customJcrObservationEventListenerItems" class="org.springframework.beans.factory.config.ListFactoryBean">
        <property name="sourceList">
          <list>
            <bean class="org.hippoecm.hst.core.jcr.EventListenerItemImpl">
              <property name="nodeAddedEnabled" value="false" />
              <property name="nodeRemovedEnabled" value="false" />
              <property name="propertyAddedEnabled" value="false" />
              <property name="propertyChangedEnabled" value="true" />
              <property name="propertyRemovedEnabled" value="false" />
              <property name="absolutePath" value="/" />
              <property name="deep" value="true" />
              <property name="uuids">
                <null />
              </property>
              <property name="nodeTypeNames" value="properties:properties" />
              <property name="noLocal" value="false" />
              <property name="eventListener">
                <bean class="org.onehippo.forge.properties.listener.PropertiesEventListener">
                  <property name="propertiesManager" ref="org.onehippo.forge.properties.api.PropertiesManager.labels" />
                </bean>
              </property>
            </bean>
            </list>
        </property>
      </bean>

    NB: You can also provide your own custom manager. Above configuration will by default search for properties documents in the /construction/labels folder by the name of common, but the API provides ways to do more. See the PropertiesManager.java interface.

  3. Make sure you use classpath loaded beans in the web.xml of your site the following value to context parameter hst-beans-annotated-classes (note that the values are comma separated):

    <context-param>
      <param-name>hst-beans-annotated-classes</param-name>
      <param-value>
        classpath*:org/onehippo/forge/**/*.class
      </param-value>
    </context-param>

For usage in Java/JSP code, see here