Interface ResourceResolver<T>

Type Parameters:
T - the domain type for this resolver

@ExperimentalJSentinelApi public interface ResourceResolver<T>
Application-provided adapter that materialises a ResourceRef into a domain object and exposes the attributes a policy might want to reason about (owner id, status, …).

Each resolver covers a single resource type. The application registers all its resolvers with a ResourceResolverRegistry at startup — typically inside a VaadinServiceInitListener or equivalent bootstrap hook — after which ResourcePredicates can consult the registry from inside a policy evaluation.

  • Method Summary

    Modifier and Type
    Method
    Description
    attributes(T resource)
    Extracts the predicate-relevant attributes of a resolved resource (e.g.
    Loads the domain object for the given resource id, or returns empty if no such resource exists.
    Stable, non-blank resource type identifier (e.g.
  • Method Details

    • resourceType

      String resourceType()
      Stable, non-blank resource type identifier (e.g. "document"). Must match the ResourceRef.resourceType() of every reference this resolver should handle.
      Returns:
      resource type
    • resolve

      Optional<T> resolve(String id)
      Loads the domain object for the given resource id, or returns empty if no such resource exists. Resolvers should not throw for unknown ids — return Optional.empty() so policies can deny gracefully.
      Parameters:
      id - resource id; never null or blank
      Returns:
      domain object, or empty
    • attributes

      Map<String,Object> attributes(T resource)
      Extracts the predicate-relevant attributes of a resolved resource (e.g. ownerId, status). The returned map is read-only — callers must not mutate it. Implementations should include only fields that are safe to expose to policy code.
      Parameters:
      resource - non-null resolved domain object
      Returns:
      read-only attribute map