Skip to content
Jeroen Ticheler edited this page Jan 28, 2014 · 13 revisions
Date 27/1/2014 Contacts Jose García and María Arias de Reyna
Status Development Release 3.0.0
Resources Resources needed Ticket # #366
Source code spring-mvc
Funding GeoCat

Overview

We are phasing out Jeeves and moving to Spring MVC. In this proporsal, we want to add Spring MVC to GeoNetwork. This was discussed for the 3.0 roadmap.

  • Easier to develop, also for new developers. Widely used framework.
  • Easier to support i18n (internationalization)
  • Make it easier to develop plugins (make GeoNetwork more modular)
  • Easier to support multiple output formats (json, XML, PDF, HTML etcetera)
  • Good integration with Spring JPA and Spring Security frameworks already used in GeoNetwork

Technical Details:

How it works

Spring now handles all requests. If there is a Spring service implemented for the request URI, Spring will return this service. If there is no Spring service, then it will fall back to Jeeves, using the GenericController.

To finish this integration we just have to migrate all services to Spring MVC. But, in the meantime, we can use this GenericController so we don't have to migrate all services at once.

There is also a new interceptor class to define the language internationalization named UrlLocaleChangeInterceptor. This class reads the URL and stores the language defined in the session. This means that internationalization is also migrated to Spring and can be used easily on all Spring-i18n related parts, like JSP.

To migrate to Spring MVC there are three important steps to do:

Deprecate exec

    @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.

Autowire dependencies

Some services have Jeeves dependencies that need to be used in 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 a dependency directly because it is too tightly coupled with the Jeeves engine and we need to create a special Spring dependency that supplies the same functionality:

    @Autowired
    private SpringSettingManager sm;

(re)Implement service

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.

Proposal Type:

  • Type: Improvement
  • Module: All

Voting History

Not yet

Participants

  • All
Clone this wiki locally