OpenReports - Flexible configuration and deployment using Spring
January 31st, 2008
OpenReports 3.0 uses the Spring Framework to configure and wire together its components. For most users there is no need to modify this configuration because the most important properties can be modified in the openreports.properties file, but there are some cases where it can be useful to modify the Spring configuration itself.
The Spring configuration file, applicationContext.xml, is located in the WebRoot/WEB-INF directory of the OpenReports distribution. You will need to rebuild the OpenReports war file after making any changes to this file.
1) Moving openreports.properties outside the war file
The applicationContext.xml file can be modified to look for the openreports.properties file outside of the war file. This can be helpful if you would like to use one war file in multiple environments. In order to do this, you must modify the PropertyPlaceholderConfigurer
<bean id=”environment”
class=”org.springframework.beans.factory.config.PropertyPlaceholderConfigurer” lazy-init=”false”> <property name=”ignoreResourceNotFound” value=”true” />
<property name=”locations”>
<list>
<value>classpath:openreports.properties</value>
</list>
</property>
</bean>
The important part is the location, classpath:openreports.properties. This tells Spring to look for openreports.properties in the classpath. To look for the openreports.properties on the file system, change classpath to file.
<bean id=”environment”
class=”org.springframework.beans.factory.config.PropertyPlaceholderConfigurer” lazy-init=”false”>
<property name=”ignoreResourceNotFound” value=”true” />
<property name=”locations”>
<list>
<value>file:///usr/share/openreports/openreports.properties</value>
</list>
</property>
</bean>
2) Mail Session configuration
By default, the mail session used to send scheduled reports is configured from the Settings page of the OpenReports Administration UI. If you need a more advanced mail session configuration, for authentication or other purposes, you can override this mail session with one configured through Spring. Add the following xml to the applicationContext.xml file to create a mail session that will look for the mail.user, mail.password, and mail.smtp.host properties in the openreports.properties file.
<bean id=”mailAuthenticator” class=”org.efs.openreports.util.SMTPAuthenticator”>
<constructor-arg index=”0″ value=”${mail.user}” />
<constructor-arg index=”1″ value=”${mail.password}” />
</bean>
<bean id=”mailSession” class=”javax.mail.Session” factory-method=”getInstance”>
<constructor-arg index=”0″>
<props>
<prop key=”mail.smtp.host”>${mail.smtp.host}</prop>
</props>
</constructor-arg>
<constructor-arg index=”1″ ref=”mailAuthenticator” />
</bean>
3) JNDI DataSources
The applicationContext.xml file can also be used to configure OpenReports to use JNDI DataSources. Just replace the hibernateDataSource and the quartDataSource beans with beans defined like the example below:
<bean id=”hibernateDataSource” class=”org.springframework.jndi.JndiObjectFactoryBean”>
<property name=”jndiName” value=”java:comp/env/jdbc/myHibernateDs”/>
</bean>
Entry Filed under: All
Leave a Comment
Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>
Trackback this post | Subscribe to the comments via RSS Feed