Package org.codehaus.jam

Examples of org.codehaus.jam.JMethod


        addExtensionElement(fac, binding, soap12, BINDING_LOCAL_NAME, TRANSPORT, TRANSPORT_URI, STYLE, generationParams
            .getStyle());

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

            if (jmethod.isPublic()) {
                OMElement operation = fac.createOMElement(OPERATION_LOCAL_NAME, wsdl);
                binding.addChild(operation);
                operation.declareNamespace(URI_WSDL12_SOAP, SOAP12_PREFIX);

                addExtensionElement(fac,
                                    operation,
                                    soap12,
                                    OPERATION_LOCAL_NAME,
                                    SOAP_ACTION,
                                    URN_PREFIX + COLON_SEPARATOR + jmethod.getSimpleName(),
                                    STYLE,
                                    generationParams.getStyle());
                operation.addAttribute(ATTRIBUTE_NAME, jmethod.getSimpleName(), null);

                OMElement input = fac.createOMElement(IN_PUT_LOCAL_NAME, wsdl);
                addExtensionElement(fac,
                                    input,
                                    soap12,
                                    SOAP_BODY,
                                    SOAP_USE,
                                    generationParams.getUse(),
                                    "namespace",
                                    generationParams.getTargetNamespace());
                operation.addChild(input);

                if (!jmethod.getReturnType().isVoidType()) {
                    OMElement output = fac.createOMElement(OUT_PUT_LOCAL_NAME, wsdl);
                    addExtensionElement(fac,
                                        output,
                                        soap12,
                                        SOAP_BODY,
View Full Code Here


        Hashtable namespaceMap = new Hashtable();
        String namespacePrefix = null;
        String namespaceURI = null;
        QName messagePartType = null;
        for (int i = 0; i < method.length; i++) {
            JMethod jmethod = method[i];

            if (jmethod.isPublic()) {
                // Request Message
                OMElement requestMessge = fac.createOMElement(MESSAGE_LOCAL_NAME, wsdl);
                requestMessge.addAttribute(ATTRIBUTE_NAME, jmethod.getSimpleName() + MESSAGE_SUFFIX, null);
                definitions.addChild(requestMessge);

                // only if a type for the message part has already been defined
                if ((messagePartType =
                    typeTable.getComplexSchemaTypeName(generationParams.getSchemaTargetNamespace(), jmethod
                        .getSimpleName())) != null) {
                    namespaceURI = messagePartType.getNamespaceURI();
                    // avoid duplicate namespaces
                    if ((namespacePrefix = (String)namespaceMap.get(namespaceURI)) == null) {
                        namespacePrefix = generatePrefix();
                        namespaceMap.put(namespaceURI, namespacePrefix);
                    }

                    OMElement requestPart = fac.createOMElement(PART_ATTRIBUTE_NAME, wsdl);
                    requestMessge.addChild(requestPart);
                    requestPart.addAttribute(ATTRIBUTE_NAME, "part1", null);

                    requestPart.addAttribute(ELEMENT_ATTRIBUTE_NAME, namespacePrefix + COLON_SEPARATOR
                        + jmethod.getSimpleName(), null);
                }

                // only if a type for the message part has already been defined
                if ((messagePartType =
                    typeTable.getComplexSchemaTypeName(generationParams.getSchemaTargetNamespace(), jmethod
                        .getSimpleName() + RESPONSE)) != null) {
                    namespaceURI = messagePartType.getNamespaceURI();
                    if ((namespacePrefix = (String)namespaceMap.get(namespaceURI)) == null) {
                        namespacePrefix = generatePrefix();
                        namespaceMap.put(namespaceURI, namespacePrefix);
                    }
                    // Response Message
                    OMElement responseMessge = fac.createOMElement(MESSAGE_LOCAL_NAME, wsdl);
                    responseMessge.addAttribute(ATTRIBUTE_NAME, jmethod.getSimpleName() + RESPONSE_MESSAGE, null);
                    definitions.addChild(responseMessge);
                    OMElement responsePart = fac.createOMElement(PART_ATTRIBUTE_NAME, wsdl);
                    responseMessge.addChild(responsePart);
                    responsePart.addAttribute(ATTRIBUTE_NAME, "part1", null);

                    responsePart.addAttribute(ELEMENT_ATTRIBUTE_NAME, namespacePrefix + COLON_SEPARATOR
                        + jmethod.getSimpleName()
                        + RESPONSE, null);
                }
            }
        }
View Full Code Here

    protected String filePostFix = ".java";
    protected JamService jam;
   

  public boolean isValidProperty(JProperty it) {
        JMethod getter = it.getGetter();
        return getter != null && it.getSetter() != null && getter.isStatic() == false && getter.getAnnotation("openwire:property") != null;
    }
View Full Code Here

        JMethod getter = it.getGetter();
        return getter != null && it.getSetter() != null && getter.isStatic() == false && getter.getAnnotation("openwire:property") != null;
    }

    public boolean isCachedProperty(JProperty it) {
        JMethod getter = it.getGetter();
        if (!isValidProperty(it))
            return false;
        JAnnotationValue value = getter.getAnnotation("openwire:property").getValue("cache");
        return value != null && value.asBoolean();
    }
View Full Code Here

      axisService.setTargetNamespace(targetNamespace);
    }
    JMethod[] method = schemaGenerator.getMethods();
    PhasesInfo pinfo = axisConfiguration.getPhasesInfo();
    for (int i = 0; i < method.length; i++) {
      JMethod jmethod = method[i];
      AxisOperation operation = axisService.getOperation(new QName(
          jmethod.getSimpleName()));
      String mep = operation.getMessageExchangePattern();
      MessageReceiver mr;
      if (messageReceiverClassMap != null) {

        if (messageReceiverClassMap.get(mep) != null) {
View Full Code Here

        HashMap uniqueMethods = new HashMap();
        XmlSchemaComplexType methodSchemaType;
        XmlSchemaSequence sequence = null;

        for (int i = 0; i < declaredMethods.length; i++) {
            JMethod jMethod = declaredMethods[i];
            JAnnotation methodAnnon = jMethod.getAnnotation(AnnotationConstants.WEB_METHOD);
            if (methodAnnon != null) {
                if (methodAnnon.getValue(AnnotationConstants.EXCLUDE).asBoolean()) {
                    continue;
                }
            }
            String methodName = getSimpleName(jMethod);
            // no need to think abt this method , since that is system
            // config method
            if (excludeMethods.contains(methodName)) {
                continue;
            }

            if (uniqueMethods.get(methodName) != null) {
                log.warn("We don't support method overloading. Ignoring [" +
                        jMethod.getQualifiedName() + "]");
                continue;
            }

            if (!jMethod.isPublic()) {
                // no need to generate Schema for non public methods
                continue;
            }
            boolean addToService = false;
            AxisOperation axisOperation = service.getOperation(new QName(methodName));
            if (axisOperation == null) {
                axisOperation = Utils.getAxisOperationForJmethod(jMethod);
                if (WSDL2Constants.MEP_URI_ROBUST_IN_ONLY.equals(
                        axisOperation.getMessageExchangePattern())){
                    AxisMessage outMessage = axisOperation.getMessage(
                            WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
                    if (outMessage !=null ){
                        outMessage.setName(methodName + RESPONSE);
                    }
                }
                addToService = true;
            }
            // Maintain a list of methods we actually work with
            list.add(jMethod);

            processException(jMethod,axisOperation);
            uniqueMethods.put(methodName, jMethod);
            JParameter[] paras = jMethod.getParameters();
            String parameterNames[] = null;
            AxisMessage inMessage = axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
            if (inMessage != null) {
                inMessage.setName(methodName + Java2WSDLConstants.MESSAGE_SUFFIX);
            }
            if (paras.length > 0) {
                parameterNames = methodTable.getParameterNames(methodName);
                sequence = new XmlSchemaSequence();

                methodSchemaType = createSchemaTypeForMethodPart(methodName);
                methodSchemaType.setParticle(sequence);
                inMessage.setElementQName(typeTable.getQNamefortheType(methodName));
                service.addMessageElementQNameToOperationMapping(methodSchemaType.getQName(),
                        axisOperation);
            }

            for (int j = 0; j < paras.length; j++) {
                JParameter methodParameter = paras[j];
                String parameterName = null;
                JAnnotation paramterAnnon =
                        methodParameter.getAnnotation(AnnotationConstants.WEB_PARAM);
                if (paramterAnnon != null) {
                    parameterName =
                            paramterAnnon.getValue(AnnotationConstants.NAME).asString();
                }
                if (parameterName == null || "".equals(parameterName)) {
                    parameterName = (parameterNames != null && parameterNames[j] != null) ?
                            parameterNames[j] : getSimpleName(methodParameter);
                }
                JClass paraType = methodParameter.getType();
                if (nonRpcMethods.contains(getSimpleName(jMethod))) {
                    generateSchemaForType(sequence, null, getSimpleName(jMethod));
                    break;
                } else {
                    generateSchemaForType(sequence, paraType, parameterName);
                }
            }
            // for its return type
            JClass returnType = jMethod.getReturnType();

            if (!returnType.isVoidType()) {
                String partQname = methodName + RESPONSE;
                methodSchemaType =
                        createSchemaTypeForMethodPart(partQname);
                sequence = new XmlSchemaSequence();
                methodSchemaType.setParticle(sequence);
                JAnnotation returnAnnon =
                        jMethod.getAnnotation(AnnotationConstants.WEB_RESULT);
                String returnName = "return";
                if (returnAnnon != null) {
                    returnName = returnAnnon.getValue(AnnotationConstants.NAME).asString();
                    if (returnName != null && !"".equals(returnName)) {
                        returnName = "return";
View Full Code Here

        HashMap uniqueMethods = new HashMap();
        XmlSchemaComplexType methodSchemaType;
        XmlSchemaSequence sequence;

        for (int i = 0; i < declaredMethods.length; i++) {
            JMethod jMethod = declaredMethods[i];
            JAnnotation methodAnnon = jMethod.getAnnotation(AnnotationConstants.WEB_METHOD);
            if (methodAnnon != null) {
                if (methodAnnon.getValue(AnnotationConstants.EXCLUDE).asBoolean()) {
                    continue;
                }
            }
            String methodName = getSimpleName(jMethod);
            // no need to think abt this method , since that is system
            // config method
            if (excludeMethods.contains(getSimpleName(jMethod))) {
                continue;
            }

            if (uniqueMethods.get(getSimpleName(jMethod)) != null) {
                log.warn("We don't support method overloading. Ignoring [" +
                        jMethod.getQualifiedName() + "]");
                continue;
            }

            if (!jMethod.isPublic()) {
                // no need to generate Schema for non public methods
                continue;
            }

            boolean addToService = false;
            AxisOperation axisOperation = service.getOperation(new QName(methodName));
            if (axisOperation == null) {
                axisOperation = Utils.getAxisOperationForJmethod(jMethod);
                if (WSDL2Constants.MEP_URI_ROBUST_IN_ONLY.equals(
                        axisOperation.getMessageExchangePattern())){
                    AxisMessage outMessage = axisOperation.getMessage(
                            WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
                    if (outMessage !=null ){
                        outMessage.setName(methodName + RESULT);
                    }
                }
                addToService = true;
            }

            // Maintain a list of methods we actually work with
            list.add(jMethod);
            processException(jMethod,axisOperation);
            uniqueMethods.put(getSimpleName(jMethod), jMethod);
            //create the schema type for the method wrapper

            uniqueMethods.put(getSimpleName(jMethod), jMethod);
            JParameter[] paras = jMethod.getParameters();
            String parameterNames[] = methodTable.getParameterNames(methodName);
            AxisMessage inMessage = axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
            if (inMessage != null) {
                inMessage.setName(methodName + "RequestMessage");
            }
            if (paras.length > 1) {
                sequence = new XmlSchemaSequence();
                methodSchemaType = createSchemaTypeForMethodPart(getSimpleName(jMethod));
                methodSchemaType.setParticle(sequence);
                inMessage.setElementQName(typeTable.getQNamefortheType(methodName));
                service.addMessageElementQNameToOperationMapping(methodSchemaType.getQName(),
                        axisOperation);
                inMessage.setPartName(methodName);
                for (int j = 0; j < paras.length; j++) {
                    JParameter methodParameter = paras[j];
                    if (generateRequestSchema(methodParameter, parameterNames, j, jMethod, sequence)) {
                        break;
                    }
                }
            } else if (paras.length == 1) {
                if (paras[0].getType().isArrayType()) {
                    sequence = new XmlSchemaSequence();

                    methodSchemaType = createSchemaTypeForMethodPart(methodName);
                    methodSchemaType.setParticle(sequence);
                    JParameter methodParameter = paras[0];
                    inMessage.setElementQName(typeTable.getQNamefortheType(methodName));
                    service.addMessageElementQNameToOperationMapping(methodSchemaType.getQName(),
                            axisOperation);
                    inMessage.setPartName(methodName);
                    if (generateRequestSchema(methodParameter, parameterNames, 0, jMethod, sequence)) {
                        break;
                    }
                } else {
                    String parameterName = null;
                    JParameter methodParameter = paras[0];
                    JAnnotation paramterAnnon =
                            methodParameter.getAnnotation(AnnotationConstants.WEB_PARAM);
                    if (paramterAnnon != null) {
                        parameterName =
                                paramterAnnon.getValue(AnnotationConstants.NAME).asString();
                    }
                    if (parameterName == null || "".equals(parameterName)) {
                        parameterName = (parameterNames != null && parameterNames[0] != null) ?
                                parameterNames[0] : getSimpleName(methodParameter);
                    }
                    JMethod processMethod = (JMethod) processedParameters.get(parameterName);
                    if (processMethod != null) {
                        throw new AxisFault("Inavalid Java class," +
                                " there are two methods [" + processMethod.getSimpleName() + " and " +
                                jMethod.getSimpleName() + " ]which have the same parameter names");
                    } else {
                        processedParameters.put(parameterName, jMethod);
                        generateSchemaForType(null, paras[0].getType(), parameterName);
                        inMessage.setElementQName(typeTable.getQNamefortheType(parameterName));
View Full Code Here

        WSDLInterface portType = womDescription.createInterface();
        portType.setName(new QName(serviceName + "Port"));

        //adding message refs
        for (int i = 0; i < method.length; i++) {
            JMethod jmethod = method[i];
            //creating WSDLOperation
            WSDLOperation operation = womDescription.createOperation();
            operation.setName(new QName(jmethod.getSimpleName()));

            MessageReference messageRefinput = wsdlComponentFactory.createMessageReference();
            QName typeName = table.getComplexScheamType(jmethod.getSimpleName() +
                    SchemaGenerator.METHOD_REQUEST_WRAPPER);
            messageRefinput.setElementQName(typeName);
            messageRefinput.setDirection(org.apache.wsdl.WSDLConstants.WSDL_MESSAGE_DIRECTION_IN);
            operation.setInputMessage(messageRefinput);
            portType.setOperation(operation);

            if (!jmethod.getReturnType().isVoidType()) {
                MessageReference messageRefiout = wsdlComponentFactory.createMessageReference();
                messageRefiout.setElementQName(table.getQNamefortheType(jmethod.getSimpleName() +
                        SchemaGenerator.METHOD_RESPONSE_WRAPPER));
                messageRefiout.setDirection(org.apache.wsdl.WSDLConstants.WSDL_MESSAGE_DIRECTION_OUT);
                operation.setOutputMessage(messageRefiout);
            }
        }
View Full Code Here

            // 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());
View Full Code Here

     * </complexType>
     * </element>
     */
    private void generateWrapperElements(JMethod methods[]) {
        for (int i = 0; i < methods.length; i++) {
            JMethod method = methods[i];
            if (method.getSimpleName().equals("init"))
                continue;
            if (!method.isPublic())
                continue;
            genereteWrapperElementforMethod(method);
        }
    }
View Full Code Here

TOP

Related Classes of org.codehaus.jam.JMethod

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.