App Status integrates nicely with Spring. Instead of using AppStatusStatic.getInstance() and status-check.properties, you can use Spring to create and inject the main AppStatus object.
<bean id="appStatus" class="net.sf.appstatus.core.AppStatus"
init-method="init" scope="singleton">
<property name="objectInstanciationListener" ref="appStatusInstanciation" />
<property name="batchManager" ref="batchManager" />
<property name="serviceManager" ref="serviceManager" />
<property name="checkers">
<list>
<ref bean="statusCheck1" />
<ref bean="statusCheck2" />
</list>
</property>
<property name="propertyProviders">
<list>
<ref bean="property1" />
<ref bean="property2" />
</list>
</property>
<property name="configuration">
<props>
<prop key="propKey">propValue</prop>
</props>
</property>
</bean>
<bean id="appStatusInstanciation"
class="net.sf.appstatus.support.spring.SpringObjectInstantiationListener"
scope="singleton" />
<bean id="batchManager" class="net.sf.appstatus.batch.InProcessBatchManager"
scope="singleton"></bean>
<bean id="serviceManager" class="net.sf.appstatus.services.InProcessServiceManager"
scope="singleton">
<!-- Configuration -->
<property name="configuration">
<props>
<prop key="services.log.format">spring:${correlationId}|${group}|${name}|${responseTime}|${cache}|${status}|${statusMessage}
</prop>
<prop key="services.useThreadLocal">true</prop>
</props>
</property>
</bean>
<bean id="statusCheck1" class="your.package.StatusCheck1" scope="prototype"/>
<bean id="statusCheck2" class="your.package.StatusCheck2" scope="prototype"/>
<bean id="property1" class="your.package.PropertyProvider1" scope="prototype"/>
<bean id="property2" class="your.package.PropertyProvider2" scope="prototype"/>
When using appstatus-web, you have to tell AppStatus which bean is the entry point :
<servlet>
<servlet-name>status</servlet-name>
<servlet-class>net.sf.appstatus.web.StatusServlet</servlet-class>
<init-param>
<param-name>bean</param-name>
<param-value>appStatus</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
AppStatus cache wrapper automatically flag the current service monitor as using cache if there is a cache hit
<!-- Any spring cache : ehcache as example --> <bean id="ehcacheCacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager" p:cache-manager-ref="ehcache" /> <bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" p:config-location="classpath:/ehcache.xml" /> <!-- appstatus cache wrapper --> <bean id="cacheManager" class="net.sf.appstatus.support.spring.cache.AppStatusCacheManager" p:cache-manager-ref="ehcacheCacheManager" /> <cache:annotation-driven proxy-target-class="true" />
Instead of using explicitely service monitors in your code, you can use AOP to automatically perform monitor calls.
<bean id="appStatusInterceptor" class="net.sf.appstatus.support.aop.AppStatusServiceInterceptor" scope="singleton"> <property name="serviceManager" ref="serviceManager" /> </bean> <aop:config> <aop:advisor id="serviceCallAdvisor" advice-ref="appStatusInterceptor" pointcut="execution(public * net.sf.appstatus.demo.batch.ServiceSample.getRefsAOP(..))" /> </aop:config>