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


Java RESTEasyBindingData类代码示例

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


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

示例1: compose

import org.switchyard.component.resteasy.composer.RESTEasyBindingData; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Message compose(RESTEasyBindingData source, Exchange exchange) throws Exception {
    final Message message = super.compose(source, exchange);
    if (message.getContent() instanceof BaseClientResponse) {
        BaseClientResponse<?> clientResponse = (BaseClientResponse<?>) message.getContent();
        if (clientResponse.getResponseStatus() == Response.Status.NOT_FOUND) {
            throw new ItemNotFoundException("Item not found");
        }
    } else if (source.getOperationName().equals("addItem") && (source.getParameters().length == 2)) {
        // Wrap the parameters
        Item item = new Item((Integer) source.getParameters()[0], (String) source.getParameters()[1]);
        message.setContent(item);
    }
    return message;
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:19,代码来源:CustomComposer.java

示例2: decompose

import org.switchyard.component.resteasy.composer.RESTEasyBindingData; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public RESTEasyBindingData decompose(Exchange exchange, RESTEasyBindingData target) throws Exception {
    Object content = exchange.getMessage().getContent();
    if (exchange.getState().equals(ExchangeState.FAULT)) {
        if (content instanceof HandlerException) {
            HandlerException he = (HandlerException) content;
            if (he.getCause() instanceof ItemNotFoundException) {
                throw (Exception) he.getCause();
            }
        }
    }

    target = super.decompose(exchange, target);

    if (target.getOperationName().equals("addItem") && (content != null) && (content instanceof Item)) {
        // Unwrap the parameters
        target.setParameters(new Object[] { ((Item) content).getItemId(), ((Item) content).getName() });
    }
    return target;
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:24,代码来源:CustomComposer.java

示例3: invoke

import org.switchyard.component.resteasy.composer.RESTEasyBindingData; //导入依赖的package包/类
public RESTEasyBindingData invoke(final RESTEasyBindingData restMessageRequest, final boolean oneWay) {
    Object input = restMessageRequest.getParameters().length == 0 ? null : restMessageRequest.getParameters()[0];
    String operationName = restMessageRequest.getOperationName();
    if (operationName.equals("getItem")) {
        Assert.assertTrue(input instanceof Integer);
        Assert.assertTrue((Integer)input == 1);
        Assert.assertFalse(oneWay);
        return new RESTEasyBindingData(new Item(1, "Apple"));
    } else if (operationName.equals("addItem") || operationName.equals("updateItem")) {
        Assert.assertTrue(input instanceof Item);
        Assert.assertFalse(oneWay);
        return new RESTEasyBindingData(((Item)input).toString());
    } else if (operationName.equals("removeItem")) {
        Assert.assertTrue(input instanceof Integer);
        Assert.assertFalse(oneWay);
        return new RESTEasyBindingData("2");
    } else if (operationName.equals("getItemCount")) {
        Assert.assertTrue(input == null);
        Assert.assertFalse(oneWay);
        return new RESTEasyBindingData(0);
    } else if (operationName.equals("testVoid")) {
        Assert.assertTrue(input == null);
        Assert.assertTrue(oneWay);
    }
    return null;
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:27,代码来源:ClassUtilTest.java

示例4: decompose

import org.switchyard.component.resteasy.composer.RESTEasyBindingData; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public RESTEasyBindingData decompose(Exchange exchange, RESTEasyBindingData target) throws Exception {
    Object content = exchange.getMessage().getContent();
    String opName = exchange.getContract().getProviderOperation().getName();
    if (opName.equals("getItem") && (content == null)) {
        exchange.getContext().setProperty(RESTEasyContextMapper.HTTP_RESPONSE_STATUS, 404)
                .addLabels(new String[] { EndpointLabel.HTTP.label() });
    }

    target = super.decompose(exchange, target);

    if (target.getOperationName().equals("addItem") && (content != null) && (content instanceof Item)) {
        // Unwrap the parameters
        target.setParameters(new Object[] { ((Item) content).getItemId(), ((Item) content).getName(),
                ((Item) content).getPrice() });
    }

    return target;
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:23,代码来源:CustomComposer.java

示例5: mapTo

import org.switchyard.component.resteasy.composer.RESTEasyBindingData; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void mapTo(Context context, RESTEasyBindingData target) throws Exception {
    // delegate to parent to pick up existing context mapping logic for RESTEasy
    super.mapTo(context, target);
    // add a custom header
    target.addHeader("bar", "123");
    target.addHeader("bar", "456");
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:12,代码来源:AnotherCustomMapper.java

示例6: mapTo

import org.switchyard.component.resteasy.composer.RESTEasyBindingData; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void mapTo(Context context, RESTEasyBindingData target) throws Exception {
    // delegate to parent to pick up existing context mapping logic for RESTEasy
    super.mapTo(context, target);
    // add a custom header
    target.addHeader("foo", "123");
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:11,代码来源:CustomMapper.java

示例7: compose

import org.switchyard.component.resteasy.composer.RESTEasyBindingData; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Message compose(RESTEasyBindingData source, Exchange exchange) throws Exception {
    final Message message = super.compose(source, exchange);
    if (source.getOperationName().equals("addItem") && (source.getParameters().length == 3)) {
        // Wrap the parameters
        Item item = new Item((Integer) source.getParameters()[0], (String) source.getParameters()[1],
                (Integer) source.getParameters()[2]);
        message.setContent(item);
    }
    return message;
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:15,代码来源:CustomComposer.java

示例8: invoke

import org.switchyard.component.resteasy.composer.RESTEasyBindingData; //导入依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    String methodName = method.getName();
    if (methodName.equals("toString")) {
        return this.toString();
    } else if (methodName.equals("equals")) {
        if (proxy == null || args[0] == null) {
            return false;
        } else if (proxy == args[0]) {
            return true;
        }
        return false;
    } else if (methodName.equals("hashCode")) {
        return this.hashCode();
    }

    RESTEasyBindingData requestData = new RESTEasyBindingData();
    HttpHeaders headers = ResteasyProviderFactory.getContextData(HttpHeaders.class);
    if (headers != null) {
        requestData.setHeaders(headers.getRequestHeaders());
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace("Incoming Headers to SwitchYard through InboundHandler [");
            traceLog(LOGGER, headers.getRequestHeaders());
            LOGGER.trace("]");
        }
    }
    SecurityContext securityContext = ResteasyProviderFactory.getContextData(SecurityContext.class);
    if (securityContext != null) {
        if (securityContext instanceof ServletSecurityContext && SERVLET_REQUEST_ACCESS != null) {
            HttpServletRequest servletRequest = SERVLET_REQUEST_ACCESS.read((ServletSecurityContext)securityContext);
            requestData.setServletRequest(servletRequest);
        }
        requestData.setSecured(securityContext.isSecure());
        requestData.setPrincipal(securityContext.getUserPrincipal());
    }
    requestData.setOperationName(methodName);
    if ((args != null) && (args.length > 0)) {
        requestData.setParameters(args);
        if (LOGGER.isTraceEnabled()) {
            LOGGER.trace(args);
        }
    }
    RESTEasyBindingData responseData = _serviceConsumer.invoke(requestData, method.getReturnType().equals(Void.TYPE));
    Response.ResponseBuilder builder = Response.ok();
    if (responseData != null) {
        if (method.getReturnType().equals(Response.class)) {
            if (responseData.getParameters().length > 0) {
                Object param = responseData.getParameters()[0];
                if (param instanceof Response) {
                    // In future use builder = Response.ResponseBuilder.fromResponse((Response)param);
                    Response response = (Response)param;
                    builder.entity(response.getEntity());
                    builder.status(response.getStatus());
                } else {
                    builder.entity(param);
                }
            }
            // Data overrides status
            if (responseData.getStatusCode() != null) {
                builder.status(responseData.getStatusCode());
            }
            for (Map.Entry<String, List<String>> entry : responseData.getHeaders().entrySet()) {
                String name = entry.getKey();
                List<String> values = entry.getValue();
                for (String value : values) {
                    builder.header(name, value);
                }
            }
            if (LOGGER.isTraceEnabled()) {
                LOGGER.trace("Outgoing Headers from SwitchYard through InboundHandler [");
                traceLog(LOGGER, responseData.getHeaders());
                LOGGER.trace("]");
            }
        } else if (responseData.getParameters().length > 0) {
            return responseData.getParameters()[0];
        }
    }
    return builder.build();
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:80,代码来源:RESTEasyProxy.java

示例9: mapTo

import org.switchyard.component.resteasy.composer.RESTEasyBindingData; //导入依赖的package包/类
@Override
public void mapTo(Context context, RESTEasyBindingData target) throws Exception {
    super.mapTo(context, target);
    Map<String, List<String>> httpHeaders = target.getHeaders();
    httpHeaders.put("Access-Control-Allow-Origin", Arrays.asList("http://localhost:18080"));
}
 
开发者ID:tadayosi,项目名称:samples-switchyard,代码行数:7,代码来源:CorsRESTEasyContextMapper.java

示例10: invoke

import org.switchyard.component.resteasy.composer.RESTEasyBindingData; //导入依赖的package包/类
/**
 * Invokes the JAX-RS method.
 *
 * @param exchange SwitchYard exchange
 * @param args the method arguments
 * @param headers the HTTP headers to be set on the request
 * @return the method's response entity and headers wrapped in RESTEasyBindingData
 */
RESTEasyBindingData invoke(Exchange exchange, Object[] args, MultivaluedMap<String, String> headers);
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:10,代码来源:MethodInvoker.java


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