Package org.codehaus.jam

Examples of org.codehaus.jam.JClass


        JamService service = factory.createService(jam_service_parms);
        QName extraSchemaTypeName = null;
        JamClassIterator jClassIter = service.getClasses();
        // all most all the time the ittr will have only one class in it
        while (jClassIter.hasNext()) {
            JClass jclass = (JClass)jClassIter.next();
            // serviceName = jclass.getSimpleName();
            // todo in the future , when we support annotation we can use this
            // JAnnotation[] annotations = jclass.getAnnotations();

            if (jclass.getQualifiedName().equals(generationParams.getSourceClassName())) {
                /**
                 * Schema genertaion done in two stage 1. Load all the methods
                 * and create type for methods parameters (if the parameters are
                 * Bean then it will create Complex types for those , and if the
                 * parameters are simple type which decribe in SimpleTypeTable
                 * nothing will happen) 2. In the next stage for all the methods
                 * messages and port types will be creteated
                 */
                methods = jclass.getDeclaredMethods();
                // short the elements in the array
                Arrays.sort(methods);

                // since we do not support overload
                HashMap uniqueMethods = new HashMap();
                XmlSchemaComplexType methodSchemaType;
                XmlSchemaSequence sequence = null;

                for (int i = 0; i < methods.length; i++) {
                    JMethod jMethod = methods[i];

                    String methodName = methods[i].getSimpleName();
                    // no need to think abt this method , since that is system
                    // config method
                    if (excludeMethods.contains(jMethod.getSimpleName())) {
                        continue;
                    }

                    if (uniqueMethods.get(jMethod.getSimpleName()) != null) {
                        throw new Exception(" Sorry we don't support methods overloading !!!! ");
                    }

                    if (!jMethod.isPublic()) {
                        // no need to generate Schema for non public methods
                        continue;
                    }
                    uniqueMethods.put(jMethod.getSimpleName(), jMethod);
                    // create the schema type for the method wrapper

                    uniqueMethods.put(jMethod.getSimpleName(), jMethod);
                    JParameter[] paras = jMethod.getParameters();
                    String parameterNames[] = null;
                    // better to handle void types too
                    parameterNames = methodTable.getParameterNames(methodName);
                    sequence = new XmlSchemaSequence();

                    methodSchemaType = createSchemaTypeForMethodPart(jMethod.getSimpleName());
                    methodSchemaType.setParticle(sequence);

                    for (int j = 0; j < paras.length; j++) {
                        JParameter methodParameter = paras[j];
                        JClass paraType = methodParameter.getType();
                        generateSchemaForType(sequence, paraType, (parameterNames != null && parameterNames[j] != null)
                            ? parameterNames[j] : methodParameter.getSimpleName());
                    }
                    // for its return type
                    JClass returnType = jMethod.getReturnType();

                    // better to handle void types too
                    methodSchemaType = createSchemaTypeForMethodPart(jMethod.getSimpleName() + RESPONSE);
                    sequence = new XmlSchemaSequence();
                    methodSchemaType.setParticle(sequence);
View Full Code Here


    }

    public void generate() throws IOException {
        List list = new ArrayList();
        for (int i = 0; i < classes.length; i++) {
            JClass type = classes[i];
            if (implementsInterface(type, Scenario.class) && !type.isAbstract() && !type.isInterface()) {
                generateTestsFor(type);
                list.add(type);
            }
        }
View Full Code Here

    protected void generatePropertiesFile(List list) throws IOException {
        PrintWriter writer = new PrintWriter(new FileWriter(scenariosFile));
        try {
            for (Iterator iter = list.iterator(); iter.hasNext();) {
                JClass type = (JClass) iter.next();
                writer.print(type.getQualifiedName());
                writer.print(" = ");
                writeInterfaces(writer, type);
                writer.println();
            }
        }
View Full Code Here

    protected void writeInterfaces(PrintWriter writer, JClass type) {
        List interfaces = new ArrayList();
        addAllInterfaces(interfaces, type);
        boolean first = true;
        for (Iterator iter = interfaces.iterator(); iter.hasNext();) {
            JClass interfaceType = (JClass) iter.next();
            if (first) {
                first = false;
            }
            else {
                writer.print(", ");
            }
            writer.print(interfaceType.getQualifiedName());
        }
    }
View Full Code Here

    }

    protected void addAllInterfaces(List list, JClass type) {
        JClass[] interfaces = type.getInterfaces();
        for (int i = 0; i < interfaces.length; i++) {
            JClass interfaceType = interfaces[i];
            list.add(interfaceType);
        }
        JClass superclass = type.getSuperclass();
        if (superclass != null) {
            addAllInterfaces(list, superclass);
        }
    }
View Full Code Here

    }

    protected boolean implementsInterface(JClass type, Class interfaceClass) {
        JClass[] interfaces = type.getInterfaces();
        for (int i = 0; i < interfaces.length; i++) {
            JClass anInterface = interfaces[i];
            if (anInterface.getQualifiedName().equals(interfaceClass.getName())) {
                return true;
            }
        }
        JClass superclass = type.getSuperclass();
        if (superclass == null || superclass == type) {
            return false;
        }
        else {
            return implementsInterface(superclass, interfaceClass);
View Full Code Here

    }

    public void generate() throws IOException {
        List list = new ArrayList();
        for (int i = 0; i < classes.length; i++) {
            JClass type = classes[i];
            if (implementsInterface(type, Scenario.class) && !type.isAbstract() && !type.isInterface()) {
                generateTestsFor(type);
                list.add(type);
            }
        }
View Full Code Here

    protected void generatePropertiesFile(List list) throws IOException {
        PrintWriter writer = new PrintWriter(new FileWriter(scenariosFile));
        try {
            for (Iterator iter = list.iterator(); iter.hasNext();) {
                JClass type = (JClass) iter.next();
                writer.print(type.getQualifiedName());
                writer.print(" = ");
                writeInterfaces(writer, type);
                writer.println();
            }
        }
View Full Code Here

    protected void writeInterfaces(PrintWriter writer, JClass type) {
        List interfaces = new ArrayList();
        addAllInterfaces(interfaces, type);
        boolean first = true;
        for (Iterator iter = interfaces.iterator(); iter.hasNext();) {
            JClass interfaceType = (JClass) iter.next();
            if (first) {
                first = false;
            }
            else {
                writer.print(", ");
            }
            writer.print(interfaceType.getQualifiedName());
        }
    }
View Full Code Here

    }

    protected void addAllInterfaces(List list, JClass type) {
        JClass[] interfaces = type.getInterfaces();
        for (int i = 0; i < interfaces.length; i++) {
            JClass interfaceType = interfaces[i];
            list.add(interfaceType);
        }
        JClass superclass = type.getSuperclass();
        if (superclass != null) {
            addAllInterfaces(list, superclass);
        }
    }
View Full Code Here

TOP

Related Classes of org.codehaus.jam.JClass

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.