本文整理汇总了Java中org.glassfish.jersey.internal.MapPropertiesDelegate类的典型用法代码示例。如果您正苦于以下问题:Java MapPropertiesDelegate类的具体用法?Java MapPropertiesDelegate怎么用?Java MapPropertiesDelegate使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MapPropertiesDelegate类属于org.glassfish.jersey.internal包,在下文中一共展示了MapPropertiesDelegate类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createContainerRequest
import org.glassfish.jersey.internal.MapPropertiesDelegate; //导入依赖的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;
}
示例2: createRequestDetails
import org.glassfish.jersey.internal.MapPropertiesDelegate; //导入依赖的package包/类
public JaxRsRequest createRequestDetails() throws URISyntaxException {
//headers
headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null, new MapPropertiesDelegate());
//uri info
UriInfo uriInfo = mock(UriInfo.class);
when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
//mocks
provider = spy(TestJaxRsDummyPatientProviderDstu3.class);
doReturn(uriInfo).when(provider).getUriInfo();
doReturn(BASEURI).when(provider).getBaseForRequest();
doReturn(BASEURI).when(provider).getBaseForServer();
doReturn(headers).when(provider).getHeaders();
return new JaxRsRequest(provider, RESOURCE_STRING, RequestTypeEnum.GET, RestOperationTypeEnum.HISTORY_TYPE);
}
示例3: createRequestDetails
import org.glassfish.jersey.internal.MapPropertiesDelegate; //导入依赖的package包/类
public JaxRsRequest createRequestDetails() throws URISyntaxException {
//headers
headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null, new MapPropertiesDelegate());
//uri info
UriInfo uriInfo = mock(UriInfo.class);
when(uriInfo.getQueryParameters()).thenReturn(queryParameters);
//mocks
provider = spy(TestJaxRsDummyPatientProvider.class);
doReturn(uriInfo).when(provider).getUriInfo();
doReturn(BASEURI).when(provider).getBaseForRequest();
doReturn(BASEURI).when(provider).getBaseForServer();
doReturn(headers).when(provider).getHeaders();
return new JaxRsRequest(provider, RESOURCE_STRING, RequestTypeEnum.GET, RestOperationTypeEnum.HISTORY_TYPE);
}
示例4: messageReceived
import org.glassfish.jersey.internal.MapPropertiesDelegate; //导入依赖的package包/类
protected void messageReceived(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception {
URI baseUri = getBaseUri(ctx, request);
URI requestUri = baseUri.resolve(request.getUri());
ByteBuf responseContent = PooledByteBufAllocator.DEFAULT.buffer();
FullHttpResponse response =
new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK, responseContent);
NettyRestResponseWriter responseWriter = new NettyRestResponseWriter(ctx, response);
ContainerRequest containerRequest = new ContainerRequest(baseUri, requestUri,
request.getMethod().name(), getSecurityContext(), new MapPropertiesDelegate());
containerRequest.setEntityStream(new ByteBufInputStream(request.content()));
HttpHeaders httpHeaders = request.headers();
for (String headerName: httpHeaders.names()) {
List<String> headerValues = httpHeaders.getAll(headerName);
containerRequest.headers(headerName, headerValues);
}
containerRequest.setWriter(responseWriter);
try {
applicationHandler.handle(containerRequest);
} finally {
responseWriter.releaseConnection();
}
}
示例5: getRequestInfo
import org.glassfish.jersey.internal.MapPropertiesDelegate; //导入依赖的package包/类
@GET
@Path("/requestInspect")
public Map getRequestInfo(@QueryParam("requestUri") String requestUri, @Context ContainerRequestContext request) {
ContainerRequest
containerRequest =
new ContainerRequest(request.getUriInfo().getBaseUri(), URI.create(requestUri), "GET", null,
new MapPropertiesDelegate());
RoutingFilter routingFilter = GondolaApplication.getRoutingFilter();
routingFilter.extractShardAndBucketIdFromRequest(containerRequest);
Map<Object, Object> map = new LinkedHashMap<>();
map.put("bucketId", containerRequest.getProperty("bucketId"));
map.put("shardId", containerRequest.getProperty("shardId"));
return map;
}
示例6: setUp
import org.glassfish.jersey.internal.MapPropertiesDelegate; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
// headers
headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
new MapPropertiesDelegate());
// uri info
queryParameters = new MultivaluedHashMap<String, String>();
providers = new ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider>();
provider = createConformanceProvider(providers);
}
示例7: setUp
import org.glassfish.jersey.internal.MapPropertiesDelegate; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
// headers
headers = new ContainerRequest(new URI(BASEURI), new URI(REQUESTURI), HttpMethod.GET, null,
new MapPropertiesDelegate());
// uri info
queryParameters = new MultivaluedHashMap<String, String>();
providers = new ConcurrentHashMap<Class<? extends IResourceProvider>, IResourceProvider>();
provider = createConformanceProvider(providers);
}
示例8: channelRead0
import org.glassfish.jersey.internal.MapPropertiesDelegate; //导入依赖的package包/类
@Override
protected void channelRead0(ChannelHandlerContext ctx, HttpMessage msg) throws Exception {
Writer w = new Writer(ctx);
PropertiesDelegate properties = new MapPropertiesDelegate();
SecurityContext securityContext = new SecurityContext() {
@Override
public Principal getUserPrincipal() {
return null;
}
@Override
public boolean isUserInRole(String s) {
return false;
}
@Override
public boolean isSecure() {
return false;
}
@Override
public String getAuthenticationScheme() {
return null;
}
};
}
示例9: createContainerRequest
import org.glassfish.jersey.internal.MapPropertiesDelegate; //导入依赖的package包/类
/**
* Creates the container request from the http request
*
* @param httpRequest
* @return
*/
protected ContainerRequest createContainerRequest(MessageContext context) {
Application<ApplicationConfiguration> application = context.getApplication();
FullHttpRequest httpRequest = context.getRequest();
URI baseUri = URI.create(context.getBaseUri().resolve(application.getPath()) + "/");
URI requestUri = HttpUtil.createURI(httpRequest.getUri());
ContainerRequest containerRequest = new ContainerRequest(baseUri, requestUri, httpRequest.getMethod().name(), null, new MapPropertiesDelegate());
// containerRequest.setProperty(REQUEST_PROPERTY_REMOTE_ADDR, context.getRequest().channel().remoteAddress());
containerRequest.setEntityStream(new ByteBufInputStream(httpRequest.content()));
for (Map.Entry<String, String> headerEntry : httpRequest.headers()) {
containerRequest.getHeaders().add(headerEntry.getKey(), headerEntry.getValue());
}
return containerRequest;
}
示例10: readRequest
import org.glassfish.jersey.internal.MapPropertiesDelegate; //导入依赖的package包/类
/**
* Reads an request object generated by an AWS_PROXY integration in API Gateway and transforms it into a Jersey
* <code>ContainerRequest</code> object.
*
* @param request The incoming request object
* @param securityContext A jax-rs SecurityContext object (@see com.amazonaws.serverless.proxy.SecurityContextWriter)
* @param lambdaContext The AWS Lambda context for the request
* @param config The container config object, this is passed in by the LambdaContainerHandler
* @return A populated ContainerRequest object
* @throws InvalidRequestEventException When the method fails to parse the incoming request
*/
@Override
public ContainerRequest readRequest(AwsProxyRequest request, SecurityContext securityContext, Context lambdaContext, ContainerConfig config)
throws InvalidRequestEventException {
currentRequest = request;
currentLambdaContext = lambdaContext;
request.setPath(stripBasePath(request.getPath(), config));
URI basePathUri;
URI requestPathUri;
String basePath = "/";
try {
basePathUri = new URI(basePath);
} catch (URISyntaxException e) {
log.error("Could not read base path URI", e);
throw new InvalidRequestEventException("Error while generating base path URI: " + basePath, e);
}
UriBuilder uriBuilder = UriBuilder.fromPath(request.getPath());
if (request.getQueryStringParameters() != null) {
for (String paramKey : request.getQueryStringParameters().keySet()) {
uriBuilder = uriBuilder.queryParam(paramKey, request.getQueryStringParameters().get(paramKey));
}
}
requestPathUri = uriBuilder.build();
PropertiesDelegate apiGatewayProperties = new MapPropertiesDelegate();
apiGatewayProperties.setProperty(API_GATEWAY_CONTEXT_PROPERTY, request.getRequestContext());
apiGatewayProperties.setProperty(API_GATEWAY_STAGE_VARS_PROPERTY, request.getStageVariables());
apiGatewayProperties.setProperty(LAMBDA_CONTEXT_PROPERTY, lambdaContext);
ContainerRequest requestContext = new ContainerRequest(basePathUri, requestPathUri, request.getHttpMethod(), securityContext, apiGatewayProperties);
if (request.getBody() != null) {
if (request.isBase64Encoded()) {
requestContext.setEntityStream(new ByteArrayInputStream(Base64.getDecoder().decode(request.getBody())));
} else {
requestContext.setEntityStream(new ByteArrayInputStream(request.getBody().getBytes()));
}
}
if (request.getHeaders() != null) {
for (final String headerName : request.getHeaders().keySet()) {
requestContext.headers(headerName, request.getHeaders().get(headerName));
}
}
return requestContext;
}
示例11: LocalTestRoutingServer
import org.glassfish.jersey.internal.MapPropertiesDelegate; //导入依赖的package包/类
public LocalTestRoutingServer(Gondola gondola, RoutingHelper routingHelper, ProxyClientProvider proxyClientProvider,
Map<String, RoutingService> services, ChangeLogProcessor changeLogProcessor) throws Exception {
routingFilter = new RoutingFilter(gondola, routingHelper, proxyClientProvider, services, changeLogProcessor);
routingFilter.start();
localTestServer = new LocalTestServer((request, response, context) -> {
try {
URI requestUri = URI.create(request.getRequestLine().getUri());
URI
baseUri =
URI.create(requestUri.getScheme() + "://" + requestUri.getHost() + ":" + requestUri.getPort());
ContainerRequest
containerRequest =
new ContainerRequest(baseUri, requestUri, request.getRequestLine().getMethod(), null,
new MapPropertiesDelegate());
routingFilter.filter(containerRequest);
Response abortResponse = containerRequest.getAbortResponse();
Response jaxrsResponse;
if (abortResponse != null) {
jaxrsResponse = abortResponse;
} else {
jaxrsResponse = new OutboundJaxrsResponse.Builder(null).status(200).build();
}
ContainerResponse containerResponse = new ContainerResponse(containerRequest, jaxrsResponse);
routingFilter.filter(containerRequest, containerResponse);
response.setStatusCode(containerResponse.getStatus());
response.setEntity(new StringEntity(containerResponse.getEntity().toString()));
Set<Map.Entry<String, List<Object>>> entries = containerResponse.getHeaders().entrySet();
for (Map.Entry<String, List<Object>> e : entries) {
String headerName = e.getKey();
for (Object o : e.getValue()) {
String headerValue = o.toString();
response.setHeader(headerName, headerValue);
}
}
} catch (Exception e) {
e.printStackTrace();
throw e;
}
});
host = localTestServer.start();
}
示例12: apply
import org.glassfish.jersey.internal.MapPropertiesDelegate; //导入依赖的package包/类
/**
* {@inheritDoc}
* <p/>
* Transforms client-side request to server-side and invokes it on provided
* application ({@link ApplicationHandler} instance).
*
* @param clientRequest
* client side request to be invoked.
*/
@Override
public ClientResponse apply(final ClientRequest clientRequest) {
final PropertiesDelegate propertiesDelegate = new MapPropertiesDelegate();
final ContainerRequest containerRequest = new ContainerRequest(this.baseUri, clientRequest.getUri(),
clientRequest.getMethod(), null, propertiesDelegate);
containerRequest.getHeaders().putAll(clientRequest.getStringHeaders());
final ByteArrayOutputStream clientOutput = new ByteArrayOutputStream();
if (clientRequest.getEntity() != null) {
clientRequest.setStreamProvider(new OutboundMessageContext.StreamProvider() {
@Override
public OutputStream getOutputStream(final int contentLength) throws IOException {
final MultivaluedMap<String, Object> clientHeaders = clientRequest.getHeaders();
if (contentLength != -1 && !clientHeaders.containsKey(HttpHeaders.CONTENT_LENGTH)) {
containerRequest.getHeaders().putSingle(HttpHeaders.CONTENT_LENGTH,
String.valueOf(contentLength));
}
return clientOutput;
}
});
clientRequest.enableBuffering();
try {
clientRequest.writeEntity();
} catch (final IOException e) {
final String msg = "Error while writing entity to the output stream.";
CdiAwareInMemoryConnector.LOGGER.log(Level.SEVERE, msg, e);
throw new ProcessingException(msg, e);
}
}
containerRequest.setEntityStream(new ByteArrayInputStream(clientOutput.toByteArray()));
final boolean followRedirects = ClientProperties.getValue(clientRequest.getConfiguration().getProperties(),
ClientProperties.FOLLOW_REDIRECTS, true);
final InMemoryResponseWriter inMemoryResponseWriter = new InMemoryResponseWriter();
containerRequest.setWriter(inMemoryResponseWriter);
containerRequest.setSecurityContext(new SecurityContext() {
@Override
public String getAuthenticationScheme() {
return null;
}
@Override
public Principal getUserPrincipal() {
return null;
}
@Override
public boolean isSecure() {
return false;
}
@Override
public boolean isUserInRole(final String role) {
return false;
}
});
this.appHandler.handle(containerRequest);
return tryFollowRedirects(followRedirects,
CdiAwareInMemoryConnector.createClientResponse(clientRequest, inMemoryResponseWriter),
new ClientRequest(clientRequest));
}
示例13: request
import org.glassfish.jersey.internal.MapPropertiesDelegate; //导入依赖的package包/类
public ContainerRequest request(String uri, String method, String content, MediaType contentType, Map<String, String> headers) {
return createContainerRequest(URI.create(""), URI.create(uri), method, content, headers,
null, new MapPropertiesDelegate());
}