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


Java HttpRequest类代码示例

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


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

示例1: createResteasyHttpRequest

import org.jboss.resteasy.spi.HttpRequest; //导入依赖的package包/类
@Override
public HttpRequest createResteasyHttpRequest(final String httpMethod,
                                             final HttpServletRequest request,
                                             final ResteasyHttpHeaders headers,
                                             final ResteasyUriInfo uriInfo,
                                             final HttpResponse theResponse,
                                             final HttpServletResponse response)
{
	return new HttpServletInputMessage(request,
	                                   response,
	                                   request.getServletContext(),
	                                   theResponse,
	                                   headers,
	                                   uriInfo,
	                                   httpMethod.toUpperCase(),
	                                   (SynchronousDispatcher) dispatcher.getDispatcher());
}
 
开发者ID:petergeneric,项目名称:stdlib,代码行数:18,代码来源:ResteasyRequestResponseFactory.java

示例2: aroundRequest

import org.jboss.resteasy.spi.HttpRequest; //导入依赖的package包/类
@Override
public void aroundRequest(HttpRequest req, RunnableWithException<IOException> continuation) throws IOException {
       BoundRequestContext cdiContext = CDI.current().select(BoundRequestContext.class).get();
       Map<String,Object> contextMap = new HashMap<String,Object>();
       cdiContext.associate(contextMap);
       cdiContext.activate();
       try {
       	// FIXME: associate CDI thread context on thread change, like Resteasy context?
       	continuation.run();
       }finally {
   		if(req.getAsyncContext().isSuspended()) {
   			req.getAsyncContext().getAsyncResponse().register((CompletionCallback)(t) -> {
       			cdiContext.invalidate();
       			cdiContext.deactivate();
       			cdiContext.dissociate(contextMap);
   			});
   		}else {
   			cdiContext.invalidate();
   			cdiContext.deactivate();
   			cdiContext.dissociate(contextMap);
   		}		
       }
}
 
开发者ID:FroMage,项目名称:redpipe,代码行数:24,代码来源:CdiPlugin.java

示例3: testURIParamsAuthentication

import org.jboss.resteasy.spi.HttpRequest; //导入依赖的package包/类
/**
 * Test method for
 * {@link org.jboss.dcp.api.rest.AuthenticationInterceptor#preProcess(org.jboss.resteasy.spi.HttpRequest, org.jboss.resteasy.core.ResourceMethod)}
 * .
 */
@Test
public void testURIParamsAuthentication() {
	AuthenticationInterceptor tested = getTested();

	HttpRequest requestMock = getHttpRequestMock();
	ResourceMethod methodMock = Mockito.mock(ResourceMethod.class);

	@SuppressWarnings("unchecked")
	MultivaluedMap<String, String> queryParamsMock = Mockito.mock(MultivaluedMap.class);
	Mockito.when(queryParamsMock.getFirst("provider")).thenReturn(uname);
	Mockito.when(queryParamsMock.getFirst("pwd")).thenReturn(pwd);

	Mockito.when(requestMock.getUri().getQueryParameters()).thenReturn(queryParamsMock);
	Mockito.when(tested.providerService.authenticate(uname, pwd)).thenReturn(true);

	ServerResponse res = tested.preProcess(requestMock, methodMock);
	Assert.assertNull(res);
	Mockito.verify(tested.providerService, Mockito.times(1)).authenticate(Mockito.anyString(), Mockito.anyString());

	SecurityContext ctx = ResteasyProviderFactory.getContextData(SecurityContext.class);
	Assert.assertEquals("uname", ctx.getUserPrincipal().getName());
	Assert.assertEquals("CUSTOM", ctx.getAuthenticationScheme());
}
 
开发者ID:macanhhuy,项目名称:dcp-api,代码行数:29,代码来源:AuthenticationInterceptorTest.java

示例4: service

import org.jboss.resteasy.spi.HttpRequest; //导入依赖的package包/类
private void service(int i, Context context, HttpServerRequest req, HttpServerResponse resp, HttpRequest vertxReq,
		HttpResponse vertxResp, boolean handleNotFound) throws IOException {
	if(i < plugins.size())
		plugins.get(i).aroundRequest(vertxReq, () -> service(i+1, context, req, resp, vertxReq, vertxResp, handleNotFound));
	else
		super.service(context, req, resp, vertxReq, vertxResp, handleNotFound);
}
 
开发者ID:FroMage,项目名称:redpipe,代码行数:8,代码来源:PluginRequestDispatcher.java

示例5: VertxAsynchronousResponse

import org.jboss.resteasy.spi.HttpRequest; //导入依赖的package包/类
public VertxAsynchronousResponse(final ResteasyProviderFactory providerFactory,
    final HttpRequest request,
    final RoutingContext routingContext) {

    this.providerFactory = providerFactory;
    this.request = request;
    this.routingContext = routingContext;

}
 
开发者ID:trajano,项目名称:app-ms,代码行数:10,代码来源:VertxAsynchronousResponse.java

示例6: VertxExecutionContext

import org.jboss.resteasy.spi.HttpRequest; //导入依赖的package包/类
public VertxExecutionContext(final RoutingContext routingContext,
    final ResteasyProviderFactory providerFactory,
    final HttpRequest request) {

    this.request = request;
    this.providerFactory = providerFactory;
    this.routingContext = routingContext;
}
 
开发者ID:trajano,项目名称:app-ms,代码行数:9,代码来源:VertxExecutionContext.java

示例7: RestEasyRequestContext

import org.jboss.resteasy.spi.HttpRequest; //导入依赖的package包/类
public RestEasyRequestContext(Providers providers, HttpRequest request) {
    super(providers,
            new RequestPac4JSecurityContext(ResteasyProviderFactory.getContextData(SecurityContext.class)).context()
                    // if we went through a pac4j security filter
                    .map(sc -> sc.getContext().getRequestContext())
                    // if not, we create a new ContainerRequestContext
                    .orElse(new PreMatchContainerRequestContext(request)));
}
 
开发者ID:pac4j,项目名称:jax-rs-pac4j,代码行数:9,代码来源:RestEasyRequestContext.java

示例8: preProcess

import org.jboss.resteasy.spi.HttpRequest; //导入依赖的package包/类
@Override
public ServerResponse preProcess(HttpRequest hr, ResourceMethodInvoker rmi) throws Failure, WebApplicationException {
    String methodName = rmi.getMethod().getName();
    String remoteAddress = servletRequest.getRemoteAddr();
    String requestUri = servletRequest.getRequestURI();
    String queryString = servletRequest.getQueryString();
    String httpMethod = servletRequest.getMethod();

    String requestData = "Remote Adress: " + remoteAddress + "\n\t\t\t"
            + "Method: " + methodName + "\n\t\t\t"
            + "Request URI: " + requestUri + "\n\t\t\t"
            + "Query String: " + queryString + "\n\t\t\t"
            + "HTTP Method: " + httpMethod;

    LOGGER.info(requestData);

    Enumeration<String> headerNames = servletRequest.getHeaderNames();
    servletRequest.getHeader("");

    if (LOGGER.isTraceEnabled()) {
        while (headerNames.hasMoreElements()) {
            String headerName = headerNames.nextElement();

            Enumeration<String> headers = servletRequest.getHeaders(headerName);
            while (headers.hasMoreElements()) {
                String headerValue = headers.nextElement();
                LOGGER.trace(headerName + ": " + headerValue);
            }
        }
    } else {
        String contentType = servletRequest.getHeader("content-type");
        LOGGER.info("content-type: " + contentType);

        String acceptEnconding = servletRequest.getHeader("accept-encoding");
        LOGGER.info("accept-encoding: " + acceptEnconding);
    }

    return null;
}
 
开发者ID:jokoframework,项目名称:notification-server,代码行数:40,代码来源:LoggingInterceptor.java

示例9: createResource

import org.jboss.resteasy.spi.HttpRequest; //导入依赖的package包/类
@Override
public Object createResource(final HttpRequest request,
                             final HttpResponse response,
                             final ResteasyProviderFactory factory)
{
  final Object resource = entry.getValue();
  propertyInjector.inject(request, response, resource);
  return resource;
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:10,代码来源:SisuResourceFactory.java

示例10: before

import org.jboss.resteasy.spi.HttpRequest; //导入依赖的package包/类
@Before
public void before() {
    requestFilter = new APIVersionRequestFilter();
    HttpRequest mockHttpRequest = mock(HttpRequest.class);
    HttpHeaders httpHeaders = mock(HttpHeaders.class);
    when(httpHeaders.getRequestHeaders()).thenReturn(new MultivaluedHashMap<>());
    when(httpHeaders.getHeaderString(anyString())).then(invocation -> httpHeaders.getRequestHeaders().getFirst((String) invocation.getArguments()[0]));
    when(mockHttpRequest.getHttpHeaders()).thenReturn(httpHeaders);
    when(mockHttpRequest.getMutableHeaders()).thenReturn(new MultivaluedHashMap<>());
    requestContext = new PreMatchContainerRequestContext(mockHttpRequest);
}
 
开发者ID:projectomakase,项目名称:omakase,代码行数:12,代码来源:APIVersionRequestFilterTest.java

示例11: preProcess

import org.jboss.resteasy.spi.HttpRequest; //导入依赖的package包/类
public ServerResponse preProcess(HttpRequest request, ResourceMethodInvoker method)
        throws Failure, WebApplicationException {
    if (logger.isDebugEnabled()) {

        String httpMethod = request.getHttpMethod();

        URI uri = ui.getRequestUri();

        String uriPath = uri.getPath();
        if (uri.getQuery() != null) {
            uriPath += "?" + uri.getQuery();
        }
        if (uri.getFragment() != null) {
            uriPath += "#" + uri.getFragment();
        }

        String sessionid = null;
        List<String> headerSessionId = request.getHttpHeaders().getRequestHeader("sessionid");
        if (headerSessionId != null) {
            sessionid = headerSessionId.get(0);
        }
        if (logger.isDebugEnabled()) {
            // log only in debug mode
            logger.debug(sessionid + "|" + httpMethod + "|" + uriPath);
        }
    }
    return null;
}
 
开发者ID:ow2-proactive,项目名称:scheduling,代码行数:29,代码来源:LoggingInterceptor.java

示例12: createResource

import org.jboss.resteasy.spi.HttpRequest; //导入依赖的package包/类
@Override
public Object createResource(HttpRequest request, HttpResponse response, ResteasyProviderFactory factory)
{
    Object resource = provider.get();
    contextPropertyInjector.inject(request, response, resource);
    return resource;
}
 
开发者ID:treasure-data,项目名称:digdag,代码行数:8,代码来源:GuiceRsApplicationServlet.java

示例13: bindRequestScope

import org.jboss.resteasy.spi.HttpRequest; //导入依赖的package包/类
/**
 * @see <code>>org.jboss.resteasy.plugins.guice.ext.RequestScopeModule.ResteasyContextProvider</code>
 */
private void bindRequestScope(){
    bindScope(RequestScoped.class, new Scope()
    {
        @Override
        public <T> com.google.inject.Provider<T> scope(final Key<T> key, final com.google.inject.Provider<T> creator)
        {
            return new com.google.inject.Provider<T>()
            {
                @SuppressWarnings("unchecked")
                @Override
                public T get()
                {
                    Class<T> instanceClass = (Class<T>) key.getTypeLiteral().getType();
                    T instance = ResteasyProviderFactory.getContextData(instanceClass);

                    if (instance == null) {
                        instance = creator.get();
                        ResteasyProviderFactory.pushContext(instanceClass, instance);
                    }

                    return instance;
                }

                @Override
                public String toString() {
                    return String.format("%s[%s]", creator, this);
                }
            };
        }
    });
    bind(HttpRequest.class).toProvider(new ResteasyContextProvider<HttpRequest>(HttpRequest.class)).in(RequestScoped.class);
    bind(HttpResponse.class).toProvider(new ResteasyContextProvider<HttpResponse>(HttpResponse.class)).in(RequestScoped.class);
    bind(Request.class).toProvider(new ResteasyContextProvider<Request>(Request.class)).in(RequestScoped.class);
    bind(HttpHeaders.class).toProvider(new ResteasyContextProvider<HttpHeaders>(HttpHeaders.class)).in(RequestScoped.class);
    bind(UriInfo.class).toProvider(new ResteasyContextProvider<UriInfo>(UriInfo.class)).in(RequestScoped.class);
    bind(SecurityContext.class).toProvider(new ResteasyContextProvider<SecurityContext>(SecurityContext.class)).in(RequestScoped.class);
}
 
开发者ID:buzzxu,项目名称:resteasy-netty-guice,代码行数:41,代码来源:GuiceModule.java

示例14: createResource

import org.jboss.resteasy.spi.HttpRequest; //导入依赖的package包/类
public Object createResource(HttpRequest request, HttpResponse response, InjectorFactory factory) 
{ 
   // Push this onto event context so we have it available in ResteasyContextInjectionInterceptor 
   Contexts.getEventContext().set(ResteasyContextInjectionInterceptor.RE_HTTP_REQUEST_VAR, request); 
   Contexts.getEventContext().set(ResteasyContextInjectionInterceptor.RE_HTTP_RESPONSE_VAR, response); 
   log.debug("creating RESTEasy resource instance by looking up Seam component: " + seamComponent.getName()); 
   return Component.getInstance(seamComponent.getName()); 
}
 
开发者ID:windup,项目名称:windup-rulesets,代码行数:9,代码来源:SeamResteasyResourceFactory.java

示例15: service

import org.jboss.resteasy.spi.HttpRequest; //导入依赖的package包/类
public void service(HttpRequest request, HttpResponse response, boolean handleNotFound) throws IOException
{
    BoundRequestContext requestContext = CDI.current().select(BoundRequestContext.class).get();
    Map<String,Object> requestMap = new HashMap<String,Object>();
    requestContext.associate(requestMap);
    requestContext.activate();
    try {
        super.service(request,response,handleNotFound);
    }
    finally {
        requestContext.invalidate();
        requestContext.deactivate();
        requestContext.dissociate(requestMap);
    }
}
 
开发者ID:johnament,项目名称:resteasy-netty-cdi,代码行数:16,代码来源:CDIRequestDispatcher.java


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