jbuedel
02-09-2007, 10:03 PM
I am seeing unexpected behavior (to me anyway) where calling IConfigurableApplicationContext.Refresh on my context is not calling the methods I've registered via the destroy-method attribute. Shouldn't it?
I think I've gotten around the problem by calling IApplicationContext.Dispose before calling Refresh. But that doesn't seem right as I expect a Disposed object to be "invalid". Would someone care to comment on my solution (below) and perhaps suggest a better way?
I've got a system setup where a FileSystemWatcher detects changes in my Spring.Net config file and attempt to update the context, via this function:
private void OnSpringObjectsFileChangedHandler(object state)
{
try
{
Log.Info("Spring objects definition file changed. Refreshing the IApplicationContext.");
IApplicationContext context = ContextRegistry.GetContext();
context.Dispose();
IConfigurableApplicationContext c = (IConfigurableApplicationContext) context;
c.Refresh();
}
catch (Exception ex)
{
Log.Error("Error while refreshing the IApplicationContext.", ex);
}
}Thanks for any help!
Josh
I think I've gotten around the problem by calling IApplicationContext.Dispose before calling Refresh. But that doesn't seem right as I expect a Disposed object to be "invalid". Would someone care to comment on my solution (below) and perhaps suggest a better way?
I've got a system setup where a FileSystemWatcher detects changes in my Spring.Net config file and attempt to update the context, via this function:
private void OnSpringObjectsFileChangedHandler(object state)
{
try
{
Log.Info("Spring objects definition file changed. Refreshing the IApplicationContext.");
IApplicationContext context = ContextRegistry.GetContext();
context.Dispose();
IConfigurableApplicationContext c = (IConfigurableApplicationContext) context;
c.Refresh();
}
catch (Exception ex)
{
Log.Error("Error while refreshing the IApplicationContext.", ex);
}
}Thanks for any help!
Josh