aws-cloudformation / aws-cloudformation/cloudformation-cli-java-plugin
Reusing code between resources
- Vorherrschende Sprache
- Java
- Sterne
- 30
- Forks
- 48
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Hi, I'm from AWS IoT, we have a question/feature request.
Our handlers across different resources use the same code for exception translations and listing resource tags. These resources reside in the same GitHub repository, yet, since each resource has its own Maven project, we're unable to reuse that common code and haven't seen solutions in other repositories.
Specific examples from our AWS IoT repo (code is still in PRs):
1. Exception translation code - [link](https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-iot/blob/09e62a47f99448c366eb7eaceb8c8ea76f8d6d36/aws-iot-securityprofile/src/main/java/com/amazonaws/iot/securityprofile/Translator.java#L295). We have this method in the Translator class for each resource.
1. `listTags` method (calls IoT::ListTagsForResource) - [link](https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-iot/blob/09e62a47f99448c366eb7eaceb8c8ea76f8d6d36/aws-iot-securityprofile/src/main/java/com/amazonaws/iot/securityprofile/HandlerUtils.java#L46).
For both of these, we're able to reuse the code between handlers for the same resource, but we had to copy paste this piece of code for each resource.
Is there a solution available for our use case?
Beitragsleitfaden
Rechercherichtung
Beginne mit den verlinkten AWS IoT-Beispielen in Translator.java und HandlerUtils.java und konzentriere dich auf die Methoden zur Ausnahmeübersetzung und listTags, die in den Maven-Projekten der Ressourcen dupliziert sind. Untersuche anschließend, wie dieses Java-Plugin separate Projekte generiert, und ermittle, ob gemeinsamer Code unterstützt werden kann. Die Aufgabe ist abgeschlossen, wenn ein konkreter Ansatz zur Wiederverwendung dieser Handler dokumentiert oder implementiert wurde.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- java
- Bereich
- build-system, tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100