Package org.apache.tuscany.container.spring.model

Examples of org.apache.tuscany.container.spring.model.SpringComponentType


            // FIXME hack since the builder registry loads the implementation type and the Spring implementation loader
            // needs to as well. The second call is done by the builder registry and we just ignore it.
            return;
        }
        Resource resource = implementation.getApplicationResource();
        SpringComponentType componentType = new SpringComponentType();
        // REVIEW andyp -- pass in deploymentContext.getClassLoader()?
        AbstractRefreshableApplicationContext ctx;
        if (runtimeInfo instanceof SpringRuntimeInfo) {
            ctx = ((SpringRuntimeInfo) runtimeInfo).getApplicationContext();
        } else {
            ctx = new ScaApplicationContext(resource, componentType);
        }
        componentType.setApplicationContext(ctx); // FIXME andyp@bea.com -- don't do this!

        // If there are <sca:service> elements, they define (and limit) the services exposed
        // in the componentType.
        String [] serviceBeanNames = ctx.getBeanNamesForType(ScaServiceExporter.class);
        for (String serviceBeanName : serviceBeanNames) {
            int nSuffix = serviceBeanName.indexOf(SERVICE_BEAN_SUFFIX);
            if (nSuffix == -1) {
                continue;
            }

            String serviceName = serviceBeanName.substring(0, nSuffix);
            ScaServiceExporter serviceBean = (ScaServiceExporter) ctx.getBean(serviceName);
            // REVIEW andyp -- use the class directly?
            String serviceTypeName = serviceBean.getServiceType().getName();
            try {
                Class serviceInterface = Class.forName(serviceTypeName, true, deploymentContext.getClassLoader());
                componentType.addServiceType(serviceName, serviceInterface);
                //ServiceDefinition service = createService(serviceInterface);
                //componentType.getServices().put(serviceName, service);
            } catch (ClassNotFoundException e) {
                throw new LoaderException(e);
            }
        }
        // if no service tags are specified, expose all beans
        componentType.setExposeAllBeans(componentType.getServiceTypes().isEmpty());
        implementation.setComponentType(componentType);
    }
View Full Code Here


        ClassLoader classLoader = deploymentContext.getClassLoader();
        if (!contextProvided()) {
            implementation.setApplicationResource(getApplicationContextResource(locationAttr, classLoader));
        }
        registry.loadComponentType(parent, implementation, deploymentContext);
        SpringComponentType type = implementation.getComponentType();
        while (true) {
            switch (reader.next()) {
                case START_ELEMENT:
                    QName qname = reader.getName();
                    if (SERVICE_ELEMENT.equals(qname)) {
                        BoundServiceDefinition service =
                            (BoundServiceDefinition) registry.load(parent, reader, deploymentContext);
                        if (!type.isExposeAllBeans()) {
                            String name = service.getName();
                            if (!type.getServiceTypes().containsKey(name)) {
                                LoaderException e = new LoaderException("No service defined in Spring context for ");
                                e.setIdentifier(name);
                                throw e;
                            }
                        }
                        type.getDeclaredServices().put(service.getName(), service);
                    } else if (REFERENCE_ELEMENT.equals(qname)) {
                        BoundReferenceDefinition reference =
                            (BoundReferenceDefinition) registry.load(parent, reader, deploymentContext);
                        type.getDeclaredReferences().put(reference.getName(), reference);
                    }
                    break;
                case END_ELEMENT:
                    if (IMPLEMENTATION_SPRING.equals(reader.getName())) {
                        return implementation;
View Full Code Here

     * Verfies basic build of a spring context
     */
    @SuppressWarnings("unchecked")
    public void testBuild() throws Exception {
        // Create an assembly model consisting of a component implemented by Spring
        SpringImplementation impl = new SpringImplementation(new SpringComponentType(createContext()));
        ComponentDefinition<SpringImplementation> componentDefinition =
            new ComponentDefinition<SpringImplementation>("spring", impl);

        // Configure the mock builder registry
        BuilderRegistry registry = createNiceMock(BuilderRegistry.class);
View Full Code Here

        verify(registry);
    }

    @SuppressWarnings("unchecked")
    private SpringComponentType createComponentType() {
        SpringComponentType componentType = new SpringComponentType(createContext());
        BoundServiceDefinition<TestBinding> serviceDefinition = new BoundServiceDefinition<TestBinding>();
        serviceDefinition.setName("fooService");
        serviceDefinition.setBinding(new TestBinding());
        try {
            serviceDefinition.setTarget(new URI("foo"));
        } catch (URISyntaxException e) {
            throw new AssertionError();
        }
        componentType.add(serviceDefinition);
        return componentType;
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.container.spring.model.SpringComponentType

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.