Package org.apache.tuscany.model.assembly

Examples of org.apache.tuscany.model.assembly.ConfiguredReference


        JavaServiceContract inter = factory.createJavaServiceContract();
        inter.setInterface(HelloWorldService.class);
        ref.setServiceContract(inter);


        ConfiguredReference cref = factory.createConfiguredReference(ref.getName(), "target");
        cref.setPort(ref);
        cref.initialize(assemblyContext);
        sourceEP.setConfiguredReference(cref);
        sourceEP.initialize(assemblyContext);

        Module module = factory.createModule();
        module.setName("test.module");
View Full Code Here


        refContract.setInterface(Target.class);
        Reference reference = systemFactory.createReference();
        reference.setName("setTarget");
        reference.setServiceContract(refContract);
        componentType.getReferences().add(reference);
        ConfiguredReference cReference = systemFactory.createConfiguredReference(reference.getName(), "target");
        cReference.initialize(assemblyContext);
        source.getConfiguredReferences().add(cReference);

        // wire multiplicity using a setter
        JavaServiceContract refContract2 = systemFactory.createJavaServiceContract();
        refContract2.setInterface(Target.class);
        Reference reference2 = systemFactory.createReference();
        reference2.setName("setTargets");
        reference2.setServiceContract(refContract2);
        reference2.setMultiplicity(Multiplicity.ONE_N);
        componentType.getReferences().add(reference2);
        ConfiguredReference cReference2 = systemFactory.createConfiguredReference(reference2.getName(), "target");
        cReference2.initialize(assemblyContext);
        source.getConfiguredReferences().add(cReference2);

        // wire multiplicity using a field
        JavaServiceContract refContract3 = systemFactory.createJavaServiceContract();
        refContract3.setInterface(Target.class);
        Reference reference3 = systemFactory.createReference();
        reference3.setName("targetsThroughField");
        reference3.setServiceContract(refContract3);
        reference3.setMultiplicity(Multiplicity.ONE_N);
        componentType.getReferences().add(reference3);
        ConfiguredReference cReference3 = systemFactory.createConfiguredReference(reference3.getName(), "target");
        cReference3.initialize(assemblyContext);
        source.getConfiguredReferences().add(cReference3);

        // wire multiplicity using a array
        JavaServiceContract refContract4 = systemFactory.createJavaServiceContract();
        refContract4.setInterface(Target.class);
        Reference reference4 = systemFactory.createReference();
        reference4.setName("setArrayOfTargets");
        reference4.setServiceContract(refContract4);
        reference4.setMultiplicity(Multiplicity.ONE_N);
        componentType.getReferences().add(reference4);
        ConfiguredReference cReference4 = systemFactory.createConfiguredReference(reference4.getName(), "target");
        cReference4.initialize(assemblyContext);
        source.getConfiguredReferences().add(cReference4);

        source.initialize(assemblyContext);

        Module module = systemFactory.createModule();
View Full Code Here

        refContract.setInterface(Target.class);
        Reference reference = systemFactory.createReference();
        reference.setName("setTarget");
        reference.setServiceContract(refContract);
        componentType.getReferences().add(reference);
        ConfiguredReference cReference = systemFactory.createConfiguredReference(reference.getName(), "target");
        cReference.initialize(assemblyContext);
        source.getConfiguredReferences().add(cReference);

        // wire multiplicity using a setter
        JavaServiceContract refContract2 = systemFactory.createJavaServiceContract();
        refContract2.setInterface(Target.class);
        Reference reference2 = systemFactory.createReference();
        reference2.setName("setTargets");
        reference2.setServiceContract(refContract2);
        reference2.setMultiplicity(Multiplicity.ONE_N);
        componentType.getReferences().add(reference2);
        ConfiguredReference cReference2 = systemFactory.createConfiguredReference(reference2.getName(), "target");
        cReference2.initialize(assemblyContext);
        source.getConfiguredReferences().add(cReference2);

        // wire multiplicity using a field
        JavaServiceContract refContract3 = systemFactory.createJavaServiceContract();
        refContract3.setInterface(Target.class);
        Reference reference3 = systemFactory.createReference();
        reference3.setName("targetsThroughField");
        reference3.setServiceContract(refContract3);
        reference3.setMultiplicity(Multiplicity.ONE_N);
        componentType.getReferences().add(reference3);
        ConfiguredReference cReference3 = systemFactory.createConfiguredReference(reference3.getName(), "target");
        cReference3.initialize(assemblyContext);
        source.getConfiguredReferences().add(cReference3);

        // wire multiplicity using a array
        JavaServiceContract refContract4 = systemFactory.createJavaServiceContract();
        refContract4.setInterface(Target.class);
        Reference reference4 = systemFactory.createReference();
        reference4.setName("setArrayOfTargets");
        reference4.setServiceContract(refContract4);
        reference4.setMultiplicity(Multiplicity.ONE_N);
        componentType.getReferences().add(reference4);
        ConfiguredReference cReference4 = systemFactory.createConfiguredReference(reference4.getName(), "target");
        cReference4.initialize(assemblyContext);
        source.getConfiguredReferences().add(cReference4);

        source.initialize(assemblyContext);

        Module module = systemFactory.createModule();
View Full Code Here

        impl = factory.createSystemImplementation();
        impl.setComponentType(componentType);
        component = factory.createSimpleComponent();
        component.setName("source");
        component.setImplementation(impl);
        ConfiguredReference cRef = factory.createConfiguredReference("ref", "target");
        component.getConfiguredReferences().add(cRef);
        component.initialize(assemblyContext);
        module.getComponents().add(component);

        EntryPoint ep = factory.createEntryPoint();
        JavaServiceContract contract = factory.createJavaServiceContract();
        contract.setInterface(ModuleScopeSystemComponent.class);
        service = factory.createService();
        service.setServiceContract(contract);
        ConfiguredService cService = factory.createConfiguredService();
        cService.setPort(service);
        cService.initialize(assemblyContext);
        ep.setConfiguredService(cService);
        SystemBinding binding = factory.createSystemBinding();
        ep.getBindings().add(binding);
        ConfiguredReference cEpRef = factory.createConfiguredReference();
        Reference epRef = factory.createReference();
        cEpRef.setPort(epRef);
        ep.setConfiguredReference(cEpRef);
        ep.initialize(assemblyContext);
        module.getEntryPoints().add(ep);

        List<ContextFactoryBuilder> builders = new ArrayList<ContextFactoryBuilder>();
        builders.add(new TestBuilder());
        AssemblyVisitorImpl visitor = new AssemblyVisitorImpl(builders);
        module.initialize(assemblyContext);
        visitor.start(module);

        Assert.assertSame(MARKER, component.getContextFactory());
        Assert.assertSame(MARKER, cRef.getProxyFactory());
        Assert.assertSame(MARKER, ep.getContextFactory());
        Assert.assertSame(MARKER, cEpRef.getProxyFactory());

    }
View Full Code Here

        ep.setName(name);

        Reference ref = systemFactory.createReference();
        ref.setName(refName);
        ref.setServiceContract(contract);
        ConfiguredReference configuredReference = systemFactory.createConfiguredReference();
        configuredReference.setPort(ref);
        Service service = systemFactory.createService();
        service.setServiceContract(contract);

        ConfiguredService cService = systemFactory.createConfiguredService();
        cService.setPort(service);
        cService.initialize(assemblyContext);

        configuredReference.getTargetConfiguredServices().add(cService);
        ep.setConfiguredReference(configuredReference);

        Service epService = systemFactory.createService();
        epService.setServiceContract(contract);
View Full Code Here

     * @param refName       the name of the entry point reference
     * @param componentName the name of the target to resolve
     */
    public static EntryPoint createEntryPointWithStringRef(String name, Class interfaz, String refName, String componentName) {
        EntryPoint ep = createEPSystemBinding(name, interfaz, refName, null);
        ConfiguredReference cRef = systemFactory.createConfiguredReference();
        Reference ref = systemFactory.createReference();
        cRef.setPort(ref);
        Service service = systemFactory.createService();
        service.setName(componentName);
        ConfiguredService cService = systemFactory.createConfiguredService();
        cService.setPort(service);
        cRef.getTargetConfiguredServices().add(cService);
        cRef.initialize(assemblyContext);
        cService.initialize(assemblyContext);
        JavaServiceContract contract = systemFactory.createJavaServiceContract();
        contract.setInterface(interfaz);
        ref.setServiceContract(contract);
        ep.setConfiguredReference(cRef);
View Full Code Here

        List<Reference> references = sourceComponentType.getReferences();
        List<ConfiguredReference> configuredReferences = source.getConfiguredReferences();

        // wire source to target
        references.add(systemFactory.createReference("setTarget", Target.class));
        ConfiguredReference configuredReference = systemFactory.createConfiguredReference("setTarget", "target");
        configuredReferences.add(configuredReference);

        // wire multiplicity using a setter
        references.add(systemFactory.createReference("setTargets", Target.class, Multiplicity.ONE_N));
        configuredReference = systemFactory.createConfiguredReference("setTargets", "target");
View Full Code Here

            switch (reader.next()) {
                case START_ELEMENT:
                    String name = reader.getLocalName();
                    String uri = reader.getElementText();

                    ConfiguredReference configuredReference = component.getConfiguredReference(name);
                    if (configuredReference == null) {
                        configuredReference = factory.createConfiguredReference();
                        configuredReference.setName(name);
                        configuredReferences.add(configuredReference);
                    }

                    configuredReference.getTargets().add(uri);
                    break;
                case END_ELEMENT:
                    return;
            }
        }
View Full Code Here

        configuredService.setPort(service);
        entryPoint.setConfiguredService(configuredService);

        Reference reference = factory.createReference();
        reference.setMultiplicity(StAXUtil.multiplicity(reader.getAttributeValue(null, "multiplicity"), Multiplicity.ONE_ONE));
        ConfiguredReference configuredReference = factory.createConfiguredReference();
        configuredReference.setPort(reference);
        entryPoint.setConfiguredReference(configuredReference);

        while (true) {
            switch (reader.next()) {
            case START_ELEMENT:
                QName qname = reader.getName();
                if (AssemblyConstants.REFERENCE.equals(qname)) {
                    String uri = reader.getElementText();
                    configuredReference.getTargets().add(uri);
                } else {
                    AssemblyObject o = registry.load(reader, loaderContext);
                    if (o instanceof Binding) {
                        entryPoint.getBindings().add((Binding) o);
                    } else if (o instanceof ServiceContract) {
View Full Code Here

        logger = this.serviceUnit.getComponent().getLogger();
        ComponentContext ctx = this.serviceUnit.getComponent().getComponentContext();
        activated = ctx.activateEndpoint(service, endpoint);
        channel = ctx.getDeliveryChannel();
        // Get the target service
        ConfiguredReference referenceValue = entryPoint.getConfiguredReference();
        ConfiguredService targetServiceEndpoint = referenceValue.getTargetConfiguredServices().get(0);
        // Get the business interface
        Class serviceInterface = targetServiceEndpoint.getService().getServiceContract().getInterface();
        List<Class> classes = new ArrayList<Class>();
        methodMap = new HashMap<Class, Method>();
        for (Method mth : serviceInterface.getMethods()) {
View Full Code Here

TOP

Related Classes of org.apache.tuscany.model.assembly.ConfiguredReference

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.