Package org.switchyard.config.model.composite

Examples of org.switchyard.config.model.composite.ComponentReferenceModel


                channelModel.setOperation(operation);
            }
            String reference = channelAnnotation.reference();
            if (!UNDEFINED.equals(reference)) {
                channelModel.setReference(reference);
                ComponentReferenceModel componentReferenceModel = new V1ComponentReferenceModel(switchyardNamespace.uri());
                componentReferenceModel.setName(reference);
                Class<?> interfaze = channelAnnotation.interfaze();
                if (!Channel.UndefinedInterface.class.isAssignableFrom(interfaze)) {
                    InterfaceModel interfaceModel = new V1InterfaceModel(InterfaceModel.JAVA);
                    interfaceModel.setInterface(interfaze.getName());
                    componentReferenceModel.setInterface(interfaceModel);
                    componentModel.addReference(componentReferenceModel);
                }
            }
            channelsModel.addChannel(channelModel);
        }
View Full Code Here


    // Verify that the ConsumerBean reference is picked up by the scanner
    @Test
    public void checkReference() throws Exception {
        scan(new File("./target/test-classes").toURI().toURL());
        ComponentModel consumerBeanModel = null;
        ComponentReferenceModel oneWayReference = null;
       
        for (ComponentModel component : _scannedModel.getComposite().getComponents()) {
            BeanComponentImplementationModel beanImp =
                (BeanComponentImplementationModel)component.getImplementation();
            if (ServiceWithReferenceBean.class.getName().equals(beanImp.getClazz())) {
View Full Code Here

                ComponentImplementationModel impl = component.getImplementation();
                Assert.assertTrue(impl.hasPolicyRequirement(SecurityPolicy.AUTHORIZATION.getQName()));
                ComponentServiceModel svc = component.getServices().get(0);
                Assert.assertTrue(svc.hasPolicyRequirement(SecurityPolicy.CLIENT_AUTHENTICATION.getQName()));
                Assert.assertTrue(svc.hasPolicyRequirement(SecurityPolicy.CONFIDENTIALITY.getQName()));
                ComponentReferenceModel ref = component.getReferences().get(0);
                Assert.assertTrue(ref.hasPolicyRequirement(SecurityPolicy.AUTHORIZATION.getQName()));
                Assert.assertTrue(ref.hasPolicyRequirement(SecurityPolicy.CLIENT_AUTHENTICATION.getQName()));
                Assert.assertTrue(ref.hasPolicyRequirement(SecurityPolicy.CONFIDENTIALITY.getQName()));
                ssFound = true;
                continue;
            }
           
            if(component.getName().equals("LocalTransactionService")) {
                ComponentServiceModel svc = component.getServices().get(0);
                Assert.assertTrue(svc.hasPolicyRequirement(TransactionPolicy.SUSPENDS_TRANSACTION.getQName()));
                ComponentReferenceModel ref = component.getReferences().get(0);
                Assert.assertTrue(ref.hasPolicyRequirement(TransactionPolicy.SUSPENDS_TRANSACTION.getQName()));
                ltsFound = true;
                continue;
            }
           
            if(component.getName().equals("SharedTransactionService")) {
                ComponentServiceModel svc = component.getServices().get(0);
                Assert.assertTrue(svc.hasPolicyRequirement(TransactionPolicy.PROPAGATES_TRANSACTION.getQName()));
                ComponentReferenceModel ref = component.getReferences().get(0);
                Assert.assertTrue(ref.hasPolicyRequirement(TransactionPolicy.PROPAGATES_TRANSACTION.getQName()));
                stsFound = true;
                continue;
            }
        }
       
View Full Code Here

            if (!field.isAnnotationPresent(Reference.class)) {
                continue;
            }
           
            Class<?> reference = field.getType();
            ComponentReferenceModel referenceModel = new V1ComponentReferenceModel(switchyardNamespace.uri());
            InterfaceModel interfaceModel = new V1InterfaceModel(InterfaceModel.JAVA);
                 
            if (field.getAnnotation(Reference.class) != null) {
                Reference ref = field.getAnnotation(Reference.class);
                if (ref.value() == null || "".equals(ref.value())) {
                    referenceModel.setName(reference.getSimpleName());
                } else {
                    QName qname = QName.valueOf(ref.value());
                    referenceModel.setName(qname.getLocalPart());
                }
            } else {
                referenceModel.setName(reference.getSimpleName());
            }
           
            referenceModel.setInterface(interfaceModel);
            interfaceModel.setInterface(reference.getCanonicalName());
            // Add policy requirements to reference if specified
            Requires refRequires = field.getAnnotation(Requires.class);
            if (refRequires != null) {
                for (SecurityPolicy secPolicy : refRequires.security()) {
                    if (!secPolicy.supports(PolicyType.INTERACTION)) {
                        throw BeanMessages.MESSAGES.referenceOnlyCouldBeMarkedWithInteractionPolicyButIsNotTheOne(secPolicy.toString());
                    }
                    referenceModel.addPolicyRequirement(secPolicy.getQName());
                }
                for (TransactionPolicy txPolicy : refRequires.transaction()) {
                    if (!txPolicy.supports(PolicyType.INTERACTION)) {
                        throw BeanMessages.MESSAGES.referenceOnlyCouldBeMarkedWithInteractionPolicyButIsNotTheOne(txPolicy.toString());
                    }
                    referenceModel.addPolicyRequirement(txPolicy.getQName());
                }
                // Make sure we don't have conflicting policies
                QName ptx = TransactionPolicy.PROPAGATES_TRANSACTION.getQName();
                QName stx = TransactionPolicy.SUSPENDS_TRANSACTION.getQName();
                if (referenceModel.hasPolicyRequirement(ptx) && referenceModel.hasPolicyRequirement(stx)) {
                    throw BeanMessages.MESSAGES.transactionPoliciesCannotCoexistService(ptx, stx, name);
                }
            }
            references.add(referenceModel);
        }
View Full Code Here

        ComponentModel component = port.getBinding().getService().getComposite().getComponents().get(0);
        ComponentServiceModel componentService = component.getServices().get(0);
        Assert.assertEquals("SimpleService", componentService.getName());
        Assert.assertTrue(componentService.hasPolicyRequirement(new QName("clientAuthentication")));
        Assert.assertEquals("theSecurityName", componentService.getSecurity());
        ComponentReferenceModel componentReference = component.getReferences().get(0);
        Assert.assertEquals("anotherService", componentReference.getName());
        Assert.assertTrue(componentReference.hasPolicyRequirement(new QName("clientAuthentication")));
        Assert.assertEquals("theSecurityName", componentReference.getSecurity());
        String name = component.getName();
        Assert.assertEquals("SimpleService", name);
        // Verify transform configuration
        TransformsModel transforms = switchyard.getTransforms();
        JavaTransformModel java_transform = (JavaTransformModel)transforms.getTransforms().get(0);
View Full Code Here

        Assert.assertEquals("SimpleService", component.getName());
        Assert.assertEquals(new QName(tns, "SimpleService"), component.getQName());
        ComponentServiceModel componentService = component.getServices().iterator().next();
        Assert.assertEquals("SimpleService", componentService.getName());
        Assert.assertEquals(new QName(tns, "SimpleService"), componentService.getQName());
        ComponentReferenceModel componentReference = component.getReferences().iterator().next();
        Assert.assertEquals("anotherService", componentReference.getName());
        Assert.assertEquals(new QName(tns, "anotherService"), componentReference.getQName());
    }
View Full Code Here

                    componentLoop: for (ComponentModel component : composite.getComponents()) {
                        if (componentName.equals(component.getName())) {
                            List<ComponentReferenceModel> componentReferences = component.getReferences();
                            if (namesCount == 1) {
                                if (componentReferences.size() > 0) {
                                    ComponentReferenceModel componentReference = componentReferences.iterator().next();
                                    if (componentReference != null) {
                                        list.add(componentReference);
                                        componentMissing = false;
                                        break componentLoop;
                                    }
                                }
                            } else if (namesCount == 2) {
                                for (ComponentReferenceModel componentReference : componentReferences) {
                                    if (componentReferenceName.equals(componentReference.getName())) {
                                        list.add(componentReference);
                                        componentMissing = false;
                                        break componentLoop;
                                    }
                                }
View Full Code Here

            if (service != null) {
                _services.add(service);
            }
        }
        for (Configuration reference_config : config.getChildren(ComponentReferenceModel.REFERENCE)) {
            ComponentReferenceModel reference = (ComponentReferenceModel)readModel(reference_config);
            if (reference != null) {
                _references.add(reference);
            }
        }
        for (Configuration property_config : config.getChildren(PropertyModel.PROPERTY)) {
View Full Code Here

            List<ComponentReferenceModel> componentRefModels = compositeRefModel.getComponentReferences();
            switch (componentRefModels.size()) {
                case 0:
                    break;
                case 1:
                    ComponentReferenceModel componentRefModel = componentRefModels.iterator().next();
                    if (hasComponentReferenceInterface(componentRefModel)) {
                        serviceInterface = loadServiceInterface(componentRefModel.getInterface());
                    }
                    break;
                default:
                    throw new SwitchYardException("A composite reference interface must be defined if promoting more than one component reference.");
            }
View Full Code Here

    }

    @Test
    public void requiresOnReference() throws Exception {
        ComponentModel comp = _model.getComponents().get(0);
        ComponentReferenceModel ref = comp.getReferences().get(0);
        Assert.assertTrue(ref.hasPolicyRequirement(POLICY_BAR));
    }
View Full Code Here

TOP

Related Classes of org.switchyard.config.model.composite.ComponentReferenceModel

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.