Package org.apache.tuscany.sca.interfacedef

Examples of org.apache.tuscany.sca.interfacedef.DataType


        final Class<?> cls = exceptionType.getPhysical();
        if (cls == FaultException.class) {
            return true;
        }
        DataType faultType = (DataType)exceptionType.getLogical();
        Class<?> faultBean = null;
        final WebFault fault = cls.getAnnotation(WebFault.class);
        if (fault != null) {
            if (!"".equals(fault.name()) || !"".equals(fault.targetNamespace())) {
                QName faultQName = ((XMLType)faultType.getLogical()).getElementName();
                String faultNS =
                    "".equals(fault.targetNamespace()) ? faultQName.getNamespaceURI() : fault.targetNamespace();
                String faultLocal = "".equals(fault.name()) ? faultQName.getLocalPart() : fault.name();
                faultName = new QName(faultNS, faultLocal);
                XMLType xmlType = new XMLType(faultName, null);
                faultType.setLogical(xmlType);
            }
            if (!"".equals(fault.faultBean())) {
                faultBean = AccessController.doPrivileged(new PrivilegedAction<Class<?>>() {
                    public Class<?> run() {
                        try {
                            return Class.forName(fault.faultBean(), false, cls.getClassLoader());
                        } catch (ClassNotFoundException e) {
                            throw new ServiceRuntimeException(e);
                        }
                    }
                });
            } else {
                Method m;
                try {
                    m = cls.getMethod("getFaultInfo", (Class[])null);
                    faultBean = m.getReturnType();
                } catch (NoSuchMethodException e) {
                    // Ignore
                }
            }
        }

        if (faultBean == null) {
            final String faultBeanClassName = CodeGenerationHelper.getPackagePrefix(cls) + cls.getSimpleName() + "Bean";
            final QName qname = faultName;
            faultType = AccessController.doPrivileged(new PrivilegedAction<DataType<XMLType>>() {
                public DataType<XMLType> run() {
                    try {
                        Class<?> faultBean = Class.forName(faultBeanClassName, false, cls.getClassLoader());
                        return new DataTypeImpl<XMLType>(faultBean, new XMLType(qname, qname));
                    } catch (ClassNotFoundException e) {
                        if (generatingFaultBean) {
                            Class<? extends Throwable> t = (Class<? extends Throwable>)cls;
                            ClassLoader parent =
                                operation == null ? t.getClassLoader() : ((JavaInterface)operation.getInterface())
                                    .getJavaClass().getClassLoader();
                            GeneratedClassLoader cl = new GeneratedClassLoader(parent);
                            GeneratedDataTypeImpl dt = new GeneratedDataTypeImpl(xmlAdapterExtensionPoint, t, cl);
                            return dt;
                        } else {
                            return new DataTypeImpl<XMLType>(cls, new XMLType(qname, qname));
                        }
                    }
                }
            });
        } else {
            faultType.setDataBinding(null);
            faultType.setGenericType(faultBean);
            faultType.setPhysical(faultBean);
        }

        // TODO: Use the databinding framework to introspect the fault bean class
        if (faultType.getDataBinding() == null && dataBindingExtensionPoint != null) {
            faultBean = faultType.getPhysical();
            result =
                dataBindingExtensionPoint.introspectType(faultType, operation);
        }
        ((DataType) exceptionType).setLogical(faultType);

        /*
         The introspection of the fault DT may not have calculated the correct element name,
         though we may have already done this in this method.  Let's look at the DataType now
         that introspection is done, and, if it has an XMLType, let's set the element to the
         'faultName' if we calculated one.
         */
        if ((faultName != null) && (faultType.getLogical() instanceof XMLType)) {
            XMLType faultTypeXML = (XMLType)faultType.getLogical();
            // The element name (if set) should match the fault name
            faultTypeXML.setElementName(faultName);
        }

        return result;
View Full Code Here


        Class<?> physical = dataType.getPhysical();
        if (!physical.isArray() || physical == byte[].class) {
            return false;
        }
        Class<?> componentType = physical.getComponentType();
        DataType logical = new DataTypeImpl(componentType, dataType.getLogical());
        introspectType(logical, operation);
        dataType.setDataBinding("java:array");
        dataType.setLogical(logical);
        return true;
    }
View Full Code Here

        return true;
    }

    public DataType introspectType(Object value, Operation operation) {
        loadDataBindings();
        DataType dataType = null;
        for (DataBinding binding : databindings) {
            // don't introspect for JavaBeansDatabinding as all javatypes will
            // anyways match to its basetype
            // which is java.lang.Object. Default to this only if no databinding
            // results
View Full Code Here

            if (et.getPhysical().isInstance(fault)) {
                Throwable ex = (Throwable)fault;
                DataType<DataType> exType =
                    new DataTypeImpl<DataType>(ex.getClass(), new DataTypeImpl<XMLType>(ex.getClass(), XMLType.UNKNOWN));
                faultExceptionMapper.introspectFaultDataType(exType, operation, false);
                DataType faultType = exType.getLogical();
                Object faultInfo = faultExceptionMapper.getFaultInfo(ex, faultType.getPhysical(), operation);
                faultInfo = copy(faultInfo, dataBindings.getDataBinding(faultType.getDataBinding()), faultType);
                fault = faultExceptionMapper.wrapFaultInfo(exType, ex.getMessage(), faultInfo, ex.getCause(), operation);
                return fault;
            }
        }
        return fault;
View Full Code Here

        if (source.isWrapperStyle() != target.isWrapperStyle()) {
            return true;
        }

        // Check output type
        DataType sourceOutputType = source.getOutputType();
        DataType targetOutputType = target.getOutputType();

        // Note the target output type is now the source for checking
        // compatibility
        if (isTransformationRequired(targetOutputType, sourceOutputType)) {
            return true;
View Full Code Here

                // If the result is from an InvocationTargetException look at
                // the actual cause.
                if (result instanceof InvocationTargetException) {
                    result = ((InvocationTargetException)result).getCause();
                }
                DataType targetDataType = null;
                for (DataType exType : targetOperation.getFaultTypes()) {
                    if (((Class)exType.getPhysical()).isInstance(result)) {
                        if (result instanceof FaultException) {
                            DataType faultType = (DataType)exType.getLogical();
                            if (((FaultException)result).isMatchingType(faultType.getLogical())) {
                                targetDataType = exType;
                                break;
                            }
                        } else {
                            targetDataType = exType;
                            break;
                        }
                    }
                }

                /*
                if (targetDataType == null) {
                    // Not a business exception
                    return resultMsg;
                }
                */

                DataType targetFaultType = getFaultType(targetDataType);
                if (targetFaultType == null) {
                    // No matching fault type, it's a system exception
                    Throwable cause = (Throwable) result;
                    throw new ServiceRuntimeException(cause);
                }

                // FIXME: How to match a source fault type to a target fault
                // type?
                DataType sourceDataType = null;
                DataType sourceFaultType = null;
                for (DataType exType : sourceOperation.getFaultTypes()) {
                    DataType faultType = getFaultType(exType);
                    // Match by the QName (XSD element) of the fault type
                    if (faultType != null && typesMatch(targetFaultType.getLogical(), faultType.getLogical())) {
                        sourceDataType = exType;
                        sourceFaultType = faultType;
                        break;
                    }
                }
View Full Code Here

                                                              DataType targetDataType,
                                                              int size,
                                                              int index,
                                                              Transformer transformer,
                                                              Map<String, Object> metadata) {
        DataType sourceType =
            (index == 0) ? sourceDataType : new DataTypeImpl<Object>(transformer.getSourceDataBinding(), Object.class,
                                                                     sourceDataType.getLogical());
        DataType targetType =
            (index == size - 1) ? targetDataType : new DataTypeImpl<Object>(transformer.getTargetDataBinding(),
                                                                            Object.class, targetDataType.getLogical());
       
        //FIXME The ClassLoader should be passed in
        // Allow privileged access to get ClassLoader. Requires RuntimePermission in security
View Full Code Here

        mediator = new MediatorImpl(dataBindingRegistry, registry);
    }

    private TransformationContext createTransformationContext(Class sourceType, Class targetType) {
        TransformationContext context = new TransformationContextImpl();
        DataType sourceDataType = new DataTypeImpl<Class>(sourceType.getName(), sourceType, sourceType);
        DataType targetDataType = new DataTypeImpl<Class>(targetType.getName(), targetType, targetType);
        context.setSourceDataType(sourceDataType);
        context.setTargetDataType(targetDataType);
        return context;
    }
View Full Code Here

        }
        copy.faultTypes = clonedFaultTypes;

        List<DataType> clonedLogicalTypes = new ArrayList<DataType>();
        for (DataType t : inputType.getLogical()) {
            DataType type = (DataType) t.clone();
            clonedLogicalTypes.add(type);
        }
        DataType<List<DataType>> clonedInputType =
            new DataTypeImpl<List<DataType>>(inputType.getPhysical(), clonedLogicalTypes);
        clonedInputType.setDataBinding(inputType.getDataBinding());
View Full Code Here

                        if (d.getDataBinding() == null) {
                            d.setDataBinding(dataBinding);
                        }
                    }
                }
                DataType outputType = op.getOutputType();
                if (outputType != null && outputType.getDataBinding() == null) {
                    outputType.setDataBinding(dataBinding);
                }
                List<DataType> faultTypes = op.getFaultTypes();
                if (faultTypes != null) {
                    for (DataType d : faultTypes) {
                        if (d.getDataBinding() == null) {
                            d.setDataBinding(dataBinding);
                        }
                        DataType ft = (DataType) d.getLogical();
                        if (ft.getDataBinding() == null) {
                            ft.setDataBinding(dataBinding);
                        }

                    }
                }
                if (op.isWrapperStyle()) {
                    WrapperInfo wrapper = op.getWrapper();
                    if (wrapper != null) {
                        DataType<List<DataType>> unwrappedInputType = wrapper.getUnwrappedInputType();
                        if (unwrappedInputType != null) {
                            for (DataType d : unwrappedInputType.getLogical()) {
                                if (d.getDataBinding() == null) {
                                    d.setDataBinding(dataBinding);
                                }
                            }
                        }
                        DataType unwrappedOutputType = wrapper.getUnwrappedOutputType();
                        if (unwrappedOutputType != null && unwrappedOutputType.getDataBinding() == null) {
                            unwrappedOutputType.setDataBinding(dataBinding);
                        }
                    }
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.interfacedef.DataType

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.