Package org.apache.tuscany.spi

Examples of org.apache.tuscany.spi.QualifiedName


        Map<Operation, InvocationChain> chains = new HashMap<Operation, InvocationChain>();
        chains.put(operation, chain);
        expectLastCall().andReturn(chains);
        OutboundWire outboundWire = createMock(OutboundWire.class);
        outboundWire.getTargetName();
        expectLastCall().andReturn(new QualifiedName("foo/bar"));
        replay(chain);
        replay(wire);
        replay(outboundWire);
        TestReference<Object> ref = new TestReference<Object>(Object.class);
        ref.setInboundWire(wire);
View Full Code Here


        for (BoundServiceDefinition<? extends Binding> serviceDefinition : componentType.getServices().values()) {
            // call back into builder registry to handle building of services
            Service service = (Service) builderRegistry.build(parent, serviceDefinition, deploymentContext);
            // wire serviceDefinition to bean invokers
            InboundWire wire = service.getInboundWire();
            QualifiedName targetName = new QualifiedName(serviceDefinition.getTarget().getPath());
            for (InboundInvocationChain chain : wire.getInvocationChains().values()) {
                // FIXME this should go to the connector and get policy and be invoked from SpringComposite.prepare()
                chain.addInterceptor(new SpringInterceptor());
                chain.setTargetInvoker(component.createTargetInvoker(targetName.getPartName(), chain.getOperation()));
            }
            component.register(service);
        }
        for (BoundReferenceDefinition<?> referenceDefinition : componentType.getReferences().values()) {
            // call back into builder registry to handle building of references
View Full Code Here

    public void testWire() throws NoSuchMethodException {
        Target target = new TargetImpl();
        SystemInboundWire inboundWire = EasyMock.createMock(SystemInboundWire.class);
        EasyMock.expect(inboundWire.getTargetService()).andReturn(target);
        EasyMock.replay(inboundWire);
        QualifiedName qName = new QualifiedName("service");
        SystemOutboundWire outboundWire = new SystemOutboundWireImpl("setTarget", qName, Target.class);
        outboundWire.setTargetWire(inboundWire);
        assertSame(outboundWire.getTargetService(), target);
        EasyMock.verify(inboundWire);
    }
View Full Code Here

                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());
                wire = new SystemOutboundWireImpl(referenceName, targetName, interfaze);
            }
            component.addOutboundWire(wire);
        }
    }
View Full Code Here

        Map<Operation<?>, OutboundInvocationChain> outboundChains =
            new HashMap<Operation<?>, OutboundInvocationChain>();
        outboundChains.put(operation, outboundChain);
        OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class);
        EasyMock.expect(outboundWire.getServiceContract()).andReturn(contract).anyTimes();
        EasyMock.expect(outboundWire.getTargetName()).andReturn(new QualifiedName("target/FooService")).anyTimes();
        EasyMock.expect(outboundWire.getInvocationChains()).andReturn(outboundChains).anyTimes();
        EasyMock.replay(outboundWire);

        Reference reference = EasyMock.createMock(Reference.class);
        EasyMock.expect(reference.getParent()).andReturn(null);
View Full Code Here

        outboundChains.put(operation, outboundChain);
        OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class);
        outboundWire.getTargetCallbackInvocationChains();
        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
        EasyMock.expect(outboundWire.getServiceContract()).andReturn(contract).anyTimes();
        EasyMock.expect(outboundWire.getTargetName()).andReturn(new QualifiedName("target/FooService")).anyTimes();
        EasyMock.expect(outboundWire.getInvocationChains()).andReturn(outboundChains).anyTimes();

        // create the service
        Service service = EasyMock.createMock(Service.class);
        EasyMock.expect(service.getName()).andReturn("source");
View Full Code Here

        Map<Operation<?>, OutboundInvocationChain> outboundChains =
            new HashMap<Operation<?>, OutboundInvocationChain>();
        outboundChains.put(operation, outboundChain);
        OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class);
        EasyMock.expect(outboundWire.getServiceContract()).andReturn(contract).anyTimes();
        EasyMock.expect(outboundWire.getTargetName()).andReturn(new QualifiedName("target/FooService")).anyTimes();
        EasyMock.expect(outboundWire.getInvocationChains()).andReturn(outboundChains).anyTimes();
        outboundWire.getTargetCallbackInvocationChains();
        EasyMock.expectLastCall().andReturn(Collections.emptyMap());

        Map<String, List<OutboundWire>> outboundWires = new HashMap<String, List<OutboundWire>>();
View Full Code Here

            new HashMap<Operation<?>, OutboundInvocationChain>();
        outboundChains.put(operation, outboundChain);
        OutboundWire sourceWire = EasyMock.createMock(OutboundWire.class);
        EasyMock.expect(sourceWire.getContainer()).andReturn(component);
        EasyMock.expect(sourceWire.getServiceContract()).andReturn(contract).anyTimes();
        EasyMock.expect(sourceWire.getTargetName()).andReturn(new QualifiedName("target/FooService")).anyTimes();
        EasyMock.expect(sourceWire.getInvocationChains()).andReturn(outboundChains).anyTimes();
        sourceWire.getTargetCallbackInvocationChains();
        EasyMock.expectLastCall().andReturn(Collections.emptyMap());
        EasyMock.replay(sourceWire);
View Full Code Here

    public SystemService build(CompositeComponent parent,
                               BoundServiceDefinition<SystemBinding> boundServiceDefinition,
                               DeploymentContext deploymentContext) {
        Class<?> interfaze = boundServiceDefinition.getServiceContract().getInterfaceClass();
        QualifiedName targetName = new QualifiedName(boundServiceDefinition.getTarget().getPath());
        Component target = (Component) parent.getSystemChild(targetName.getPartName());
        if (target == null) {
            throw new BuilderConfigException("Target not found: [" + targetName + ']');
        }
        String name = boundServiceDefinition.getName();
        InboundWire inboundWire =
View Full Code Here

     * @param sourceWire
     * @throws BuilderConfigException
     */
    private void connect(SCAObject source, OutboundWire sourceWire, SCAObject target) throws BuilderConfigException {
        assert sourceWire.getTargetName() != null : "Wire target name was null";
        QualifiedName targetName = sourceWire.getTargetName();

        if (target instanceof AtomicComponent) {
            AtomicComponent targetComponent = (AtomicComponent) target;
            InboundWire targetWire = targetComponent.getInboundWire(targetName.getPortName());
            if (targetWire == null) {
                String refName = sourceWire.getReferenceName();
                BuilderConfigException e = new BuilderConfigException("No target service for reference " + refName);
                e.setIdentifier(targetName.getPortName());
                throw e;
            }
            checkIfWireable(sourceWire, targetWire);
            boolean optimizable = isOptimizable(source.getScope(), target.getScope());
            connect(sourceWire, targetWire, optimizable);
        } else if (target instanceof Reference) {
            InboundWire targetWire = ((Reference) target).getInboundWire();
            assert targetWire != null;
            checkIfWireable(sourceWire, targetWire);
            boolean optimizable = isOptimizable(source.getScope(), target.getScope());
            connect(sourceWire, targetWire, optimizable);
        } else if (target instanceof CompositeComponent) {
            CompositeComponent composite = (CompositeComponent) target;
            InboundWire targetWire = null;
            if (source.isSystem()) {
                for (Object child : composite.getSystemChildren()) {
                    if (child instanceof CompositeService) {
                        CompositeService compServ = (CompositeService) child;
                        targetWire = compServ.getInboundWire();
                        assert targetWire != null;
                        Class<?> sourceInterface = sourceWire.getServiceContract().getInterfaceClass();
                        Class<?> targetInterface = targetWire.getServiceContract().getInterfaceClass();
                        if (sourceInterface.isAssignableFrom(targetInterface)) {
                            target = compServ;
                            break;
                        } else {
                            targetWire = null;
                        }
                    }
                }
            } else {
                for (Object child : composite.getChildren()) {
                    if (child instanceof CompositeService) {
                        CompositeService compServ = (CompositeService) child;
                        targetWire = compServ.getInboundWire();
                        assert targetWire != null;
                        Class<?> sourceInterface = sourceWire.getServiceContract().getInterfaceClass();
                        Class<?> targetInterface = targetWire.getServiceContract().getInterfaceClass();
                        if (sourceInterface.isAssignableFrom(targetInterface)) {
                            target = compServ;
                            break;
                        } else {
                            targetWire = null;
                        }
                    }
                }
            }
            if (targetWire == null) {
                throw new BuilderConfigException("No target composite service in composite");
            }
            boolean optimizable = isOptimizable(source.getScope(), target.getScope());
            connect(sourceWire, targetWire, optimizable);
        } else {
            String name = sourceWire.getReferenceName();
            BuilderConfigException e = new BuilderConfigException("Invalid target type for reference " + name);
            e.setIdentifier(targetName.getQualifiedName());
            throw e;
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.spi.QualifiedName

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.