}
public Object invoke (Invocation mi)
throws Exception
{
EnterpriseContext ctx = (EnterpriseContext)mi.getEnterpriseContext ();
try
{
// Invoke through interceptors
return getNext ().invoke (mi);
}
catch (RemoteException e)
{
ctx = null;
throw e;
}
catch (RuntimeException e)
{
ctx = null;
throw e;
}
catch (Error e)
{
ctx = null;
throw e;
}
finally
{
if ( (ctx != null) && (ctx.getId () != null) )
// Still a valid instance and instance not removed
//
{
// Everything went ok (at least no J2EE problem) and the instance will most probably be called
// many more times. Consequently, we need to synchronize the state of our bean instance with
// our persistant store (which will forward this to its HASessionState implementation) for clustering
// behaviour.
//
if(isModified == null)
{
synchronizeState (ctx);
}
else
{
Boolean modified = (Boolean) isModified.invoke (ctx.getInstance (), new Object[0]);
if (modified.booleanValue ())
synchronizeState (ctx);
}
}
}