以下是grails中控制器单元测试类的setUp方法中的一段代码。我想了解以下设置代码的用途。该应用程序有一个TimeService,负责执行时间操作。我感谢任何帮助!了解遗留的grails代码?
def customPropertyEditor = new CustomPropertyEditorRegistrar(timeService: new TimeService())
def map = (Map<String, PropertyEditorRegistrar>) servletContext.getAttribute(GrailsDataBinder.PROPERTY_EDITOR_REGISTRARS)
if (!map) servletContext.setAttribute(GrailsDataBinder.PROPERTY_EDITOR_REGISTRARS, [customPropertyEditor: customPropertyEditor])
else map.put('customPropertyEditor', customPropertyEditor)