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

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


    }

    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()) {
                ContributionResolveException loaderException =
                    new ContributionResolveException("Fail to resolve class: " + factoryName);
                throw loaderException;
            }
            try {
                Class<?> factoryClass = resolved.getJavaClass();
                register(factoryClass, importSDO.getHelperContext());
            } catch (Exception e) {
                throw new ContributionResolveException(e);
            }
            importSDO.setUnresolved(false);
View Full Code Here


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

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

     * Handle artifact resolution when the specific class reference is imported from another contribution
     * @param unresolved
     * @return
     */
    private ClassReference resolveImportedModel(ClassReference unresolved) {
        ClassReference resolved = unresolved;

        if (this.contribution != null) {
            for (Import import_ : this.contribution.getImports()) {

                if (resolved == unresolved && bundle != null) {
View Full Code Here

        }

        if (clazz != null) {
            //if we load the class           
            // Store a new ClassReference wrappering the loaded class
            ClassReference classReference = new ClassReference(clazz);
            map.put(getPackageName(classReference), classReference);

            // Return the resolved ClassReference
            return modelClass.cast(classReference);
        } else {
View Full Code Here

            // Ignore error, non-OSGi classloading is used in this case
        }
    }

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

    /**
     * Test ClassReference resolution
     *
     */
    public void testResolveClass() {
        ClassReference ref = new ClassReference(getClass().getName());
        ClassReference clazz = resolver.resolveModel(ClassReference.class, ref);
        assertFalse(clazz.isUnresolved());
        assertTrue(clazz.getJavaClass() == getClass());
    }
View Full Code Here

        }

        if (clazz != null) {
            //if we load the class           
            // Store a new ClassReference wrappering the loaded class
            ClassReference classReference = new ClassReference(clazz);
            map.put(clazz.getName(), classReference);

            // Return the resolved ClassReference
            return modelClass.cast(classReference);
        } else {
View Full Code Here

    /**
     * Test ClassReference resolution of inexistent class
     *
     */
    public void testUnresolvedClass() {
        ClassReference ref = new ClassReference("NonExistentClass");
        ClassReference clazz = resolver.resolveModel(ClassReference.class, ref);
        assertTrue(clazz.isUnresolved());
        assertTrue(clazz.getJavaClass() == null);
    }
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 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 wrappering 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.