Package org.apache.tuscany.model.assembly

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


            module.getComponents().addAll(oldModule.getComponents());
            module.getEntryPoints().addAll(oldModule.getEntryPoints());
            module.getExternalServices().addAll(oldModule.getExternalServices());
        } else {
            if (model instanceof Component) {
                Component component = (Component) model;
                module.getComponents().add(component);
                configuration = (ContextFactory<Context>) component.getContextFactory();
                if (configuration == null) {
                    ConfigurationException e = new MissingContextFactoryException("Context factory not set");
                    e.setIdentifier(component.getName());
                    e.addContextName(getName());
                    throw e;
                }
                registerConfiguration(configuration);
                if (component instanceof ModuleComponent) {
View Full Code Here


        for (Component component : components) {
            ContextFactory<Context> source = (ContextFactory<Context>) component.getContextFactory();
            Assert.assertNotNull(source);
            for (SourceWireFactory pFactory : source.getSourceWireFactories()) {
                WireConfiguration pConfig = pFactory.getConfiguration();
                Component target = compMap.get(pConfig.getTargetName().getPartName());

                if (target != null) {
                    ContextFactory targetConfig = (ContextFactory) target.getContextFactory();
                    boolean downScope = strategy.downScopeReference(source.getScope(), targetConfig.getScope());
                    wireBuilder.connect(pFactory, targetConfig.getTargetWireFactory(pFactory.getConfiguration().getTargetName()
                            .getPortName()), targetConfig.getClass(), downScope, scopeContext);
                }
                pFactory.initialize();
View Full Code Here

    public void build(AssemblyObject modelObject) throws BuilderException {
        if (!(modelObject instanceof Component)) {
            return;
        }
        Component nonGenricComponent = (Component) modelObject;
        if (!implementationClass.isAssignableFrom(nonGenricComponent.getImplementation().getClass())) {
            return;
        }
        Component<T> component = (Component<T>) modelObject;
        List<Service> services = component.getImplementation().getComponentType().getServices();
        Scope previous = null;
View Full Code Here

        // bootstrap the minimal set of loaders needed to read the system module files
        // all others should be defined in the system.module file
        components.add(bootstrapLoader(factory, introspector, ModuleLoader.class));
        components.add(bootstrapLoader(factory, introspector, ModuleFragmentLoader.class));
        Component propFactory = factory.createSystemComponent("org.apache.tuscany.core.system.loader.DefaultPropertyFactory", StAXPropertyFactory.class, StringParserPropertyFactory.class, Scope.MODULE);
        introspector.introspect(StAXPropertyFactory.class);
        components.add(propFactory);
        components.add(bootstrapLoader(factory, introspector, ComponentLoader.class));
        components.add(bootstrapLoader(factory, introspector, EntryPointLoader.class));
        components.add(bootstrapLoader(factory, introspector, InterfaceJavaLoader.class));
View Full Code Here

        try {
            implementation.setComponentType(introspector.introspect(loaderClass));
        } catch (ConfigurationException e) {
            throw (AssertionError) new AssertionError("Invalid bootstrap loader").initCause(e);
        }
        Component component = factory.createSimpleComponent();
        component.setName(loaderClass.getName());
        component.setImplementation(implementation);
        return component;
    }
View Full Code Here

    private static <T> void bootstrapService(SystemAssemblyFactory factory, ComponentTypeIntrospector introspector, Module module, Class<T> service, Class<? extends T> impl) {
        String epName = service.getName();
        String compName = impl.getName();

        Component component = factory.createSystemComponent(compName, service, impl, Scope.MODULE);
        try {
            component.getImplementation().setComponentType(introspector.introspect(impl));
        } catch (ConfigurationException e) {
            throw (AssertionError) new AssertionError("Invalid bootstrap loader").initCause(e);
        }

        EntryPoint entryPoint = factory.createSystemEntryPoint(epName, service, compName);
View Full Code Here

    }

    public Component load(XMLStreamReader reader, LoaderContext loaderContext) throws XMLStreamException, ConfigurationLoadException {
        assert COMPONENT.equals(reader.getName());

        Component component = factory.createSimpleComponent();
        component.setName(reader.getAttributeValue(null, "name"));

        while (true) {
            switch (reader.next()) {
                case START_ELEMENT:
                    QName name = reader.getName();
                    if (PROPERTIES.equals(name)) {
                        loadProperties(reader, loaderContext.getResourceLoader(), component);
                    } else if (REFERENCES.equals(name)) {
                        loadReferences(reader, component);
                    } else {
                        AssemblyObject o = registry.load(reader, loaderContext);
                        if (o instanceof Implementation) {
                            Implementation impl = (Implementation) o;
                            impl.initialize(registry.getContext());
                            component.setImplementation(impl);
                        }
                    }
                    reader.next();
                    break;
                case END_ELEMENT:
                    List<Property> props = component.getImplementation().getComponentType().getProperties();
                    for (Property property : props) {
                        if (property.isRequired()) {
                            if (component.getConfiguredProperty(property.getName()) == null) {
                                ConfigurationLoadException e = new ConfigurationLoadException("Required property not configured");
                                e.setIdentifier(property.getName());
                                throw e;
                            }
                        }
View Full Code Here

    /**
     * Creates an composite component with the given name
     */
    public static Component createCompositeComponent(String name) throws ConfigurationLoadException {
        Component sc = systemFactory.createModuleComponent();
        Module impl = systemFactory.createModule();
        impl.setName(name);
        //impl.setImplementationClass(CompositeContextImpl.class);
        sc.setImplementation(impl);
        Service s = systemFactory.createService();
        JavaServiceContract ji = systemFactory.createJavaServiceContract();
        s.setServiceContract(ji);
        ji.setScope(Scope.AGGREGATE);
        //impl.setComponentType(systemFactory.createComponentType());
        impl.setImplementationClass(CompositeContextImpl.class);
        impl.setComponentType(getCompositeComponentType());
        impl.getComponentType().getServices().add(s);
        sc.setName(name);
        sc.setImplementation(impl);

        return sc;
    }
View Full Code Here

    /**
     * Creates a system composite component with the given name
     */
    public static Component createSystemCompositeComponent(String name) throws ConfigurationLoadException {
        Component sc = systemFactory.createModuleComponent();
        Module impl = systemFactory.createSystemModule();
        impl.setName(name);
        //impl.setImplementationClass(SystemCompositeContextImpl.class);
        sc.setImplementation(impl);
        Service s = systemFactory.createService();
        JavaServiceContract ji = systemFactory.createJavaServiceContract();
        s.setServiceContract(ji);
        ji.setScope(Scope.AGGREGATE);
        impl.setComponentType(getComponentType());
        //impl.setComponentType(systemFactory.createComponentType());
        impl.getComponentType().getServices().add(s);
        sc.setName(name);
        sc.setImplementation(impl);
        return sc;
    }
View Full Code Here

    /**
     * Creates a module with a Java-based "target" component wired to a "source"
     */
    public static Module createModule(Scope sourceScope, Scope targetScope) throws ConfigurationLoadException {
        Component sourceComponent = createNonIntrospectedComponent("source", ModuleScopeComponent.class, ModuleScopeComponentImpl.class, sourceScope);
        Component targetComponent = createNonIntrospectedComponent("target", ModuleScopeComponent.class, ModuleScopeComponentImpl.class, targetScope);

        Service targetService = factory.createService();
        JavaServiceContract targetContract = factory.createJavaServiceContract();
        targetContract.setInterface(GenericComponent.class);
        targetService.setServiceContract(targetContract);
        targetService.setName("GenericComponent");
        targetContract.setScope(targetScope);
        ConfiguredService cTargetService = factory.createConfiguredService();
        cTargetService.setPort(targetService);
        cTargetService.initialize(assemblyContext);
        targetComponent.getConfiguredServices().add(cTargetService);
        targetComponent.initialize(assemblyContext);

        Reference ref = factory.createReference();
        ref.setName("setGenericComponent");
        JavaServiceContract inter = factory.createJavaServiceContract();
        inter.setInterface(GenericComponent.class);
View Full Code Here

TOP

Related Classes of org.apache.tuscany.model.assembly.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.