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 featureR- 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
ConstructorsModifierConstructorDescriptionprotectedAbstractRegistry(int defaultPageSize) Creates a registry with the given default page size. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdds or replaces an item by name.protected booleanaddItemIfAbsent(R item) Adds the item if none is registered under the same name; returnsfalseif one already exists.protected intReturns the configured default page size.protected voidNotifies registered listeners that the registry contents have changed.@Nullable RReturns the item by name, ornullif not found.getAll()Returns all registered items.booleanisEmpty()Returns whether the registry is empty.Lists all descriptors with pagination.Lists descriptors with pagination and filter.protected PaginatedResult<R> Lists items with pagination, returning feature instances.voidRegisters a callback invoked when the registry contents change.protected booleanremoveItem(String name) Removes the item with the specified name and notifies change listeners when an item is removed.
-
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
Registers a callback invoked when the registry contents change.- Parameters:
callback- the change listener
-
addItem
Adds or replaces an item by name.- Parameters:
item- the feature to add
-
addItemIfAbsent
Adds the item if none is registered under the same name; returnsfalseif one already exists.- Parameters:
item- the feature to add- Returns:
trueif added,falseif an item with that name already exists
-
removeItem
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:
trueif an item was removed,falseif no item matched the name
-
fireOnChange
protected void fireOnChange()Notifies registered listeners that the registry contents have changed. -
get
Returns the item by name, ornullif not found.- Parameters:
name- the item name- Returns:
- the item, or
null
-
getAll
Returns all registered items.- Returns:
- all items
-
isEmpty
public boolean isEmpty()Returns whether the registry is empty.- Returns:
trueif empty
-
listItems
Lists items with pagination, returning feature instances.- Parameters:
limit- max results (0=default)cursor- pagination cursor, ornull- Returns:
- paginated results
-
list
Lists all descriptors with pagination.- Parameters:
limit- max results (0=default)cursor- pagination cursor, ornull- Returns:
- paginated descriptors
-
list
Lists descriptors with pagination and filter.- Parameters:
limit- max results (0=default)cursor- pagination cursor, ornullfilter- descriptor filter predicate- Returns:
- paginated descriptors
-