eclipse / jnosql

Eclipse JNoSQL is a framework which has the goal to help Java developers to create Jakarta EE applications with NoSQL.
Other
231 stars 72 forks source link

Enhancement Proposal - Support for CDI Lite and Reflectionless Solution in Eclipse JNoSQL #416

Closed otaviojava closed 1 year ago

otaviojava commented 1 year ago

This proposal aims to enhance Eclipse JNoSQL to support CDI Lite and introduce a reflectionless solution. Currently, the project relies on reflection and CDI full, which is suitable for most Jakarta EE and Microprofile solutions. However, to ensure compatibility with frameworks that do not work with Java annotations, such as Quarkus, and to improve performance and maintainability, it is essential to refactor the project and create a metadata API that allows for transparent usage of information from either reflection or Java annotation processing.

Objectives

  1. Refactor Eclipse JNoSQL to explore inversion of control by creating a metadata API.
  2. Enable support for CDI Lite, ensuring compatibility with lightweight frameworks like Quarkus.
  3. Implement a reflectionless solution to improve performance and eliminate the reliance on reflection, enhancing maintainability.

Proposed Steps

Step 1: Refactoring and Metadata API

The initial step is to refactor Eclipse JNoSQL to create a metadata API. The metadata API will serve as a unified interface to obtain necessary information about classes, fields, and methods, irrespective of the source (reflection or Java annotations). This step will ensure that the underlying engine remains transparent to the source of metadata.

Step 2: CDI Lite Support

Once the metadata API is in place, we can start enabling support for CDI Lite. CDI Lite is a lightweight version of CDI, suitable for environments like Quarkus, where full CDI might not be available. The project will be updated to leverage CDI Lite's functionalities for dependency injection and component discovery, thus ensuring that Eclipse JNoSQL can be seamlessly integrated with Quarkus and similar frameworks.

Step 3: Reflectionless Solution using Java Annotation Processing

To achieve the reflectionless solution, we will explore the world of Java Annotation Processing. Using annotation processing, we can generate necessary metadata during compilation, eliminating the need for reflection at runtime. This approach will improve performance and eliminate any potential reflection-related issues. Importantly, this step won't significantly impact the learning curve for the development team, as it will continue to use familiar Java annotations.

Expected Benefits

  1. Enhanced Compatibility: With support for CDI Lite, Eclipse JNoSQL will be compatible with lightweight frameworks like Quarkus, extending its usability to a broader range of applications and enabling developers to take advantage of its features in various environments.
  2. Improved Performance: The reflectionless solution will lead to improved performance, reduced startup times, and optimized resource usage, resulting in a more efficient overall system.
  3. Maintenance and Reliability: Eliminating reflection in favor of Java Annotation Processing will enhance code maintainability, reducing the likelihood of runtime errors and improving the reliability of the project.
  4. Future-Proofing: By leveraging CDI Lite and exploring Java Annotation Processing, Eclipse JNoSQL will be better prepared for the evolving Java ecosystem and future developments in the Jakarta EE and Microprofile communities.

Potential Challenges

  1. Compatibility Testing: Ensuring compatibility with various lightweight frameworks may require rigorous testing across different environments to guarantee seamless integration.
  2. Community Adoption: Convincing the community to embrace this change may require clear communication of the advantages and potential impact on existing codebases.

Conclusion

Enabling support for CDI Lite and implementing a reflectionless solution in Eclipse JNoSQL will significantly enhance the project's capabilities, compatibility, and performance. By refactoring the project and creating a metadata API, we can ensure that the transition to CDI Lite and Java Annotation Processing is smooth, providing users with a more flexible, efficient, and future-proof solution. This proposal outlines the steps and benefits of the enhancement and aims to secure community support for the advancement of Eclipse JNoSQL.