From d7ddf3710f6aff40d0595430f5f49255c89fdca1 Mon Sep 17 00:00:00 2001 From: "Begonia, HE" <163421589+BegoniaHe@users.noreply.github.com> Date: Sun, 25 Jan 2026 04:52:35 +0100 Subject: refactor(java): modularize Java detection and management system - Split monolithic java.rs (1089 lines) into focused modules - detection: Java installation discovery - validation: Version validation and requirements checking - priority: Installation selection priority logic - provider: Java download provider trait - providers: Provider implementations (Adoptium) - persistence: Cache and catalog management - Add java_path_override field to Instance struct for per-instance Java configuration - Export JavaInstallation at core module level This refactoring improves maintainability and prepares for multi-vendor Java provider support. Reviewed-by: Claude Sonnet 4.5 --- src-tauri/src/core/java/provider.rs | 41 +++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src-tauri/src/core/java/provider.rs (limited to 'src-tauri/src/core/java/provider.rs') diff --git a/src-tauri/src/core/java/provider.rs b/src-tauri/src/core/java/provider.rs new file mode 100644 index 0000000..0f9d78a --- /dev/null +++ b/src-tauri/src/core/java/provider.rs @@ -0,0 +1,41 @@ +use crate::core::java::{ImageType, JavaCatalog, JavaDownloadInfo}; +use tauri::AppHandle; + +/// Trait for Java download providers (Adoptium, Temurin, Corretto, etc.) +/// +/// Implements SOLID principles: +/// - Single Responsibility: Each provider handles one download source +/// - Open/Closed: New providers can be added without modifying existing code +/// - Liskov Substitution: All providers are interchangeable +/// - Interface Segregation: Minimal required methods +/// - Dependency Inversion: Code depends on trait, not concrete implementations +pub trait JavaProvider: Send + Sync { + /// Fetch the Java catalog (all available versions for this provider) + async fn fetch_catalog( + &self, + app_handle: &AppHandle, + force_refresh: bool, + ) -> Result; + + /// Fetch a specific Java release + async fn fetch_release( + &self, + major_version: u32, + image_type: ImageType, + ) -> Result; + + /// Get list of available major versions + async fn available_versions(&self) -> Result, String>; + + /// Get provider name (e.g., "adoptium", "corretto") + fn provider_name(&self) -> &'static str; + + /// Get OS name for this provider's API + fn os_name(&self) -> &'static str; + + /// Get architecture name for this provider's API + fn arch_name(&self) -> &'static str; + + /// Get installation directory prefix (e.g., "temurin", "corretto") + fn install_prefix(&self) -> &'static str; +} -- cgit v1.2.3-70-g09d2