Package org.apache.tuscany.model.assembly

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


        contract.setInterface(interfaz);

        EntryPoint ep = systemFactory.createEntryPoint();
        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);
View Full Code Here


     * @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);
        ep.initialize(assemblyContext);
        return ep;
    }
View Full Code Here

            addReference(name, field.getType(), annotation.required(), type);
        }
    }

    private void addReference(String name, Class<?> paramType, boolean required, ComponentType type) {
        Reference reference = factory.createReference();
        reference.setName(name);
        ServiceContract contract = factory.createJavaServiceContract();
        contract.setInterface(paramType);
        reference.setServiceContract(contract);
        boolean many = paramType.isArray() || Collection.class.isAssignableFrom(paramType);
        Multiplicity multiplicity;
        if (required)
            multiplicity = many ? Multiplicity.ONE_N : Multiplicity.ONE_ONE;
        else
            multiplicity = many ? Multiplicity.ZERO_N : Multiplicity.ZERO_ONE;
        reference.setMultiplicity(multiplicity);
        type.getReferences().add(reference);
    }
View Full Code Here

        return REFERENCE;
    }

    public Reference load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException {
        assert REFERENCE.equals(reader.getName());
        Reference reference = factory.createReference();
        reference.setName(reader.getAttributeValue(null, "name"));
        reference.setMultiplicity(StAXUtil.multiplicity(reader.getAttributeValue(null, "multiplicity"), Multiplicity.ONE_ONE));

        while (true) {
            switch (reader.next()) {
            case START_ELEMENT:
                AssemblyObject o = registry.load(reader, loaderContext);
                if (o instanceof ServiceContract) {
                    reference.setServiceContract((ServiceContract) o);
                }
                reader.next();
                break;
            case END_ELEMENT:
                return reference;
View Full Code Here

        service.setName(name);
        ConfiguredService configuredService = factory.createConfiguredService();
        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) {
                        service.setServiceContract((ServiceContract) o);
                        reference.setServiceContract((ServiceContract) o);
                    }
                }
                reader.next();
                break;
            case END_ELEMENT:
View Full Code Here

TOP

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

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.