How to install the properties component
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>Hippo 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
-
Add this dependency to the pom.xml of your cms module:
<dependency> <groupId>org.onehippo.forge.properties</groupId> <artifactId>properties-addon-repository</artifactId> <!-- NB version is managed from parent org.onehippo.cms7:hippo-cms7-release:7.7.0 and up --> <version>2.07.03</version> </dependency>When using version 2.04.00 or below:
<dependency> <groupId>org.onehippo.forge</groupId> <artifactId>properties-addon-repository</artifactId> <version>2.04.00</version> </dependency>
-
Rebuild your project. After startup, you should have the availability of a Properties document type.
Installation in HST site
-
Add this dependency to the pom.xml of your site module:
<dependency> <groupId>org.onehippo.forge.properties</groupId> <artifactId>properties-hst-client</artifactId> <!-- NB version is managed from parent org.onehippo.cms7:hippo-cms7-release:7.7.0 and up --> <version>2.07.03</version> </dependency>When using version 2.04.00:
<dependency> <groupId>org.onehippo.forge</groupId> <artifactId>properties-hst-client</artifactId> <version>2.04.00</version> </dependency>
-
When using version 2.02.00 or lower, also include the artifact properties-hst-api:
<dependency> <groupId>org.onehippo.forge</groupId> <artifactId>properties-hst-api</artifactId> <version>2.02.00</version> </dependency>
-
In the web.xml, make sure HstContainerServlet has uncommented init-params clientComponentManagerClass and clientComponentManagerConfigurations.
-
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 site/src/main/resources/META-INF/client-assembly/base.xml:
<bean id="org.onehippo.forge.properties.api.PropertiesManager" class="org.onehippo.forge.properties.impl.PropertiesManagerImpl"> <property name="defaultDocumentLocation" value="construction/labels"/> <property name="defaultDocumentName" value="common"/> </bean>You may want to set up caching by using org.onehippo.forge.properties.impl.CachingPropertiesManagerImpl. Please see the properties-demo project on how to set up the accompanying PropertiesEventListener that invalidates that cache.
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.
-
A) If you use classpath loaded beans (available since HST 2.20), add 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/properties/annotated/**/*.class </param-value> </context-param>B) If you use the xml file to define your beans, add these beans in the HST file site/src/main/webapp/WEB-INF/beans-annotated-classes.xml
<hst-content-beans> <annotated-class> org.onehippo.forge.properties.annotated.Property </annotated-class> <annotated-class> org.onehippo.forge.properties.annotated.Properties </annotated-class> </hst-content-beans>
For usage in Java/JSP code, see here