GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — uavorg#481 · charooo/uavstack@5b12e03

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • com.creditease.uav.base/src/main/java/com/creditease/agent/profile/api
    • StandardProfileModeler.java
  • com.creditease.uav.monitorframework/src/main/java/com/creditease/uav/profiling
    • handlers
      • ComponentProfileHandler.java
    • spi
      • ProfileServiceMapMgr.java
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎com.creditease.uav.base/src/main/java/com/creditease/agent/profile/api/StandardProfileModeler.java‎

Copy file name to clipboardExpand all lines: com.creditease.uav.base/src/main/java/com/creditease/agent/profile/api/StandardProfileModeler.java
+109-89Lines changed: 109 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,9 @@ private void buildJEEServiceComponents(MonitorDataFrame mdf, Map<String, Object>
540540
// get spring mvc urls
541541
String springmvcBaseURL = getBaseURL(serviceServlets, "springmvc");
542542

543-
getSpringMVCURLs(springmvcBaseURL, compServices, springMVC);
543+
getSpringMVCURLs(appurl, springmvcBaseURL, compServices, springMVC);
544544

545-
getSpringMVCURLs(springmvcBaseURL, compServices, springMVCRest);
545+
getSpringMVCURLs(appurl, springmvcBaseURL, compServices, springMVCRest);
546546

547547
// get struts2 urls
548548
Map<String, Object> strutsAction = mdf.getElemInstValues(appid, "cpt", "com.opensymphony.xwork2.Action");
@@ -846,28 +846,41 @@ private void getJAXWSProviderURLs(String jaxwsBaseUrl, Map<String, Set<String>>
846846
* @param spring
847847
*/
848848
@SuppressWarnings("unchecked")
849-
private void getSpringMVCURLs(String springMVCBaseUrl, Map<String, Set<String>> compServices,
849+
private void getSpringMVCURLs(String appurl, String springMVCBaseUrl, Map<String, Set<String>> compServices,
850850
Map<String, Object> spring) {
851851

852-
String realSpringMVCBaseUrl = null;
853-
String suffix = "";
854-
if (springMVCBaseUrl != null) {
852+
Set<String> realSpringMVCBaseUrls = new HashSet<>();
853+
Set<String> servletPaths = new HashSet<>();
855854

856-
// NOTE: handle *.xxx,should remove *.xxx
857-
realSpringMVCBaseUrl = springMVCBaseUrl;
855+
if (StringHelper.isEmpty(springMVCBaseUrl) || springMVCBaseUrl.length() < appurl.length()) {
856+
return;
857+
}
858+
859+
String[] springMVCBaseUrls = springMVCBaseUrl.split(",");
860+
861+
for (String url : springMVCBaseUrls) {
862+
863+
// shouldn't happened
864+
if (url.length() < appurl.length()) {
865+
continue;
866+
}
858867

859-
int allIndex = realSpringMVCBaseUrl.indexOf("*");
868+
String servletPath = url.substring(appurl.length());
860869

870+
int allIndex = servletPath.indexOf("*");
861871
if (allIndex > -1) {
862872

863873
// check if there is suffix, such as *.do
864-
if (allIndex != realSpringMVCBaseUrl.length() - 1) {
865-
suffix = realSpringMVCBaseUrl.substring(allIndex + 1, realSpringMVCBaseUrl.length() - 1);
866-
}
874+
int indexOfDot = servletPath.indexOf(".", allIndex);
875+
if (indexOfDot > -1) {
867876

877+
servletPath = servletPath.substring(indexOfDot, servletPath.length() - 1);
878+
}
868879
// get the real access path
869-
realSpringMVCBaseUrl = realSpringMVCBaseUrl.substring(0, allIndex);
880+
url = url.substring(0, appurl.length() + allIndex);
870881
}
882+
servletPaths.add(servletPath);
883+
realSpringMVCBaseUrls.add(url);
871884
}
872885

873886
for (String compId : spring.keySet()) {
@@ -916,99 +929,100 @@ private void getSpringMVCURLs(String springMVCBaseUrl, Map<String, Set<String>>
916929
resourceClassRelativePaths.add("");
917930
}
918931

919-
for (String resourceClassRelativePath : resourceClassRelativePaths) {
920-
921-
resourceClassRelativePath = formatRelativePath(resourceClassRelativePath);
932+
// get the resource class path
933+
for (String realSpringMVCBaseUrl : realSpringMVCBaseUrls) {
922934

923-
// get the resource class path
924-
String resourceClassPath = realSpringMVCBaseUrl + resourceClassRelativePath;
935+
for (String resourceClassRelativePath : resourceClassRelativePaths) {
936+
resourceClassRelativePath = formatRelativePath(resourceClassRelativePath);
937+
String resourceClassPath = realSpringMVCBaseUrl + resourceClassRelativePath;
925938

926-
// get methods path
927-
Map<String, Object> compMethodInfo = (Map<String, Object>) compInfo.get("methods");
939+
// get methods path
940+
Map<String, Object> compMethodInfo = (Map<String, Object>) compInfo.get("methods");
928941

929-
for (String method : compMethodInfo.keySet()) {
942+
for (String method : compMethodInfo.keySet()) {
930943

931-
Map<String, Object> methodInfo = (Map<String, Object>) compMethodInfo.get(method);
944+
Map<String, Object> methodInfo = (Map<String, Object>) compMethodInfo.get(method);
932945

933-
if (!methodInfo.containsKey("anno")) {
934-
continue;
935-
}
936-
937-
Map<String, Object> methodAnnoInfo = (Map<String, Object>) methodInfo.get("anno");
938-
939-
String serviceURL = formatRelativePath(resourceClassPath);
940-
941-
/**
942-
* each method has Path info except only one
943-
*/
944-
if (methodAnnoInfo.containsKey("org.springframework.web.bind.annotation.RequestMapping")
945-
|| methodAnnoInfo.containsKey("org.springframework.web.bind.annotation.PostMapping")
946-
|| methodAnnoInfo.containsKey("org.springframework.web.bind.annotation.GetMapping")
947-
|| methodAnnoInfo.containsKey("org.springframework.web.bind.annotation.PutMapping")
948-
|| methodAnnoInfo.containsKey("org.springframework.web.bind.annotation.DeleteMapping")
949-
|| methodAnnoInfo.containsKey("org.springframework.web.bind.annotation.PatchMapping")) {
950-
951-
Map<String, Object> pathAnnoInfo = (Map<String, Object>) methodAnnoInfo
952-
.get("org.springframework.web.bind.annotation.RequestMapping");
953-
954-
if (pathAnnoInfo == null) {
955-
pathAnnoInfo = (Map<String, Object>) methodAnnoInfo
956-
.get("org.springframework.web.bind.annotation.PostMapping");
957-
}
958-
if (pathAnnoInfo == null) {
959-
pathAnnoInfo = (Map<String, Object>) methodAnnoInfo
960-
.get("org.springframework.web.bind.annotation.GetMapping");
961-
}
962-
if (pathAnnoInfo == null) {
963-
pathAnnoInfo = (Map<String, Object>) methodAnnoInfo
964-
.get("org.springframework.web.bind.annotation.PutMapping");
965-
}
966-
if (pathAnnoInfo == null) {
967-
pathAnnoInfo = (Map<String, Object>) methodAnnoInfo
968-
.get("org.springframework.web.bind.annotation.DeleteMapping");
969-
}
970-
if (pathAnnoInfo == null) {
971-
pathAnnoInfo = (Map<String, Object>) methodAnnoInfo
972-
.get("org.springframework.web.bind.annotation.PatchMapping");
946+
if (!methodInfo.containsKey("anno")) {
947+
continue;
973948
}
974949

975-
List<String> methodRelativePaths = (List<String>) pathAnnoInfo.get("value");
950+
Map<String, Object> methodAnnoInfo = (Map<String, Object>) methodInfo.get("anno");
951+
952+
String serviceURL = formatRelativePath(resourceClassPath);
953+
954+
/**
955+
* each method has Path info except only one
956+
*/
957+
if (methodAnnoInfo.containsKey("org.springframework.web.bind.annotation.RequestMapping")
958+
|| methodAnnoInfo.containsKey("org.springframework.web.bind.annotation.PostMapping")
959+
|| methodAnnoInfo.containsKey("org.springframework.web.bind.annotation.GetMapping")
960+
|| methodAnnoInfo.containsKey("org.springframework.web.bind.annotation.PutMapping")
961+
|| methodAnnoInfo.containsKey("org.springframework.web.bind.annotation.DeleteMapping")
962+
|| methodAnnoInfo.containsKey("org.springframework.web.bind.annotation.PatchMapping")) {
963+
964+
Map<String, Object> pathAnnoInfo = (Map<String, Object>) methodAnnoInfo
965+
.get("org.springframework.web.bind.annotation.RequestMapping");
966+
if (pathAnnoInfo == null) {
967+
pathAnnoInfo = (Map<String, Object>) methodAnnoInfo
968+
.get("org.springframework.web.bind.annotation.PostMapping");
969+
}
970+
if (pathAnnoInfo == null) {
971+
pathAnnoInfo = (Map<String, Object>) methodAnnoInfo
972+
.get("org.springframework.web.bind.annotation.GetMapping");
973+
}
974+
if (pathAnnoInfo == null) {
975+
pathAnnoInfo = (Map<String, Object>) methodAnnoInfo
976+
.get("org.springframework.web.bind.annotation.PutMapping");
977+
}
978+
if (pathAnnoInfo == null) {
979+
pathAnnoInfo = (Map<String, Object>) methodAnnoInfo
980+
.get("org.springframework.web.bind.annotation.DeleteMapping");
981+
}
982+
if (pathAnnoInfo == null) {
983+
pathAnnoInfo = (Map<String, Object>) methodAnnoInfo
984+
.get("org.springframework.web.bind.annotation.PatchMapping");
985+
}
986+
List<String> methodRelativePaths = (List<String>) pathAnnoInfo.get("value");
976987

977-
// try to get info from filed 'path'
978-
if (methodRelativePaths == null) {
979-
methodRelativePaths = (List<String>) pathAnnoInfo.get("path");
980-
}
988+
// try to get info from filed 'path'
989+
if (methodRelativePaths == null) {
990+
methodRelativePaths = (List<String>) pathAnnoInfo.get("path");
991+
}
981992

982-
// FIX NPE
983-
if (methodRelativePaths == null) {
984-
compServicesURLs.add(serviceURL);
985-
continue;
986-
}
993+
// FIX NPE
994+
if (methodRelativePaths == null) {
995+
compServicesURLs.add(serviceURL);
996+
continue;
997+
}
987998

988-
for (String methodRelativePath : methodRelativePaths) {
999+
for (String methodRelativePath : methodRelativePaths) {
9891000

990-
methodRelativePath = formatRelativePath(methodRelativePath);
1001+
methodRelativePath = formatRelativePath(methodRelativePath);
9911002

992-
String methodServiceURL;
1003+
String methodServiceURL = formatRelativePath(serviceURL + "/" + methodRelativePath);
1004+
if (methodRelativePath.indexOf(".") > -1 || servletPaths.isEmpty()) {
1005+
compServicesURLs.add(methodServiceURL);
1006+
continue;
1007+
}
9931008

994-
if (methodRelativePath.endsWith(suffix)) {
1009+
for (String servletPath : servletPaths) {
1010+
int indexOfDot = servletPath.indexOf(".");
1011+
if (indexOfDot > -1) {
1012+
compServicesURLs.add(methodServiceURL + servletPath.substring(indexOfDot));
1013+
}
1014+
else if (realSpringMVCBaseUrl.endsWith("/" + servletPath)) {
1015+
compServicesURLs.add(methodServiceURL);
1016+
}
1017+
}
9951018

996-
methodServiceURL = formatRelativePath(serviceURL + "/" + methodRelativePath);
9971019
}
998-
else {
999-
// endwith "#" means the suffix is added from springMVCBaseUrl,should be removed while on query
1000-
methodServiceURL = formatRelativePath(
1001-
serviceURL + "/" + methodRelativePath + suffix + "#");
1002-
}
1003-
1004-
compServicesURLs.add(methodServiceURL);
10051020
}
1006-
}
1007-
else {
1008-
compServicesURLs.add(serviceURL);
1021+
else {
1022+
compServicesURLs.add(serviceURL);
1023+
}
10091024
}
10101025
}
1011-
10121026
}
10131027
}
10141028
}
@@ -1390,7 +1404,13 @@ else if (engine.indexOf("jersey") > -1) {
13901404
serviceServlets.put("jersey", serviceURL);
13911405
}
13921406
else if (engine.indexOf("springmvc") > -1) {
1393-
serviceServlets.put("springmvc", serviceURL);
1407+
// 一个servlet mapping多个URL用逗号隔开.
1408+
if (StringHelper.isEmpty(serviceServlets.get("springmvc"))) {
1409+
serviceServlets.put("springmvc", serviceURL);
1410+
}
1411+
else {
1412+
serviceServlets.put("springmvc", serviceServlets.get("springmvc") + "/," + serviceURL);
1413+
}
13941414
}
13951415
else if (engine.indexOf("jaxws-ri") > -1) {
13961416
serviceServlets.put("jaxws-ri", serviceURL);

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.