Package cloud.opencode.base.lock.event
package cloud.opencode.base.lock.event
Lock Event Package - Lock Lifecycle Event Notification (JDK 25)
锁事件包 - 锁生命周期事件通知 (JDK 25)
This package provides an event-driven observation mechanism for lock lifecycle transitions. It enables monitoring, auditing, and metrics collection without modifying existing lock implementations.
此包提供锁生命周期转换的事件驱动观察机制。它支持在不修改现有锁实现的 情况下进行监控、审计和指标收集。
Core Types | 核心类型
LockEvent- Immutable event recordLockListener- Event listener interfaceObservableLock- Lock decorator with events
Quick Start | 快速开始
// Wrap any lock with event observation | 用事件观察包装任意锁
Lock<Long> baseLock = new LocalLock();
ObservableLock<Long> lock = new ObservableLock<>(baseLock, "order-lock");
// Register listeners | 注册监听器
lock.addListener(event ->
System.out.println(event.type() + ": " + event.lockName()));
// Use normally - events fire automatically | 正常使用 - 事件自动触发
try (var guard = lock.lock()) {
// Critical section
}
- Since:
- JDK 25, opencode-base-lock V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
ClassDescriptionLock Lifecycle Event Record 锁生命周期事件记录Lock Event Type Enumeration 锁事件类型枚举Lock Event Listener Interface 锁事件监听器接口Observable Lock Decorator with Event Notification 带事件通知的可观察锁装饰器