boxlang-interceptors

Create interceptors for named events in BoxLang applications.

16|78|Updated Nov 28, 2014
One-click install
npx skills add https://github.com/ortus-docs/coldbox-docs --skill boxlang-interceptors
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: boxlang-interceptors
Source: https://github.com/ortus-docs/coldbox-docs/tree/main/.agents/skills/boxlang-interceptors
Command: npx skills add https://github.com/ortus-docs/coldbox-docs --skill boxlang-interceptors

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

BoxLang interceptors provide a clean way to implement cross-cutting logic (such as logging, security checks, validation, and caching) without coupling to business code.

Core Features & Use Cases

  • Create interceptors to react to named events and implement pre/post operation hooks.
  • Register interceptors at application level or per module via ModuleConfig.bx or BoxRegisterInterceptor().
  • Announce events synchronously with announce() and asynchronously with announceAsync() to decouple concerns.
  • Use Module Registration to apply interceptors across modules and maintain a hierarchical flow.

Quick Start

Create an interceptor class with event handlers and register it in ModuleConfig.bx or at runtime with BoxRegisterInterceptor().

Frequently Asked Questions about boxlang-interceptors

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement cross-cutting concerns in BoxLang without coupling to business code?

BoxLang interceptors implement cross-cutting concerns by reacting to named events, allowing you to handle logging, security checks, and validation cleanly. You decouple this logic by creating interceptor classes with event handlers.

How do I register an interceptor in BoxLang?

You register interceptors in BoxLang at the application level or per module via ModuleConfig.bx, or dynamically at runtime using the BoxRegisterInterceptor() function to ensure they respond to announced events.

What is the difference between announce() and announceAsync() in BoxLang event systems?

The announce() function dispatches named events synchronously, while announceAsync() dispatches them asynchronously. Both decouple concerns, but asynchronous processing allows non-blocking execution of interceptors.

Can I use interceptors for security guards and pre-operation hooks in BoxLang?

Yes, BoxLang interceptors support pre-operation and post-operation hooks across modules. You can build security guards that respond to named events to validate access before executing business logic.

Does BoxLang support hierarchical event interception across multiple modules?

Yes, BoxLang supports module registration to apply interceptors across modules and maintain a hierarchical flow. This allows events announced in one module to be intercepted by registered cross-cutting concerns.