• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java ClientExecutionContext类的典型用法和代码示例

java 1次浏览

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

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

示例1: execute

点赞 2

import org.jboss.resteasy.spi.interception.ClientExecutionContext; //导入依赖的package包/类
@Override
public ClientResponse execute(ClientExecutionContext ctx) throws Exception {
    String token = tokenManager.getAccessTokenString();
    if (null != token) {
        ctx.getRequest().header(HttpHeaders.AUTHORIZATION,
                                "Bearer " + token);
    }
    return ctx.proceed();
}
 

开发者ID:kiegroup,
项目名称:appformer,
代码行数:10,
代码来源:BearerAuthenticationInterceptor.java

示例2: testExecute

点赞 2

import org.jboss.resteasy.spi.interception.ClientExecutionContext; //导入依赖的package包/类
@Test
public void testExecute() throws Exception {
    ClientExecutionContext ctx = mock(ClientExecutionContext.class);
    ClientRequest request = mock(ClientRequest.class);
    ClientResponse response = mock(ClientResponse.class);
    when(ctx.getRequest()).thenReturn(request);
    when(ctx.proceed()).thenReturn(response);
    ClientResponse response1 = this.interceptor.execute(ctx);
    verify(request,
           times(1)).header(eq(HttpHeaders.AUTHORIZATION),
                            eq("Bearer token1"));
    Assert.assertEquals(response,
                        response1);
}
 

开发者ID:kiegroup,
项目名称:appformer,
代码行数:15,
代码来源:AuthenticationClientExecutionInterceptorTest.java

示例3: execute

点赞 2

import org.jboss.resteasy.spi.interception.ClientExecutionContext; //导入依赖的package包/类
public ClientResponse execute(ClientExecutionContext ctx) throws Exception {
    ClientRequest request = ctx.getRequest();
    ClientResponse response = null;

    response = ctx.proceed();
    if ((response.getResponseStatus() != null) && (response.getResponseStatus().getStatusCode() == 404)) {
        BaseClientResponse r = (BaseClientResponse) response;
        MultivaluedMap<String, String> headers = r.getHeaders();
        headers.add("full-path", request.getUri());
        r.setHeaders(headers);
    }
    return response;
}
 

开发者ID:jboss-switchyard,
项目名称:switchyard,
代码行数:14,
代码来源:MyClientExecutionInterceptor.java

示例4: execute

点赞 2

import org.jboss.resteasy.spi.interception.ClientExecutionContext; //导入依赖的package包/类
/**
 * Set headers to advertise ability to accept LZF compression  <p/>
 * Check if client response has HTTP header "Accept-Encoding" set: <p/>
 * <ul>   <li>- If none, set header to "lzf", if has a header, add lzf to the list</li></ul>
 * @param ctx Client execution context
 * @return Response with headers appended
 * @throws Exception
 */
public ClientResponse execute(ClientExecutionContext ctx) throws Exception {
    String encoding = ctx.getRequest().getHeaders().getFirst(HttpHeaders.ACCEPT_ENCODING);
    if (encoding == null) {
        ctx.getRequest().header(HttpHeaders.ACCEPT_ENCODING, "lzf");
    } else {
        if (!encoding.contains("lzf")) {
            encoding += ", lzf";
            ctx.getRequest().header(HttpHeaders.ACCEPT_ENCODING, encoding);
        }
    }
    return ctx.proceed();
}
 

开发者ID:svanoort,
项目名称:rest-compress,
代码行数:21,
代码来源:AcceptLZFClientInterceptor.java

示例5: getProxy

点赞 2

import org.jboss.resteasy.spi.interception.ClientExecutionContext; //导入依赖的package包/类
/**
 * Returns the Snmp proxy Object.
 */
public Snmp getProxy()
{

    snmpServiceURL = snmpServiceURL + "/" + deviceIP + "/" + snmpPort + "/";

    LOGGER.info( "[SNMP Service REST URL][" + snmpServiceURL + "]" );

    ResteasyProviderFactory factory = new ResteasyProviderFactory();
    RegisterBuiltin.register( factory );
    factory.getClientExecutionInterceptorRegistry().register( new ClientExecutionInterceptor()
    {
        @Override
        public ClientResponse execute( ClientExecutionContext ctx ) throws Exception
        {
            ClientResponse response = ctx.proceed();
            if ( ( "application/xml".equals( response.getHeaders().getFirst( HttpHeaders.CONTENT_TYPE ) ) )
                    || ( "text/plain".equals( response.getHeaders().getFirst( HttpHeaders.CONTENT_TYPE ) ) ) )
            {
                response.getHeaders().putSingle( HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML );
            }
            return response;
        }
    } );

    this.snmp = ProxyFactory.create( Snmp.class, URI.create( snmpServiceURL ), new ApacheHttpClient4Executor(),
            factory );

    // this.snmp = ProxyFactory.create( Snmp.class, snmpServiceURL );

    return snmp;
}
 

开发者ID:Comcast,
项目名称:cats,
代码行数:35,
代码来源:SnmpServiceProxy.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)