-
-
Notifications
You must be signed in to change notification settings - Fork 503
Spring MVC
| Date | {date of proposal} //FIXME | Contacts | Jose García and María Arias de Reyna |
| Status | Development | Release | 3.0 |
| Resources | Resources needed | Ticket # | N/A |
| Source code | spring-mvc | ||
| Funding | GeoCat | ||
We want to stop using Jeeves and implement full Spring support. On this proporsal, we want to add Spring MVC to geoNetwork.
BaseController.
Coding Example org.fao.geonet.services.config.Get.java
To migrate to Spring MVC there are three important steps to do:
@Deprecated
public Element exec(Element params, ServiceContext context)
It is important to mark the exec function as deprecated and not remove it until we get rid of all Jeeves services.
Some services have Jeeves dependencies that needs to be used on our service. We have to autowire them or extend BaseController.java to have them autowired:
@Autowired
protected ApplicationContext context;
@Autowired
protected ServletContext servletContext;
@Autowired
private XmlCacheManager cacheManager;
@Autowired
private SchemaManager schemaManager;
Sometimes we cannot autowire directly a dependency because it is too much coupled with Jeeves engine and we need to create a special Spring dependency that supplies the same functionality:
@Autowired
private SpringSettingManager sm;
We have to implement the spring call on a new function like this:
@RequestMapping(value = "/{lang}/admin.config.list2", produces = "application/xml")
public @ResponseBody
ReturnType xml(
@PathVariable String lang,
@RequestParam(required = false, defaultValue = "false") Boolean asTree)
The request mapping shows the uri where the service is going to be placed. You can also see how to manage wildcards like the language and request parameters like the asTree boolean parameter.
If this function is going to have a json version with "@json" on its url, we can easily implement it by using the following function:
@RequestMapping(value = "/{lang}/admin.config.list@json", produces = "application/json")
public @ResponseBody
ReturnType json(
@PathVariable String lang,
@RequestParam(required = false, defaultValue = "false") Boolean asTree) {
return xml(lang, asTree);
}
For easier maintenance, it is good to share coding parts with the exec function, but this is not always possible.
- Type: Improvement
- Module: All
Not yet
- All
If you have some comments, start a discussion, raise an issue or use one of our other communication channels to talk to us.