Class AbstractRegistry<D extends ServerFeature.Descriptor,R extends ServerFeature<D>>

java.lang.Object
dev.tachyonmcp.core.server.features.AbstractRegistry<D,R>
Type Parameters:
D - the descriptor type for this feature
R - the feature type registered in this registry
Direct Known Subclasses:
DefaultPromptRegistry, DefaultTaskRegistry, DefaultToolRegistry

@InternalApi public abstract class AbstractRegistry<D extends ServerFeature.Descriptor,R extends ServerFeature<D>> extends Object
Abstract registry for named, paginated MCP features.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractRegistry(int defaultPageSize)
    Creates a registry with the given default page size.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    addItem(R item)
    Adds or replaces an item by name.
    protected boolean
    Adds the item if none is registered under the same name; returns false if one already exists.
    protected int
    Returns the configured default page size.
    protected void
    Notifies registered listeners that the registry contents have changed.
    @Nullable R
    get(String name)
    Returns the item by name, or null if not found.
    Returns all registered items.
    boolean
    Returns whether the registry is empty.
    list(int limit, @Nullable String cursor)
    Lists all descriptors with pagination.
    list(int limit, @Nullable String cursor, Predicate<D> filter)
    Lists descriptors with pagination and filter.
    protected PaginatedResult<R>
    listItems(int limit, @Nullable String cursor)
    Lists items with pagination, returning feature instances.
    void
    onChange(Runnable callback)
    Registers a callback invoked when the registry contents change.
    protected boolean
    Removes the item with the specified name and notifies change listeners when an item is removed.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AbstractRegistry

      protected AbstractRegistry(int defaultPageSize)
      Creates a registry with the given default page size.
      Parameters:
      defaultPageSize - the default page size for paginated queries
  • Method Details

    • defaultPageSize

      protected int defaultPageSize()
      Returns the configured default page size.
      Returns:
      the default page size
    • onChange

      public void onChange(Runnable callback)
      Registers a callback invoked when the registry contents change.
      Parameters:
      callback - the change listener
    • addItem

      protected void addItem(R item)
      Adds or replaces an item by name.
      Parameters:
      item - the feature to add
    • addItemIfAbsent

      protected boolean addItemIfAbsent(R item)
      Adds the item if none is registered under the same name; returns false if one already exists.
      Parameters:
      item - the feature to add
      Returns:
      true if added, false if an item with that name already exists
    • removeItem

      protected boolean removeItem(String name)
      Removes the item with the specified name and notifies change listeners when an item is removed.
      Parameters:
      name - the name of the item to remove
      Returns:
      true if an item was removed, false if no item matched the name
    • fireOnChange

      protected void fireOnChange()
      Notifies registered listeners that the registry contents have changed.
    • get

      public @Nullable R get(String name)
      Returns the item by name, or null if not found.
      Parameters:
      name - the item name
      Returns:
      the item, or null
    • getAll

      public Collection<R> getAll()
      Returns all registered items.
      Returns:
      all items
    • isEmpty

      public boolean isEmpty()
      Returns whether the registry is empty.
      Returns:
      true if empty
    • listItems

      protected PaginatedResult<R> listItems(int limit, @Nullable String cursor)
      Lists items with pagination, returning feature instances.
      Parameters:
      limit - max results (0=default)
      cursor - pagination cursor, or null
      Returns:
      paginated results
    • list

      public PaginatedResult<D> list(int limit, @Nullable String cursor)
      Lists all descriptors with pagination.
      Parameters:
      limit - max results (0=default)
      cursor - pagination cursor, or null
      Returns:
      paginated descriptors
    • list

      public PaginatedResult<D> list(int limit, @Nullable String cursor, Predicate<D> filter)
      Lists descriptors with pagination and filter.
      Parameters:
      limit - max results (0=default)
      cursor - pagination cursor, or null
      filter - descriptor filter predicate
      Returns:
      paginated descriptors