Package org.apache.tuscany.sca.implementation.java.introspect.impl

Examples of org.apache.tuscany.sca.implementation.java.introspect.impl.NoConstructorException


            constructor = definition.getConstructor();
        } else {
            // no definition, heuristically determine constructor
            Constructor[] constructors = clazz.getConstructors();
            if (constructors.length == 0) {
                throw new NoConstructorException("No public constructor for class");
            } else if (constructors.length == 1) {
                // Only one constructor, take it
                constructor = constructors[0];
            } else {
                // multiple constructors scenario
                Constructor<T> selected = null;               
                for (Constructor<T> ctor : constructors) {
                    if (ctor.getParameterTypes().length == 0) {
                        selected = ctor;
                    } else if (ctor.getParameterTypes().length == conArgs.size()) {
                        // we will find a constructor which has atleast one
                      // reference or property as its parameter types.
                      Class<?>[] parametersTypes = ctor.getParameterTypes();
                    for (Class<?> pType: parametersTypes) {
                      for (JavaElementImpl property : props.values()) {                   
                        if (pType.equals(property.getType()))
                          selected = ctor;
                      }
                      for (JavaElementImpl reference : refs.values()) {
                        if (pType.equals(reference.getType()))
                          selected = ctor;
                      }                                     
                    }
                    }
                }
                if (selected == null) {
                    throw new NoConstructorException();
                }
                constructor = selected;
            }
            definition = type.getConstructors().get(constructor);
            type.setConstructor(definition);
View Full Code Here


            constructor = definition.getConstructor();
        } else {
            // no definition, heuristically determine constructor
            Constructor[] constructors = clazz.getConstructors();
            if (constructors.length == 0) {
                throw new NoConstructorException("No public constructor for class");
            } else if (constructors.length == 1) {
                // Only one constructor, take it
                constructor = constructors[0];
            } else {
                // multiple constructors scenario
                Constructor<T> selected = null;               
                for (Constructor<T> ctor : constructors) {
                    if (ctor.getParameterTypes().length == 0) {
                        selected = ctor;
                    } else if (ctor.getParameterTypes().length == conArgs.size()) {
                        // we will find a constructor which has atleast one
                      // reference or property as its parameter types.
                      Class<?>[] parametersTypes = ctor.getParameterTypes();
                    for (Class<?> pType: parametersTypes) {
                      for (JavaElementImpl property : props.values()) {                   
                        if (pType.equals(property.getType()))
                          selected = ctor;
                      }
                      for (JavaElementImpl reference : refs.values()) {
                        if (pType.equals(reference.getType()))
                          selected = ctor;
                      }                                     
                    }
                    }
                }
                if (selected == null) {
                    throw new NoConstructorException();
                }
                constructor = selected;
            }
            definition = type.getConstructors().get(constructor);
            type.setConstructor(definition);
View Full Code Here

            constructor = definition.getConstructor();
        } else {
            // no definition, heuristically determine constructor
            Constructor[] constructors = clazz.getConstructors();
            if (constructors.length == 0) {
                throw new NoConstructorException("No public constructor for class");
            } else if (constructors.length == 1) {
                // Only one constructor, take it
                constructor = constructors[0];
            } else {
                // multiple constructors scenario
                Constructor<T> selected = null;               
                for (Constructor<T> ctor : constructors) {
                    if (ctor.getParameterTypes().length == 0) {
                        selected = ctor;
                    } else if (ctor.getParameterTypes().length == conArgs.size()) {
                        // we will find a constructor which has atleast one
                      // reference or property as its parameter types.
                      Class<?>[] parametersTypes = ctor.getParameterTypes();
                    for (Class<?> pType: parametersTypes) {
                      for (JavaElementImpl property : props.values()) {                   
                        if (pType.equals(property.getType()))
                          selected = ctor;
                      }
                      for (JavaElementImpl reference : refs.values()) {
                        if (pType.equals(reference.getType()))
                          selected = ctor;
                      }                                     
                    }
                    }
                }
                if (selected == null) {
                    throw new NoConstructorException();
                }
                constructor = selected;
            }
            definition = type.getConstructors().get(constructor);
            type.setConstructor(definition);
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.implementation.java.introspect.impl.NoConstructorException

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.