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

        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

    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

        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 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

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.