Skip to content

Commit

Permalink
Merge pull request #432 from ddh27/master
Browse files Browse the repository at this point in the history
Support for springmvc's @postmapping, @GetMapping, @putmapping, @deletemapping, @patchmapping annotation portrait
  • Loading branch information
zxy0728 committed Nov 9, 2018
2 parents 64adf9a + 0c7b1ba commit 068188e
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -935,10 +935,36 @@ private void getSpringMVCURLs(String springMVCBaseUrl, Map<String, Set<String>>
/**
* each method has Path info except only one
*/
if (methodAnnoInfo.containsKey("org.springframework.web.bind.annotation.RequestMapping")) {
if (methodAnnoInfo.containsKey("org.springframework.web.bind.annotation.RequestMapping")
|| methodAnnoInfo.containsKey("org.springframework.web.bind.annotation.PostMapping")
|| methodAnnoInfo.containsKey("org.springframework.web.bind.annotation.GetMapping")
|| methodAnnoInfo.containsKey("org.springframework.web.bind.annotation.PutMapping")
|| methodAnnoInfo.containsKey("org.springframework.web.bind.annotation.DeleteMapping")
|| methodAnnoInfo.containsKey("org.springframework.web.bind.annotation.PatchMapping")) {

Map<String, Object> pathAnnoInfo = (Map<String, Object>) methodAnnoInfo
.get("org.springframework.web.bind.annotation.RequestMapping");

if (pathAnnoInfo == null) {
pathAnnoInfo = (Map<String, Object>) methodAnnoInfo
.get("org.springframework.web.bind.annotation.PostMapping");
}
if (pathAnnoInfo == null) {
pathAnnoInfo = (Map<String, Object>) methodAnnoInfo
.get("org.springframework.web.bind.annotation.GetMapping");
}
if (pathAnnoInfo == null) {
pathAnnoInfo = (Map<String, Object>) methodAnnoInfo
.get("org.springframework.web.bind.annotation.PutMapping");
}
if (pathAnnoInfo == null) {
pathAnnoInfo = (Map<String, Object>) methodAnnoInfo
.get("org.springframework.web.bind.annotation.DeleteMapping");
}
if (pathAnnoInfo == null) {
pathAnnoInfo = (Map<String, Object>) methodAnnoInfo
.get("org.springframework.web.bind.annotation.PatchMapping");
}

List<String> methodRelativePaths = (List<String>) pathAnnoInfo.get("value");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -911,10 +911,10 @@ private String getImplClassAsKey(String key, Node jaxws, ClassLoader cl, String

Node beanClazz = processor
.selectXMLNode("/beans/bean[@id='" + impl.getNodeValue() + "']/@class");
if(beanClazz!=null) {

if (beanClazz != null) {
return beanClazz.getNodeValue();
}
}
}

// step 2.3 load serviceBean|implementor/@ref
Expand All @@ -925,9 +925,9 @@ private String getImplClassAsKey(String key, Node jaxws, ClassLoader cl, String
Node beanClazz = processor
.selectXMLNode("/beans/bean[@id='" + impl.getNodeValue() + "']/@class");

if(beanClazz!=null) {
if (beanClazz != null) {
return beanClazz.getNodeValue();
}
}
}

return key;
Expand Down Expand Up @@ -1959,8 +1959,21 @@ public Map<String, Object> process(Class annoCls, Class<?> comCls, ProfileContex

getClassAnnoInfo(comCls, info, annoClasses);

// load methodAnno class
Class[] methodAnnoClasses = this.loadAnnoClasses(context,
"org.springframework.web.bind.annotation.RequestMapping",
"org.springframework.web.bind.annotation.PostMapping",
"org.springframework.web.bind.annotation.GetMapping",
"org.springframework.web.bind.annotation.PutMapping",
"org.springframework.web.bind.annotation.DeleteMapping",
"org.springframework.web.bind.annotation.PatchMapping");

if (null == methodAnnoClasses || methodAnnoClasses.length == 0) {
return info;
}

// get method info
getMethodInfo(comCls, info, annoClasses[annoClasses.length - 1]);
getMethodInfo(comCls, info, methodAnnoClasses);

return info;
}
Expand Down Expand Up @@ -2643,6 +2656,27 @@ else if (classPathAnnoClass.equals("org.springframework.web.bind.annotation.Requ

Map<String, Object> methodPathAnno = (Map<String, Object>) methodAnno.get(methodPathAnnoClass);

if (methodPathAnno == null) {
methodPathAnno = (Map<String, Object>) methodAnno
.get("org.springframework.web.bind.annotation.PostMapping");
}
if (methodPathAnno == null) {
methodPathAnno = (Map<String, Object>) methodAnno
.get("org.springframework.web.bind.annotation.GetMapping");
}
if (methodPathAnno == null) {
methodPathAnno = (Map<String, Object>) methodAnno
.get("org.springframework.web.bind.annotation.PutMapping");
}
if (methodPathAnno == null) {
methodPathAnno = (Map<String, Object>) methodAnno
.get("org.springframework.web.bind.annotation.DeleteMapping");
}
if (methodPathAnno == null) {
methodPathAnno = (Map<String, Object>) methodAnno
.get("org.springframework.web.bind.annotation.PatchMapping");
}

if (methodPathAnno == null) {
continue;
}
Expand Down Expand Up @@ -2928,8 +2962,8 @@ private void getDynInfoForWebService(String componentClassName, ProfileElementIn
Class<?> annoClass = annoAvailableClasses.get(componentClassName);
if (null == annoClass) {
return;
}
}

List<String> coms = fcs.getNamesOfClassesWithAnnotation(annoClass);

if (null == coms || coms.isEmpty()) {
Expand Down

0 comments on commit 068188e

Please sign in to comment.