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

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


            return modelClass.cast(resolved);
           
        } else if (unresolved instanceof ClassReference) {
           
            // Load a class on demand
            ClassReference classReference = (ClassReference)unresolved;
            Class<?> clazz;
            try {
                clazz = Class.forName(classReference.getClassName(), true, classLoader.get());
            } catch (ClassNotFoundException e) {
               
                // Return the unresolved object
                return unresolved;
            }
           
            // Store a new ClassReference wrappering the loaded class
            resolved = new ClassReference(clazz);
            map.put(resolved, resolved);
           
            // Return the resolved ClassReference
            return modelClass.cast(resolved);
               
View Full Code Here


            return modelClass.cast(resolved);
           
        } else if (unresolved instanceof ClassReference) {
           
            // Load a class on demand
            ClassReference classReference = (ClassReference)unresolved;
            Class<?> clazz;
            try {
                clazz = Class.forName(classReference.getClassName(), true, classLoader.get());
            } catch (ClassNotFoundException e) {
               
                // Return the unresolved object
                return unresolved;
            }
           
            // Store a new ClassReference wrapping the loaded class
            resolved = new ClassReference(clazz);
            map.put(resolved, resolved);
           
            // Return the resolved ClassReference
            return modelClass.cast(resolved);
               
View Full Code Here

            // Resolve the Java interface
            javaInterface = resolver.resolveModel(JavaInterface.class, javaInterface);
            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);
                Class javaClass = classReference.getJavaClass();
                if (javaClass == null) {
                    error("ClassNotFoundException", resolver, javaInterface.getName());
                    return javaInterface;
                    //throw new ContributionResolveException(new ClassNotFoundException(javaInterface.getName()));
                }
View Full Code Here

        try {

            // Load the class and return a class reference for it
            String className = ((ClassReference)unresolved).getClassName();
            Class<?> clazz = Class.forName(className, true, this);
            return modelClass.cast(new ClassReference(clazz));

        } catch (ClassNotFoundException e) {
            return unresolved;
        } catch (NoClassDefFoundError 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));
            if (!classReference.isUnresolved()) {
                return classReference.getJavaClass();
            }
        }

        // Next, try to load the class from the current contribution
        Class<?> clazz = super.findClass(name);
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) {
          error("ClassNotFoundException", resolver, javaImplementation.getName());
            //throw new ContributionResolveException(new ClassNotFoundException(javaImplementation.getName()));
          return;
        }
View Full Code Here

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

            return modelClass.cast(resolved);
           
        } else if (unresolved instanceof ClassReference) {
           
            // Load a class on demand
            ClassReference classReference = (ClassReference)unresolved;
            Class clazz;
            try {
                clazz = Class.forName(classReference.getClassName(), true, classLoader.get());
            } catch (ClassNotFoundException e) {
               
                // Return the unresolved object
                return unresolved;
            }
           
            // Store a new ClassReference wrapping the loaded class
            resolved = new ClassReference(clazz);
            map.put(resolved, resolved);
           
            // Return the resolved ClassReference
            return modelClass.cast(resolved);
          
View Full Code Here

    }

    private void importFactory(ImportSDO importSDO, ModelResolver resolver) throws ContributionResolveException {
        String factoryName = importSDO.getFactoryClassName();
        if (factoryName != null) {
            ClassReference reference = new ClassReference(factoryName);
            ClassReference resolved = resolver.resolveModel(ClassReference.class, reference);
            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("ContributionResolveException", resolver, ce);
View Full Code Here

            return modelClass.cast(resolved);
           
        } else if (unresolved instanceof ClassReference) {
           
            // Load a class on demand
            ClassReference classReference = (ClassReference)unresolved;
            Class clazz;
            try {
                clazz = Class.forName(classReference.getClassName(), true, classLoader.get());
            } catch (ClassNotFoundException e) {
               
                // Return the unresolved object
                return unresolved;
            }
           
            // Store a new ClassReference wrapping the loaded class
            resolved = new ClassReference(clazz);
            map.put(resolved, resolved);
           
            // Return the resolved ClassReference
            return modelClass.cast(resolved);
               
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.