CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-springframework--spring-context

Spring Context module providing core application context functionality for dependency injection, lifecycle management, event-driven architecture, task scheduling, caching, validation, and cross-cutting concerns in Spring-based applications

Pending
Overview
Eval results
Files

stereotypes.mddocs/

Stereotype Annotations

Core Stereotypes

@Component  // Generic component
@Service    // Business logic layer
@Repository // Data access layer (adds PersistenceExceptionTranslation)
@Controller // Web MVC controller
@Configuration // Bean definition source

@Component

@Component
@Scope("prototype")
@Lazy
public class GenericComponent {
    // Auto-detected by component scanning
}

@Component("customName")
public class NamedComponent {}

@Service

@Service
public class UserService {

    @Autowired
    private UserRepository repository;

    public User findById(Long id) {
        return repository.findById(id);
    }
}

@Repository

@Repository
public class JdbcUserRepository {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public User findById(Long id) {
        // DataAccessException translation applied automatically
        return jdbcTemplate.queryForObject(
            "SELECT * FROM users WHERE id = ?",
            new UserRowMapper(),
            id
        );
    }
}

Custom Stereotypes

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Service
@Transactional
public @interface TransactionalService {
    String value() default "";
}

@TransactionalService
public class OrderService {
    // Combines @Service and @Transactional
}

Meta-Annotations

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Component
@Scope("prototype")
@Lazy
public @interface PrototypeComponent {
    @AliasFor(annotation = Component.class)
    String value() default "";
}

@PrototypeComponent
public class PrototypeScopedBean {}

JSR-330 Annotations

@Named("userService")  // Equivalent to @Component
@Singleton             // Equivalent to @Scope("singleton")
public class UserService {

    @Inject  // Equivalent to @Autowired
    private UserRepository repository;

    @PostConstruct
    public void init() {}

    @PreDestroy
    public void cleanup() {}
}

Install with Tessl CLI

npx tessl i tessl/maven-org-springframework--spring-context

docs

annotation-config.md

aot.md

caching.md

context-lifecycle.md

events.md

formatting.md

i18n.md

index.md

jmx.md

resilience.md

scheduling.md

stereotypes.md

validation.md

tile.json