Package org.apache.camel.component.bean

Examples of org.apache.camel.component.bean.BeanInvocation


                    if (exchange.getIn().getBody() == null) {
                        return null;
                    }

                    // if its a bean invocation then if it has no arguments then it should be threaded as null body allowed
                    BeanInvocation bi = exchange.getIn().getBody(BeanInvocation.class);
                    if (bi != null && (bi.getArgs() == null || bi.getArgs().length == 0 || bi.getArgs()[0] == null)) {
                        return null;
                    }
                }

                try {
View Full Code Here


    public void marshal(Exchange exchange, final Object inputObject, OutputStream stream) throws IOException {
        checkElementNameStrategy(exchange);

        String soapAction = getSoapActionFromExchange(exchange);
        if (soapAction == null && inputObject instanceof BeanInvocation) {
            BeanInvocation beanInvocation = (BeanInvocation) inputObject;
            WebMethod webMethod = beanInvocation.getMethod().getAnnotation(WebMethod.class);
            if (webMethod != null && webMethod.action() != null) {
                soapAction = webMethod.action();
            }
        }
        Body body = new Body();
View Full Code Here

     */
    @SuppressWarnings({ "unchecked", "rawtypes" })
    private JAXBElement<?> createBodyContentFromObject(final Object inputObject, String soapAction) {
        Object paramObject;
        if (inputObject instanceof BeanInvocation) {
            BeanInvocation bi = (BeanInvocation) inputObject;
            if (bi.getArgs() == null || bi.getArgs().length == 0) {
                paramObject = null;
            } else if (bi.getArgs().length == 1) {
                paramObject = bi.getArgs()[0];
            } else {
                throw new RuntimeCamelException("SoapDataFormat does not work with "
                        + "Beaninvocations that contain more than 1 parameter");               
            }
        } else {
View Full Code Here

                    if (exchange.getIn().getBody() == null) {
                        return null;
                    }

                    // if its a bean invocation then if it has no arguments then it should be threaded as null body allowed
                    BeanInvocation bi = exchange.getIn().getBody(BeanInvocation.class);
                    if (bi != null && (bi.getArgs() == null || bi.getArgs().length == 0 || bi.getArgs()[0] == null)) {
                        return null;
                    }
                }

                try {
View Full Code Here

    public void marshal(Exchange exchange, final Object inputObject, OutputStream stream) throws IOException {
        checkElementNameStrategy(exchange);

        String soapAction = getSoapActionFromExchange(exchange);
        if (soapAction == null && inputObject instanceof BeanInvocation) {
            BeanInvocation beanInvocation = (BeanInvocation) inputObject;
            WebMethod webMethod = beanInvocation.getMethod().getAnnotation(WebMethod.class);
            if (webMethod != null && webMethod.action() != null) {
                soapAction = webMethod.action();
            }
        }
               
View Full Code Here

    private List<JAXBElement<?>> createContentFromObject(final Object inputObject, String soapAction,
                                                         List<JAXBElement<?>> headerElements) {
        List<Object> bodyParts = new ArrayList<Object>();
        List<Object> headerParts = new ArrayList<Object>();
        if (inputObject instanceof BeanInvocation) {
            BeanInvocation bi = (BeanInvocation)inputObject;
            Annotation[][] annotations = bi.getMethod().getParameterAnnotations();

            List<WebParam> webParams = new ArrayList<WebParam>();
            for (Annotation[] singleParameterAnnotations : annotations) {
                for (Annotation annotation : singleParameterAnnotations) {
                    if (annotation instanceof WebParam) {
                        webParams.add((WebParam)annotation);
                    }
                }
            }

            if (webParams.size() > 0) {
                if (webParams.size() == bi.getArgs().length) {
                    int index = -1;
                    for (Object o : bi.getArgs()) {
                        if (webParams.get(++index).header()) {
                            headerParts.add(o);
                        } else {
                            bodyParts.add(o);
                        }
                    }
                } else {
                    throw new RuntimeCamelException(
                                                    "The number of bean invocation parameters does not "
                                                        + "match the number of parameters annotated with @WebParam for the method [ "
                                                        + bi.getMethod().getName() + "].");
                }
            } else {
                // try to map all objects for the body
                for (Object o : bi.getArgs()) {
                    bodyParts.add(o);
                }
            }

        } else {
View Full Code Here

                    if (exchange.getIn().getBody() == null) {
                        return null;
                    }

                    // if its a bean invocation then if it has no arguments then it should be threaded as null body allowed
                    BeanInvocation bi = exchange.getIn().getBody(BeanInvocation.class);
                    if (bi != null && (bi.getArgs() == null || bi.getArgs().length == 0 || bi.getArgs()[0] == null)) {
                        return null;
                    }
                }

                try {
View Full Code Here

                // special for files so we can work with them out of the box
                InputStream is = exchange.getContext().getTypeConverter().convertTo(InputStream.class, exchange, body);
                answer = new InputSource(is);
            } else if (body instanceof BeanInvocation) {
                // if its a null bean invocation then handle that specially
                BeanInvocation bi = exchange.getContext().getTypeConverter().convertTo(BeanInvocation.class, exchange, body);
                if (bi.getArgs() != null && bi.getArgs().length == 1 && bi.getArgs()[0] == null) {
                    // its a null argument from the bean invocation so use null as answer
                    answer = null;
                }
            } else if (body instanceof String) {
                answer = new InputSource(new StringReader((String) body));
View Full Code Here

                // special for bean invocation
                if (source == null) {
                    if (body instanceof BeanInvocation) {
                        // if its a null bean invocation then handle that
                        BeanInvocation bi = exchange.getContext().getTypeConverter().convertTo(BeanInvocation.class, body);
                        if (bi.getArgs() != null && bi.getArgs().length == 1 && bi.getArgs()[0] == null) {
                            // its a null argument from the bean invocation so use null as answer
                            source = null;
                        }
                    }
                }
View Full Code Here

    public void marshal(Exchange exchange, Object inputObject, OutputStream stream) throws IOException, SAXException {
        checkElementNameStrategy(exchange);

        String soapAction = getSoapActionFromExchange(exchange);
        if (soapAction == null && inputObject instanceof BeanInvocation) {
            BeanInvocation beanInvocation = (BeanInvocation) inputObject;
            WebMethod webMethod = beanInvocation.getMethod().getAnnotation(WebMethod.class);
            if (webMethod != null && webMethod.action() != null) {
                soapAction = webMethod.action();
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.camel.component.bean.BeanInvocation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.