or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

annotation-processing.mdaot-optimization.mdcore-infrastructure.mdenvironment-config.mdindex.mdresource-management.mdtask-execution.mdtype-conversion.mdutilities.md
tile.json

tessl/maven-org-springframework--spring-core

Spring Framework Core - IoC Container and Dependency Injection

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.springframework/spring-core@6.2.x

To install, run

npx @tessl/cli install tessl/maven-org-springframework--spring-core@6.2.0

index.mddocs/

Spring Framework Core Module

Package Information

  • Name: Spring Framework Core (spring-core)
  • Type: Java Framework Library
  • Language: Java (with Kotlin support)
  • Version: 6.2.8
  • Repository: https://github.com/spring-projects/spring-framework

Core Imports

Gradle Dependency

dependencies {
    implementation 'org.springframework:spring-core:6.2.8'
}

Maven Dependency

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-core</artifactId>
    <version>6.2.8</version>
</dependency>

Common Import Patterns

// Core interfaces and utilities
import org.springframework.core.*;
import org.springframework.core.annotation.*;
import org.springframework.core.io.*;
import org.springframework.core.env.*;
import org.springframework.core.convert.*;
import org.springframework.core.task.*;
import org.springframework.aot.*;
import org.springframework.util.*;
import org.springframework.lang.*;

// Specific commonly used classes
import org.springframework.core.Ordered;
import org.springframework.core.PriorityOrdered;
import org.springframework.core.ResolvableType;
import org.springframework.core.MethodParameter;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.env.Environment;
import org.springframework.core.convert.ConversionService;
import org.springframework.util.StringUtils;
import org.springframework.util.ReflectionUtils;

Basic Usage

Simple Resource Loading

import org.springframework.core.io.*;

// Create resource loader
ResourceLoader loader = new DefaultResourceLoader();

// Load resources from various sources
Resource classpathResource = loader.getResource("classpath:config.properties");
Resource fileResource = loader.getResource("file:./data.txt");
Resource urlResource = loader.getResource("https://example.com/api");

// Use resources
if (classpathResource.exists()) {
    InputStream inputStream = classpathResource.getInputStream();
    // Process input stream
}

Type Resolution and Conversion

import org.springframework.core.*;
import org.springframework.core.convert.*;

// Resolve generic types
ResolvableType listType = ResolvableType.forClass(List.class);
ResolvableType stringListType = ResolvableType.forClassWithGenerics(List.class, String.class);
Class<?> resolvedClass = stringListType.resolve();

// Convert between types
ConversionService conversionService = new DefaultConversionService();
Integer converted = conversionService.convert("123", Integer.class);
List<String> stringList = conversionService.convert("a,b,c", List.class);

Annotation Processing

import org.springframework.core.annotation.*;

// Work with annotations
@Order(1)
public class MyComponent implements Ordered {
    @Override
    public int getOrder() {
        return 1;
    }
}

// Find annotations on methods/classes
Method method = MyComponent.class.getMethod("someMethod");
Order orderAnnotation = AnnotationUtils.findAnnotation(method, Order.class);
boolean hasOrder = AnnotatedElementUtils.hasAnnotation(MyComponent.class, Order.class);

Architecture

The Spring Framework Core follows a carefully designed layered architecture that provides the foundational infrastructure for the entire Spring ecosystem:

Foundation Layer

The core abstractions that define Spring's fundamental contracts:

  • Ordering System: Ordered and PriorityOrdered interfaces for component precedence
  • Resource Abstraction: Unified Resource interface abstracting files, classpath, URLs, and streams
  • Environment Model: Environment and PropertyResolver for configuration management
  • Attribute System: AttributeAccessor for metadata attachment and retrieval

Utility Layer

Comprehensive utilities that power Spring's internal operations:

  • String Processing: StringUtils for null-safe string manipulation and parsing
  • Reflection Utilities: ReflectionUtils for simplified and safe reflection operations
  • Collection Support: MultiValueMap and CollectionUtils for enhanced data structures
  • Path Matching: AntPathMatcher for flexible pattern-based resource resolution

Type System

Advanced type handling and conversion capabilities:

  • Generic Type Resolution: ResolvableType for complex generic type introspection
  • Method Parameter Analysis: MethodParameter for runtime parameter discovery
  • Type Conversion: ConversionService framework for extensible type transformations
  • Type Descriptors: Rich metadata system for conversion context

Integration Layer

Modern integration and optimization features:

  • Task Execution: Flexible asynchronous processing with TaskExecutor implementations
  • AOT Compilation: Native image support through RuntimeHints and code generation
  • Annotation Processing: Meta-annotation and attribute merging capabilities
  • Exception Handling: Nested exception support for detailed error context

Design Principles

Modularity: Each layer has clear responsibilities with minimal coupling between components.

Extensibility: Strategy and factory patterns allow customization of core behaviors.

Performance: Optimized implementations with caching, lazy initialization, and efficient algorithms.

Type Safety: Comprehensive generic type support with compile-time and runtime type checking.

Integration: Seamless integration points for other Spring modules (Context, AOP, Web, etc.).

This architecture enables Spring Core to serve as the stable foundation upon which the entire Spring Framework is built, from dependency injection containers to web applications and enterprise integration solutions.

Capabilities

The Spring Framework Core module provides fundamental infrastructure for the entire Spring ecosystem, organized into these key functional areas:

Core Infrastructure

  • Ordered Interface System: Priority-based ordering for components with Ordered and PriorityOrdered interfaces
  • Type Resolution: Advanced generic type handling with ResolvableType and MethodParameter
  • Alias Management: Component name aliasing through AliasRegistry
  • Attribute Access: Metadata attachment via AttributeAccessor
  • Exception Handling: Nested exception support with NestedRuntimeException and NestedCheckedException
  • Parameter Discovery: Runtime parameter name resolution

Resource Management

  • Resource Abstraction: Unified Resource interface for files, classpath, URLs, and byte arrays
  • Resource Loading: Flexible loading strategies with ResourceLoader and pattern matching
  • I/O Operations: Comprehensive support for input/output operations across resource types
  • Path Pattern Matching: Ant-style pattern matching for resource resolution

Type Conversion and Validation

  • Conversion Service: Extensible type conversion system with ConversionService
  • Type Descriptors: Rich type metadata with TypeDescriptor
  • Custom Converters: Pluggable converter implementations
  • Generic Type Support: Full generic type conversion capabilities

Annotation Processing

  • Merged Annotations: Attribute override and composition support
  • Annotation Utilities: Comprehensive annotation introspection
  • Meta-Annotations: Support for annotation composition and inheritance
  • Order Comparators: Annotation-aware sorting and ordering

Environment and Configuration

  • Environment Abstraction: Profile-based configuration with Environment
  • Property Sources: Hierarchical property resolution
  • Profile Management: Runtime profile activation and management
  • Property Placeholders: Expression and placeholder resolution

Task Execution

  • Task Executors: Asynchronous task execution with various strategies
  • Virtual Thread Support: Java Project Loom integration
  • Task Decoration: Customizable task wrapping and enhancement
  • Synchronous/Asynchronous: Both sync and async execution models

AOT Optimization

  • Runtime Hints: GraalVM native image optimization hints
  • Reflection Registration: AOT-safe reflection usage
  • Resource Registration: Static resource bundling for native images
  • Code Generation: Ahead-of-time code generation support

Utilities and Bundled Libraries

  • String Utilities: Comprehensive string manipulation with StringUtils
  • Reflection Utilities: Simplified reflection operations
  • Collection Utilities: Enhanced collection support including MultiValueMap
  • MIME Type Support: Content type handling and negotiation
  • Path Matching: Ant-style path pattern matching
  • Bundled Libraries: ASM, CGLib, JavaPoet, and Objenesis integration

Core API Overview

Key Interfaces

// Core ordering and priority
public interface Ordered {
    int HIGHEST_PRECEDENCE = Integer.MIN_VALUE;
    int LOWEST_PRECEDENCE = Integer.MAX_VALUE;
    int getOrder();
}

public interface PriorityOrdered extends Ordered {
}

// Resource abstraction  
public interface Resource extends InputStreamSource {
    boolean exists();
    boolean isReadable();
    boolean isFile();
    URL getURL() throws IOException;
    URI getURI() throws IOException;
    File getFile() throws IOException;
    String getDescription();
    InputStream getInputStream() throws IOException;
}

public interface ResourceLoader {
    String CLASSPATH_URL_PREFIX = "classpath:";
    Resource getResource(String location);
    ClassLoader getClassLoader();
}

// Environment and properties
public interface Environment extends PropertyResolver {
    String[] getActiveProfiles();
    String[] getDefaultProfiles();
    boolean acceptsProfiles(Profiles... profiles);
}

public interface PropertyResolver {
    boolean containsProperty(String key);
    String getProperty(String key);
    <T> T getProperty(String key, Class<T> targetType);
    String getRequiredProperty(String key);
    String resolvePlaceholders(String text);
}

// Type conversion
public interface ConversionService {
    boolean canConvert(Class<?> sourceType, Class<?> targetType);
    <T> T convert(Object source, Class<T> targetType);
    Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType);
}

// Task execution
public interface TaskExecutor extends Executor {
    void execute(Runnable task);
}

public interface AsyncTaskExecutor extends TaskExecutor {
    Future<?> submit(Runnable task);
    <T> Future<T> submit(Callable<T> task);
}

Key Classes

// Type resolution
public final class ResolvableType {
    public static ResolvableType forField(Field field);
    public static ResolvableType forMethodParameter(Method method, int parameterIndex);
    public static ResolvableType forClass(Class<?> clazz);
    public static ResolvableType forClassWithGenerics(Class<?> clazz, Class<?>... generics);
    
    public Class<?> resolve();
    public ResolvableType getSuperType();
    public ResolvableType[] getInterfaces();
    public ResolvableType getGeneric(int... indexes);
    public boolean isAssignableFrom(ResolvableType other);
}

// Method parameter handling
public class MethodParameter {
    public MethodParameter(Method method, int parameterIndex);
    public MethodParameter(Constructor<?> constructor, int parameterIndex);
    
    public Class<?> getParameterType();
    public Type getGenericParameterType();
    public Annotation[] getParameterAnnotations();
    public String getParameterName();
    public boolean isOptional();
}

// Annotation utilities
public abstract class AnnotationUtils {
    public static <A extends Annotation> A findAnnotation(Method method, Class<A> annotationType);
    public static <A extends Annotation> A findAnnotation(Class<?> clazz, Class<A> annotationType);
    public static Map<String, Object> getAnnotationAttributes(Annotation annotation);
    public static <A extends Annotation> A synthesizeAnnotation(A annotation);
}

// String utilities
public abstract class StringUtils {
    public static boolean hasLength(String str);
    public static boolean hasText(String str);
    public static boolean isEmpty(Object str);
    public static String trimWhitespace(String str);
    public static String[] split(String toSplit, String delimiter);
    public static String[] tokenizeToStringArray(String str, String delimiters);
    public static String collectionToCommaDelimitedString(Collection<?> coll);
    public static String capitalize(String str);
    public static String uncapitalize(String str);
}

// Reflection utilities
public abstract class ReflectionUtils {
    public static Field findField(Class<?> clazz, String name);
    public static Method findMethod(Class<?> clazz, String name, Class<?>... paramTypes);
    public static Object invokeMethod(Method method, Object target, Object... args);
    public static void makeAccessible(Field field);
    public static void makeAccessible(Method method);
    public static void doWithFields(Class<?> clazz, FieldCallback fc);
    public static void doWithMethods(Class<?> clazz, MethodCallback mc);
}

Type Definitions

Core Types

// Callback interfaces
@FunctionalInterface
public interface FieldCallback {
    void doWith(Field field) throws IllegalArgumentException, IllegalAccessException;
}

@FunctionalInterface  
public interface MethodCallback {
    void doWith(Method method) throws IllegalArgumentException, IllegalAccessException;
}

@FunctionalInterface
public interface TaskDecorator {
    Runnable decorate(Runnable runnable);
}

// Converter interfaces
@FunctionalInterface
public interface Converter<S, T> {
    T convert(S source);
}

public interface ConverterFactory<S, R> {
    <T extends R> Converter<S, T> getConverter(Class<T> targetType);
}

public interface GenericConverter {
    Set<ConvertiblePair> getConvertibleTypes();
    Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType);
    
    final class ConvertiblePair {
        public ConvertiblePair(Class<?> sourceType, Class<?> targetType);
        public Class<?> getSourceType();
        public Class<?> getTargetType();
    }
}

// Property source types
public abstract class PropertySource<T> {
    public PropertySource(String name, T source);
    public String getName();
    public T getSource(); 
    public abstract Object getProperty(String name);
}

// Exception types
public abstract class NestedRuntimeException extends RuntimeException {
    public NestedRuntimeException(String msg);
    public NestedRuntimeException(String msg, Throwable cause);
    public Throwable getRootCause();
    public Throwable getMostSpecificCause();
}

public abstract class NestedCheckedException extends Exception {
    public NestedCheckedException(String msg);
    public NestedCheckedException(String msg, Throwable cause);
    public Throwable getRootCause();
    public Throwable getMostSpecificCause();
}

Annotation Types

// Core annotations
@Target({ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Order {
    int value() default Ordered.LOWEST_PRECEDENCE;
}

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME) 
@Documented
public @interface AliasFor {
    String value() default "";
    String attribute() default "";
    Class<? extends Annotation> annotation() default Annotation.class;
}

// Null-safety annotations
@Target({ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Nullable {
}

@Target({ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Documented  
public @interface NonNull {
}

@Target(ElementType.PACKAGE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface NonNullApi {
}

@Target(ElementType.PACKAGE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface NonNullFields {
}

Utility Constants

// Spring version information
public final class SpringVersion {
    public static String getVersion();
}

// Native image detection
public final class NativeDetector {
    public static boolean inNativeImage();
}

// Kotlin detection
public final class KotlinDetector {
    public static boolean isKotlinPresent();
    public static boolean isKotlinType(Class<?> clazz);
}

// AOT detection  
public final class AotDetector {
    public static final String AOT_ENABLED = "spring.aot.enabled";
    public static boolean useGeneratedArtifacts();
}

Package Structure

The Spring Framework Core module contains 376+ public API components organized across these packages:

  • org.springframework.core (45+ classes) - Core functionality and utilities
  • org.springframework.core.annotation (25+ classes) - Annotation processing and meta-annotation support
  • org.springframework.core.io (35+ classes) - Resource abstraction and I/O operations
  • org.springframework.core.env (20+ classes) - Environment and property management
  • org.springframework.core.convert (25+ classes) - Type conversion system
  • org.springframework.core.task (15+ classes) - Task execution framework
  • org.springframework.aot (40+ classes) - AOT compilation and native image support
  • org.springframework.util (85+ classes) - Comprehensive utility library
  • org.springframework.lang (8+ classes) - Language annotations and utilities
  • org.springframework.asm (50+ classes) - Bundled ASM bytecode library
  • org.springframework.cglib (40+ classes) - Bundled CGLib proxy library
  • org.springframework.javapoet (25+ classes) - Bundled JavaPoet code generation
  • org.springframework.objenesis (8+ classes) - Bundled Objenesis instantiation library

This comprehensive API surface provides the foundational infrastructure that powers the entire Spring Framework ecosystem, from dependency injection and aspect-oriented programming to web applications and enterprise integration.