Class MicroserviceSubscriptionsServiceImpl
java.lang.Object
com.cumulocity.microservice.subscription.service.impl.MicroserviceSubscriptionsServiceImpl
- All Implemented Interfaces:
MicroserviceSubscriptionsService
@Service
public class MicroserviceSubscriptionsServiceImpl
extends Object
implements MicroserviceSubscriptionsService
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
-
Constructor Summary
ConstructorDescriptionMicroserviceSubscriptionsServiceImpl
(PlatformProperties properties, org.springframework.context.ApplicationEventPublisher eventPublisher, MicroserviceSubscriptionsRepository repository, MicroserviceMetadataRepresentation microserviceMetadataRepresentation, ContextService<MicroserviceCredentials> contextService) -
Method Summary
Modifier and TypeMethodDescription<T> T
callForTenant
(String tenant, Callable<T> runnable) Invokes runnable in context of subscribed tenant.getAll()
Gets current microservice subscriptions' credentialsgetCredentials
(String tenant) Gets microservice credentials of the given tenantReturns current tenant.boolean
void
<T> void
listen
(Class<T> clazz, MicroserviceSubscriptionsServiceImpl.MicroserviceChangedListener<T> listener) void
runForEachTenant
(Runnable runnable) Invokes runnable in context of all subscribed tenants.void
runForTenant
(String tenant, Runnable runnable) Invokes runnable in context of subscribed tenant.void
Fetches microservice subscriptions and emits MicroserviceSubscriptionRemovedEvent, MicroserviceSubscriptionAddedEvent to the MicroserviceChangedListener listeners
-
Constructor Details
-
MicroserviceSubscriptionsServiceImpl
@Autowired public MicroserviceSubscriptionsServiceImpl(PlatformProperties properties, org.springframework.context.ApplicationEventPublisher eventPublisher, MicroserviceSubscriptionsRepository repository, MicroserviceMetadataRepresentation microserviceMetadataRepresentation, ContextService<MicroserviceCredentials> contextService)
-
-
Method Details
-
listen
-
listen
public <T> void listen(Class<T> clazz, MicroserviceSubscriptionsServiceImpl.MicroserviceChangedListener<T> listener) -
subscribe
public void subscribe()Description copied from interface:MicroserviceSubscriptionsService
Fetches microservice subscriptions and emits MicroserviceSubscriptionRemovedEvent, MicroserviceSubscriptionAddedEvent to the MicroserviceChangedListener listenersIf a listener throws exception during event execution, the event is created again in the next call to the method.
- Specified by:
subscribe
in interfaceMicroserviceSubscriptionsService
-
getAll
Description copied from interface:MicroserviceSubscriptionsService
Gets current microservice subscriptions' credentials- Specified by:
getAll
in interfaceMicroserviceSubscriptionsService
- Returns:
- collection of microservice credentials
-
getCredentials
Description copied from interface:MicroserviceSubscriptionsService
Gets microservice credentials of the given tenant- Specified by:
getCredentials
in interfaceMicroserviceSubscriptionsService
- Parameters:
tenant
- tenant id- Returns:
Optional.of
microservice credentials if tenant is found in current subscriptions;Optional.<MicroserviceCredentials>empty()
otherwise
-
getTenant
Description copied from interface:MicroserviceSubscriptionsService
Returns current tenant.- Specified by:
getTenant
in interfaceMicroserviceSubscriptionsService
- Returns:
- current tenant id
-
runForEachTenant
Description copied from interface:MicroserviceSubscriptionsService
Invokes runnable in context of all subscribed tenants.- Specified by:
runForEachTenant
in interfaceMicroserviceSubscriptionsService
- Parameters:
runnable
- runnable to execute
-
runForTenant
Description copied from interface:MicroserviceSubscriptionsService
Invokes runnable in context of subscribed tenant.- Specified by:
runForTenant
in interfaceMicroserviceSubscriptionsService
- Parameters:
tenant
- tenant idrunnable
- runnable to execute
-
callForTenant
Description copied from interface:MicroserviceSubscriptionsService
Invokes runnable in context of subscribed tenant.- Specified by:
callForTenant
in interfaceMicroserviceSubscriptionsService
- Type Parameters:
T
- generic type of expected result object- Parameters:
tenant
- tenant idrunnable
- callable to execute- Returns:
- result object
-
isRegisteredSuccessfully
public boolean isRegisteredSuccessfully()- Specified by:
isRegisteredSuccessfully
in interfaceMicroserviceSubscriptionsService
-