Package org.apache.tuscany.spi.model

Examples of org.apache.tuscany.spi.model.CompositeImplementation


        replay(reader);

        replay(context);
        replay(artifactRepository);

        CompositeImplementation impl = loader.load(null, reader, context);
        verify(reader);
        verify(context);
        verify(artifactRepository);
        assertEquals(name, impl.getName());
        assertNull(impl.getScdlLocation());
        assertNull(impl.getClassLoader());
    }
View Full Code Here


        replay(context);
        URL url = new URL("http://www.example.com/sca/base.jar");
        artifactRepository.resolve(artifactMatcher(url, "com.example", name, "1.0"));
        replay(artifactRepository);

        CompositeImplementation impl = loader.load(null, reader, context);
        verify(reader);
        verify(context);
        verify(artifactRepository);
        assertEquals(name, impl.getName());
        assertEquals(new URL("jar:http://www.example.com/sca/base.jar!/META-INF/sca/default.scdl"), impl.getScdlLocation());
        assertTrue(impl.getClassLoader() instanceof CompositeClassLoader);
    }
View Full Code Here

        expect(context.getScdlLocation()).andReturn(new URL("http://www.example.com/sca/base.scdl"));
        expect(context.getClassLoader()).andReturn(cl);
        replay(context);
        replay(artifactRepository);

        CompositeImplementation impl = loader.load(null, reader, context);
        verify(reader);
        verify(context);
        verify(artifactRepository);
        assertEquals(name, impl.getName());
        assertEquals(new URL("http://www.example.com/sca/bar.scdl"), impl.getScdlLocation());
        assertSame(cl, impl.getClassLoader());
    }
View Full Code Here

        expect(context.getScdlLocation()).andReturn(new URL("http://www.example.com/sca/base.scdl"));
        expect(context.getClassLoader()).andReturn(cl);
        replay(context);
        replay(artifactRepository);

        CompositeImplementation impl = loader.load(null, reader, context);
        verify(reader);
        verify(context);
        verify(artifactRepository);
        assertEquals(name, impl.getName());
        assertEquals(new URL("jar:http://www.example.com/sca/bar.jar!/META-INF/sca/default.scdl"),
                     impl.getScdlLocation());
    }
View Full Code Here

    private BuilderRegistryImpl registry;

    public void testRegistrationWithoutGenerics() {
        RawBuilder builder = new RawBuilder();
        registry.register(CompositeImplementation.class, builder);
        CompositeImplementation implementation = new CompositeImplementation();
        ComponentDefinition<CompositeImplementation> componentDefinition =
            new ComponentDefinition<CompositeImplementation>(implementation);
        componentDefinition.getImplementation().setComponentType(new CompositeComponentType());
        registry.build(null, componentDefinition, deploymentContext);
    }
View Full Code Here

        if (appScdl == null) {
            throw new LoaderException("No application scdl found");
        }

        // create a ComponentDefinition to represent the component we are going to deploy
        CompositeImplementation impl = new CompositeImplementation();
        impl.setScdlLocation(appScdl);
        impl.setClassLoader(applicationLoader);
        ComponentDefinition<CompositeImplementation> moduleDefinition =
            new ComponentDefinition<CompositeImplementation>(name, impl);

        // deploy the component into the runtime under the system parent
        CompositeComponent parent = runtime.getRootComponent();
View Full Code Here

                                                       String name,
                                                       URL applicationScdl,
                                                       ClassLoader applicationClassLoader)
        throws LoaderException {

        CompositeImplementation impl = new CompositeImplementation();
        impl.setScdlLocation(applicationScdl);
        impl.setClassLoader(applicationClassLoader);
        ComponentDefinition<CompositeImplementation> definition =
            new ComponentDefinition<CompositeImplementation>(name, impl);

        return (CompositeComponent) deployer.deploy(parent, definition);
    }
View Full Code Here

        String version = reader.getAttributeValue(null, "version");
        String scdlLocation = reader.getAttributeValue(null, "scdlLocation");
        String jarLocation = reader.getAttributeValue(null, "jarLocation");
        LoaderUtil.skipToEndElement(reader);

        CompositeImplementation impl = new CompositeImplementation();
        impl.setName(name);
        if (scdlLocation != null) {
            try {
                impl.setScdlLocation(new URL(deploymentContext.getScdlLocation(), scdlLocation));
            } catch (MalformedURLException e) {
                InvalidValueException ive = new InvalidValueException(scdlLocation, e);
                ive.setIdentifier(name);
                throw ive;
            }
            impl.setClassLoader(deploymentContext.getClassLoader());
        } else if (jarLocation != null) {
            URL jarUrl;
            try {
                jarUrl = new URL(deploymentContext.getScdlLocation(), jarLocation);
            } catch (MalformedURLException e) {
                InvalidValueException ive = new InvalidValueException(jarLocation, e);
                ive.setIdentifier(name);
                throw ive;
            }
            try {
                impl.setScdlLocation(new URL("jar:" + jarUrl.toExternalForm() + "!/META-INF/sca/default.scdl"));
            } catch (MalformedURLException e) {
                throw new AssertionError("Could not convert URL to a jar: url");
            }
            impl.setClassLoader(new CompositeClassLoader(new URL[]{jarUrl}, deploymentContext.getClassLoader()));
        } else if (artifactRepository != null && group != null && version != null) {
            Artifact artifact = new Artifact();
            artifact.setGroup(group);
            artifact.setName(name);
            artifact.setVersion(version);
            artifact.setType("jar");
            artifactRepository.resolve(artifact);
            if (artifact.getUrl() == null) {
                MissingResourceException mre = new MissingResourceException(artifact.toString());
                mre.setIdentifier(name);
                throw mre;
            }
            try {
                impl.setScdlLocation(new URL("jar:" + artifact.getUrl() + "!/META-INF/sca/default.scdl"));
            } catch (MalformedURLException e) {
                throw new AssertionError(e);
            }
            Set<URL> artifactURLs = artifact.getUrls();
            URL[] urls = new URL[artifactURLs.size()];
            int i = 0;
            for (URL artifactURL : artifactURLs) {
                urls[i++] = artifactURL;
            }
            impl.setClassLoader(new CompositeClassLoader(urls, deploymentContext.getClassLoader()));
        }
        return impl;
    }
View Full Code Here

public class CompositeBuilder extends ComponentBuilderExtension<CompositeImplementation> {

    public Component build(CompositeComponent parent,
                           ComponentDefinition<CompositeImplementation> componentDefinition,
                           DeploymentContext deploymentContext) throws BuilderConfigException {
        CompositeImplementation implementation = componentDefinition.getImplementation();
        CompositeComponentType<?, ?, ?> componentType = implementation.getComponentType();

        // create lists of all components, services and references in this composite
        List<ComponentDefinition<? extends Implementation<?>>> allComponents =
            new ArrayList<ComponentDefinition<? extends Implementation<?>>>();
        allComponents.addAll(componentType.getComponents().values());
View Full Code Here

        CompositeComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> outerType =
            new CompositeComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>>();
        outerType.add(createSourceComponentDef());
        outerType.add(createTargetComponentDef());

        CompositeImplementation outerImpl = new CompositeImplementation();
        outerImpl.setComponentType(outerType);

        return new ComponentDefinition<CompositeImplementation>(outerImpl);
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.spi.model.CompositeImplementation

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.