Examples of JavaMappedReference


Examples of org.apache.tuscany.spi.implementation.java.JavaMappedReference

                                   CompositeComponent parent,
                                   SystemAtomicComponentImpl component) {
        // no proxies needed for system components
        for (ReferenceTarget target : definition.getReferenceTargets().values()) {
            String referenceName = target.getReferenceName();
            JavaMappedReference referenceDefiniton = references.get(referenceName);
            Class interfaze = referenceDefiniton.getServiceContract().getInterfaceClass();
            OutboundWire wire;
            if (referenceDefiniton.isAutowire()) {
                boolean required = referenceDefiniton.isRequired();
                wire = new SystemOutboundAutowire(referenceName, interfaze, parent, required);
            } else {
                //FIXME support multiplicity!
                assert target.getTargets().size() == 1 : "Multiplicity not yet implemented";
                QualifiedName targetName = new QualifiedName(target.getTargets().get(0).getPath());
View Full Code Here

Examples of org.apache.tuscany.spi.implementation.java.JavaMappedReference

    ReferenceProcessor processor =
        new ReferenceProcessor(new JavaInterfaceProcessorRegistryImpl());

    public void testMethodAnnotation() throws Exception {
        processor.visitMethod(null, ReferenceProcessorTestCase.Foo.class.getMethod("setFoo", Ref.class), type, null);
        JavaMappedReference reference = type.getReferences().get("foo");
        assertNotNull(reference);
        ServiceContract contract = reference.getServiceContract();
        assertEquals(Ref.class, contract.getInterfaceClass());
        assertEquals("ReferenceProcessorTestCase$Ref", contract.getInterfaceName());
    }
View Full Code Here

Examples of org.apache.tuscany.spi.implementation.java.JavaMappedReference

    }

    public void testMethodRequired() throws Exception {
        processor
            .visitMethod(null, ReferenceProcessorTestCase.Foo.class.getMethod("setFooRequired", Ref.class), type, null);
        JavaMappedReference prop = type.getReferences().get("fooRequired");
        assertNotNull(prop);
        assertTrue(prop.isRequired());
    }
View Full Code Here

Examples of org.apache.tuscany.spi.implementation.java.JavaMappedReference

        assertNotNull(type.getReferences().get("bar"));
    }

    public void testFieldAnnotation() throws Exception {
        processor.visitField(null, ReferenceProcessorTestCase.Foo.class.getDeclaredField("baz"), type, null);
        JavaMappedReference reference = type.getReferences().get("baz");
        assertNotNull(reference);
        ServiceContract contract = reference.getServiceContract();
        assertEquals(Ref.class, contract.getInterfaceClass());
        assertEquals("ReferenceProcessorTestCase$Ref", contract.getInterfaceName());
    }
View Full Code Here

Examples of org.apache.tuscany.spi.implementation.java.JavaMappedReference

        assertEquals("ReferenceProcessorTestCase$Ref", contract.getInterfaceName());
    }

    public void testFieldRequired() throws Exception {
        processor.visitField(null, ReferenceProcessorTestCase.Foo.class.getDeclaredField("bazRequired"), type, null);
        JavaMappedReference prop = type.getReferences().get("bazRequired");
        assertNotNull(prop);
        assertTrue(prop.isRequired());
    }
View Full Code Here

Examples of org.apache.tuscany.spi.implementation.java.JavaMappedReference

        CompositeComponent parent = new CompositeComponentImpl(null, null, null, null);

        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> sourceType =
            new PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
        sourceType.setImplementationScope(Scope.MODULE);
        JavaMappedReference reference = new JavaMappedReference();
        reference.setName("target");
        reference.setMember(SourceImpl.class.getMethod("setTarget", Target.class));
        sourceType.add(reference);

        ServiceContract<?> sourceContract = new JavaServiceContract(Source.class);
        JavaMappedService sourceServiceDefinition = new JavaMappedService();
        sourceServiceDefinition.setName("Source");
View Full Code Here

Examples of org.apache.tuscany.spi.implementation.java.JavaMappedReference

        Class<?> param,
        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
        List<String> injectionNames) throws InvalidAutowireException, InvalidConstructorException {
        // the param is marked as an autowire
        Autowire autowireAnnot = (Autowire) annot;
        JavaMappedReference reference = new JavaMappedReference();
        reference.setAutowire(true);
        String name = autowireAnnot.name();
        if (name == null || name.length() == 0) {
            if (constructorNames.length > 1 && (constructorNames.length < pos + 1 || constructorNames[pos] == null)) {
                throw new InvalidAutowireException("Names in @Constructor and autowire parameter do not match at "
                    + (pos + 1));
            } else if (constructorNames.length == 1 && constructorNames[0].length() == 0) {
                // special case when @Constructor present with all autowire params not specifying any name
                name = param.getName() + String.valueOf(pos);
            } else if (constructorNames.length == 1
                && (constructorNames.length < pos + 1 || constructorNames[pos] == null)) {
                throw new InvalidAutowireException("Names in @Constructor and autowire parameter do not match at "
                    + (pos + 1));
            } else if (constructorNames.length == 1 && constructorNames[0].length() > 0) {
                name = constructorNames[pos];
            } else if (constructorNames.length == 0 || constructorNames[pos].length() == 0) {
                name = param.getName() + String.valueOf(pos);
            } else {
                name = constructorNames[pos];
            }
        } else if (pos < constructorNames.length && constructorNames[pos] != null
            && constructorNames[pos].length() != 0 && !name.equals(constructorNames[pos])) {
            throw new InvalidConstructorException("Name specified by @Constructor does not match autowire name at "
                + (pos + 1));
        }
        reference.setName(name);

        reference.setRequired(autowireAnnot.required());

        ServiceContract<?> contract = new JavaServiceContract();
        contract.setInterfaceClass(param);
        reference.setServiceContract(contract);
        type.getReferences().put(name, reference);
        addName(injectionNames, pos, name);
    }
View Full Code Here

Examples of org.apache.tuscany.spi.implementation.java.JavaMappedReference

        List<String> explicitNames) throws ProcessingException {

        // TODO multiplicity
        // the param is marked as a reference
        Reference refAnnotation = (Reference) annot;
        JavaMappedReference reference = new JavaMappedReference();
        String name = refAnnotation.name();
        if (name == null || name.length() == 0) {
            if (constructorNames.length < pos + 1 || constructorNames[pos] == null
                || constructorNames[pos].length() == 0) {
                throw new InvalidReferenceException("No name specified for reference parameter " + (pos + 1));
            }
            name = constructorNames[pos];
        } else if (pos < constructorNames.length && constructorNames[pos] != null
            && constructorNames[pos].length() != 0 && !name.equals(constructorNames[pos])) {
            throw new InvalidConstructorException("Name specified by @Constructor does not match reference name at "
                + (pos + 1));
        }
        if (type.getReferences().get(name) != null) {
            throw new DuplicateReferenceException(name);
        }
        reference.setName(name);
        reference.setRequired(refAnnotation.required());
        try {
            ServiceContract<?> contract = registry.introspect(param);
            reference.setServiceContract(contract);
        } catch (InvalidServiceContractException e) {
            throw new ProcessingException(e);
        }
        type.getReferences().put(name, reference);
        addName(explicitNames, pos, name);
View Full Code Here

Examples of org.apache.tuscany.spi.implementation.java.JavaMappedReference

        addName(explicitNames, pos, name);
    }

    public JavaMappedReference createReference(String name, Member member, Class<?> paramType)
        throws ProcessingException {
        JavaMappedReference reference = new JavaMappedReference();
        reference.setName(name);
        reference.setMember(member);
        reference.setRequired(false);
        ServiceContract contract = null;
        try {
            contract = registry.introspect(paramType);
        } catch (InvalidServiceContractException e1) {
            throw new ProcessingException(e1);
        }
        try {
            processCallback(paramType, contract);
        } catch (IllegalCallbackException e) {
            throw new ProcessingException(e);
        }
        reference.setServiceContract(contract);
        return reference;
    }
View Full Code Here

Examples of org.apache.tuscany.spi.implementation.java.JavaMappedReference

        }
        if (type.getReferences().get(name) != null) {
            throw new DuplicateReferenceException(name);
        }

        JavaMappedReference reference = new JavaMappedReference();
        reference.setMember(method);
        reference.setAutowire(isAutowire);
        reference.setRequired(required);
        reference.setName(name);
        ServiceContract contract;
        try {
            contract = regsitry.introspect(method.getParameterTypes()[0]);
        } catch (InvalidServiceContractException e) {
            throw new ProcessingException(e);
        }
        reference.setServiceContract(contract);
        type.getReferences().put(name, reference);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.