Ejemplo n.º 1
0
        private static void mapMethods(method[] methodsToMap,string javaClassName, SpringMvcController controllerForCurrentClass, List<SpringMvcController> springMvcControllers, string fileName)
        {
            if (methodsToMap != null)            
                foreach(var methodToMap in methodsToMap)
                {
                    var mappedController = getRequestMapping(methodToMap);
                    if (mappedController != null) // || controllerForCurrentClass != null) 
                    {
                        if (mappedController.HttpRequestUrl == null && controllerForCurrentClass!=null)
                            mappedController.HttpRequestUrl = controllerForCurrentClass.HttpRequestUrl;

                        mappedController.JavaClass = javaClassName;
                        mappedController.JavaFunction = (FilteredSignature.createFilteredSignatureFromJavaMethod(mappedController.JavaClass, methodToMap.name, methodToMap.descriptor).sFunctionNameAndParamsAndReturnClass);
                        mappedController.JavaClassAndFunction = string.Format("{0}.{1}", mappedController.JavaClass, mappedController.JavaFunction);
                        mappedController.AutoWiredJavaObjects = getAutoWiredJavaObjects(methodToMap);
                        mappedController.FileName = fileName;
                        mappedController.LineNumber = (uint)methodToMap.lineNumber;
                        springMvcControllers.Add(mappedController);
                    }

                    //springMvcController.URL = ;
                    //methodToMap.attribute
                    // methodToMap.SpringMvcMapping
                }            
        }
 private static List<SpringMvcParameter> getAutoWiredJavaObjects(method methodToMap)
 {
     var springMvcParamters = new List<SpringMvcParameter>();
     if (methodToMap.parameterAnnotation != null)
         foreach (var parameterAnnotation in methodToMap.parameterAnnotation)
         {
             var springMvcParameter = new SpringMvcParameter();
             switch (parameterAnnotation.typeName)
             { 
                 case "org.springframework.web.bind.annotation.RequestParam":
                 case "org.springframework.web.bind.annotation.ModelAttribute":
                 case "org.springframework.web.bind.annotation.PathVariable":
                     springMvcParameter.autoWiredMethodUsed = parameterAnnotation.typeName.Replace("org.springframework.web.bind.annotation.", "");
                     if (parameterAnnotation.member != null)
                         springMvcParameter.name = decodeString(parameterAnnotation.member.memberValue).Replace("\"","");
                     break;
                 
                 default:
                     if (parameterAnnotation.typeName !=null)
                         springMvcParameter.autoWiredMethodUsed = parameterAnnotation.typeName;
                     break;
             }
             springMvcParamters.Add(springMvcParameter);             
         }
     return springMvcParamters;
 }
Ejemplo n.º 3
0
 public static annotation getAnnotation(method methodToAnalyze, string annotationTypeToRetrieve)
 {
     if (methodToAnalyze != null && methodToAnalyze.attribute != null)
         foreach (var attributeToAnalyze in methodToAnalyze.attribute)
         {
             var annotationValue = getAnnotation(attributeToAnalyze, annotationTypeToRetrieve);
             if (annotationValue != null)
                 return annotationValue;
         }
     return null;
 }
Ejemplo n.º 4
0
 public static SpringMvcController getRequestMapping(method methodToAnalyze)
 {
     var requestMappingAnnotation = getAnnotation(methodToAnalyze,SPRING_MVC_CLASS_REQUEST_MAPPING);
     if (requestMappingAnnotation!= null && requestMappingAnnotation.member == null)      // in this case make the method name the name of the current method
         requestMappingAnnotation.member = new [] {new member {memberName = "method", memberValue = methodToAnalyze.name}};
     return getRequestMapping(requestMappingAnnotation);
 }