Package org.apache.tuscany.sca.assembly

Examples of org.apache.tuscany.sca.assembly.ComponentType


     * @param resolver
     * @param impl
     */
    private void mergeComponentType(ModelResolver resolver, BPELImplementation impl) {
        // FIXME: Need to clarify how to merge
        ComponentType componentType = getComponentType(resolver, impl);
        if (componentType != null && !componentType.isUnresolved()) {
           
            Map<String, Reference> refMap = new HashMap<String, Reference>();
            for (Reference ref : impl.getReferences()) {
                refMap.put(ref.getName(), ref);
            }
            for (Reference reference : componentType.getReferences()) {
                refMap.put(reference.getName(), reference);
            }
            impl.getReferences().clear();
            impl.getReferences().addAll(refMap.values());

            Map<String, Service> serviceMap = new HashMap<String, Service>();
            for (Service svc : impl.getServices()) {
                if(svc != null) {
                    serviceMap.put(svc.getName(), svc);   
                }
            }
            for (Service service : componentType.getServices()) {
                //set default dataBinding to DOM
                service.getInterfaceContract().getInterface().resetDataBinding(DOMDataBinding.NAME);
               
                serviceMap.put(service.getName(), service);
            }
View Full Code Here



    private ComponentType getComponentType(ModelResolver resolver, BPELImplementation impl) {
        String bpelProcessURI = impl.getProcessDefinition().getURI().toString();
        String componentTypeURI = bpelProcessURI.replace(".bpel", ".componentType");
        ComponentType componentType = assemblyFactory.createComponentType();
        componentType.setUnresolved(true);
        componentType.setURI(componentTypeURI);
        componentType = resolver.resolveModel(ComponentType.class, componentType);
        if (!componentType.isUnresolved()) {
            return componentType;
        }
        return null;
    }
View Full Code Here

    public void testReadComponentType() throws Exception {
        ComponentTypeProcessor componentTypeProcessor = new ComponentTypeProcessor(assemblyFactory, policyFactory, staxProcessor);
        InputStream is = getClass().getResourceAsStream("/CalculatorServiceImpl.componentType");
        XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
        ComponentType componentType = componentTypeProcessor.read(reader);
        assertNotNull(componentType);
       
        SCABinding referenceSCABinding = (SCABinding) componentType.getReferences().get(0).getBindings().get(0);
        assertNotNull(referenceSCABinding);
       
        SCABinding serviceSCABinding   = (SCABinding) componentType.getServices().get(0).getBindings().get(0);
        assertNotNull(serviceSCABinding);    

        //new PrintUtil(System.out).print(componentType);
    }
View Full Code Here

    
     */
    private void processComponentType(SpringImplementation springImplementation) {

        // Create a ComponentType and mark it unresolved
        ComponentType componentType = assemblyFactory.createComponentType();
        componentType.setUnresolved(true);
        springImplementation.setComponentType(componentType);
    } // end processComponentType
View Full Code Here

            springLoader.load(springImplementation);
        } catch (ContributionReadException e) {
            throw new ContributionResolveException(e);
        }

        ComponentType ct = springImplementation.getComponentType();
        if (ct.isUnresolved()) {
            // If the introspection fails to resolve, try to find a side file...
            ComponentType componentType = resolver.resolveModel(ComponentType.class, ct);
            if (componentType.isUnresolved()) {
                throw new ContributionResolveException(
                                                       "SpringArtifactProcessor: unable to resolve componentType for Spring component");
            }
            springImplementation.setComponentType(componentType);
View Full Code Here

    public ComponentTypeModelResolver(Contribution contribution, ModelFactoryExtensionPoint modelFactories) {
      this.contribution = contribution;
    }

    public void addModel(Object resolved) {
        ComponentType componentType = (ComponentType)resolved;
        map.put(componentType.getURI(), componentType);
    }
View Full Code Here

        if (uri == null) {
          return (T)unresolved;
        }
       
        //lookup the componentType
        ComponentType resolved = (ComponentType) map.get(uri);
        if (resolved != null) {
            return modelClass.cast(resolved);
        }
       
        //If not found, delegate the resolution to the imports (in this case based on the java imports)
        //compute the package name from the componentType URI
        if (unresolved instanceof ComponentType) {
            //FIXME The core assembly model now depends on java imports to
            // resolve componentTypes of all kinds, this is not right at all!!!
            int s = uri.lastIndexOf('/');
            if (s != -1) {
                String packageName = uri.substring(0, uri.lastIndexOf("/"));
                for (Import import_ : this.contribution.getImports()) {
                    if (import_ instanceof JavaImport) {
                      JavaImport javaImport = (JavaImport)import_;
                      //check the import location against the computed package name from the componentType URI
                        if (javaImport.getPackage().equals(packageName)) {
                            // Delegate the resolution to the import resolver
                            resolved = javaImport.getModelResolver().resolveModel(ComponentType.class, (ComponentType)unresolved);
                            if (!resolved.isUnresolved()) {
                                return modelClass.cast(resolved);
                            }
                        }
                    }
                }
View Full Code Here

    public void testReadComponentType() throws Exception {
        ComponentTypeProcessor componentTypeProcessor = new ComponentTypeProcessor(assemblyFactory, policyFactory, staxProcessor);
        InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
        XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
        ComponentType componentType = componentTypeProcessor.read(reader);
        assertNotNull(componentType);

        //new PrintUtil(System.out).print(componentType);
    }
View Full Code Here

        if (lastDot < 0) {
            return;
        }
        String sideFileName = name.substring(0, lastDot) + ".componentType";

        ComponentType componentType = assemblyFactory.createComponentType();
        componentType.setURI(sideFileName);
        componentType.setUnresolved(true);

        componentType = resolver.resolveModel(ComponentType.class, componentType);

        if (!componentType.isUnresolved()) {
            for (Reference reference : componentType.getReferences()) {
                impl.getReferences().add(reference);
            }
            for (Service service : componentType.getServices()) {
                impl.getServices().add(service);
            }
            for (Property property : componentType.getProperties()) {
                impl.getProperties().add(property);
            }
            if (componentType.getConstrainingType() != null) {
                impl.setConstrainingType(componentType.getConstrainingType());
            }
        }
    }
View Full Code Here

    public void testReadComponentType() throws Exception {
        ComponentTypeProcessor componentTypeReader = new ComponentTypeProcessor(assemblyFactory, policyFactory, staxProcessor);
        InputStream is = getClass().getResourceAsStream("CalculatorImpl.componentType");
        XMLStreamReader reader = inputFactory.createXMLStreamReader(is);
        ComponentType componentType = componentTypeReader.read(reader);
        assertNotNull(componentType);

        //new PrintUtil(System.out).print(componentType);
    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.assembly.ComponentType

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.