Class LocalPool
- java.lang.Object
-
- org.streamingpool.core.service.impl.LocalPool
-
- All Implemented Interfaces:
DiscoveryService,ProvidingService,StreamFactoryRegistry
public class LocalPool extends java.lang.Object implements DiscoveryService, ProvidingService, StreamFactoryRegistry
Local pool for providing and discovery ofPublishers. (this class is both aDiscoveryServiceand aProvidingService). The most important feature of theLocalPoolis that it supports the lazy creation of the streams, specifically, they are created when discovered usingStreamFactorys. When aStreamIdis discovered, the discovery is delegated to a new instance ofTrackKeepingDiscoveryService. TheTrackKeepingDiscoveryServicethen tries to create the stream using the providedTypedStreamFactorys if no matchingStreamIdhas already been provided.
-
-
Constructor Summary
Constructors Constructor Description LocalPool(java.util.List<StreamFactory> factories, PoolConfiguration poolConfiguration, PoolContent content)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFallback(StreamFactory fallbackFactory)Add a given factory as a falback.voidaddIntercept(StreamFactory interceptFactory)Add a given factory as an interceptor.Intercept means that the factory will have a possibility to create publisher before standard injected factories.<T> org.reactivestreams.Publisher<T>discover(StreamId<T> id)Given aStreamId, this method returns the correspondentPublisher.<T> voidprovide(StreamId<T> id, org.reactivestreams.Publisher<T> obs)Provides the stream with the specified id.
-
-
-
Constructor Detail
-
LocalPool
public LocalPool(java.util.List<StreamFactory> factories, PoolConfiguration poolConfiguration, PoolContent content)
-
-
Method Detail
-
provide
public <T> void provide(StreamId<T> id, org.reactivestreams.Publisher<T> obs)
Description copied from interface:ProvidingServiceProvides the stream with the specified id. From the moment the stream is provided, it can be accessed fromDiscoveryServiceusing the sameStreamId.- Specified by:
providein interfaceProvidingService- Parameters:
id- theStreamIdthat identifies the specified streamobs- thePublisherto be provided
-
discover
public <T> org.reactivestreams.Publisher<T> discover(StreamId<T> id)
Description copied from interface:DiscoveryServiceGiven aStreamId, this method returns the correspondentPublisher. This method should not return null, instead is preferred to throw a specific exception in the case the given id is not present in the system. From the API level, this behavior is not forced.- Specified by:
discoverin interfaceDiscoveryService- Parameters:
id- the identifier of the stream to be discovered- Returns:
- the discovered
Publisher
-
addIntercept
public void addIntercept(StreamFactory interceptFactory)
Description copied from interface:StreamFactoryRegistryAdd a given factory as an interceptor.Intercept means that the factory will have a possibility to create publisher before standard injected factories.- Specified by:
addInterceptin interfaceStreamFactoryRegistry
-
addFallback
public void addFallback(StreamFactory fallbackFactory)
Description copied from interface:StreamFactoryRegistryAdd a given factory as a falback. Fallback means that the factory will act after all others stream factories.- Specified by:
addFallbackin interfaceStreamFactoryRegistry
-
-