SIFT ist ein Befehlszeilen-Tool, das Softwaresystemdesigns von JVM-Bytecode analysiert und umgekehrt. Es wird durch Verarbeitung von .Class- oder .jar -Dateien mit vordefinierten Vorlagen durchgeführt, die als Systemmodellvorlagen bezeichnet werden. Diese Vorlagen vermitteln Kenntnisse über Technologiestapel oder projektspezifische Konstrukte, mit denen das Tool ein umfassendes Modell des Systems generieren kann.
Das resultierende Systemmodell besteht aus Entitäten, die die Struktur und das Verhalten des Systems beschreiben.
--diff , um die Auswirkungen neuer Funktionen oder Änderungen zu analysieren.
Springboot mit Axon Framework-Vorlage in Aktion; Filterung auf Versand und bestätigte Bestellungen in https://github.com/eugenp/tutorials/tree/master/axon.




Usage: sift [OPTIONS]
Sift is a command-line tool that analyzes and reverse models software system designs
from JVM bytecode.
Template options:
-t, --template TEMPLATE The template producing the system model.
-l, --list-templates Print all installed templates.
-T, --list-entity-types Lists entity types defined by template.
-f, --class-dir, --classes PATH|URI|MAVEN_COORD
Provide class input as a directory, JAR file, URI
(pointing to a JAR), or Maven coordinate.
-d, --diff FILE_JSON|URI|MAVEN_COORD Compare the system model from '-f' with another,
specified as a JSON file (previously saved System
Model), class input as a directory, JAR file, URI
(pointing to a JAR), or Maven coordinate.
--profile Print execution times and input/output for the
executed template.
-D, --dump-system-model Print all entities along with their properties and
metadata.
Entity tree/graph options:
-L, --max-depth INT Max display depth of the tree.
-F, --filter REGEX Filter nodes by label. (repeatable)
-S, --filter-context REGEX Filter nodes by label, while also including
sibling nodes. (repeatable)
-e, --exclude REGEX Exclude nodes when label matches REGEX.
(repeatable)
-c, --column [all|element-id|element-type|entity-type]
Columns to display. (repeatable)
-E, --exclude-type ENTITY_TYPE Exclude entity types from tree. (repeatable)
-r, --tree-root ENTITY_TYPE Tree built around requested entity type.
(repeatable)
--no-emoji Disables printing emoji in entity labels.
Visualization options:
-R, --render Render entities with graphviz's DOT language.
--edge-layout [spline|polyline|ortho]
Sets the layout for the lines between nodes.
(default: spline)
Serialization options:
-s, --save FILE_JSON Save the resulting system model as json.
--load FILE_JSON Load a previously saved system model.
Debug options:
--debug Print log/logCount statements from the executed
template.
-X, --debug-inverse-trace Print the inverse element trace for the elements
specified with --debug-element-traces
-x, --debug-element-trace ELEMENT_ID Print all element traces leading to the specified
elements
Miscellaneous options:
-a, --ansi [none|ansi16|ansi256|truecolor]
Override automatically detected ANSI support.
--stacktrace Print stacktrace to stderr if an error occurs
--version Print version and release date.
-m, --maven-repository VALUE Additional maven repositories to use for
downloading artifacts. Maven central
(https://repo1.maven.org/maven2/) and local user
repositories are always included.
--statistics Print internal statistics about the system model
template context.
--generate-completion [bash|zsh|fish]
-h, --help Show this message and exit
Examples:
sift --template spring-axon -f my-spring-project
Model the system using the "spring-axon" template on the classes in the
"my-spring-project" directory.
sift -t spring-axon -f . -F "Order(Created|Shipped)"
Model the system using the "spring-axon" template on the current directory's
classes, filter nodes containing the regular expression "Order(Created|Shipped)".
sift -t spring-axon -f . --diff feature-01.json
Compare the current design of the system using the "spring-axon" template on
the classes in the current directory against a previously saved system model
from "feature-01.json" and show the differences.
sift -t sift -f "net.onedaybeard.sift:core:0.13.0" --diff "net.onedaybeard.sift:core:0.9.0"
Compare two different versions of the DSL API using the 'sift' template, specified
by their maven coordinates.
Das Systemmodell beschreibt die Struktur und die Beziehungen von Entitäten innerhalb eines Systems. Eine Entität ist ein Objekt oder eine Komponente innerhalb des Systems, die durch eine Klasse, Methode, Feld, Parameter oder generische Signatur eindeutig identifiziert wird.
Entitäten werden nach ihrer Entity.Type eingestuft. Ein Entitätstyp repräsentiert einen bemerkenswerten Teil des Systems. Beispielsweise können Typen REST -Controller, HTTP -Endpunkte, eingehende/ausgehende Nachrichten, RDS, Repositories und mehr umfassen.
$ sift --template spring-axon -f target/classes --list-entity-types
entity types of spring-axon
1 aggregate
2 aggregate-ctor
1 aggregate-member
6 command
6 command-handler
1 controller
13 endpoint
7 event
7 event-handler
7 event-sourcing-handler
1 projection
3 query
4 query-handlerSystemmodellvorlagen beschreiben, wie Entitäten in einem bestimmten Technologiestapel und/oder projektspezifischen Konstrukten identifiziert werden. Die Vorlagen sind in einem deklarativen DSL geschrieben und werden verwendet, um das Systemmodell aus Eingangsklassen zu erstellen. Die DSL liefert hochrangige Abstraktionen zum Identifizieren und Zusammenhang zwischen Klassenstruktur oder Verwendung.
Der folgende Code zeigt eine einfache Systemmodellvorlage, die REST -Controller und HTTP -Endpunkte innerhalb eines Systems identifiziert und die beiden Entitäten assoziiert.
val controller = Entity . Type ( " controller " )
val endpoint = Entity . Type ( " endpoint " )
template {
// iterate over all input classes
classes {
annotatedBy< RestController >() // filter classes
entity(controller) // mark remaining as 'controller'
methods { // iterate all controller methods
annotatedBy< Endpoint >() // filter @Endpoint methods
entity(endpoint)
// associate controllers with their endpoints
controller[ " endpoints " ] = endpoint
}
}
} Eingabelemente (Klassen, Methoden, Parameter, Felder, generische Signaturen) werden in Stapeln, Linien-für-Linie verarbeitet. Die Ausführung einer Systemmodellvorlage kann mit der Option --profile -Option eingedämmt werden.

Eine typische Vorlage kann in ca. 100-200 Codezeilen ausgedrückt werden. Einige Vorlagen wie JPA und JDBI sind besonders kürzer. Benutzerdefinierte Vorlagen können mehrere vorhandene Vorlagen enthalten, um das zugrunde liegende System besser zu beschreiben und gleichzeitig das resultierende DSL präzise zu halten.
SIFT erfordert eine Java 17 oder später Laufzeit.
Für Fensterbenutzer wird empfohlen, Sift unter WSL auszuführen, bis die richtigen Fensterpfade vorhanden sind.
Der einfachste Weg, SIFT zu installieren, besteht darin, das Repository zu klonen und mvn install auszuführen und dann SIFT.ZSH | SH an einen Ort auf dem $PATH zu kopieren, z. B.:
mvn install von Project Root. Dies installiert SIFT in ~/.local/share/sift/binsift.zsh oder sift.sh nach ~/.local/bin/sift Der main verweist immer auf das neueste Veröffentlichungsausschuss.
Wenn Graalvm und natives Image installiert sind, kann ein nationales Binärdatum mit dem native-image Maven-Profil erstellt werden: mvn install -P native-image . Die resultierende Binärdatei befindet sich in ~/.local/share/sift/bin/sift . sift.zsh und sift.sh prüft zuerst, ob die native binäre verfügbar ist, andernfalls versucht es, das Glas zu betreiben.
Die native binäre ist erheblich schneller als das Glas, kann jedoch Probleme verursachen, wenn es ein Systemmodell (über --load oder --diff ) oder Systemmodellvorlage, die unbekannte Typen enthält (z. B. von withValue() ), deserialisieren muss.