Package org.switchyard.config.model.composite.v1

Examples of org.switchyard.config.model.composite.v1.V1ComponentModel


        componentImplementationModel.setManifest(toManifestModel(bpm.manifest(), bpmNamespace));
        componentImplementationModel.setProperties(toPropertiesModel(bpm.properties(), bpmNamespace));
        componentImplementationModel.setUserGroupCallback(toUserGroupCallbackModel(bpm.userGroupCallback(), bpmNamespace));
        componentImplementationModel.setWorkItemHandlers(toWorkItemHandlersModel(bpm.workItemHandlers(), bpmNamespace));
        componentModel.setImplementation(componentImplementationModel);
        ComponentServiceModel componentServiceModel = new V1ComponentServiceModel(switchyardNamespace.uri());
        InterfaceModel interfaceModel = new V1InterfaceModel(InterfaceModel.JAVA);
        interfaceModel.setInterface(bpmInterface.getName());
        componentServiceModel.setInterface(interfaceModel);
        componentServiceModel.setName(bpmName);
        componentModel.addService(componentServiceModel);
        return componentModel;
    }
View Full Code Here


        componentImplementationModel.setListeners(toListenersModel(rules.listeners(), rulesNamespace));
        componentImplementationModel.setLoggers(toLoggersModel(rules.loggers(), rulesNamespace));
        componentImplementationModel.setManifest(toManifestModel(rules.manifest(), rulesNamespace));
        componentImplementationModel.setProperties(toPropertiesModel(rules.properties(), rulesNamespace));
        componentModel.setImplementation(componentImplementationModel);
        ComponentServiceModel componentServiceModel = new V1ComponentServiceModel(switchyardNamespace.uri());
        InterfaceModel interfaceModel = new V1InterfaceModel(InterfaceModel.JAVA);
        interfaceModel.setInterface(rulesInterface.getName());
        componentServiceModel.setInterface(interfaceModel);
        componentServiceModel.setName(rulesName);
        componentModel.addService(componentServiceModel);
        return componentModel;
    }
View Full Code Here

    }

    @Test
    public void buildPolicyConfig() throws Exception {
        // Test service policy
        ComponentServiceModel svc = new V1ComponentServiceModel(SwitchYardNamespace.DEFAULT.uri());
        svc.addPolicyRequirement(POLICY_FOO);
        svc.addPolicyRequirement(POLICY_BAR);
        Assert.assertTrue(svc.hasPolicyRequirement(POLICY_FOO));
        Assert.assertTrue(svc.hasPolicyRequirement(POLICY_BAR));

        // Test reference policy
        ComponentReferenceModel ref = new V1ComponentReferenceModel(SwitchYardNamespace.DEFAULT.uri());
        ref.addPolicyRequirement(POLICY_BAR);
        Assert.assertTrue(ref.hasPolicyRequirement(POLICY_BAR));
        Assert.assertFalse(ref.hasPolicyRequirement(POLICY_FOO));
        svc.addPolicyRequirement(POLICY_FOO);
        Assert.assertTrue(svc.hasPolicyRequirement(POLICY_FOO));
    }
View Full Code Here

     */
    @Override
    public ScannerOutput<SwitchYardModel> scan(ScannerInput<SwitchYardModel> input) throws IOException {
        SwitchYardNamespace switchyardNamespace = input.getSwitchyardNamespace();
        SwitchYardModel switchyardModel = new V1SwitchYardModel(switchyardNamespace.uri());
        CompositeModel compositeModel = new V1CompositeModel();
        compositeModel.setName(input.getCompositeName());

        BeanNamespace beanNamespace = BeanNamespace.DEFAULT;
        for (BeanNamespace value : BeanNamespace.values()) {
            if (value.versionMatches(switchyardNamespace)) {
                beanNamespace = value;
                break;
            }
        }

        List<Class<?>> serviceClasses = scanForServiceBeans(input);

        for (Class<?> serviceClass : serviceClasses) {
            if (serviceClass.isInterface()) {
                continue;
            }
            if (Modifier.isAbstract(serviceClass.getModifiers())) {
                continue;
            }

            ComponentModel componentModel = new V1ComponentModel();
            ComponentServiceModel serviceModel = new V1ComponentServiceModel(switchyardNamespace.uri());
            String name = serviceClass.getSimpleName();
           
            BeanComponentImplementationModel beanModel = new V1BeanComponentImplementationModel(beanNamespace.uri());
            beanModel.setClazz(serviceClass.getName());
            componentModel.setImplementation(beanModel);

            Service service = serviceClass.getAnnotation(Service.class);
            if (service != null) {
                Class<?> iface = service.value();
                if (iface == Service.class) {
                    Class<?>[] interfaces = serviceClass.getInterfaces();
                    if (interfaces.length == 1) {
                        iface = interfaces[0];
                    } else {
                        throw BeanMessages.MESSAGES.unexpectedExceptionTheServiceAnnotationHasNoValueItCannotBeOmmittedUnlessTheBeanImplementsExactlyOneInterface();
                    }
                }
                InterfaceModel csiModel = new V1InterfaceModel(InterfaceModel.JAVA);

                if (service.name().equals(Service.EMPTY)) {
                    name = iface.getSimpleName();
                } else {
                    name = service.name();
                }
               
                serviceModel.setName(name);
                serviceModel.setInterface(csiModel);
                csiModel.setInterface(iface.getName());
               
                componentModel.addService(serviceModel);
            }
           
            // Check to see if a policy requirements have been defined
            Requires requires = serviceClass.getAnnotation(Requires.class);
            if (requires != null) {
                for (SecurityPolicy secPolicy : requires.security()) {
                    if (secPolicy == SecurityPolicy.AUTHORIZATION) {
                        // authorization supports both interaction and implementation,
                        // and we want to add it as implementation to be more correct.
                        beanModel.addPolicyRequirement(secPolicy.getQName());
                    } else if (secPolicy.supports(PolicyType.INTERACTION)) {
                        serviceModel.addPolicyRequirement(secPolicy.getQName());
                    } else if (secPolicy.supports(PolicyType.IMPLEMENTATION)) {
                        beanModel.addPolicyRequirement(secPolicy.getQName());
                    } else {
                        throw BeanMessages.MESSAGES.unknownPolicy(secPolicy.toString());
                    }
                }
                for (TransactionPolicy txPolicy : requires.transaction()) {
                    if (txPolicy.supports(PolicyType.INTERACTION)) {
                        serviceModel.addPolicyRequirement(txPolicy.getQName());
                    } else if (txPolicy.supports(PolicyType.IMPLEMENTATION)) {
                        beanModel.addPolicyRequirement(txPolicy.getQName());
                    } else {
                        throw BeanMessages.MESSAGES.unknownPolicy(txPolicy.toString());
                    }
                }
                // Make sure we don't have conflicting policies
                QName ptx = TransactionPolicy.PROPAGATES_TRANSACTION.getQName();
                QName stx = TransactionPolicy.SUSPENDS_TRANSACTION.getQName();
                if (serviceModel.hasPolicyRequirement(ptx) && serviceModel.hasPolicyRequirement(stx)) {
                    throw BeanMessages.MESSAGES.transactionPoliciesCannotCoexistService(ptx, stx, name);
                }
                QName gtx = TransactionPolicy.MANAGED_TRANSACTION_GLOBAL.getQName();
                QName ltx = TransactionPolicy.MANAGED_TRANSACTION_LOCAL.getQName();
                QName ntx = TransactionPolicy.NO_MANAGED_TRANSACTION.getQName();
                if (beanModel.hasPolicyRequirement(gtx) && beanModel.hasPolicyRequirement(ltx)
                        || beanModel.hasPolicyRequirement(gtx) && beanModel.hasPolicyRequirement(ntx)
                        || beanModel.hasPolicyRequirement(ltx) && beanModel.hasPolicyRequirement(ntx)) {
                    throw BeanMessages.MESSAGES.transactionPoliciesCannotCoexistImplementation(gtx, ltx, ntx, name);
                }
            }

            // Add any references
            for (ComponentReferenceModel reference : getReferences(switchyardNamespace, serviceClass, name)) {
                componentModel.addReference(reference);
            }
           
            compositeModel.addComponent(componentModel);
            componentModel.setName(getComponentName(name, service));
            compositeModel.addComponent(componentModel);
        }

        if (!compositeModel.getModelChildren().isEmpty()) {
            switchyardModel.setComposite(compositeModel);
        }

        return new ScannerOutput<SwitchYardModel>().setModel(switchyardModel);
    }
View Full Code Here

     */
    @Override
    public ScannerOutput<SwitchYardModel> scan(ScannerInput<SwitchYardModel> input) throws IOException {
        SwitchYardNamespace switchyardNamespace = input.getSwitchyardNamespace();
        SwitchYardModel switchyardModel = new V1SwitchYardModel(switchyardNamespace.uri());
        CompositeModel compositeModel = new V1CompositeModel();
        compositeModel.setName(input.getCompositeName());
        ClasspathScanner bpmScanner = new ClasspathScanner(_bpmFilter);
        for (URL url : input.getURLs()) {
            bpmScanner.scan(url);
        }
        List<Class<?>> bpmClasses = _bpmFilter.getMatchedTypes();
        for (Class<?> bpmClass : bpmClasses) {
            compositeModel.addComponent(scan(bpmClass, switchyardNamespace));
        }
        if (!compositeModel.getModelChildren().isEmpty()) {
            switchyardModel.setComposite(compositeModel);
        }
        return new ScannerOutput<SwitchYardModel>().setModel(switchyardModel);
    }
View Full Code Here

     */
    @Override
    public ScannerOutput<SwitchYardModel> scan(ScannerInput<SwitchYardModel> input) throws IOException {
        SwitchYardNamespace switchyardNamespace = input.getSwitchyardNamespace();
        SwitchYardModel switchyardModel = new V1SwitchYardModel(switchyardNamespace.uri());
        CompositeModel compositeModel = new V1CompositeModel();
        compositeModel.setName(input.getCompositeName());
        ClasspathScanner rulesScanner = new ClasspathScanner(_rulesFilter);
        for (URL url : input.getURLs()) {
            rulesScanner.scan(url);
        }
        List<Class<?>> rulesClasses = _rulesFilter.getMatchedTypes();
        for (Class<?> rulesClass : rulesClasses) {
            compositeModel.addComponent(scan(rulesClass, switchyardNamespace));
        }
        if (!compositeModel.getModelChildren().isEmpty()) {
            switchyardModel.setComposite(compositeModel);
        }
        return new ScannerOutput<SwitchYardModel>().setModel(switchyardModel);
    }
View Full Code Here

    @Override
    public ScannerOutput<SwitchYardModel> scan(ScannerInput<SwitchYardModel> input) throws IOException {
        SwitchYardNamespace switchyardNamespace = input.getSwitchyardNamespace();
        SwitchYardModel switchyardModel = new V1SwitchYardModel(switchyardNamespace.uri());
        CompositeModel compositeModel = new V1CompositeModel();
        compositeModel.setName(input.getCompositeName());

        CamelNamespace camelNamespace = CamelNamespace.DEFAULT;
        for (CamelNamespace value : CamelNamespace.values()) {
            if (value.versionMatches(switchyardNamespace)) {
                camelNamespace = value;
                break;
            }
        }

        List<Class<?>> routeClasses = scanForRoutes(input.getURLs());

        // Create a Camel component model for each class
        for (Class<?> routeClass : routeClasses) {
            // Top-level component definition
            ComponentModel componentModel = new V1ComponentModel();
            componentModel.setName(routeClass.getSimpleName());

            // Component implementation definition
            CamelComponentImplementationModel camelModel = new V1CamelImplementationModel(camelNamespace.uri());
            camelModel.setJavaClass(routeClass.getName());
            componentModel.setImplementation(camelModel);
            compositeModel.addComponent(componentModel);

            // Component service definition
            ComponentServiceModel serviceModel = new V1ComponentServiceModel(switchyardNamespace.uri());
            InterfaceModel csiModel = new V1InterfaceModel(InterfaceModel.JAVA);
            Class<?> serviceInterface = routeClass.getAnnotation(Route.class).value();
            serviceModel.setName(getServiceName(routeClass));
            csiModel.setInterface(serviceInterface.getName());
            serviceModel.setInterface(csiModel);
            componentModel.addService(serviceModel);

            // Component reference definition(s)
            // Need to add these!
        }

        if (!compositeModel.getModelChildren().isEmpty()) {
            switchyardModel.setComposite(compositeModel);
        }

        return new ScannerOutput<SwitchYardModel>().setModel(switchyardModel);
    }
View Full Code Here

        _httpInbound.start();

        HttpBindingModel config = new V1HttpBindingModel(HttpNamespace.DEFAULT.uri()) {
            @Override
            public CompositeReferenceModel getReference() {
                return new V1CompositeReferenceModel();
            }
        };
        config.setServiceName(_proxyConsumerService1.getServiceName());
        config.setName("proxy-test");
        config.setMethod("PUT");
View Full Code Here

        _resteasyInbound.start();

        RESTEasyBindingModel config = new V1RESTEasyBindingModel(RESTEasyNamespace.DEFAULT.uri()) {
            @Override
            public CompositeReferenceModel getReference() {
                return new V1CompositeReferenceModel();
            }
        };
        config.setServiceName(_authConsumerService1.getServiceName());
        config.setName("auth-test");
        config.setInterfaces("org.switchyard.component.resteasy.HelloResource");
View Full Code Here

        URL serviceURL = new URL("http://" + host + ":" + port + "/HelloWebService");

        SOAPBindingModel config = new V1SOAPBindingModel(SOAPNamespace.DEFAULT.uri()) {
            @Override
            public CompositeReferenceModel getReference() {
                return new V1CompositeReferenceModel();
            }
        };
        config.setWsdl(serviceURL.toExternalForm() + "?wsdl");
        config.setServiceName(_authConsumerService1.getServiceName());
        config.setName("auth-test");
View Full Code Here

TOP

Related Classes of org.switchyard.config.model.composite.v1.V1ComponentModel

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.