Class FilterChainFactory

java.lang.Object
io.kroxylicious.proxy.bootstrap.FilterChainFactory
All Implemented Interfaces:
AutoCloseable

public class FilterChainFactory extends Object implements AutoCloseable
Builds per-connection filter instances for a single virtual cluster's filter chain.

Scope

A FilterChainFactory is scoped to one VirtualClusterModel. Its lifetime is bound to that VCM — constructed when the VCM is built, closed when the VCM is closed (driven by VirtualClusterRegistry when the lifecycle reaches Stopped).

What it holds

  • An ordered list of NamedFilterDefinitions — the VC's filter chain, as resolved from VirtualCluster.filters() (or defaultFilters when the cluster opts in to the proxy-wide default chain).
  • A per-name map of initialized FilterChainFactory.Wrappers. Each Wrapper owns the expensive initResult (KMS clients, caches, rule files, etc.) produced by FilterFactory.initialize. Wrappers are deduped by name — a chain that references audit twice (e.g. before-and-after positions) initializes the audit factory once and reuses the initResult across both positions.

What it does

createFilters(FilterFactoryContext) returns a fresh list of Filter instances for one downstream channel. The chain order is the order this factory was constructed with; instances are fresh per-call, but the underlying initResult is shared across all calls to this factory (i.e. across all connections to the same VC).
  • Constructor Details

  • Method Details

    • empty

      public static FilterChainFactory empty()
      Returns a FilterChainFactory with an empty filter chain, for callers that have no filters to apply and therefore no PluginFactoryRegistry to supply (for example virtual clusters that opt out of the default chain, and tests that do not exercise the chain).
      Returns:
      an empty FilterChainFactory
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
    • createFilters

      public List<FilterAndInvoker> createFilters(io.kroxylicious.proxy.filter.FilterFactoryContext context)
      Creates a fresh list of Filter instances for the chain this factory was built with. Returned instances are per-call — every connection gets its own filter instances — but the underlying initResult is shared across all connections through the FilterChainFactory.Wrappers held by this factory.
      Parameters:
      context - the filter factory context (typically per-connection)
      Returns:
      the new chain, in the order the factory was constructed with; empty if this factory was constructed with a null or empty chain