This document demonstrates how Konveyor Kantra can identify legacy practices and guide application modernization, showing both analysis findings and implemented solutions.
Konveyor is an open-source project providing tools for application modernization, helping organizations migrate applications to cloud-native environments.
Kantra is Konveyor's static analysis tool that identifies:
- Legacy patterns and antipatterns
- Cloud-native readiness issues
- Migration blockers and modernization opportunities
- Dependency concerns
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Legacy App │ │ Kantra │ │ Analysis │
│ (Source Code) │ ──> │ Analysis │ ──> │ Report │
└─────────────────┘ │ Engine │ │ (output.yaml) │
└─────────────────┘ └─────────────────┘
│
▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ Custom Rules │ │ Built-in │ │ Modernization │
│ (YAML files) │ ──> │ Rules │ ──> │ Solutions │
└─────────────────┘ └─────────────────┘ └─────────────────┘
mmdemo/
├── before-container/ # Legacy application to analyze
├── after-container/ # Modernized version with fixes
└── migration-konveyor/ # Analysis tools and configuration
├── rulesets/ # Custom and built-in rules
├── reports/ # Analysis output
├── kantra/ # Kantra binary and dependencies
└── analyze.sh # Analysis script
- Tested on macOS (Darwin) with Apple Silicon (ARM64)
- For other platforms:
- macOS (Darwin) with Intel: Update KANTRA_URL to use x86_64 binary
- Windows: Update KANTRA_URL to use windows binary and adjust paths
- Linux: Update KANTRA_URL to use Linux binary and adjust paths
- Konveyor Kantra v0.6.1
- curl, unzip, bash shell, Git
{
"analysis": {
"mode": "containerless",
"target": "cloud-readiness",
"scope": "source",
"output": {
"format": "yaml",
"include-insights": true
}
}
}- Preparation: Clean artifacts, verify rules, check workspace
- Execution: Run analysis, evaluate rules, generate output
- Output Generation: Create logs and reports
- Validation: Review findings, verify rule triggers
| Rule ID | Description | Pattern | Effort |
|---|---|---|---|
| custom-ruleset-legacy-code-01000 | Legacy Code Style | .*\.java$ |
3 |
| custom-ruleset-legacy-config-01000 | Hard coded Configuration | .*\.properties$ |
5 |
| custom-ruleset-legacy-logging-01000 | File-based Logging | .*\.log$ |
5 |
| custom-ruleset-legacy-storage-01000 | File-based Storage | .*\.json$ |
5 |
-
Legacy Code Style Issues
- Files: Java model, service, and servlet classes
- Issues: Missing documentation, inconsistent formatting, non-standard patterns
-
Hard coded Configuration Paths
- Files: Properties and configuration files
- Issues: Local file system references, absolute paths, environment-specific values
-
File-based Logging
- Files: Log files and logging configuration
- Issues: Local storage, non-structured logging, container-incompatible paths
-
File-based Storage
- Files: JSON data files
- Issues: No transaction support, data consistency problems
-
Embedded Cache Libraries
- Files: EhCache JAR, configuration, and implementation
- Issues: Container-incompatible caching, local dependencies
Location: after-container/src/main/java/
- Implemented Google Style Guide compliance with Checkstyle
- Added comprehensive documentation (JavaDoc at all levels)
- Standardized 2-space indentation and 100-character line limits
- Enabled automated style checking integrated with CI/CD
Location: after-container/podman/
- Moved configuration to environment variables with validation
- Removed hard coded paths and implemented path resolution
- Added container-friendly configuration and runtime detection
- Implemented environment separation with secure defaults
Location: after-container/src/main/resources/logback.xml
- Implemented container stdout/stderr logging with console appender
- Added JSON-formatted structured logs with correlation
- Removed all file-based logging mechanisms
Location: after-container/src/main/java/com/example/todo/service/TodoStorage.java
- Replaced file storage with PostgreSQL database
- Implemented connection pooling with HikariCP
- Added proper transaction management and data validation
- Removed all file system dependencies
Location: after-container/src/main/java/com/example/todo/service/
- Removed EhCache dependency completely
- Implemented stateless design with request context
- Prepared for horizontal scaling with session handling
Konveyor Kantra helps:
- Identify legacy practices in applications
- Provide specific modernization guidance
- Track improvements through analysis
- Guide the modernization process
Successful application modernization typically requires a combination of automated tools, manual review, expert knowledge, and business context.
For more details on the modernization approach, see the after-container README.