Package org.apache.servicemix.expression

Examples of org.apache.servicemix.expression.Expression


        return beanInfo.createInvocation(pojo, messageExchange);
    }


    public void loadDefaultRegistry() {
        addParameterMapping(MessageExchange.class, new Expression() {
            public Object evaluate(MessageExchange messageExchange, NormalizedMessage normalizedMessage)
                throws MessagingException {
                return messageExchange;
            }
        });

        addParameterMapping(NormalizedMessage.class, new Expression() {
            public Object evaluate(MessageExchange messageExchange, NormalizedMessage normalizedMessage)
                throws MessagingException {
                return normalizedMessage;
            }
        });

        addParameterMapping(Source.class, new Expression() {
            public Object evaluate(MessageExchange messageExchange, NormalizedMessage normalizedMessage)
                throws MessagingException {
                return normalizedMessage.getContent();
            }
        });
View Full Code Here


        Class[] parameterTypes = method.getParameterTypes();
        Annotation[][] parameterAnnotations = method.getParameterAnnotations();
        final Expression[] parameterExpressions = new Expression[parameterTypes.length];
        for (int i = 0; i < parameterTypes.length; i++) {
            Class parameterType = parameterTypes[i];
            Expression expression = createParameterUnmarshalExpression(clazz, method,
                    parameterType, parameterAnnotations[i]);
            if (expression == null) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("No expression available for method: "
                            + method.toString() + " parameter: " + i + " so ignoring method");
                }
                return;
            }
            parameterExpressions[i] = expression;
        }

        // now lets add the method to the repository
        String opName = method.getName();
        if (method.getAnnotation(Operation.class) != null) {
            String name = method.getAnnotation(Operation.class).name();
            if (name != null && name.length() > 0) {
                opName = name;
            }
        }
        Expression parametersExpression = createMethodParametersExpression(parameterExpressions);
        operations.put(opName, new MethodInfo(clazz, method, parametersExpression));
    }
View Full Code Here

        Expression parametersExpression = createMethodParametersExpression(parameterExpressions);
        operations.put(opName, new MethodInfo(clazz, method, parametersExpression));
    }

    protected Expression createMethodParametersExpression(final Expression[] parameterExpressions) {
        return new Expression() {

            public Object evaluate(MessageExchange messageExchange,
                                   NormalizedMessage normalizedMessage) throws MessagingException {
                Object[] answer = new Object[parameterExpressions.length];
                for (int i = 0; i < parameterExpressions.length; i++) {
                    Expression parameterExpression = parameterExpressions[i];
                    answer[i] = parameterExpression.evaluate(messageExchange, normalizedMessage);
                }
                return answer;
            }
        };
    }
View Full Code Here

     */
    protected Expression createParameterUnmarshalExpression(Class clazz, Method method,
                Class parameterType, Annotation[] parameterAnnotation) {
        // TODO look for a parameter annotation that converts into an expression
        for (Annotation annotation : parameterAnnotation) {
            Expression answer = createParameterUnmarshalExpressionForAnnotation(
                    clazz, method, parameterType, annotation);
            if (answer != null) {
                return answer;
            }
        }
View Full Code Here

        }
        return null;
    }

    protected Expression createContentExpression(final PojoMarshaler marshaller) {
        return new Expression() {
            public Object evaluate(MessageExchange exchange, NormalizedMessage message) throws MessagingException {
                return MessageHelper.getBody(message, marshaller);
            }
        };
    }
View Full Code Here

        Class[] parameterTypes = method.getParameterTypes();
        Annotation[][] parameterAnnotations = method.getParameterAnnotations();
        final Expression[] parameterExpressions = new Expression[parameterTypes.length];
        for (int i = 0; i < parameterTypes.length; i++) {
            Class parameterType = parameterTypes[i];
            Expression expression = createParameterUnmarshalExpression(clazz, method,
                    parameterType, parameterAnnotations[i]);
            if (expression == null) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("No expression available for method: "
                            + method.toString() + " parameter: " + i + " so ignoring method");
                }
                return;
            }
            parameterExpressions[i] = expression;
        }

        // now lets add the method to the repository
        String opName = method.getName();
        if (method.getAnnotation(Operation.class) != null) {
            String name = method.getAnnotation(Operation.class).name();
            if (name != null && name.length() > 0) {
                opName = name;
            }
        }
        Expression parametersExpression = createMethodParametersExpression(parameterExpressions);
        operations.put(opName, new MethodInfo(clazz, method, parametersExpression));
    }
View Full Code Here

        Expression parametersExpression = createMethodParametersExpression(parameterExpressions);
        operations.put(opName, new MethodInfo(clazz, method, parametersExpression));
    }

    protected Expression createMethodParametersExpression(final Expression[] parameterExpressions) {
        return new Expression() {

            public Object evaluate(MessageExchange messageExchange,
                                   NormalizedMessage normalizedMessage) throws MessagingException {
                Object[] answer = new Object[parameterExpressions.length];
                for (int i = 0; i < parameterExpressions.length; i++) {
                    Expression parameterExpression = parameterExpressions[i];
                    answer[i] = parameterExpression.evaluate(messageExchange, normalizedMessage);
                }
                return answer;
            }
        };
    }
View Full Code Here

     */
    protected Expression createParameterUnmarshalExpression(Class clazz, Method method,
                Class parameterType, Annotation[] parameterAnnotation) {
        // TODO look for a parameter annotation that converts into an expression
        for (Annotation annotation : parameterAnnotation) {
            Expression answer = createParameterUnmarshalExpressionForAnnotation(
                    clazz, method, parameterType, annotation);
            if (answer != null) {
                return answer;
            }
        }
View Full Code Here

        }
        return null;
    }

    protected Expression createContentExpression(final PojoMarshaler marshaller) {
        return new Expression() {
            public Object evaluate(MessageExchange exchange, NormalizedMessage message) throws MessagingException {
                return MessageHelper.getBody(message, marshaller);
            }
        };
    }
View Full Code Here

        return beanInfo.createInvocation(pojo, messageExchange);
    }


    protected void loadDefaultRegistry() {
        addParameterMapping(MessageExchange.class, new Expression() {
            public Object evaluate(MessageExchange messageExchange, NormalizedMessage normalizedMessage) throws MessagingException {
                return messageExchange;
            }
        });

        addParameterMapping(NormalizedMessage.class, new Expression() {
            public Object evaluate(MessageExchange messageExchange, NormalizedMessage normalizedMessage) throws MessagingException {
                return normalizedMessage;
            }
        });

        addParameterMapping(Source.class, new Expression() {
            public Object evaluate(MessageExchange messageExchange, NormalizedMessage normalizedMessage) throws MessagingException {
                return normalizedMessage.getContent();
            }
        });
    }
View Full Code Here

TOP

Related Classes of org.apache.servicemix.expression.Expression

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.