Package org.apache.tuscany.sca.interfacedef.java

Examples of org.apache.tuscany.sca.interfacedef.java.JavaOperation


                .getPolicySets());

            // Read intents on the service interface methods
            List<Operation> operations = javaInterface.getOperations();
            for (Operation op : operations) {
                JavaOperation operation = (JavaOperation)op;
                Method method = operation.getJavaMethod();
                if (method.getAnnotation(Requires.class) != null || method.getAnnotation(PolicySets.class) != null) {
                    readIntents(method.getAnnotation(Requires.class), op.getRequiredIntents());
                    readPolicySets(method.getAnnotation(PolicySets.class), op.getPolicySets());
                }
            }
View Full Code Here


    public List<JavaInterfaceVisitor> getInterfaceVisitors() {
        return visitors;
    }

    public JavaOperation createJavaOperation(Method method) {
        JavaOperation op =  new JavaOperationImpl();
        op.setJavaMethod(method);
        op.setName(method.getName());
        return op;
    }
View Full Code Here

                                                        "Method should not declare exceptions with an @OneWay annotation. " + method,
                                                        method);
                }
            }

            JavaOperation operation = new JavaOperationImpl();
            operation.setName(name);
           
            // Set outputType to null for void
            XMLType xmlReturnType = new XMLType(new QName(ns, "return"), null);
            DataType<XMLType> returnDataType =
                returnType == void.class ? null : new DataTypeImpl<XMLType>(UNKNOWN_DATABINDING, returnType, method
                    .getGenericReturnType(), xmlReturnType);
            List<DataType> paramDataTypes = new ArrayList<DataType>(parameterTypes.length);
            Type[] genericParamTypes = method.getGenericParameterTypes();
            for (int i = 0; i < parameterTypes.length; i++) {
                Class<?> paramType = parameterTypes[i];
                XMLType xmlParamType = new XMLType(new QName(ns, "arg" + i), null);                           
    
                DataTypeImpl<XMLType> xmlDataType = new DataTypeImpl<XMLType>(
                    UNKNOWN_DATABINDING, paramType, genericParamTypes[i],xmlParamType);
                ParameterMode mode = ParameterMode.IN;
                // Holder pattern. Physical types of Holder<T> classes are updated to <T> to aid in transformations.
                if ( Holder.class == paramType) {
                  Type firstActual = getFirstActualType( genericParamTypes[ i ] );
                  if ( firstActual != null ) {
                    xmlDataType.setPhysical( (Class<?>)firstActual );
                    mode = ParameterMode.INOUT;
                  }
                }
                paramDataTypes.add( xmlDataType);
                operation.getParameterModes().add(mode);
            }
                   
            // Fault types                                                         
            List<DataType> faultDataTypes = new ArrayList<DataType>(faultTypes.length);
            Type[] genericFaultTypes = method.getGenericExceptionTypes();
            if( method.isAnnotationPresent(AsyncFault.class) ) {
              genericFaultTypes = readAsyncGenericFaultTypes( method );
            } // end if
            for (int i = 0; i < faultTypes.length; i++) {
                Class<?> faultType = faultTypes[i];
                // Only add checked exceptions
                // JAXWS Specification v2.1 section 3.7 says RemoteException should not be mapped
                if (Exception.class.isAssignableFrom(faultType) && (!RuntimeException.class.isAssignableFrom(faultType))
                    && (!RemoteException.class.isAssignableFrom(faultType))) {
                    XMLType xmlFaultType = new XMLType(new QName(ns, faultType.getSimpleName()), null);
                    DataType<XMLType> faultDataType =
                        new DataTypeImpl<XMLType>(UNKNOWN_DATABINDING, faultType, genericFaultTypes[i], xmlFaultType);
                    faultDataTypes.add(new DataTypeImpl<DataType>(UNKNOWN_DATABINDING, faultType, genericFaultTypes[i],
                                                                  faultDataType));
                }
            }

            DataType<List<DataType>> inputType =
                new DataTypeImpl<List<DataType>>(IDL_INPUT, Object[].class, paramDataTypes);
          
            operation.setInputType(inputType);
            operation.setOutputType(returnDataType);
            operation.setFaultTypes(faultDataTypes);
            operation.setNonBlocking(nonBlocking);
            operation.setJavaMethod(method);
            operations.add(operation);
        }
        return operations;
    }
View Full Code Here

                                         Mediator mediator) {
        super();
        this.sourceOperation = sourceOperation;
        this.targetOperation = targetOperation;
        if ( sourceOperation instanceof JavaOperation ) {
          JavaOperation javaOp = (JavaOperation) sourceOperation;
          Method sourceMethod = javaOp.getJavaMethod();
        }
        // Holder pattern. In order to perform data mediation on Holder return types, it is
        // necessary to set up a data transformation on the Holder<T> class T. on return.
        DataType<DataType> returnTargetType = getFirstHolderType( sourceOperation.getInputType() );
        if ( returnTargetType != null ) {
View Full Code Here

     * @return - the synchronous form of the operation - for an input operation that is not async server in form, this
     *           method simply returns the original operation unchanged
     */
    private Operation getSyncFormOfOperation( JavaOperation operation ) {
      if( isAsyncServerOperation( operation ) ) {
            JavaOperation syncOperation = new JavaOperationImpl();
            String opName = operation.getName().substring(0, operation.getName().length() - 5 );
         
            // Prepare the list of equivalent input parameters, which simply excludes the (final) DispatchResponse object
            // and the equivalent return parameter, which is the (generic) type from the DispatchResponse object
            DataType<List<DataType>> requestParams = operation.getInputType();

          DataType<List<DataType>> inputType = prepareSyncInputParams( requestParams );
            DataType<XMLType> returnDataType = prepareSyncReturnParam( requestParams );
            List<DataType> faultDataTypes = prepareSyncFaults( operation );
         
          syncOperation.setName(opName);
          syncOperation.setAsyncServer(true);
            syncOperation.setInputType(inputType);
            syncOperation.setOutputType(returnDataType);
            syncOperation.setFaultTypes(faultDataTypes);
            syncOperation.setNonBlocking(operation.isNonBlocking());
            syncOperation.setJavaMethod(operation.getJavaMethod());
            syncOperation.setInterface(this);
        return syncOperation;
      } else {
        // If it's not Async form, then it's a synchronous operation
        return operation;
      } // end if
View Full Code Here

            dataBindingId = dataBinding.value();
            wrapperStyle = dataBinding.wrapped();
        }

        for (Operation op : javaInterface.getOperations()) {
            JavaOperation operation = (JavaOperation) op;
            // In the case of @WebMethod, the method name can be different from the operation name

            if (dataBindingId != null) {
                op.setDataBinding(dataBindingId);
                op.setWrapperStyle(wrapperStyle);
            }

            Method method = operation.getJavaMethod();

            DataBinding methodDataBinding = clazz.getAnnotation(DataBinding.class);
            if (methodDataBinding == null) {
                methodDataBinding = dataBinding;
            }
            dataBindingId = null;
            wrapperStyle = false;
            if (dataBinding != null) {
                dataBindingId = dataBinding.value();
                wrapperStyle = dataBinding.wrapped();
                operation.setDataBinding(dataBindingId);
                operation.setWrapperStyle(wrapperStyle);
            }

            // FIXME: We need a better way to identify simple java types
            int i = 0;
            for (org.apache.tuscany.sca.interfacedef.DataType<?> d : operation.getInputType().getLogical()) {
                if (d.getDataBinding() == null) {
                    d.setDataBinding(dataBindingId);
                }
                for (Annotation a : method.getParameterAnnotations()[i]) {
                    if (a.annotationType() == org.apache.tuscany.sca.databinding.annotation.DataType.class) {
                        String value = ((org.apache.tuscany.sca.databinding.annotation.DataType)a).value();
                        d.setDataBinding(value);
                    }
                }
                dataBindingRegistry.introspectType(d, operation);
                i++;
            }
            if (operation.getOutputType() != null) {
                DataType<?> d = operation.getOutputType();
                if (d.getDataBinding() == null) {
                    d.setDataBinding(dataBindingId);
                }
                org.apache.tuscany.sca.databinding.annotation.DataType dt =
                    method.getAnnotation(org.apache.tuscany.sca.databinding.annotation.DataType.class);
View Full Code Here

            List<Operation> operations =
                filterOperationsByHttpMethod(interfaceContract, bindingContext.getHttpRequest().getMethod());

            Operation operation = findOperation(path, operations);

            final JavaOperation javaOperation = (JavaOperation)operation;
            final Method method = javaOperation.getJavaMethod();

            if (path != null && path.length() > 0) {
                if (method.getAnnotation(Path.class) != null) {
                    msg.setBody(new Object[] {path});
                }
View Full Code Here

     */
    private Operation findOperation(String path, List<Operation> operations) {
        Operation operation = null;

        for (Operation op : operations) {
            final JavaOperation javaOperation = (JavaOperation)op;
            final Method method = javaOperation.getJavaMethod();

            if (path != null && path.length() > 0) {
                if (method.getAnnotation(Path.class) != null) {
                    operation = op;
                    break;
View Full Code Here

     */
    // FIXME: Should it be in the InterfaceContractMapper?
    @SuppressWarnings("unchecked")
    private static boolean match(Operation operation, Method method) {
        if (operation instanceof JavaOperation) {
            JavaOperation javaOp = (JavaOperation)operation;
            Method m = javaOp.getJavaMethod();
            if (!method.getName().equals(m.getName())) {
                return false;
            }
            if (method.equals(m)) {
                return true;
View Full Code Here

            if (operation == null) {
                throw new RuntimeException("Invalid Operation '" + operationName + "'" );
            }

            final JavaOperation javaOperation = (JavaOperation)operation;
            final Method method = javaOperation.getJavaMethod();

            List<Object> messageParameters = new ArrayList<Object>();
            for(int i=0; i<method.getParameterTypes().length; i++) {
                for(Annotation annotation : method.getParameterAnnotations()[i]) {
                    if (annotation instanceof QueryParam) {
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.interfacedef.java.JavaOperation

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.