Skip to content

Add Spring annotations for repository and REST endpoints - #1

Open
Amir-Golmoradi wants to merge 1 commit into
amigoscode:mainfrom
Amir-Golmoradi:add-annotations
Open

Add Spring annotations for repository and REST endpoints#1
Amir-Golmoradi wants to merge 1 commit into
amigoscode:mainfrom
Amir-Golmoradi:add-annotations

Conversation

@Amir-Golmoradi

Copy link
Copy Markdown

This PR introduces four essential Spring-like annotations to the mini-spring framework, completing the core stereotype and mapping annotations needed for a fully-featured dependency injection and web framework.

Added Annotations

  1. @repository - Marks a class as a data access object

    • Equivalent to Spring's @Repository
    • Indicates a class handles database/data access operations
    • Managed as a singleton bean by the framework
    • Can be injected via @Autowired
  2. @component - Generic managed component annotation

    • Equivalent to Spring's @Component
    • Used for classes that don't fit into more specific stereotypes
    • Provides a base annotation for component scanning
    • Enables automatic instantiation and lifecycle management
  3. @PostMapping - HTTP POST request mapping

    • Equivalent to Spring's @PostMapping
    • Allows methods to handle POST requests
    • Supports optional path parameters via value() attribute
    • Complements existing @Get annotation for request mapping
  4. @GetMapping - HTTP GET request mapping

    • Equivalent to Spring's @GetMapping
    • Allows methods to handle GET requests
    • Supports optional path parameters via value() attribute
    • Provides more semantic alternative to generic @Get annotation

Motivation

These annotations are essential for:

  • Following Spring Framework conventions and patterns
  • Providing developers with familiar APIs
  • Enabling comprehensive stereotype-based component detection
  • Supporting both GET and POST HTTP methods explicitly

Implementation Notes

  • All annotations follow the existing pattern used in the framework
  • Properly configured with @Target(ElementType.TYPE) or @Target(ElementType.METHOD) as appropriate
  • Use @Retention(RetentionPolicy.RUNTIME) for reflection-based processing
  • Include clear Javadoc comments explaining functionality
  • Maintain consistency with existing annotation structure

Testing

These annotations integrate seamlessly with existing framework components:

  • Work with the DI container for component registration
  • Compatible with @Autowired for dependency injection
  • Fully compatible with the routing system

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant