Package org.apache.tuscany.spi.component

Examples of org.apache.tuscany.spi.component.Component


        ComponentDefinition<SystemCompositeImplementation> definition =
            new ComponentDefinition<SystemCompositeImplementation>(extensionName, implementation);

        Deployer deployer = (Deployer) composite.getSystemChild("deployer").getServiceInstance();
        Component component = deployer.deploy(composite, definition);

        component.start();
    }
View Full Code Here


        ComponentDefinition<SystemCompositeImplementation> definition =
            new ComponentDefinition<SystemCompositeImplementation>(extensionName,
                implementation);

        Deployer deployer = (Deployer) composite.getSystemChild("deployer").getServiceInstance();
        Component component = deployer.deploy(composite, definition);

        component.start();
    }
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

            if (isOneWayOperation && operationHasCallback) {
                throw new ComponentRuntimeException("Operation cannot be marked one-way and have a callback");
            }
            TargetInvoker invoker = null;
            if (target instanceof Component) {
                Component component = (Component) target;
                if (isOneWayOperation || operationHasCallback) {
                    invoker = component.createAsyncTargetInvoker(targetWire, inboundOperation);
                } else {
                    String portName = sourceWire.getTargetName().getPortName();
                    invoker = component.createTargetInvoker(portName, inboundOperation);
                }
            } else if (target instanceof Reference) {
                Reference reference = (Reference) target;
                if (!(reference instanceof CompositeReference) && operationHasCallback) {
                    // Notice that for bound references we only use async target invokers for callback operations
                    invoker = reference.createAsyncTargetInvoker(sourceWire, inboundOperation);
                } else {
                    ServiceContract targetContract = targetWire.getServiceContract();
                    invoker = reference.createTargetInvoker(targetContract, inboundOperation);
                }
            } else if (target instanceof CompositeService) {
                CompositeService compServ = (CompositeService) target;
                invoker = compServ.createTargetInvoker(targetWire.getServiceContract(), inboundChain.getOperation());
            }

            if (source instanceof Service && !(source instanceof CompositeService)) {
                // services are a special case: invoker must go on the inbound chain
                if (target instanceof Component && (isOneWayOperation || operationHasCallback)) {
                    // if the target is a component and the operation is non-blocking
                    connect(outboundChain, inboundChain, null, true);
                } else {
                    connect(outboundChain, inboundChain, null, false);
                }
                Service service = (Service) source;
                InboundInvocationChain chain = service.getInboundWire().getInvocationChains().get(operation);
                chain.setTargetInvoker(invoker);
            } else {
                if (target instanceof Component && (isOneWayOperation || operationHasCallback)) {
                    // if the target is a component and the operation is non-blocking
                    connect(outboundChain, inboundChain, invoker, true);
                } else {
                    connect(outboundChain, inboundChain, invoker, false);
                }
            }
        }

        // create source callback chains and connect them if target callback chains exist
        Map<Operation<?>, OutboundInvocationChain> sourceCallbackChains =
            targetWire.getSourceCallbackInvocationChains(source.getName());
        for (InboundInvocationChain inboundChain : sourceWire.getTargetCallbackInvocationChains().values()) {
            Operation<?> operation = inboundChain.getOperation();
            if (sourceCallbackChains != null && sourceCallbackChains.get(operation) != null) {
                String name = operation.getName();
                BuilderConfigException e =
                    new BuilderConfigException("Source callback chain should not exist for operation [" + name + "]");
                e.setIdentifier(sourceWire.getReferenceName());
                throw e;
            }
           
            Operation targetOp =
                (Operation)targetWire.getServiceContract().getCallbackOperations().get(operation.getName());
            OutboundInvocationChain outboundChain = wireService.createOutboundChain(targetOp);
            targetWire.addSourceCallbackInvocationChain(source.getName(), targetOp, outboundChain);
            if (source instanceof Component) {
                Component component = (Component) source;
                TargetInvoker invoker = component.createTargetInvoker(null, operation);
                connect(outboundChain, inboundChain, invoker, false);
            } else if (source instanceof CompositeReference) {
                CompositeReference compRef = (CompositeReference) source;
                ServiceContract sourceContract = sourceWire.getServiceContract();
                TargetInvoker invoker = compRef.createCallbackTargetInvoker(sourceContract, operation);
View Full Code Here

        // FIXME: [rfeng] Should we reset the thread context class loader here?
        // From the debugger with tomcat, the current TCCL is the RealmClassLoader
        // ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
        try {
            // Thread.currentThread().setContextClassLoader(extensionCL);
            Component component = deployer.deploy(parent, definition);
            component.start();
        } catch (LoaderException e) {
            // FIXME handle the exception
            e.printStackTrace();
        } finally {
            // Thread.currentThread().setContextClassLoader(contextCL);
View Full Code Here

            load(parent, componentDefinition, deploymentContext);
        } catch (LoaderException e) {
            e.addContextName(componentDefinition.getName());
            throw e;
        }
        Component component = (Component) build(parent, componentDefinition, deploymentContext);
        if (component instanceof CompositeComponent) {
            CompositeComponent composite = (CompositeComponent) component;
            composite.setScopeContainer(moduleScope);
        }
        component.prepare();
        parent.register(component);
        return component;
    }
View Full Code Here

            e.setIdentifier(implClass.getName());
            e.addContextName(componentDefinition.getName());
            throw e;
        }

        Component component = componentBuilder.build(parent, componentDefinition, deploymentContext);
        ComponentType<?, ?, ?> componentType = componentDefinition.getImplementation().getComponentType();
        assert componentType != null : "Component type must be set";
        // create wires for the component
        if (wireService != null && !(component instanceof SystemAtomicComponent)) {
            wireService.createWires(component, componentDefinition);
View Full Code Here

        CompositeComponent parent = createNiceMock(CompositeComponent.class);
        parent.register(isA(SCAObject.class));
        replay(parent);
        // load the boot1 file using the bootstrap deployer
        componentDefinition.setName("simple");
        Component component = deployer.deploy(parent, componentDefinition);
        assertNotNull(component);
        verify(parent);
    }
View Full Code Here

    public void testProcess1() {
        InboundWire inboundWire = createMock(InboundWire.class);
        OutboundWire outboundWire = createMock(OutboundWire.class);

        Component component = createMock(Component.class);
        CompositeComponent composite = createMock(CompositeComponent.class);
        expect(component.getParent()).andReturn(composite);
        expect(inboundWire.getContainer()).andReturn(component);
        expect(outboundWire.getContainer()).andReturn(component);

        Map<Operation<?>, OutboundInvocationChain> outboundChains =
            new HashMap<Operation<?>, OutboundInvocationChain>();
View Full Code Here

            new DataType<DataType>("idl:output", Object.class, operation2.getOutputType());

        OutboundWire outboundWire = EasyMock.createMock(OutboundWire.class);
        InboundWire inboundWire = EasyMock.createMock(InboundWire.class);
        CompositeComponent composite = EasyMock.createMock(CompositeComponent.class);
        Component component = EasyMock.createMock(Component.class);
        EasyMock.expect(component.getParent()).andReturn(composite).once();
        EasyMock.expect(outboundWire.getContainer()).andReturn(component);
        EasyMock.replay(outboundWire, inboundWire, composite, component);

        interceptor = new DataBindingInteceptor(outboundWire, operation1, inboundWire, operation2);
        Mediator mediator = createMock(Mediator.class);
View Full Code Here

TOP

Related Classes of org.apache.tuscany.spi.component.Component

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.