WSResource[] resources = m_registrationManager.find( null );
// loop through all resources found in the manager, stop if our thread has been told to shutdown
for ( int i = 0; ( i < resources.length ) && m_started; i++ )
{
final WSResource resource = resources[i];
// only examine termination time if we have not seen this resource before or we have and it supports WS-RL TerminationTime
if ( !m_noTerminationTimeSupport.containsKey( resource.getId( ) ) )
{
// tell the thread pool to run code that examines the current resource and destroys it if it is expired
m_reaperThreadPool.execute( new Runnable( )
{
public void run( )
{
TerminationTimeDocument termTimeXmlBean = null;
try
{
SOAPElement[] soapEle =
resource.getResourceProperty( ResourceLifetime11Constants.RESOURCE_PROP_QNAME_TERMINATION_TIME );
termTimeXmlBean = (TerminationTimeDocument) XmlBeansUtils.toXmlObject( soapEle[0] );
}
catch ( Throwable t )
{
m_noTerminationTimeSupport.put( resource.getId( ),
resource.getId( ) );
}
if ( ( termTimeXmlBean != null )
&& !termTimeXmlBean.isNilTerminationTime( )
&& termTimeXmlBean.getTerminationTime( ).before( Calendar.getInstance( ) ) )
{
try
{
resource.destroy( );
}
catch ( Exception destroyException )
{
// TODO: what should we do if we failed to destroy an expired resource?
//destroyException.printStackTrace( );