Interface PolicyRegistry
- All Known Implementing Classes:
InMemoryPolicyRegistry
Lookup + evaluation SPI for named policies.
Discovered via java.util.ServiceLoader; consuming applications
register a default implementation in
META-INF/services/com.svenruppert.jsentinel.policy.spi.PolicyRegistry.
If no implementation is registered, the JSentinelServiceResolver
supplies an in-memory default.
Implementations should be thread-safe: registration typically happens at startup, evaluation runs on every protected access.
-
Method Summary
Modifier and TypeMethodDescriptionevaluate(String name, PolicyContext context) Evaluates the policy with the given name against the context.Looks up a previously registered policy by name.voidRegisters a policy.
-
Method Details
-
register
Registers a policy. Implementations decide whether duplicate names replace or reject the existing entry — see the implementation's Javadoc.- Parameters:
policy- policy; must not benull
-
find
-
evaluate
Evaluates the policy with the given name against the context.If no policy is registered for
name, implementations returnDenied("unknown policy: <name>")rather than throwing — this matches the fail-closed default of the rest of the framework and lets adapters fall through to a standardForbiddenresponse without special-casing missing policies.- Parameters:
name- policy namecontext- policy context- Returns:
- decision
-