diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/RuleHelper.java b/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/RuleHelper.java index 0c8acea1..697f80e6 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/RuleHelper.java +++ b/bundles/org.palladiosimulator.somox.analyzer.rules.engine/src/org/palladiosimulator/somox/analyzer/rules/engine/RuleHelper.java @@ -399,7 +399,7 @@ private static boolean equalsWithGeneric(String withGeneric, String withoutGener return false; } String rest = withGeneric.substring(withoutGeneric.length()); - if (!rest.startsWith("<") || !rest.endsWith(">")) { + if (!rest.isEmpty() && (!rest.startsWith("<") || !rest.endsWith(">"))) { return false; } return true; diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/EcmaScriptRules.xtend b/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/EcmaScriptRules.xtend index 28d9e154..c9f15463 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/EcmaScriptRules.xtend +++ b/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/EcmaScriptRules.xtend @@ -56,7 +56,8 @@ class EcmaScriptRules implements Rule { var gatewayRoutes = List.of var Path mostSpecificGatewayPath = null for (gatewayPath : gatewayRouteMap.keySet) { - if (path.startsWith(gatewayPath) && (mostSpecificGatewayPath === null || gatewayPath.startsWith(mostSpecificGatewayPath))) { + if (gatewayPath !== null && path.startsWith(gatewayPath) && + (mostSpecificGatewayPath === null || gatewayPath.startsWith(mostSpecificGatewayPath))) { gatewayRoutes = gatewayRouteMap.get(gatewayPath) mostSpecificGatewayPath = gatewayPath } @@ -69,7 +70,8 @@ class EcmaScriptRules implements Rule { var hostname = "API-HOST" var Path mostSpecificHostnamePath = null for (hostnamePath : hostnameMap.keySet) { - if (path.startsWith(hostnamePath) && (mostSpecificHostnamePath === null || hostnamePath.startsWith(mostSpecificHostnamePath))) { + if (hostnamePath !== null && path.startsWith(hostnamePath) && + (mostSpecificHostnamePath === null || hostnamePath.startsWith(mostSpecificHostnamePath))) { hostname = hostnameMap.get(hostnamePath) mostSpecificHostnamePath = hostnamePath } @@ -79,8 +81,10 @@ class EcmaScriptRules implements Rule { val httpRequests = findAllHttpRequests(blackboard, compilationUnit) for (key : httpRequests.keySet) { for (url : httpRequests.get(key)) { - System.out.println("\t" + key + " = " + url); - pcmDetector.detectRequiredInterface(GATEWAY_NAME, mapURL(hostname, "/" + url, gatewayRoutes)); + val mappedURL = mapURL(hostname, "/" + url, gatewayRoutes) + if (!mappedURL.isPartOf("/" + hostname)) { + pcmDetector.detectRequiredInterface(GATEWAY_NAME, mappedURL); + } pcmDetector.detectProvidedOperation(GATEWAY_NAME, null, new RESTName(hostname, "/" + url, Optional.empty())); } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/JaxRSRules.xtend b/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/JaxRSRules.xtend index 56e81a0c..79f75a35 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/JaxRSRules.xtend +++ b/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/JaxRSRules.xtend @@ -40,7 +40,7 @@ class JaxRSRules implements Rule { val identifier = new CompUnitOrName(unit) val isConverter = isUnitAnnotatedWithName(unit, "Converter") val isUnitController = isUnitAnnotatedWithName(unit, "Path") - val isWebServlet = isUnitAnnotatedWithName(unit, "WebServlet") + val isWebServlet = isUnitAnnotatedWithName(unit, "WebServlet") || isImplementingOrExtending(unit, "HttpServlet") // technology based and general recognition if (isConverter) { @@ -64,7 +64,7 @@ class JaxRSRules implements Rule { methodPath = RESTHelper.replaceArgumentsWithWildcards(methodPath) // TODO: HTTP method switch-case pcmDetector.detectCompositeProvidedOperation(identifier, m.resolveBinding, - new RESTName("host", methodPath, Optional.empty)) + new RESTName("SERVICE-HOST", methodPath, Optional.empty)) } ] getFields(unit).forEach[f|pcmDetector.detectRequiredInterfaceWeakly(identifier, f)] diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/SpringGatewayRules.xtend b/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/SpringGatewayRules.xtend index 35a81afa..2c7b0958 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/SpringGatewayRules.xtend +++ b/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/SpringGatewayRules.xtend @@ -122,11 +122,13 @@ class SpringGatewayRules implements Rule { val filtersObject = route.get("filters") var path = Optional.empty - if (predicatesObject !== null && predicatesObject instanceof List) { + if (predicatesObject !== null && predicatesObject instanceof List && + (predicatesObject as List).get(0) instanceof String) { path = getPath(predicatesObject as List) } var stripPrefixLength = 0 - if (filtersObject !== null && filtersObject instanceof List) { + if (filtersObject !== null && filtersObject instanceof List && + (filtersObject as List).get(0) instanceof String) { stripPrefixLength = getStripPrefixLength(filtersObject as List) } val hasUri = uriObject !== null && uriObject instanceof String diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/SpringRules.xtend b/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/SpringRules.xtend index 6e2c3a46..8274b414 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/SpringRules.xtend +++ b/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/SpringRules.xtend @@ -214,9 +214,13 @@ class SpringRules implements Rule { } for (iface : getAllInterfaces(unit)) { - pcmDetector.detectProvidedInterface(identifier, iface.resolveBinding) - for (m : getMethods(iface)) { - pcmDetector.detectProvidedOperation(identifier, iface.resolveBinding, m) + val ifaceBinding = iface.resolveBinding + // Hide Repository interface implementations, they tend to connect composites in unrepresentative ways + if (ifaceBinding !== null && !ifaceBinding.name.endsWith("Repository")) { + pcmDetector.detectProvidedInterface(identifier, ifaceBinding) + for (m : getMethods(iface)) { + pcmDetector.detectProvidedOperation(identifier, ifaceBinding, m) + } } } } diff --git a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/SpringZuulRules.xtend b/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/SpringZuulRules.xtend index 7c0787c3..33428da7 100644 --- a/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/SpringZuulRules.xtend +++ b/bundles/org.palladiosimulator.somox.analyzer.rules.impl/src/org/palladiosimulator/somox/analyzer/rules/impl/SpringZuulRules.xtend @@ -36,7 +36,7 @@ class SpringZuulRules implements Rule { val projectRoot = SpringHelper.findProjectRoot(path, poms) val configRoot = SpringHelper.findConfigRoot(poms) - + if (configRoot === null) { return } @@ -47,14 +47,18 @@ class SpringZuulRules implements Rule { } // Execute only once for each Spring application/service - if(routeMap.containsKey(projectRoot)) return - - val bootstrapYaml = yamlMappers.get( - SpringHelper.findFile(yamlMappers.keySet, projectRoot.resolve("src/main/resources"), - Set.of("bootstrap.yaml", "bootstrap.yml"))) - val applicationProperties = propertyFiles.get( - SpringHelper.findFile(propertyFiles.keySet, projectRoot.resolve("src/main/resources"), - Set.of("application.properties"))) + if(projectRoot !== null && routeMap.containsKey(projectRoot)) return + + val bootstrapYaml = projectRoot === null + ? null + : yamlMappers.get( + SpringHelper.findFile(yamlMappers.keySet, projectRoot.resolve("src/main/resources"), + Set.of("bootstrap.yaml", "bootstrap.yml"))) + val applicationProperties = projectRoot === null + ? null + : propertyFiles.get( + SpringHelper.findFile(propertyFiles.keySet, projectRoot.resolve("src/main/resources"), + Set.of("application.properties"))) val applicationName = SpringHelper.getFromYamlOrProperties("spring.application.name", bootstrapYaml, applicationProperties) val projectConfigYaml = configRoot === null