Skip to content

Ultra-fast Java DI container with O(1) bean resolution, sub-millisecond startup, and intelligent caching for modern applications.

License

Notifications You must be signed in to change notification settings

yasmramos/warmup-framework

Repository files navigation

Warmup Framework

Java License Build Status Ask DeepWiki

A high-performance, lightweight dependency injection and IoC container with O(1) bean resolution, sub-millisecond startup times, and intelligent caching mechanisms for modern Java applications.

Warmup Framework provides lightning-fast startup times, advanced bytecode generation, and intelligent caching mechanisms while maintaining full compatibility with standard Java frameworks and GraalVM native image support.

Warmup Framework is designed for high-performance Java applications requiring ultra-fast startup and efficient dependency resolution.

πŸš€ Key Features

⚑ Ultra-Fast Performance

  • O(1) Bean Registry: Constant-time bean lookup and dependency resolution
  • Intelligent JIT Compilation: On-the-fly bytecode generation for optimal performance
  • Advanced Caching: Multi-level caching system with automatic invalidation
  • Benchmark Results: Sub-millisecond startup times and dependency resolution

πŸ”§ Modern Dependency Injection

  • @Primary & @Alternative Annotations: Intelligent bean selection and priority management
  • Constructor Injection: Full support for dependency injection via constructors
  • Field Injection: Support for field-level dependency injection
  • Method Injection: Configurable method injection with parameter resolution
  • Profile-Based Configuration: Conditional bean registration based on active profiles

🎯 Advanced Scoping

  • Singleton Scope: Default lifecycle for shared instances
  • Prototype Scope: Per-request bean creation
  • Request Scope: Web request-specific bean lifecycle
  • Session Scope: HTTP session-specific bean management
  • Custom Scopes: Extensible scope management system

πŸ” Aspect-Oriented Programming (AOP)

  • Method Interception: Advanced AOP capabilities for cross-cutting concerns
  • Performance Metrics: Built-in performance monitoring and measurement
  • Runtime Optimization: Dynamic bytecode enhancement and optimization
  • Configuration Processing: Intelligent configuration bean processing

πŸ—οΈ Modular Architecture

  • Plugin System: Extensible architecture with plugin support
  • Multi-Module Support: Modular project organization
  • Spring Integration: Seamless integration with Spring Boot ecosystem
  • Third-Party Compatibility: Support for Dagger, Guice, and other frameworks

πŸ“¦ Architecture Overview

warmup-framework/
β”œβ”€β”€ warmup-core/           # Core IoC container and dependency injection
β”œβ”€β”€ warmup-aop/           # Aspect-oriented programming implementation
β”œβ”€β”€ warmup-processor/     # Annotation processing and code generation
β”œβ”€β”€ warmup-examples/      # Usage examples and demonstrations
β”œβ”€β”€ warmup-integration/   # Integration with external frameworks
β”œβ”€β”€ warmup-benchmark/     # Performance benchmarks and comparisons
└── warmup-test/          # Testing utilities and support

πŸ› οΈ Quick Start

Maven Dependencies

Add to your pom.xml:

<dependency>
    <groupId>io.warmup.framework</groupId>
    <artifactId>warmup-core</artifactId>
    <version>1.0.0</version>
</dependency>

Basic Usage

import io.warmup.framework.core.Warmup;
import jakarta.inject.Inject;
import jakarta.inject.Singleton;

// Define your interface and implementation
public interface GreetingService {
    String greet(String name);
}

@Singleton
public class GreetingServiceImpl implements GreetingService {
    @Override
    public String greet(String name) {
        return "Hello, " + name + "!";
    }
}

// Configure your application
public class Application {
    public static void main(String[] args) throws Exception {
        // Use Warmup as the main entry point
        Warmup warmup = Warmup.create()
            .scanPackages("com.company.application")
            .withProfile("development")
            .start();
        
        // Resolve dependencies through the fluent API
        GreetingService service = warmup.getBean(GreetingService.class);
        String result = service.greet("World");
        
        System.out.println(result); // Output: Hello, World!
        
        warmup.stop();
    }
}

Advanced Configuration with @Primary

public interface Logger {
    void log(String message);
}

@Primary
@Singleton
public class ConsoleLogger implements Logger {
    @Override
    public void log(String message) {
        System.out.println("[CONSOLE] " + message);
    }
}

@Alternative
@Singleton  
public class FileLogger implements Logger {
    @Override
    public void log(String message) {
        // File logging implementation
    }
}

// Using profiles
@Profile("production")
@Primary
@Singleton
public class DatabaseLogger implements Logger {
    // Production logging
}

// Application configuration with Warmup
public class Application {
    public static void main(String[] args) {
        Warmup warmup = Warmup.runWithProfile("production");
        Logger logger = warmup.getBean(Logger.class);
        logger.log("Application started");
    }
}

Request and Session Scoped Beans

import io.warmup.framework.annotations.*;

@RequestScope
public class RequestContext {
    private String requestId;
    private long startTime;
    
    public RequestContext() {
        this.requestId = UUID.randomUUID().toString();
        this.startTime = System.currentTimeMillis();
    }
}

@SessionScope
public class UserSession {
    private String userId;
    private String sessionData;
}

🎯 Use Cases

1. Microservices Architecture

// Lightweight service container
@Singleton
public class Microservice {
    @Inject
    private DatabaseService db;
    
    @Inject  
    private MessageQueue queue;
    
    public void start() {
        // Ultra-fast startup for microservices
    }
}

// Microservice bootstrap
public class MicroserviceApplication {
    public static void main(String[] args) {
        Warmup warmup = Warmup.create()
            .scanPackages("com.company.microservice")
            .withProfile("production")
            .start();
            
        Microservice service = warmup.getBean(Microservice.class);
        service.start();
    }
}

2. High-Performance APIs

// Optimized for low-latency requirements
@Singleton
public class HighPerformanceAPI {
    @Inject
    private CacheService cache;
    
    @Inject
    private ComputationService computation;
}

// API bootstrap
public class APIApplication {
    public static void main(String[] args) {
        Warmup warmup = Warmup.quickStart();
        HighPerformanceAPI api = warmup.getBean(HighPerformanceAPI.class);
        // Ready for high-frequency requests
    }
}

3. Complex Configuration Management

@Profile("development")
@Singleton
public class DevelopmentConfig {
    @Bean
    public DatabaseConfig devDatabase() {
        return new DatabaseConfig("localhost", 5432);
    }
}

@Profile("production")
@Singleton
public class ProductionConfig {
    @Bean
    public DatabaseConfig prodDatabase() {
        return new DatabaseConfig("prod-db.company.com", 5432);
    }
}

// Configuration bootstrap
public class ConfigurationApplication {
    public static void main(String[] args) {
        Warmup warmup = Warmup.runWithProfile(
            System.getProperty("spring.profiles.active", "development")
        );
        
        DatabaseConfig dbConfig = warmup.getBean(DatabaseConfig.class);
        System.out.println("Connected to: " + dbConfig.getUrl());
    }
}

πŸ“Š Performance Benchmarks

The framework includes comprehensive performance benchmarks comparing against popular alternatives:

Operation Warmup Framework Spring Dagger 2 Guice
Container Startup 0.8ms 245ms 12ms 8ms
Bean Resolution O(1) O(log n) O(log n) O(log n)
Memory Usage ~2MB ~45MB ~8MB ~6MB
Reflection Overhead None High Medium Medium

Running Benchmarks

# Run performance benchmarks
mvn clean test -Pbenchmark

# View detailed results
cat warmup-benchmark/benchmark-results.json

πŸ”§ Configuration

Container Configuration

// Quick start with minimal configuration
Warmup warmup = Warmup.quickStart();

// Fluent API for advanced configuration
WarmupContainer container = Warmup.create()
    .scanPackages("com.company.application")
    .withProfile("development")
    .withProperty("db.url", "jdbc:h2:mem:test")
    .withAutoScan(true)
    .withLazyInit(false)
    .start();

// Multiple profiles and properties
Warmup warmup = Warmup.create()
    .withProfiles("development", "test")
    .withProperties(Map.of(
        "db.url", "jdbc:h2:mem:test",
        "cache.enabled", "true",
        "log.level", "DEBUG"
    ))
    .start();

Property-Based Configuration

# application.properties
warmup.profile=development
warmup.cache.enabled=true
warmup.metrics.enabled=true
warmup.auto.scan=true
warmup.lazy.init=false

πŸ§ͺ Testing

The framework includes comprehensive testing capabilities:

// JUnit 5 Integration
@ExtendWith(WarmupTestExtension.class)
class MyServiceTest {
    @Inject
    private MyService service;
    
    @Test
    void testServiceBehavior() {
        assertThat(service.process("input")).isNotNull();
    }
}

// Mock Framework Integration
@Test
void testWithMocks() {
    try (MockContext context = Warmup.testMode()) {
        MyService service = context.mock(MyService.class);
        when(service.process("test")).thenReturn("mocked");
        
        assertThat(service.process("test")).isEqualTo("mocked");
    }
}

πŸ”Œ Integration

Spring Boot Integration

@SpringBootApplication
@EnableWarmupContainer
public class Application {
    public static void main(String[] args) {
        // Use Warmup for faster startup
        Warmup warmup = Warmup.quickStart();
        SpringApplication.run(Application.class, args);
    }
}

Third-Party Framework Support

  • Dagger 2: Seamless migration and hybrid usage
  • Google Guice: Compatible dependency resolution
  • Spring Framework: Spring bean integration and compatibility
  • Jakarta EE: Full Jakarta EE 9+ compatibility

πŸ“ˆ Monitoring & Metrics

Built-in performance monitoring and metrics collection:

@Singleton
public class PerformanceMonitor {
    @Inject
    private MetricsCollector metrics;
    
    @PerformanceMetrics
    public void expensiveOperation() {
        // Automatically monitored
        // Metrics available via metrics collector
    }
}

Available Metrics

  • Bean Creation Time: Individual bean instantiation times
  • Dependency Resolution: Graph resolution performance
  • Cache Hit/Miss Rates: Caching effectiveness
  • Memory Usage: Heap and non-heap memory consumption
  • GC Impact: Garbage collection influence

πŸ”’ Security Features

  • ClassLoader Isolation: Secure class loading and management
  • Runtime Bytecode Validation: Safe code generation and execution
  • Access Control: Configurable security policies
  • Dependency Sandboxing: Isolated dependency resolution

πŸ“ Logging

Configure logging for debugging and monitoring:

<!-- logback.xml -->
<configuration>
    <appender name="WARMUP" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
        </encoder>
    </appender>
    
    <logger name="io.warmup.framework" level="INFO"/>
    <logger name="io.warmup.framework.performance" level="DEBUG"/>
    
    <root level="WARN">
        <appender-ref ref="WARMUP"/>
    </root>
</configuration>

🀝 Contributing

We welcome contributions! Please read our contributing guidelines:

  1. Fork the repository
  2. Create a feature branch
  3. Add comprehensive tests
  4. Ensure all benchmarks pass
  5. Submit a pull request

Development Setup

# Clone the repository
git clone https://github.com/your-org/warmup-framework.git
cd warmup-framework

# Build the project
mvn clean install

# Run all tests
mvn test

# Run performance benchmarks
mvn test -Pbenchmark

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ“ž Support

🎯 Roadmap

Version 2.0 (Planned)

  • Kotlin Support: Full Kotlin DSL and extension functions
  • Reactive Streams: Integration with Project Reactor and RxJava
  • Cloud Native: Kubernetes and Cloud Foundry native support
  • GraphQL: Advanced GraphQL integration and optimization

Version 1.5 (Next Release)

  • Enhanced AOP: Advanced aspect weaving capabilities
  • Plugin Architecture: Extensible plugin system for custom extensions
  • Configuration Hot-Reload: Runtime configuration updates without restart
  • Advanced Caching: Multi-tier caching with TTL and invalidation strategies

⚑ Why Choose Warmup Framework?

  1. Performance First: Designed from the ground up for optimal performance
  2. Modern Architecture: Built for cloud-native and microservices environments
  3. Developer Experience: Clean, intuitive API with excellent documentation
  4. Production Ready: Comprehensive testing, monitoring, and logging
  5. Future Proof: Extensible architecture designed for long-term maintainability

Quick Start Commands

# Clone and build
git clone https://github.com/your-org/warmup-framework.git
cd warmup-framework
mvn clean install

# Run examples
cd warmup-examples
mvn spring-boot:run

# Run benchmarks
mvn test -Pbenchmark

# Quick API test
java -cp "warmup-core/target/warmup-core-1.0-SNAPSHOT.jar" \
  io.warmup.framework.examples.QuickStartExample

Built with ❀️ for the Java community

About

Ultra-fast Java DI container with O(1) bean resolution, sub-millisecond startup, and intelligent caching for modern applications.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages