Package org.apache.tuscany.sca.interfacedef

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


        mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false);
    }

    @Test
    public void testIncompatibleInputTypes() throws Exception {
        InterfaceContract source = new MockContract("FooContract");
        List<DataType> sourceInputTypes = new ArrayList<DataType>();
        sourceInputTypes.add(new DataTypeImpl<Type>(Integer.class, Integer.class));
        DataType<List<DataType>> inputType = new DataTypeImpl<List<DataType>>(String.class, sourceInputTypes);
        Operation opSource1 = newOperation("op1");
        opSource1.setInputType(inputType);
        Map<String, Operation> sourceOperations = new HashMap<String, Operation>();
        sourceOperations.put("op1", opSource1);
        source.getInterface().getOperations().addAll(sourceOperations.values());

        InterfaceContract target = new MockContract("FooContract");
        List<DataType> targetInputTypes = new ArrayList<DataType>();
        targetInputTypes.add(new DataTypeImpl<Type>(String.class, String.class));
        DataType<List<DataType>> targetInputType = new DataTypeImpl<List<DataType>>(String.class, targetInputTypes);

        Operation opTarget = newOperation("op1");
        opTarget.setInputType(targetInputType);
        Map<String, Operation> targetOperations = new HashMap<String, Operation>();
        targetOperations.put("op1", opTarget);
        target.getInterface().getOperations().addAll(targetOperations.values());
        try {
            mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false);
            fail();
        } catch (IncompatibleInterfaceContractException e) {
            // expected
View Full Code Here


        // wireService.checkCompatibility(source, target, false);
    }

    @Test
    public void testOutputTypes() throws Exception {
        InterfaceContract source = new MockContract("FooContract");
        DataType sourceStringType =  new DataTypeImpl<Type>(String.class, String.class);
        ArrayList sourceTypes = new ArrayList();
        sourceTypes.add(sourceStringType);
        DataType sourceOutputType = new DataTypeImpl(Object[].class, sourceTypes);
        Operation opSource1 = newOperation("op1");
        opSource1.setOutputType(sourceOutputType);
        Map<String, Operation> sourceOperations = new HashMap<String, Operation>();
        sourceOperations.put("op1", opSource1);
        source.getInterface().getOperations().addAll(sourceOperations.values());

        InterfaceContract target = new MockContract("FooContract");
        DataType stringType = new DataTypeImpl<Type>(String.class, String.class);
        ArrayList types = new ArrayList();
        types.add(stringType);
        DataType targetOutputType = new DataTypeImpl(Object[].class, types);
        Operation opTarget = newOperation("op1");
        opTarget.setOutputType(targetOutputType);
        Map<String, Operation> targetOperations = new HashMap<String, Operation>();
        targetOperations.put("op1", opTarget);
        target.getInterface().getOperations().addAll(targetOperations.values());
        mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false);
    }
View Full Code Here

        // wireService.checkCompatibility(source, target, false);
    }

    @Test
    public void testIncompatibleOutputTypes() throws Exception {
        InterfaceContract source = new MockContract("FooContract");
        DataType sourceType = new DataTypeImpl<Type>(String.class, String.class);
        ArrayList sourceTypes = new ArrayList();
        sourceTypes.add(sourceType);
        DataType sourceOutputType = new DataTypeImpl(Object[].class, sourceTypes);
        Operation opSource1 = newOperation("op1");
        opSource1.setOutputType(sourceOutputType);
        Map<String, Operation> sourceOperations = new HashMap<String, Operation>();
        sourceOperations.put("op1", opSource1);
        source.getInterface().getOperations().addAll(sourceOperations.values());

        InterfaceContract target = new MockContract("FooContract");
        DataType targetType = new DataTypeImpl<Type>(Integer.class, Integer.class);
        ArrayList targetTypes = new ArrayList();
        targetTypes.add(targetType);
        DataType targetOutputType = new DataTypeImpl(Object[].class, targetTypes);
        Operation opTarget = newOperation("op1");
        opTarget.setOutputType(targetOutputType);
        Map<String, Operation> targetOperations = new HashMap<String, Operation>();
        targetOperations.put("op1", opTarget);
        target.getInterface().getOperations().addAll(targetOperations.values());
        try {
            mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false);
            fail();
        } catch (IncompatibleInterfaceContractException e) {
            // expected
View Full Code Here

        }
    }

    @Test
    public void testFaultTypes() throws Exception {
        InterfaceContract source = new MockContract("FooContract");
        DataType sourceFaultType = new DataTypeImpl<Type>(String.class, String.class);
        List<DataType> sourceFaultTypes = new ArrayList<DataType>();
        sourceFaultTypes.add(0, sourceFaultType);
        Operation opSource1 = newOperation("op1");
        opSource1.setFaultTypes(sourceFaultTypes);
        Map<String, Operation> sourceOperations = new HashMap<String, Operation>();
        sourceOperations.put("op1", opSource1);
        source.getInterface().getOperations().addAll(sourceOperations.values());

        InterfaceContract target = new MockContract("FooContract");
        DataType targetFaultType = new DataTypeImpl<Type>(String.class, String.class);
        List<DataType> targetFaultTypes = new ArrayList<DataType>();
        targetFaultTypes.add(0, targetFaultType);

        Operation opTarget = newOperation("op1");
        opTarget.setFaultTypes(targetFaultTypes);
        Map<String, Operation> targetOperations = new HashMap<String, Operation>();
        targetOperations.put("op1", opTarget);
        target.getInterface().getOperations().addAll(targetOperations.values());
        mapper.checkCompatibility(source, target, Compatibility.SUBSET, false, false);
    }
View Full Code Here

        if (isCallback && callInterface == null)
            return this; // already a unidirectional callback interface contract

        // contract is bidirectional, so create a new unidirectional contract       
        try {
            InterfaceContract newContract = clone();
            if (!isCallback) {
                newContract.setCallbackInterface(null); // create unidirectional forward interface contract
            } else {
                newContract.setInterface(null); // create unidirectional callback interface contract
            }
            return newContract;
        } catch (CloneNotSupportedException e) {
            // will not happen
            return null;
View Full Code Here

    }

    private void init() {
        List<Service> services = implementation.getServices();
        for (Service sevice : services) {
            InterfaceContract interfaceContract = sevice.getInterfaceContract();
            //interfaceContract.getInterface().setDefaultDataBinding(ValueRepresentation.class.getName());
            setDataBinding(interfaceContract.getInterface(), false);
        }

        List<Reference> references = implementation.getReferences();
        for (Reference reference : references) {
            InterfaceContract interfaceContract = reference.getInterfaceContract();
            //interfaceContract.getInterface().setDefaultDataBinding(ValueRepresentation.class.getName());
            setDataBinding(interfaceContract.getInterface(), true);
        }
    }
View Full Code Here

            RuntimeComponentReference reference = (RuntimeComponentReference)assemblyFactory.createComponentReference();
            reference.setName("default");
            ModelFactoryExtensionPoint factories =
                runtime.getExtensionPointRegistry().getExtensionPoint(ModelFactoryExtensionPoint.class);
            JavaInterfaceFactory javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
            InterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
            interfaceContract.setInterface(javaInterfaceFactory.createJavaInterface(businessInterface));
            reference.setInterfaceContract(interfaceContract);
            component.getReferences().add(reference);
            reference.setComponent(component);
            SCABindingFactory scaBindingFactory = factories.getFactory(SCABindingFactory.class);
            SCABinding binding = scaBindingFactory.createSCABinding();
View Full Code Here

                    addInheritedPolicySets(contract.getPolicySets(), confOp.getPolicySets());
                    addInheritedPolicySets(contract.getApplicablePolicySets(), confOp.getApplicablePolicySets());
                }
                               
                // Resolve the interface contract
                InterfaceContract interfaceContract = contract.getInterfaceContract();
                if (interfaceContract != null) {
                    extensionProcessor.resolve(interfaceContract, resolver);
                }
   
                // Resolve bindings
View Full Code Here

    protected <C extends AbstractContract> void resolveAbstractContracts(List<C> contracts, ModelResolver resolver)
        throws ContributionResolveException {
        for (AbstractContract contract : contracts) {

            // Resolve the interface contract
            InterfaceContract interfaceContract = contract.getInterfaceContract();
            if (interfaceContract != null) {
                extensionProcessor.resolve(interfaceContract, resolver);
            }
        }
    }
View Full Code Here

            RuntimeComponentReference reference = (RuntimeComponentReference)assemblyFactory.createComponentReference();
            reference.setName("default");
            ModelFactoryExtensionPoint factories =
                runtime.getExtensionPointRegistry().getExtensionPoint(ModelFactoryExtensionPoint.class);
            JavaInterfaceFactory javaInterfaceFactory = factories.getFactory(JavaInterfaceFactory.class);
            InterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
            interfaceContract.setInterface(javaInterfaceFactory.createJavaInterface(businessInterface));
            reference.setInterfaceContract(interfaceContract);
            component.getReferences().add(reference);
            reference.setComponent(component);
            SCABindingFactory scaBindingFactory = factories.getFactory(SCABindingFactory.class);
            SCABinding binding = scaBindingFactory.createSCABinding();
View Full Code Here

TOP

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

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.