Package org.apache.tuscany.sca.contribution.resolver

Examples of org.apache.tuscany.sca.contribution.resolver.ClassReference


    public void resolve(POJOImplementation implementation, ModelResolver resolver) throws ContributionResolveException {
       
        // Resolve the POJO implementation
       
        // First resolve its class
        ClassReference classReference = new ClassReference(implementation.getPOJOName());
        classReference = resolver.resolveModel(ClassReference.class, classReference);
        Class pojoClass = classReference.getJavaClass();
        if (pojoClass == null) {
            throw new ContributionResolveException("Class could not be resolved: " + implementation.getPOJOName());
        }
        implementation.setPOJOClass(pojoClass);
       
View Full Code Here


        assertFalse(inited);
        ProcessorContext context = new ProcessorContext(registry);
        ImportSDO importSDO = loader.read(reader, context);
        assertNotNull(importSDO);
        ModelResolver resolver = new TestModelResolver();
        resolver.addModel(new ClassReference(MockFactory.class), context);
        loader.resolve(importSDO, resolver, context);
        assertTrue(inited);
    }
View Full Code Here

    }

    private void importFactory(ImportSDO importSDO, ModelResolver resolver,ProcessorContext context) throws ContributionResolveException {
        String factoryName = importSDO.getFactoryClassName();
        if (factoryName != null) {
            ClassReference reference = new ClassReference(factoryName);
            ClassReference resolved = resolver.resolveModel(ClassReference.class, reference,context);
            if (resolved != null && !resolved.isUnresolved()) {
              try {
                    Class<?> factoryClass = resolved.getJavaClass();
                    register(factoryClass, importSDO.getHelperContext());
                    importSDO.setUnresolved(false);
                } catch (Exception e) {
                  ContributionResolveException ce = new ContributionResolveException(e);
                  error(context.getMonitor(), "ContributionResolveException", resolver, ce);
View Full Code Here

            // Resolve the Java interface
            javaInterface = resolver.resolveModel(JavaInterface.class, javaInterface, context);
            if (javaInterface.isUnresolved()) {

                // If the Java interface has never been resolved yet, do it now
                ClassReference classReference = new ClassReference(javaInterface.getName());
                classReference = resolver.resolveModel(ClassReference.class, classReference, context);
                Class<?> javaClass = classReference.getJavaClass();
                if (javaClass == null) {
                    error(monitor, "ClassNotFoundException", resolver, javaInterface.getName());
                    return javaInterface;
                    //throw new ContributionResolveException(new ClassNotFoundException(javaInterface.getName()));
                }
               
                try {                       
                    // Introspect the Java interface and populate the interface and
                    // operations
                    javaFactory.createJavaInterface(javaInterface, javaClass);
                   
                    // cache the contribution that was used to resolve the Java interface
                    // in case we need it to reolve a referenced WSDL file
                    javaInterface.setContributionContainingClass(classReference.getContributionContainingClass());
               
                } catch (InvalidInterfaceException e) {
                  ContributionResolveException ce = new ContributionResolveException("Resolving Java interface " + javaInterface.getName(), e);
                  //error("ContributionResolveException", javaFactory, ce);
                  error(monitor, "InvalidInterfaceException", javaFactory, e);
View Full Code Here

        if (!(unresolved instanceof ClassReference)) {
            return unresolved;
        }
       
        // Filter package name
        ClassReference classReference = (ClassReference)unresolved;
        String className = classReference.getClassName();
        int d = className.lastIndexOf('.');
        String packageName;
        if (d != -1) {
            packageName = className.substring(0, d);
        } else {
View Full Code Here

            contributionContainingClass = contribution.get();
           
            // Load the class and return a class reference for it
            String className = ((ClassReference)unresolved).getClassName();
            Class<?> clazz = Class.forName(className, false, this);
            ClassReference classReference = new ClassReference(clazz);
            classReference.setContributionContainingClass(contributionContainingClass);
            contributionContainingClass = null;
            return modelClass.cast(classReference);

        } catch (ClassNotFoundException e) {
            return unresolved;
View Full Code Here

        }

        // First try to load the class using the Java import resolvers
        ModelResolver importResolver = importResolvers.get(packageName);
        if (importResolver != null) {
            ClassReference classReference = importResolver.resolveModel(ClassReference.class, new ClassReference(name), context);
            if (!classReference.isUnresolved()) {
                contributionContainingClass = classReference.getContributionContainingClass();
                return classReference.getJavaClass();
            }
        }

        // Next, try to load the class from the current contribution
        Class<?> clazz = super.findClass(name);
View Full Code Here

        } catch (Exception e) {
        }
    }

    public void addModel(Object resolved) {
        ClassReference clazz = (ClassReference)resolved;
        map.put(clazz.getClassName(), clazz);
    }
View Full Code Here

        return xqExpression;
    }
   
    private Class<?> resolveClass(ModelResolver resolver, String className) throws ClassNotFoundException {
        ClassReference classReference = new ClassReference(className);
        classReference = resolver.resolveModel(ClassReference.class, classReference);
        Class<?> javaClass = classReference.getJavaClass();
        if (javaClass == null) {
            throw new ClassNotFoundException(className);
        } else {
            return javaClass;
        }
View Full Code Here

    }

    public void resolve(JavaImplementation javaImplementation, ModelResolver resolver)
        throws ContributionResolveException {

        ClassReference classReference = new ClassReference(javaImplementation.getName());
        classReference = resolver.resolveModel(ClassReference.class, classReference);
        Class javaClass = classReference.getJavaClass();
        if (javaClass == null) {
            throw new ContributionResolveException(new ClassNotFoundException(javaImplementation.getName()));
        }
        javaImplementation.setJavaClass(javaClass);
        javaImplementation.setUnresolved(false);
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.contribution.resolver.ClassReference

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.