/** * Creates a {@code NamespaceContext} for the specified method, based on {@link Namespaces @Namespaces} and {@link * Namespace @Namespace} annotations. * * <p>This method will search for {@link Namespaces @Namespaces} and {@link Namespace @Namespace} annotation in the * given method, its class, and its package, in reverse order. That is: package-level annotations are overridden by * class-level annotations, which again are overridden by method-level annotations. * * @param method the method to create the namespace context for * @return the namespace context */ public static NamespaceContext getNamespaceContext(Method method) { Assert.notNull(method, "'method' must not be null"); SimpleNamespaceContext namespaceContext = new SimpleNamespaceContext(); Class<?> endpointClass = method.getDeclaringClass(); Package endpointPackage = endpointClass.getPackage(); if (endpointPackage != null) { addNamespaceAnnotations(endpointPackage, namespaceContext); } addNamespaceAnnotations(endpointClass, namespaceContext); addNamespaceAnnotations(method, namespaceContext); return namespaceContext; }
public Object resolveArgument(MessageContext messageContext, MethodParameter parameter) throws TransformerException, XPathExpressionException { Class<?> parameterType = parameter.getParameterType(); QName evaluationReturnType = getReturnType(parameterType); boolean useConversionService = false; if (evaluationReturnType == null) { evaluationReturnType = XPathConstants.STRING; useConversionService = true; } XPath xpath = createXPath(); xpath.setNamespaceContext(NamespaceUtils.getNamespaceContext(parameter.getMethod())); Element rootElement = getRootElement(messageContext.getRequest().getPayloadSource()); String expression = parameter.getParameterAnnotation(XPathParam.class).value(); Object result = xpath.evaluate(expression, rootElement, evaluationReturnType); return useConversionService ? conversionService.convert(result, parameterType) : result; }
@Override public Object resolveArgument(MessageContext messageContext, MethodParameter parameter) throws TransformerException, XPathExpressionException { Class<?> parameterType = parameter.getParameterType(); QName evaluationReturnType = getReturnType(parameterType); boolean useConversionService = false; if (evaluationReturnType == null) { evaluationReturnType = XPathConstants.STRING; useConversionService = true; } XPath xpath = createXPath(); xpath.setNamespaceContext(NamespaceUtils.getNamespaceContext(parameter.getMethod())); Element rootElement = getRootElement(messageContext.getRequest().getPayloadSource()); String expression = parameter.getParameterAnnotation(XPathParam.class).value(); Object result = xpath.evaluate(expression, rootElement, evaluationReturnType); return useConversionService ? conversionService.convert(result, parameterType) : result; }
@Override public Object resolveArgument(MessageContext messageContext, MethodParameter parameter) throws TransformerException, XPathExpressionException { Class<?> parameterType = parameter.getParameterType(); QName evaluationReturnType = getReturnType(parameterType); boolean useConversionService = false; if (evaluationReturnType == null) { evaluationReturnType = XPathConstants.STRING; useConversionService = true; } XPath xpath = createXPath(); xpath.setNamespaceContext(NamespaceUtils.getNamespaceContext(parameter.getMethod())); Element rootElement = getRootElement(messageContext.getRequest().getPayloadSource()); String expression = parameter.getParameterAnnotation(XPathParam.class).value(); Object result = xpath.evaluate(expression, rootElement, evaluationReturnType); return useConversionService ? conversionService.convert(result, parameterType) : result; }
/** * Creates a {@code NamespaceContext} for the specified method, based on {@link Namespaces @Namespaces} and {@link * Namespace @Namespace} annotations. * <p/> * This method will search for {@link Namespaces @Namespaces} and {@link Namespace @Namespace} annotation in the * given method, its class, and its package, in reverse order. That is: package-level annotations are overridden by * class-level annotations, which again are overridden by method-level annotations. * * @param method the method to create the namespace context for * @return the namespace context */ public static NamespaceContext getNamespaceContext(Method method) { Assert.notNull(method, "'method' must not be null"); SimpleNamespaceContext namespaceContext = new SimpleNamespaceContext(); Class<?> endpointClass = method.getDeclaringClass(); Package endpointPackage = endpointClass.getPackage(); if (endpointPackage != null) { addNamespaceAnnotations(endpointPackage, namespaceContext); } addNamespaceAnnotations(endpointClass, namespaceContext); addNamespaceAnnotations(method, namespaceContext); return namespaceContext; }
@Override public Object resolveArgument(MessageContext messageContext, MethodParameter parameter) throws TransformerException, XPathExpressionException { Class<?> parameterType = parameter.getParameterType(); QName evaluationReturnType = getReturnType(parameterType); boolean useConversionService = false; if (evaluationReturnType == null) { evaluationReturnType = XPathConstants.STRING; useConversionService = true; } XPath xpath = createXPath(); xpath.setNamespaceContext(NamespaceUtils.getNamespaceContext(parameter.getMethod())); Element rootElement = getRootElement(messageContext.getRequest().getPayloadSource()); String expression = parameter.getParameterAnnotation(XPathParam.class).value(); Object result = xpath.evaluate(expression, rootElement, evaluationReturnType); return useConversionService ? conversionService.convert(result, parameterType) : result; }
/** * Creates a {@code NamespaceContext} for the specified method, based on {@link Namespaces @Namespaces} and {@link * Namespace @Namespace} annotations. * * <p>This method will search for {@link Namespaces @Namespaces} and {@link Namespace @Namespace} annotation in the * given method, its class, and its package, in reverse order. That is: package-level annotations are overridden by * class-level annotations, which again are overridden by method-level annotations. * * @param method the method to create the namespace context for * @return the namespace context */ public static NamespaceContext getNamespaceContext(Method method) { Assert.notNull(method, "'method' must not be null"); SimpleNamespaceContext namespaceContext = new SimpleNamespaceContext(); Class<?> endpointClass = method.getDeclaringClass(); Package endpointPackage = endpointClass.getPackage(); if (endpointPackage != null) { addNamespaceAnnotations(endpointPackage, namespaceContext); } addNamespaceAnnotations(endpointClass, namespaceContext); addNamespaceAnnotations(method, namespaceContext); return namespaceContext; }
/** * Creates a {@code NamespaceContext} for the specified method, based on {@link Namespaces @Namespaces} and {@link * Namespace @Namespace} annotations. * * <p>This method will search for {@link Namespaces @Namespaces} and {@link Namespace @Namespace} annotation in the * given method, its class, and its package, in reverse order. That is: package-level annotations are overridden by * class-level annotations, which again are overridden by method-level annotations. * * @param method the method to create the namespace context for * @return the namespace context */ public static NamespaceContext getNamespaceContext(Method method) { Assert.notNull(method, "'method' must not be null"); SimpleNamespaceContext namespaceContext = new SimpleNamespaceContext(); Class<?> endpointClass = method.getDeclaringClass(); Package endpointPackage = endpointClass.getPackage(); if (endpointPackage != null) { addNamespaceAnnotations(endpointPackage, namespaceContext); } addNamespaceAnnotations(endpointClass, namespaceContext); addNamespaceAnnotations(method, namespaceContext); return namespaceContext; }