Example usage for org.springframework.web.servlet.handler BeanNameUrlHandlerMapping getHandlerMap

List of usage examples for org.springframework.web.servlet.handler BeanNameUrlHandlerMapping getHandlerMap

Introduction

In this page you can find the example usage for org.springframework.web.servlet.handler BeanNameUrlHandlerMapping getHandlerMap.

Prototype

public final Map<String, Object> getHandlerMap() 

Source Link

Document

Return the registered handlers as an unmodifiable Map, with the registered path as key and the handler object (or handler bean name in case of a lazy-init handler) as value.

Usage

From source file:org.trpr.platform.servicefw.impl.spring.web.HomeController.java

/**
 * /*from  ww  w.j a v a  2 s.  c o m*/
 */
private void findResources() {
    Map<String, Object> handlerMap = new HashMap<String, Object>();

    DefaultAnnotationHandlerMapping annotationMapping = new DefaultAnnotationHandlerMapping();
    annotationMapping.setApplicationContext(applicationContext);
    annotationMapping.initApplicationContext();
    handlerMap.putAll(annotationMapping.getHandlerMap());

    BeanNameUrlHandlerMapping beanMapping = new BeanNameUrlHandlerMapping();
    beanMapping.setApplicationContext(applicationContext);
    beanMapping.initApplicationContext();
    handlerMap.putAll(beanMapping.getHandlerMap());

    this.urls = findUniqueUrls(handlerMap.keySet());
    this.defaultResources = findMethods(handlerMap, this.urls);
    this.jsonResources = new ArrayList<ResourceInfo>();
    for (Iterator<ResourceInfo> iterator = this.defaultResources.iterator(); iterator.hasNext();) {
        ResourceInfo info = (ResourceInfo) iterator.next();
        if (info.getUrl().endsWith(".json")) {
            iterator.remove();
            this.jsonResources.add(info);
        }
    }

}

From source file:org.springframework.batch.admin.web.util.HomeController.java

private void findResources() {
    Map<String, Object> handlerMap = new HashMap<String, Object>();

    DefaultAnnotationHandlerMapping annotationMapping = new DefaultAnnotationHandlerMapping();
    annotationMapping.setApplicationContext(applicationContext);
    annotationMapping.initApplicationContext();
    handlerMap.putAll(annotationMapping.getHandlerMap());

    BeanNameUrlHandlerMapping beanMapping = new BeanNameUrlHandlerMapping();
    beanMapping.setApplicationContext(applicationContext);
    beanMapping.initApplicationContext();
    handlerMap.putAll(beanMapping.getHandlerMap());

    this.urls = findUniqueUrls(handlerMap.keySet());
    this.defaultResources = findMethods(handlerMap, this.urls);
    this.jsonResources = new ArrayList<ResourceInfo>();
    for (Iterator<ResourceInfo> iterator = this.defaultResources.iterator(); iterator.hasNext();) {
        ResourceInfo info = (ResourceInfo) iterator.next();
        if (info.getUrl().endsWith(".json")) {
            iterator.remove();/*from w w w.  j  av a  2 s  .  co m*/
            this.jsonResources.add(info);
        }
    }

}