CheckingContextListener

CheckingContextListener is intended to perform configured sanity checks at web application context initialization.

In everything it does it is intended to be very careful and safe. A ContextListener throwing an exception would prevent the whole uPortal context from coming online. That is not the intent of the Checks API – these are not checks that veto initialization of the context, rather they are advisory diagnostic checks intended to help inform a deployer of why a context might fail to complete loading or why uPortal isn't working properly.

The last thing we want to have happen here is a uPortal instance failing solely because of misconfiguration of these diagnostics.

This context listener first performs its own sanity checks on its dependencies (is Spring present? Is the Spring bean named "checks" present as expected?

Then it executes any additional checks configured as a List of ICheck instances exposed as the Spring bean named "checks".

This is configured in applicationContext.xml:

<bean id="checks" class="java.util.ArrayList">
    <constructor-arg>
        <list>
            <bean class="org.jasig.portal.tools.checks.SpringBeanCheck">
                <!-- check that a bean named personAttributeDao is present and is of type
                       IPersonAttributeDao. -->
                <constructor-arg index="0" type="java.lang.String">
                    <value>personAttributeDao</value>
                </constructor-arg>
                <constructor-arg index="1" type="java.lang.String">
                    <value>org.jasig.portal.services.persondir.support.IPersonAttributeDao</value>
                </constructor-arg>
            </bean>
            <bean class="org.jasig.portal.tools.checks.XalanVersionCheck">
                <constructor-arg index="0" type="java.lang.String">
                    <value>Xalan Java 2.6.0</value>
                </constructor-arg>
            </bean>
        </list>
    </constructor-arg>
</bean>

applicationContext.xml must be declared to be among the bean files we're going to use, in beanRefFactory.xml.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<!--
 | This spring config is read by the SingletonBeanFactoryLocator used by
 | o.j.p.spring.PortalApplicationContextFacade class.
 |
 | The PortalApplicationContextFacade class provides a static way to get
 | a reference Spring application contexts configured in this file.
 +-->
<beans>
	<!--
	 | The default application context for uPortal. Other spring configurations
	 | should be added to the list if they have beans that need to be avalable
	 | in the uPortal application context.
	 +-->
	<bean id="org.jasig.portal" lazy-init="true"
		class="org.springframework.context.support.ClassPathXmlApplicationContext">
		<constructor-arg>
			<list>
				<value>properties/personDirectory.xml</value>
				<value>properties/applicationContext.xml</value>
			</list>
		</constructor-arg>
	</bean>
</beans>