Package org.apache.tuscany.sca.databinding

Examples of org.apache.tuscany.sca.databinding.TransformationException


    public OMElement transform(Object source, TransformationContext context) throws TransformationException {
        JAXBContext jaxbContext;
        try {
            jaxbContext = JAXBContextHelper.createJAXBContext(context, true);
        } catch (JAXBException e) {
            throw new TransformationException(e);
        }
        Object element = JAXBContextHelper.createJAXBElement(jaxbContext, context.getTargetDataType(), source);
        QName name = jaxbContext.createJAXBIntrospector().getElementName(element);
        JAXBDataSource dataSource = new JAXBDataSource(element, jaxbContext);
        OMElement omElement = AxiomHelper.createOMElement(factory, name, dataSource);
View Full Code Here


        return cache.getJAXBContext(cls);
    }

    public static JAXBContext createJAXBContext(TransformationContext tContext, boolean source) throws JAXBException {
        if (tContext == null)
            throw new TransformationException("JAXB context is not set for the transformation.");

        // TODO: [rfeng] Need to figure out what's the best granularity to create the JAXBContext
        // per interface, operation or parameter
        Operation op = source ? tContext.getSourceOperation() : tContext.getTargetOperation();
        if (op != null) {
View Full Code Here

                if (refType.isAssignableFrom(CallableReferenceExt.class)) {
                    implType = CallableReferenceExt.class;
                } else if (refType.isAssignableFrom(ServiceReferenceExt.class)) {
                    implType = ServiceReferenceExt.class;
                } else {  
                    throw new TransformationException("Unrecognized transformation target type");
                }
                Constructor constructor = implType.getConstructor(new Class[] {XMLStreamReader.class});
                return (CallableReference)constructor.newInstance(new Object[] {source});
            } else {
                return null;
            }
        } catch (Exception e) {
            throw new TransformationException(e);
        }
    }
View Full Code Here

                    return;
                }
            }
            source.next();
        }
        throw new TransformationException("<composite> element not found");
    }
View Full Code Here

    private List<Transformer> getTransformerChain(DataType sourceDataType, DataType targetDataType) {
        String sourceId = sourceDataType.getDataBinding();
        String targetId = targetDataType.getDataBinding();
        List<Transformer> path = transformers.getTransformerChain(sourceId, targetId);
        if (path == null) {
            TransformationException ex =
                new TransformationException("No path found for the transformation: " + sourceId + "->" + targetId);
            ex.setSourceDataBinding(sourceId);
            ex.setTargetDataBinding(targetId);
            throw ex;
        }
        return path;
    }
View Full Code Here

                    }
                    return JAXBContextHelper.createReturnValue(jaxbContext, context.getTargetDataType(), result);
                }
            });
        } catch (PrivilegedActionException e) {
            throw new TransformationException(e.getException());
        }
    }
View Full Code Here

    public OMElement transform(Object source, TransformationContext context) throws TransformationException {
        JAXBContext jaxbContext;
        try {
            jaxbContext = JAXBContextHelper.createJAXBContext(context, true);
        } catch (JAXBException e) {
            throw new TransformationException(e);
        }
        Object element = JAXBContextHelper.createJAXBElement(jaxbContext, context.getTargetDataType(), source);
        QName name = jaxbContext.createJAXBIntrospector().getElementName(element);
        JAXBDataSource dataSource = new JAXBDataSource(element, jaxbContext);
        OMElement omElement = AxiomHelper.createOMElement(factory, name, dataSource);
View Full Code Here

        if (dataBindingId != null) {
            DataBinding dataBinding = mediator.getDataBindings().getDataBinding(dataBindingId);
            wrapperHandler = dataBinding == null ? null : dataBinding.getWrapperHandler();
        }
        if (wrapperHandler == null && required) {
            throw new TransformationException("No wrapper handler is provided for databinding: " + dataBindingId);
        }
        return wrapperHandler;
    }
View Full Code Here

                // FIXME: Do we want to handle wrapped to wrapped?
                return mediator.mediate(response, sourceType.getLogical(), targetType.getLogical(), context
                    .getMetadata());
            }
        } catch (Exception e) {
            throw new TransformationException(e);
        }
    }
View Full Code Here

                        .getMetadata());
                Array.set(targetArray, i, targetItem);
            }
            return targetArray;
        } catch (Exception e) {
            throw new TransformationException(e);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.databinding.TransformationException

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.