RunnableFileSystemResource

The Runnable FileSystem Resource is just like a file system resource, with the addition that, when configured as input to a reloadable service, it will call code that you supply prior to checking whether the service needs to be refreshed.  This gives you the ability to be involved prior to a service being updated.

Configuration

There is no custom syntax available to configure this resource.  The class name is net.shibboleth.ext.spring.resource.RunnableFileSystemResource.  It has all the same methods as the standard Spring FileSystemResource, but the constructors are different, taking a second parameter with name "runnable"

The injected class "runnable" (which has to implement java.lang.Runnable) is expected to update the file if required.  It could 

  • Connect to a database to refresh the file

  • Reach across the network (using a protocol other than HTTP) to refresh the resource

  • By a script - the ScriptedRunnable is described below.

ScriptedRunnable

This class, when injected into a RunnableFileSystemResource, allows a script to be run as part of a ReloadableService refresh.   There are only two properties which can be set: "script" an EvaluableScript to be run and "customObject".

Example
1 2 3 4 5 6 7 8 <bean id="Script" class="net.shibboleth.utilities.java.support.scripting.EvaluableScript" c:_0=" var i = 22; var j = 7; var pi = i/j;"/> <bean id="Runnable" class="net.shibboleth.utilities.java.support.scripting.ScriptedRunnable" p:script-ref="Script" init-method="initialize"/> <bean id="Resource" class="net.shibboleth.ext.spring.resource.RunnableFileSystemResource" c:path="file" c:runnable-ref="Runnable"/>