Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve aesthetics #45

Merged
merged 7 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand All @@ -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()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object>).get(0) instanceof String) {
path = getPath(predicatesObject as List<String>)
}
var stripPrefixLength = 0
if (filtersObject !== null && filtersObject instanceof List) {
if (filtersObject !== null && filtersObject instanceof List &&
(filtersObject as List<Object>).get(0) instanceof String) {
stripPrefixLength = getStripPrefixLength(filtersObject as List<String>)
}
val hasUri = uriObject !== null && uriObject instanceof String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SpringZuulRules implements Rule {

val projectRoot = SpringHelper.findProjectRoot(path, poms)
val configRoot = SpringHelper.findConfigRoot(poms)

if (configRoot === null) {
return
}
Expand All @@ -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
Expand Down
Loading