当前位置: 首页>>代码示例>>Java>>正文


Java HttpRequestHandler类代码示例

本文整理汇总了Java中org.springframework.web.HttpRequestHandler的典型用法代码示例。如果您正苦于以下问题:Java HttpRequestHandler类的具体用法?Java HttpRequestHandler怎么用?Java HttpRequestHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


HttpRequestHandler类属于org.springframework.web包,在下文中一共展示了HttpRequestHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getHandlerMapping

import org.springframework.web.HttpRequestHandler; //导入依赖的package包/类
/**
 * Return a {@link HandlerMapping} with mapped {@link HttpRequestHandler}s.
 */
public AbstractHandlerMapping getHandlerMapping() {
	Map<String, Object> urlMap = new LinkedHashMap<String, Object>();
	for (ServletWebSocketHandlerRegistration registration : this.registrations) {
		MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();
		for (HttpRequestHandler httpHandler : mappings.keySet()) {
			for (String pattern : mappings.get(httpHandler)) {
				urlMap.put(pattern, httpHandler);
			}
		}
	}
	WebSocketHandlerMapping hm = new WebSocketHandlerMapping();
	hm.setUrlMap(urlMap);
	hm.setOrder(this.order);
	if (this.urlPathHelper != null) {
		hm.setUrlPathHelper(this.urlPathHelper);
	}
	return hm;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:22,代码来源:ServletWebSocketHandlerRegistry.java

示例2: getHandlerMapping

import org.springframework.web.HttpRequestHandler; //导入依赖的package包/类
/**
 * Return a handler mapping with the mapped ViewControllers; or {@code null}
 * in case of no registrations.
 */
public AbstractHandlerMapping getHandlerMapping() {
	Map<String, Object> urlMap = new LinkedHashMap<String, Object>();
	for (WebMvcStompWebSocketEndpointRegistration registration : this.registrations) {
		MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();
		for (HttpRequestHandler httpHandler : mappings.keySet()) {
			for (String pattern : mappings.get(httpHandler)) {
				urlMap.put(pattern, httpHandler);
			}
		}
	}
	WebSocketHandlerMapping hm = new WebSocketHandlerMapping();
	hm.setUrlMap(urlMap);
	hm.setOrder(this.order);
	if (this.urlPathHelper != null) {
		hm.setUrlPathHelper(this.urlPathHelper);
	}
	return hm;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:23,代码来源:WebMvcStompEndpointRegistry.java

示例3: handshakeHandlerAndInterceptor

import org.springframework.web.HttpRequestHandler; //导入依赖的package包/类
@Test
public void handshakeHandlerAndInterceptor() {
	WebMvcStompWebSocketEndpointRegistration registration =
			new WebMvcStompWebSocketEndpointRegistration(new String[] {"/foo"}, this.handler, this.scheduler);

	DefaultHandshakeHandler handshakeHandler = new DefaultHandshakeHandler();
	HttpSessionHandshakeInterceptor interceptor = new HttpSessionHandshakeInterceptor();

	registration.setHandshakeHandler(handshakeHandler).addInterceptors(interceptor);

	MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();
	assertEquals(1, mappings.size());

	Map.Entry<HttpRequestHandler, List<String>> entry = mappings.entrySet().iterator().next();
	assertEquals(Arrays.asList("/foo"), entry.getValue());

	WebSocketHttpRequestHandler requestHandler = (WebSocketHttpRequestHandler) entry.getKey();
	assertNotNull(requestHandler.getWebSocketHandler());
	assertSame(handshakeHandler, requestHandler.getHandshakeHandler());
	assertEquals(2, requestHandler.getHandshakeInterceptors().size());
	assertEquals(interceptor, requestHandler.getHandshakeInterceptors().get(0));
	assertEquals(OriginHandshakeInterceptor.class, requestHandler.getHandshakeInterceptors().get(1).getClass());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:WebMvcStompWebSocketEndpointRegistrationTests.java

示例4: handshakeHandlerAndInterceptorWithAllowedOrigins

import org.springframework.web.HttpRequestHandler; //导入依赖的package包/类
@Test
public void handshakeHandlerAndInterceptorWithAllowedOrigins() {
	WebMvcStompWebSocketEndpointRegistration registration =
			new WebMvcStompWebSocketEndpointRegistration(new String[] {"/foo"}, this.handler, this.scheduler);

	DefaultHandshakeHandler handshakeHandler = new DefaultHandshakeHandler();
	HttpSessionHandshakeInterceptor interceptor = new HttpSessionHandshakeInterceptor();
	String origin = "http://mydomain.com";
	registration.setHandshakeHandler(handshakeHandler).addInterceptors(interceptor).setAllowedOrigins(origin);

	MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();
	assertEquals(1, mappings.size());

	Map.Entry<HttpRequestHandler, List<String>> entry = mappings.entrySet().iterator().next();
	assertEquals(Arrays.asList("/foo"), entry.getValue());

	WebSocketHttpRequestHandler requestHandler = (WebSocketHttpRequestHandler) entry.getKey();
	assertNotNull(requestHandler.getWebSocketHandler());
	assertSame(handshakeHandler, requestHandler.getHandshakeHandler());
	assertEquals(2, requestHandler.getHandshakeInterceptors().size());
	assertEquals(interceptor, requestHandler.getHandshakeInterceptors().get(0));
	assertEquals(OriginHandshakeInterceptor.class, requestHandler.getHandshakeInterceptors().get(1).getClass());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:24,代码来源:WebMvcStompWebSocketEndpointRegistrationTests.java

示例5: setUp

import org.springframework.web.HttpRequestHandler; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    GregorianCalendar t = new GregorianCalendar(2012, Calendar.NOVEMBER, 20, 3, 47, 0);
    t.setTimeZone(TimeZone.getTimeZone("GMT"));
    lastModified = t.getTimeInMillis();

    mockResourceDirectory = mock(Resource.class);
    mockResource = mock(Resource.class);

    when(mockResource.getFilename()).thenReturn("foo.png");
    when(mockResource.getInputStream()).thenReturn(new ByteArrayInputStream("foo bar baz".getBytes()));
    when(mockResource.lastModified()).thenReturn(lastModified);
    when(mockResource.isReadable()).thenReturn(true);
    when(mockResource.exists()).thenReturn(true);

    when(mockResourceDirectory.getFilename()).thenReturn("/resources");
    when(mockResourceDirectory.createRelative("/foo.png")).thenReturn(mockResource);

    mockAlternateResourceHandler = mock(HttpRequestHandler.class);

    handler = new ResourceHttpRequestHandler();
    handler.setLocations(Collections.singletonList(mockResourceDirectory));
    handler.setServletContext(new MockServletContext());
    handler.setAlternateResourceHttpRequestHandler(mockAlternateResourceHandler);
    handler.afterPropertiesSet();
}
 
开发者ID:KRMAssociatesInc,项目名称:eHMP,代码行数:27,代码来源:ResourceHttpRequestHandlerTests.java

示例6: getHandlerMapping

import org.springframework.web.HttpRequestHandler; //导入依赖的package包/类
/**
 * Return a handler mapping with the mapped ViewControllers; or {@code null} in case
 * of no registrations.
 */
public AbstractHandlerMapping getHandlerMapping() {
	Map<String, Object> urlMap = new LinkedHashMap<>();
	for (WebMvcWampWebSocketEndpointRegistration registration : this.registrations) {
		MultiValueMap<HttpRequestHandler, String> mappings = registration
				.getMappings();
		for (HttpRequestHandler httpHandler : mappings.keySet()) {
			for (String pattern : mappings.get(httpHandler)) {
				urlMap.put(pattern, httpHandler);
			}
		}
	}
	SimpleUrlHandlerMapping hm = new SimpleUrlHandlerMapping();
	hm.setUrlMap(urlMap);
	hm.setOrder(this.order);
	if (this.urlPathHelper != null) {
		hm.setUrlPathHelper(this.urlPathHelper);
	}
	return hm;
}
 
开发者ID:ralscha,项目名称:wampspring,代码行数:24,代码来源:WebMvcWampEndpointRegistry.java

示例7: getHandlerMapping

import org.springframework.web.HttpRequestHandler; //导入依赖的package包/类
/**
 * Return a handler mapping with the mapped resource handlers; or {@code null} in case of no registrations.
 */
protected AbstractHandlerMapping getHandlerMapping() {
	if (registrations.isEmpty()) {
		return null;
	}

	Map<String, HttpRequestHandler> urlMap = new LinkedHashMap<String, HttpRequestHandler>();
	for (ResourceHandlerRegistration registration : registrations) {
		for (String pathPattern : registration.getPathPatterns()) {
			ResourceHttpRequestHandler requestHandler = registration.getRequestHandler();
			requestHandler.setServletContext(servletContext);
			requestHandler.setApplicationContext(applicationContext);
			urlMap.put(pathPattern, requestHandler);
		}
	}

	SimpleUrlHandlerMapping handlerMapping = new SimpleUrlHandlerMapping();
	handlerMapping.setOrder(order);
	handlerMapping.setUrlMap(urlMap);
	return handlerMapping;
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:24,代码来源:ResourceHandlerRegistry.java

示例8: createHandlerFromBean

import org.springframework.web.HttpRequestHandler; //导入依赖的package包/类
@SuppressWarnings("nls")
@Override
protected HttpRequestHandler createHandlerFromBean(Extension extension, Object handlerBean)
{
	RemoteInterceptor interceptor = interceptorProvider.get();
	Class<?> serviceInterface = tracker.getClassForName(extension, extension.getParameter("class").valueAsString());
	interceptor.setServiceInterface(serviceInterface);
	interceptor.setService(handlerBean);
	interceptor.setEnableRequestCapturing(tracker.isParamTrue(extension, "enableRequestCapturing", false));
	interceptor.setBeanClassLoader(handlerBean.getClass().getClassLoader());
	interceptor.afterPropertiesSet();
	return interceptor;
}
 
开发者ID:equella,项目名称:Equella,代码行数:14,代码来源:InvokerHandler.java

示例9: service

import org.springframework.web.HttpRequestHandler; //导入依赖的package包/类
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException,
	IOException
{
	Map<String, Extension> locMappings = getMappings();
	String pathInfo = request.getPathInfo();
	if( pathInfo == null )
	{
		pathInfo = request.getServletPath();
	}
	Extension extension = locMappings.get(pathInfo);
	HttpRequestHandler handler;
	if( extension != null )
	{
		handler = handlerMappings.get(extension);
		if( handler == null )
		{
			synchronized( extension )
			{
				handler = handlerMappings.get(extension);
				if( handler == null )
				{
					handler = createHandler(extension);
					handlerMappings.put(extension, handler);
				}
			}
		}
		handler.handleRequest(request, response);
		return;
	}
	response.sendError(404);
}
 
开发者ID:equella,项目名称:Equella,代码行数:33,代码来源:AbstractRemoteHandler.java

示例10: createHandler

import org.springframework.web.HttpRequestHandler; //导入依赖的package包/类
protected HttpRequestHandler createHandler(Extension extension)
{
	T handlerBean = tracker.getBeanByExtension(extension); // NOSONAR
	if( handlerBean instanceof HttpRequestHandler )
	{
		return (HttpRequestHandler) handlerBean;
	}
	return createHandlerFromBean(extension, handlerBean);
}
 
开发者ID:equella,项目名称:Equella,代码行数:10,代码来源:AbstractRemoteHandler.java

示例11: handle

import org.springframework.web.HttpRequestHandler; //导入依赖的package包/类
@Override
public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler)
		throws Exception {

	((HttpRequestHandler) handler).handleRequest(request, response);
	return null;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:HttpRequestHandlerAdapter.java

示例12: getHandlerMapping

import org.springframework.web.HttpRequestHandler; //导入依赖的package包/类
/**
 * Return a handler mapping instance ordered at {@link Integer#MAX_VALUE} containing the
 * {@link DefaultServletHttpRequestHandler} instance mapped to {@code "/**"}; or {@code null} if
 * default servlet handling was not been enabled.
 */
protected AbstractHandlerMapping getHandlerMapping() {
	if (handler == null) {
		return null;
	}

	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;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:19,代码来源:DefaultServletHandlerConfigurer.java

示例13: getHandlerMapping

import org.springframework.web.HttpRequestHandler; //导入依赖的package包/类
/**
 * Return a handler mapping with the mapped resource handlers; or {@code null} in case of no registrations.
 */
protected AbstractHandlerMapping getHandlerMapping() {
	if (registrations.isEmpty()) {
		return null;
	}

	Map<String, HttpRequestHandler> urlMap = new LinkedHashMap<String, HttpRequestHandler>();
	for (ResourceHandlerRegistration registration : this.registrations) {
		for (String pathPattern : registration.getPathPatterns()) {
			ResourceHttpRequestHandler handler = registration.getRequestHandler();
			handler.setServletContext(this.servletContext);
			handler.setApplicationContext(this.appContext);
			try {
				handler.afterPropertiesSet();
			}
			catch (Exception e) {
				throw new BeanInitializationException("Failed to init ResourceHttpRequestHandler", e);
			}
			urlMap.put(pathPattern, handler);
		}
	}

	SimpleUrlHandlerMapping handlerMapping = new SimpleUrlHandlerMapping();
	handlerMapping.setOrder(order);
	handlerMapping.setUrlMap(urlMap);
	return handlerMapping;
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:30,代码来源:ResourceHandlerRegistry.java

示例14: addSockJsServiceMapping

import org.springframework.web.HttpRequestHandler; //导入依赖的package包/类
@Override
protected void addSockJsServiceMapping(MultiValueMap<HttpRequestHandler, String> mappings,
		SockJsService sockJsService, WebSocketHandler handler, String pathPattern) {

	SockJsHttpRequestHandler httpHandler = new SockJsHttpRequestHandler(sockJsService, handler);
	mappings.add(httpHandler, pathPattern);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:8,代码来源:ServletWebSocketHandlerRegistration.java

示例15: addWebSocketHandlerMapping

import org.springframework.web.HttpRequestHandler; //导入依赖的package包/类
@Override
protected void addWebSocketHandlerMapping(MultiValueMap<HttpRequestHandler, String> mappings,
		WebSocketHandler wsHandler, HandshakeHandler handshakeHandler,
		HandshakeInterceptor[] interceptors, String path) {

	WebSocketHttpRequestHandler httpHandler = new WebSocketHttpRequestHandler(wsHandler, handshakeHandler);
	if (!ObjectUtils.isEmpty(interceptors)) {
		httpHandler.setHandshakeInterceptors(Arrays.asList(interceptors));
	}
	mappings.add(httpHandler, path);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:12,代码来源:ServletWebSocketHandlerRegistration.java


注:本文中的org.springframework.web.HttpRequestHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。