Spring Framework SimpleUrlHandlerMapping - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework SimpleUrlHandlerMapping class.

This code example shows how to use the following methods:setUrlMap, setOrder
		} 
 
		Map<String, HttpRequestHandler> urlMap = new HashMap<String, HttpRequestHandler>(); 
		urlMap.put("/**", handler); 
 
		SimpleUrlHandlerMapping handlerMapping = new SimpleUrlHandlerMapping(); 
		handlerMapping.setOrder(Integer.MAX_VALUE); 
		handlerMapping.setUrlMap(urlMap); 
		return handlerMapping; 
	} 
 
} 
7
CodeRank
This code example shows how to use the following methods:getUrlMap, getUrlPathHelper
 
		//SPR-12403 
		assertEquals(1, this.webSocketHandler.getProtocolHandlers().size());
 
		hm = (SimpleUrlHandlerMapping) this.endpointRegistry.getHandlerMapping();
		assertEquals(2, hm.getUrlMap().size());
		assertNotNull(hm.getUrlMap().get("/stompOverWebSocket"));
		assertNotNull(hm.getUrlMap().get("/stompOverSockJS/**"));
		assertSame(pathHelper, hm.getUrlPathHelper());
	} 
 
} 
6
CodeRank
This code example shows how to use the following methods:getUrlMap, getOrder
	@Test 
	public void enable() throws Exception { 
		configurer.enable(); 
		SimpleUrlHandlerMapping getHandlerMapping = getHandlerMapping(); 
		SimpleUrlHandlerMapping handlerMapping = getHandlerMapping; 
		DefaultServletHttpRequestHandler handler = (DefaultServletHttpRequestHandler) handlerMapping.getUrlMap().get("/**"); 
 
		assertNotNull(handler); 
		assertEquals(Integer.MAX_VALUE, handlerMapping.getOrder()); 
 
		handler.handleRequest(new MockHttpServletRequest(), response); 
 
		String expected = "default"; 
		assertEquals("The ServletContext was not called with the default servlet name", expected, servletContext.url); 
		assertEquals("The request was not forwarded", expected, response.getForwardedUrl()); 
	} 
 
	@Test 
	public void enableWithServletName() throws Exception { 
		configurer.enable("defaultServlet"); 
6
CodeRank
This code example shows how to use the following methods:getOrder
 
	@Test 
	public void order() { 
		this.registry.addViewController("/path"); 
		SimpleUrlHandlerMapping handlerMapping = getHandlerMapping(); 
		assertEquals(1, handlerMapping.getOrder()); 
 
		this.registry.setOrder(2); 
		handlerMapping = getHandlerMapping(); 
		assertEquals(2, handlerMapping.getOrder()); 
	} 
 
	private ParameterizableViewController getController(String path) { 
		Map<String, ?> urlMap = getHandlerMapping().getUrlMap(); 
		ParameterizableViewController controller = (ParameterizableViewController) urlMap.get(path); 
		assertNotNull(controller); 
		return controller; 
	} 
 
	private SimpleUrlHandlerMapping getHandlerMapping() { 
5
CodeRank
This code example shows how to use the following methods:getUrlMap
		assertThat(transformers.get(2), Matchers.sameInstance(cssLinkTransformer)); 
	} 
 
	private ResourceHttpRequestHandler getHandler(String pathPattern) { 
		SimpleUrlHandlerMapping handlerMapping = (SimpleUrlHandlerMapping) this.registry.getHandlerMapping(); 
		return (ResourceHttpRequestHandler) handlerMapping.getUrlMap().get(pathPattern); 
	} 
 
} 
5
CodeRank
This code example shows how to use the following methods:
 * User: jfischer 
 * Date: 9/26/11 
 * Time: 3:06 PM 
 * To change this template use File | Settings | File Templates. 
 */ 
public class BroadleafCmsSimpleUrlHandlerMapping extends SimpleUrlHandlerMapping { 
 
    @Resource(name="blConfiguration") 
    protected RuntimeEnvironmentPropertiesConfigurer configurer; 
 
    @Override 
    public void setMappings(Properties mappings) { 
        Properties clone = new Properties(); 
        for (Object propertyName: mappings.keySet()) { 
            String newName = configurer.getStringValueResolver().resolveStringValue(propertyName.toString()); 
            clone.put(newName, mappings.get(propertyName)); 
        } 
        super.setMappings(clone); 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:
 */ 
public class OWSHandlerMapping extends SimpleUrlHandlerMapping { 
 
    Catalog catalog; 
     
    public OWSHandlerMapping(Catalog catalog) { 
        this.catalog = catalog; 
    } 
     
    @Override 
    protected Object lookupHandler(String urlPath, HttpServletRequest request) throws Exception { 
        Object h = super.lookupHandler(urlPath, request); 
        if (h == null /*&& AdvancedDispatch.isSet(getApplicationContext())*/) { 
            //check for a workspace being specified in the request and strip it off 
            int i = urlPath.startsWith("/") ? 1 : 0; 
            int j = urlPath.indexOf("/", i); 
            if (j > i) { 
                String first = urlPath.substring(i, j); 
                String last = urlPath.substring(j); 
                 
5
CodeRank
This code example shows how to use the following methods:setUrlMap
        SockJsService sockJsService = new DefaultSockJsService(taskScheduler());
 
        Map<String, Object> urlMap = new HashMap<String, Object>();
        urlMap.put("/game/websocket/**", new SockJsHttpRequestHandler(sockJsService, gameHandler));
 
        SimpleUrlHandlerMapping hm = new SimpleUrlHandlerMapping();
        hm.setUrlMap(urlMap);
        return hm;
    } 
 
    @Bean 
    public ThreadPoolTaskScheduler taskScheduler() {
      ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
      taskScheduler.setThreadNamePrefix("SockJS-");
      return taskScheduler;
    } 
 
} 
4
CodeRank
This code example shows how to use the following methods:
 * 
 * @author Scott Battaglia 
 * @since 3.1 
 * 
 */ 
public final class OpenIdPostUrlHandlerMapping extends SimpleUrlHandlerMapping { 
 
    @Override 
    protected Object lookupHandler(final String urlPath, final HttpServletRequest request) throws Exception { 
 
        if ("POST".equals(request.getMethod()) 
                && ( 
                        "check_authentication".equals(request.getParameter("openid.mode")) 
                        || "associate".equals(request.getParameter("openid.mode")) 
                        ) 
                ) { 
            return super.lookupHandler(urlPath, request); 
        } 
 
        return null; 
4
CodeRank
See Code Examples for Spring Framework SimpleUrlHandlerMapping Methods: