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


Java ContainerResponseWriter类代码示例

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


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

示例1: createContainerRequest

import org.glassfish.jersey.server.spi.ContainerResponseWriter; //导入依赖的package包/类
/**
 * Creates a new {@link ContainerRequest} for the given input.
 *
 * @param request
 * @param containerResponseWriter
 * @param securityContext
 * @return
 */
@Nonnull
protected ContainerRequest createContainerRequest(@Nonnull RequestT request,
		@Nonnull ContainerResponseWriter containerResponseWriter, @Nonnull SecurityContext securityContext) {
	requireNonNull(request, "request may not be null");
	URI baseUri = request.getBaseUri();
	URI requestUri = requireNonNull(request.getRequestUri(), "request.getRequestUri() may not be null");
	String httpMethod = requireNonNull(request.getHttpMethod(), "request.getHttpMethod() may not be null");
	InputStream entityStream = requireNonNull(request.getEntityStream(),
			"request.getEntityStream() may not be null");
	Map<String, List<String>> headers = requireNonNull(request.getHeaders(),
			"request.getHeaderParams() may not be null");
	requireNonNull(containerResponseWriter, "containerResponseWriter may not be null");
	requireNonNull(securityContext, "securityContext may not be null");

	ContainerRequest requestContext = new ContainerRequest(baseUri, requestUri, httpMethod, securityContext,
			new MapPropertiesDelegate());
	requestContext.setEntityStream(entityStream);
	requestContext.getHeaders().putAll(headers);
	requestContext.setWriter(containerResponseWriter);

	return requestContext;
}
 
开发者ID:bbilger,项目名称:jrestless,代码行数:31,代码来源:JRestlessHandlerContainer.java

示例2: ByteArrayInputStream

import org.glassfish.jersey.server.spi.ContainerResponseWriter; //导入依赖的package包/类
@Test
public void createContainerRequest_RequestAndContainerResponseWriterAndSecurityContextGiven_ShouldCreateContainerRequestUsingValues() {
	URI baseUri = URI.create("/");
	URI requestUri = URI.create("/entity");
	String httpMethod = "POST";
	ByteArrayInputStream entityStream = new ByteArrayInputStream(new byte[0]);
	MultivaluedMap<String, String> headers = new MultivaluedHashMap<>();
	headers.add("hk0", "hv0_0");
	headers.add("hk0", "hv0_1");
	headers.add("hk1", "hv1_0");
	JRestlessContainerRequest request = createRequest(baseUri, requestUri, httpMethod, entityStream, headers);

	ContainerResponseWriter containerResponseWriter = mock(ContainerResponseWriter.class);
	SecurityContext securityContext = mock(SecurityContext.class);

	ContainerRequest containerRequest = container.createContainerRequest(request, containerResponseWriter, securityContext);

	assertEquals(baseUri, containerRequest.getBaseUri());
	assertEquals(requestUri, containerRequest.getRequestUri());
	assertEquals(httpMethod, containerRequest.getMethod());
	assertSame(entityStream, containerRequest.getEntityStream());
	assertEquals(headers, containerRequest.getHeaders());
	assertSame(containerResponseWriter, containerRequest.getResponseWriter());
	assertSame(securityContext, containerRequest.getSecurityContext());
}
 
开发者ID:bbilger,项目名称:jrestless,代码行数:26,代码来源:JRestlessHandlerContainerTest.java

示例3: flushResponse

import org.glassfish.jersey.server.spi.ContainerResponseWriter; //导入依赖的package包/类
private void flushResponse(RequestEvent requestEvent) {
    try {
        ContainerResponseWriter writer = requestEvent.getContainerRequest().getResponseWriter();
        writer.writeResponseStatusAndHeaders(0, requestEvent.getContainerResponse()).flush();
    } catch (Exception e) {
        // no op
    }
}
 
开发者ID:icode,项目名称:ameba-dev,代码行数:9,代码来源:ReloadRequestListener.java

示例4: createContainerRequest_NoRequestGiven_ShouldThrowNpe

import org.glassfish.jersey.server.spi.ContainerResponseWriter; //导入依赖的package包/类
@Test
public void createContainerRequest_NoRequestGiven_ShouldThrowNpe() {
	assertThrows(NullPointerException.class, () -> container.createContainerRequest(null, mock(ContainerResponseWriter.class), mock(SecurityContext.class)));
}
 
开发者ID:bbilger,项目名称:jrestless,代码行数:5,代码来源:JRestlessHandlerContainerTest.java

示例5: createContainerRequest_NoSecurityContext_ShouldThrowNpe

import org.glassfish.jersey.server.spi.ContainerResponseWriter; //导入依赖的package包/类
@Test
public void createContainerRequest_NoSecurityContext_ShouldThrowNpe() {
	assertThrows(NullPointerException.class, () -> container.createContainerRequest(createAnyRequest(), mock(ContainerResponseWriter.class), null));
}
 
开发者ID:bbilger,项目名称:jrestless,代码行数:5,代码来源:JRestlessHandlerContainerTest.java

示例6: createContainerRequest_NoRequestBaseUriGiven_ShouldPass

import org.glassfish.jersey.server.spi.ContainerResponseWriter; //导入依赖的package包/类
public void createContainerRequest_NoRequestBaseUriGiven_ShouldPass() {
	JRestlessContainerRequest request = createAnyRequest();
	when(request.getBaseUri()).thenReturn(null);
	container.createContainerRequest(request, mock(ContainerResponseWriter.class), mock(SecurityContext.class));
}
 
开发者ID:bbilger,项目名称:jrestless,代码行数:6,代码来源:JRestlessHandlerContainerTest.java

示例7: createContainerRequest_NoRequestRequestUriGiven_ShouldThrowNpe

import org.glassfish.jersey.server.spi.ContainerResponseWriter; //导入依赖的package包/类
@Test
public void createContainerRequest_NoRequestRequestUriGiven_ShouldThrowNpe() {
	JRestlessContainerRequest request = createAnyRequest();
	when(request.getRequestUri()).thenReturn(null);
	assertThrows(NullPointerException.class, () -> container.createContainerRequest(request, mock(ContainerResponseWriter.class), mock(SecurityContext.class)));
}
 
开发者ID:bbilger,项目名称:jrestless,代码行数:7,代码来源:JRestlessHandlerContainerTest.java

示例8: createContainerRequest_NoRequestHttpMethodGiven_ShouldThrowNpe

import org.glassfish.jersey.server.spi.ContainerResponseWriter; //导入依赖的package包/类
@Test
public void createContainerRequest_NoRequestHttpMethodGiven_ShouldThrowNpe() {
	JRestlessContainerRequest request = createAnyRequest();
	when(request.getHttpMethod()).thenReturn(null);
	assertThrows(NullPointerException.class, () -> container.createContainerRequest(request, mock(ContainerResponseWriter.class), mock(SecurityContext.class)));
}
 
开发者ID:bbilger,项目名称:jrestless,代码行数:7,代码来源:JRestlessHandlerContainerTest.java

示例9: createContainerRequest_NoRequestEntityStreamGiven_ShouldThrowNpe

import org.glassfish.jersey.server.spi.ContainerResponseWriter; //导入依赖的package包/类
@Test
public void createContainerRequest_NoRequestEntityStreamGiven_ShouldThrowNpe() {
	JRestlessContainerRequest request = createAnyRequest();
	when(request.getEntityStream()).thenReturn(null);
	assertThrows(NullPointerException.class, () -> container.createContainerRequest(request, mock(ContainerResponseWriter.class), mock(SecurityContext.class)));
}
 
开发者ID:bbilger,项目名称:jrestless,代码行数:7,代码来源:JRestlessHandlerContainerTest.java

示例10: createContainerRequest_NoRequestHeadersGiven_ShouldThrowNpe

import org.glassfish.jersey.server.spi.ContainerResponseWriter; //导入依赖的package包/类
@Test
public void createContainerRequest_NoRequestHeadersGiven_ShouldThrowNpe() {
	JRestlessContainerRequest request = createAnyRequest();
	when(request.getHeaders()).thenReturn(null);
	assertThrows(NullPointerException.class, () -> container.createContainerRequest(request, mock(ContainerResponseWriter.class), mock(SecurityContext.class)));
}
 
开发者ID:bbilger,项目名称:jrestless,代码行数:7,代码来源:JRestlessHandlerContainerTest.java

示例11: setWriter

import org.glassfish.jersey.server.spi.ContainerResponseWriter; //导入依赖的package包/类
/**
 * <p>setWriter.</p>
 *
 * @param responseWriter a {@link org.glassfish.jersey.server.spi.ContainerResponseWriter} object.
 */
public static void setWriter(ContainerResponseWriter responseWriter) {
    getRequest().setWriter(responseWriter);
}
 
开发者ID:icode,项目名称:ameba,代码行数:9,代码来源:Requests.java

示例12: getResponseWriter

import org.glassfish.jersey.server.spi.ContainerResponseWriter; //导入依赖的package包/类
/**
 * <p>getResponseWriter.</p>
 *
 * @return a {@link org.glassfish.jersey.server.spi.ContainerResponseWriter} object.
 */
public static ContainerResponseWriter getResponseWriter() {
    return getRequest().getResponseWriter();
}
 
开发者ID:icode,项目名称:ameba,代码行数:9,代码来源:Requests.java


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