refactor: unify platform access with service implementations#347
Conversation
📝 WalkthroughWalkthroughThis pull request adds two loader-agnostic interfaces in common: PlatformService (configDir) and ResourceReloadRegistrar (register). LogisticsConfig now uses PlatformService.INSTANCE to locate logistics.json. MaceratorRecipeManager registers its reload listener via ResourceReloadRegistrar.INSTANCE.register(...). Fabric module supplies FabricPlatformService and FabricResourceReloadRegistrar implementations discovered at runtime via ServiceLoader. Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
@CodeRabbit review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@common/src/main/java/com/logistics/core/lib/platform/PlatformService.java`:
- Around line 24-26: The ServiceLoader lookups in PlatformService and
ResourceReloadRegistrar will fail because the SPI descriptor files are missing;
add two files under fabric/src/main/resources/META-INF/services: one named
com.logistics.core.lib.platform.PlatformService containing the single
implementation class name com.logistics.fabric.FabricPlatformService, and
another named com.logistics.core.lib.platform.ResourceReloadRegistrar containing
com.logistics.fabric.FabricResourceReloadRegistrar so
ServiceLoader.load(PlatformService.class) and
ServiceLoader.load(ResourceReloadRegistrar.class) can discover the
implementations.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 604d85c8-f380-4ca6-8e65-4534ae7c07fe
📒 Files selected for processing (6)
common/src/main/java/com/logistics/core/LogisticsConfig.javacommon/src/main/java/com/logistics/core/lib/platform/PlatformService.javacommon/src/main/java/com/logistics/core/lib/platform/ResourceReloadRegistrar.javacommon/src/main/java/com/logistics/core/macerator/MaceratorRecipeManager.javafabric/src/main/java/com/logistics/fabric/FabricPlatformService.javafabric/src/main/java/com/logistics/fabric/FabricResourceReloadRegistrar.java
Summary
This update introduces a unified access layer for platform-specific functionalities through the implementation of the
PlatformServiceandResourceReloadRegistrar. This change enhances maintainability by centralizing platform access and reinforces the capabilities for resource management across different loaders.Changes
Unification of Platform Access:
PlatformServiceinterface to standardize access to platform-specific utilities.FabricPlatformServiceto provide FabricLoader access for configuration paths.Resource Management Enhancements:
ResourceReloadRegistrarinterface for the loader-agnostic registration of reload listeners.FabricResourceReloadRegistrarimplementation to facilitate resource reloading in a platform-independent way.Code Refactoring:
Notes
PlatformServiceandResourceReloadRegistrarpatterns for seamless functionality across platforms.