Package org.mule.api.transformer

Examples of org.mule.api.transformer.TransformerException


                return xpath.evaluate(expression, src, resultType);
            }
        }
        catch (XPathExpressionException e)
        {
            throw new TransformerException(this, e);
        }
    }
View Full Code Here


                return convertToText(src, encoding);
            }
        }
        catch (Exception e)
        {
            throw new TransformerException(this, e);
        }
    }
View Full Code Here

            return holder.getResultObject();
        }
        catch (Exception e)
        {
            throw new TransformerException(this, e);
        }
    }
View Full Code Here

        }

        public void error(javax.xml.transform.TransformerException exception)
                throws javax.xml.transform.TransformerException
        {
            e = new TransformerException(trans, exception);
        }
View Full Code Here

        }

        public void fatalError(javax.xml.transform.TransformerException exception)
                throws javax.xml.transform.TransformerException
        {
            e = new TransformerException(trans, exception);
        }
View Full Code Here

                return trans;
            }
        }
        else
        {
            throw new TransformerException(CoreMessages.noTransformerFoundForMessage(source, result));
        }
    }
View Full Code Here

                    return trans;
                }
            }
            catch (ResolverException e)
            {
                throw new TransformerException(CoreMessages.noTransformerFoundForMessage(source, result), e);
            }
        }
        return null;
    }
View Full Code Here

            {
                m = component.getClass().getSuperclass().getMethod(method.getName(), method.getParameterTypes());
            }
            catch (NoSuchMethodException e)
            {
                throw new TransformerException(CoreMessages.createStaticMessage(e.getMessage()), e);
            }
        }

        if (AnnotationUtils.getParamAnnotationsWithMeta(m, Evaluator.class).size() > 0)
        {
View Full Code Here

    public Object doTransform(Object src, String outputEncoding) throws TransformerException
    {
        double data = NumberUtils.toDouble(src);
        if (data == NumberUtils.DOUBLE_ERROR)
        {
            throw new TransformerException(MessageFactory.createStaticMessage("Unable to convert message to double: " + src));
        }
       
        double result;
        if (operation.equalsIgnoreCase("add"))
        {
            result = data + factor;
        }
        else if (operation.equalsIgnoreCase("subtract"))
        {
            result = data - factor;
        }
        else if (operation.equalsIgnoreCase("multiply"))
        {
            result = data * factor;
        }
        else if (operation.equalsIgnoreCase("divide"))
        {
            result = data / factor;
        }
        else
        {
            throw new TransformerException(MessageFactory.createStaticMessage("Operation " + operation + " not recognized"));
        }
       
        // no auto-boxing
        return new Double(result);
    }
View Full Code Here

            {
                firstArg = message.getPayload(DataTypeFactory.create(transformMethod.getParameterTypes()[0]));
            }
            catch (TransformerException e)
            {
                throw new TransformerException(e.getI18nMessage(), this, e);
            }
        }

        //if the source is annotated, the paramTransformer will figure out the first parameter
        if (!sourceAnnotated)
        {
            params[0] = firstArg;
            if (paramCounter == 0)
            {
                paramCounter++;
            }
        }
        //Lets see if there are any context objects to inject (i.e. JAXB)
        if (paramCounter < transformMethod.getParameterTypes().length)
        {
            for (int i = paramCounter; i < transformMethod.getParameterTypes().length; i++)
            {
                Object o;
                Class<?> type = transformMethod.getParameterTypes()[i];
                o = cachedObjects.get(type);
                if (o != null)
                {
                    params[paramCounter++] = o;
                    continue;
                }
                DataType<?> source = DataTypeFactory.createFromParameterType(transformMethod, 0);

                for (TransformerArgumentResolver resolver : resolvers)
                {
                    try
                    {
                        o = resolver.resolve(type, source, this.returnType, muleContext);
                        if (o != null)
                        {
                            params[paramCounter++] = o;
                            cachedObjects.put(type, o);
                            break;
                        }
                    }
                    catch (Exception e)
                    {
                        throw new TransformerException(this, e);
                    }

                }
                if (o == null)
                {
                    throw new IllegalArgumentException("Failed to find resolver for object type: " + type + " for transform method: " + transformMethod);
                }
            }
        }
        try
        {
            return transformMethod.invoke(proxy, params);
        }
        catch (Exception e)
        {
            e.printStackTrace();
            throw new TransformerException(this, e);
        }
    }
View Full Code Here

TOP

Related Classes of org.mule.api.transformer.TransformerException

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.