如何在 Spring.Net 中重新加载上下文
我只是想知道答案:
using Spring.Context.Support;
...
var context = ContextRegistry.GetContext();
var myObject = (MyObject)context.GetObject("MyObject");
// Making changes to the config file...
???
// Is there a way to reload context
// so I can have my newly updated object
// without restarting the whole application?
var myObjectWithChanges = (MyObject)context.GetObject("MyObject");
I would simply like to know the answer:
using Spring.Context.Support;
...
var context = ContextRegistry.GetContext();
var myObject = (MyObject)context.GetObject("MyObject");
// Making changes to the config file...
???
// Is there a way to reload context
// so I can have my newly updated object
// without restarting the whole application?
var myObjectWithChanges = (MyObject)context.GetObject("MyObject");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
此方法从持久表示(例如 xml 配置)中重新加载所有对象定义。
刷新方法不是
IApplicationContext
接口的一部分,该接口是代码片段中context
变量的推断类型。然而。它是 AbstractApplicationContext 的一部分,大多数 Spring.net 应用程序上下文均源自该上下文。You can use
This reloads all object definitions from their persistent representation (e.g. xml configuration).
The refresh method is not part of the
IApplicationContext
interface, which is the inferred type of thecontext
variable in your snippet. However. it is part ofAbstractApplicationContext
, from which most Spring.net application contexts derive.