Package org.codehaus.jam

Examples of org.codehaus.jam.JClass


        List properties = getProperties();
        for (Iterator iter = properties.iterator(); iter.hasNext();) {
            JProperty property = (JProperty) iter.next();
            JAnnotation annotation = property.getAnnotation("openwire:property");
            JAnnotationValue size = annotation.getValue("size");
            JClass propertyType = property.getType();
            String type = propertyType.getSimpleName();
            String getter = "info." + property.getSimpleName();

            if (type.equals("boolean")) {
                out.println("        dataOut.Write(" + getter + ");");
            }
            else if (type.equals("byte")) {
                out.println("        dataOut.Write(" + getter + ");");
            }
            else if (type.equals("char")) {
                out.println("        dataOut.Write(" + getter + ");");
            }
            else if (type.equals("short")) {
                out.println("        dataOut.Write(" + getter + ");");
            }
            else if (type.equals("int")) {
                out.println("        dataOut.Write(" + getter + ");");
            }
            else if (type.equals("long")) {
                out.println("        LooseMarshalLong(wireFormat, " + getter + ", dataOut);");
            }
            else if (type.equals("String")) {
                out.println("        LooseMarshalString(" + getter + ", dataOut);");
            }
            else if (type.equals("byte[]") || type.equals("ByteSequence")) {
                if (size != null) {
                    out.println("        dataOut.Write(" + getter + ", 0, " + size.asInt() + ");");
                }
                else {
                    out.println("        dataOut.Write(" + getter + "!=null);");
                    out.println("        if(" + getter + "!=null) {");
                    out.println("           dataOut.Write(" + getter + ".Length);");
                    out.println("           dataOut.Write(" + getter + ");");
                    out.println("        }");
                }
            }
            else if (propertyType.isArrayType()) {
                if (size != null) {
                    out.println("        LooseMarshalObjectArrayConstSize(wireFormat, " + getter + ", dataOut, " + size.asInt() + ");");
                }
                else {
                    out.println("        LooseMarshalObjectArray(wireFormat, " + getter + ", dataOut);");
View Full Code Here


out.println("            format.clearMarshallers();");

    List list = new ArrayList(getConcreteClasses());
    Collections.sort(list, new Comparator(){
      public int compare(Object o1, Object o2) {
        JClass c1 = (JClass) o1;
        JClass c2 = (JClass) o2;
        return c1.getSimpleName().compareTo(c2.getSimpleName());
      }});
   
    for (Iterator iter = list.iterator(); iter.hasNext();) {
      JClass jclass = (JClass) iter.next();
out.println("            format.addMarshaller(new "+jclass.getSimpleName()+"Marshaller());");
      }       

out.println("");
out.println("      }");
out.println("    }");
View Full Code Here

        }
        else if( type.isArrayType() ) {
            if( name.equals( "byte[]" ) )
                name = "unsigned char[]";

            JClass arrayClass = type.getArrayComponentType();

            if( arrayClass.isPrimitiveType() ) {
                return "std::vector<" + name.substring(0, name.length()-2) + ">";
            } else {
                return "std::vector<" + name.substring(0, name.length()-2) + "*>";
            }
        }
View Full Code Here

        }
        else if( type.isArrayType() ) {
            if( name.equals( "byte[]" ) )
                name = "unsigned char[]";

            JClass arrayClass = type.getArrayComponentType();

            if( arrayClass.isPrimitiveType() ) {
                return "std::vector<" + name.substring(0, name.length()-2) + ">";
            } else {
                return "std::vector<" + name.substring(0, name.length()-2) + "*>";
            }
        }
View Full Code Here

        }
        else if( type.isArrayType() ) {
            if( name.equals( "byte[]" ) )
                name = "unsigned char[]";

            JClass arrayClass = type.getArrayComponentType();

            if( arrayClass.isPrimitiveType() ) {
                return "std::vector<" + name.substring(0, name.length()-2) + ">";
            } else {
                return "std::vector<" + name.substring(0, name.length()-2) + "*>";
            }
        }
View Full Code Here

        !property.getType().getSimpleName().equals("ByteSequence") )
    {
        String includeName = toCppType(property.getType());
        if( property.getType().isArrayType() )
        {
            JClass arrayType = property.getType().getArrayComponentType();
            if( arrayType.isPrimitiveType() )
                continue;
        }
        if( includeName.startsWith("std::vector") ) {
            includeName = includeName.substring(12, includeName.length()-2);
        }
View Full Code Here

        JamService service = factory.createService(jam_service_parms);

        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();

            /**
             * 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();

            // since we do not support overload
            HashMap uniqueMethods = new HashMap();

            for (int i = 0; i < methods.length; i++) {
                JMethod jMethod = methods[i];
                //no need to think abt this method , since that is system config method
                if (jMethod.getSimpleName().equals("init"))
                    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);

                //it can easily get the annotations
//                jMethod.getAnnotations();
                JParameter [] paras = jMethod.getParameters();
                for (int j = 0; j < paras.length; j++) {
                    JParameter methodParameter = paras[j];
                    JClass paraType = methodParameter.getType();
                    String classTypeName = paraType.getQualifiedName();
                    if (paraType.isArrayType()) {
                        classTypeName = paraType.getArrayComponentType().getQualifiedName();
                        if (!typeTable.isSimpleType(classTypeName)) {
                            generateSchema(paraType.getArrayComponentType());
                        }
                    } else {
                        if (!typeTable.isSimpleType(classTypeName)) {
                            generateSchema(methodParameter.getType());
                        }
                    }
                    /**
                     * 1. have to check whethet its a simple type
                     * 2. then to check whther its a simple type array
                     * 3. OM elemney
                     * 4. Bean
                     */

                }
                // for its return type
                JClass retuenType = jMethod.getReturnType();
                if (!retuenType.isVoidType()) {
                    if (retuenType.isArrayType()) {
                        String returnTypeName = retuenType.getArrayComponentType().getQualifiedName();
                        if (!typeTable.isSimpleType(returnTypeName)) {
                            generateSchema(retuenType.getArrayComponentType());
                        }
                    } else {
                        if (!typeTable.isSimpleType(retuenType.getQualifiedName())) {
                            generateSchema(retuenType);
                        }
                    }
                }

View Full Code Here

                }
            }
        }

        //generating wrapper element for retuen element
        JClass methodReturnType = method.getReturnType();
        generateWrapperforReturnType(methodReturnType, methodName);

    }
View Full Code Here

            //it can posible to add the classLoader as well
            jam_service_parms.addClassLoader(beanObject.getClass().getClassLoader());
            jam_service_parms.includeClass(beanObject.getClass().getName());
            JamService service = factory.createService(jam_service_parms);
            JamClassIterator jClassIter = service.getClasses();
            JClass jClass = null;
            while (jClassIter.hasNext()) {
                jClass = (JClass) jClassIter.next();

            }
            // properties from JAM
            JProperty properties [] = jClass.getDeclaredProperties();

            BeanInfo beanInfo = Introspector.getBeanInfo(beanObject.getClass());
            PropertyDescriptor [] propDescs = beanInfo.getPropertyDescriptors();
            HashMap propertMap = new HashMap();
            for (int i = 0; i < propDescs.length; i++) {
View Full Code Here

        JamService service = factory.createService(jam_service_parms);

        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();

            /**
             * 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();

            // since we do not support overload
            HashMap uniqueMethods = new HashMap();
            XmlSchemaComplexType methodSchemaType = null;
            XmlSchemaSequence sequence = null;
            for (int i = 0; i < methods.length; i++) {
                String methodName = methods[i].getSimpleName();
                JMethod jMethod = methods[i];
                // no need to think abt this method , since that is system
                // config method
                if (excludeMethods.contains(jMethod.getSimpleName())) {
                    continue;
                }
                // if (jMethod.getSimpleName().equals("init")
                // || "setOperationContext".equals(jMethod.getSimpleName())
                // || "destroy".equals(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);
                JParameter[] paras = jMethod.getParameters();
                String parameterNames[] = null;
                if (paras.length > 0) {
                    parameterNames = methodTable.getParameterNames(methodName);
                    sequence = new XmlSchemaSequence();

                    // create the schema type for the method wrapper
                    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();
                if (!returnType.isVoidType()) {
                    methodSchemaType = createSchemaTypeForMethodPart(jMethod.getSimpleName() + RESPONSE);
                    sequence = new XmlSchemaSequence();
                    methodSchemaType.setParticle(sequence);
                    generateSchemaForType(sequence, returnType, "return");
                }
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.