Search in sources :

Example 1 with EventPublisherFactory

use of org.wso2.carbon.apimgt.eventing.EventPublisherFactory in project carbon-apimgt by wso2.

the class APIUtil method init.

/**
 * To initialize the publisherRoleCache configurations, based on configurations.
 */
public static void init() throws APIManagementException {
    APIManagerConfiguration apiManagerConfiguration = ServiceReferenceHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration();
    String isPublisherRoleCacheEnabledConfiguration = apiManagerConfiguration.getFirstProperty(APIConstants.PUBLISHER_ROLE_CACHE_ENABLED);
    isPublisherRoleCacheEnabled = isPublisherRoleCacheEnabledConfiguration == null || Boolean.parseBoolean(isPublisherRoleCacheEnabledConfiguration);
    try {
        eventPublisherFactory = ServiceReferenceHolder.getInstance().getEventPublisherFactory();
        eventPublishers.putIfAbsent(EventPublisherType.ASYNC_WEBHOOKS, eventPublisherFactory.getEventPublisher(EventPublisherType.ASYNC_WEBHOOKS));
        eventPublishers.putIfAbsent(EventPublisherType.CACHE_INVALIDATION, eventPublisherFactory.getEventPublisher(EventPublisherType.CACHE_INVALIDATION));
        eventPublishers.putIfAbsent(EventPublisherType.GLOBAL_CACHE_INVALIDATION, eventPublisherFactory.getEventPublisher(EventPublisherType.GLOBAL_CACHE_INVALIDATION));
        eventPublishers.putIfAbsent(EventPublisherType.NOTIFICATION, eventPublisherFactory.getEventPublisher(EventPublisherType.NOTIFICATION));
        eventPublishers.putIfAbsent(EventPublisherType.TOKEN_REVOCATION, eventPublisherFactory.getEventPublisher(EventPublisherType.TOKEN_REVOCATION));
        eventPublishers.putIfAbsent(EventPublisherType.BLOCKING_EVENT, eventPublisherFactory.getEventPublisher(EventPublisherType.BLOCKING_EVENT));
        eventPublishers.putIfAbsent(EventPublisherType.KEY_TEMPLATE, eventPublisherFactory.getEventPublisher(EventPublisherType.KEY_TEMPLATE));
        eventPublishers.putIfAbsent(EventPublisherType.KEYMGT_EVENT, eventPublisherFactory.getEventPublisher(EventPublisherType.KEYMGT_EVENT));
    } catch (EventPublisherException e) {
        log.error("Could not initialize the event publishers. Events might not be published properly.");
        throw new APIManagementException(e);
    }
}
Also used : APIManagerConfiguration(org.wso2.carbon.apimgt.impl.APIManagerConfiguration) APIManagementException(org.wso2.carbon.apimgt.api.APIManagementException) EventPublisherException(org.wso2.carbon.apimgt.eventing.EventPublisherException)

Aggregations

APIManagementException (org.wso2.carbon.apimgt.api.APIManagementException)1 EventPublisherException (org.wso2.carbon.apimgt.eventing.EventPublisherException)1 APIManagerConfiguration (org.wso2.carbon.apimgt.impl.APIManagerConfiguration)1