Package io.modelcontextprotocol.util
Class McpServiceLoader<S extends Supplier<R>,R>
java.lang.Object
io.modelcontextprotocol.util.McpServiceLoader<S,R>
- Type Parameters:
S- the type of the supplierR- the type of the supplier result/returned value
Instance of this class are intended to be used differently in OSGi and non-OSGi
environments. In all non-OSGi environments the supplier member will be
null and the serviceLoad method will be called to use the
ServiceLoader.load to find the first instance of the supplier (assuming one is present
in the runtime), cache it, and call the supplier's get method.
In OSGi environments, the Service component runtime (scr) will call the setSupplier method upon bundle activation (assuming one is present in the runtime), and subsequent calls will use the given supplier instance rather than the ServiceLoader.load.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionserviceLoad(Class<S> type) voidsetSupplier(S supplier) voidunsetSupplier(S supplier)
-
Constructor Details
-
McpServiceLoader
-
-
Method Details
-
setSupplier
-
unsetSupplier
-
serviceLoad
-
getDefault
-