Search in sources :

Example 1 with RedisConfig

use of org.wso2.carbon.apimgt.impl.dto.RedisConfig in project carbon-apimgt by wso2.

the class APIHandlerServiceComponent method activate.

@Activate
protected void activate(ComponentContext context) {
    BundleContext bundleContext = context.getBundleContext();
    if (log.isDebugEnabled()) {
        log.debug("API handlers component activated");
    }
    // Set public cert
    ServiceReferenceHolder.getInstance().setPublicCert();
    // Set private key
    ServiceReferenceHolder.getInstance().setPrivateKey();
    clientPool = APIKeyValidatorClientPool.getInstance();
    GatewayStartupListener gatewayStartupListener = new GatewayStartupListener();
    bundleContext.registerService(ServerStartupObserver.class.getName(), gatewayStartupListener, null);
    bundleContext.registerService(ServerShutdownHandler.class, gatewayStartupListener, null);
    bundleContext.registerService(Axis2ConfigurationContextObserver.class, gatewayStartupListener, null);
    bundleContext.registerService(JMSListenerShutDownService.class, gatewayStartupListener, null);
    // Register Tenant service creator to deploy tenant specific common synapse configurations
    TenantServiceCreator listener = new TenantServiceCreator();
    bundleContext.registerService(Axis2ConfigurationContextObserver.class.getName(), listener, null);
    bundleContext.registerService(ServerStartupObserver.class.getName(), new ServerStartupListener(), null);
    // Set APIM Gateway JWT Generator
    registration = context.getBundleContext().registerService(AbstractAPIMgtGatewayJWTGenerator.class.getName(), new APIMgtGatewayJWTGeneratorImpl(), null);
    registration = context.getBundleContext().registerService(AbstractAPIMgtGatewayJWTGenerator.class.getName(), new APIMgtGatewayUrlSafeJWTGeneratorImpl(), null);
    // Start JWT revoked map cleaner.
    RevokedJWTMapCleaner revokedJWTMapCleaner = new RevokedJWTMapCleaner();
    revokedJWTMapCleaner.startJWTRevokedMapCleaner();
    ServiceReferenceHolder.getInstance().setTracer(ServiceReferenceHolder.getInstance().getTracingService().buildTracer(APIMgtGatewayConstants.SERVICE_NAME));
    RedisConfig redisConfig = ServiceReferenceHolder.getInstance().getAPIManagerConfiguration().getRedisConfig();
    if (redisConfig.isRedisEnabled()) {
        RedisBaseDistributedCountManager redisBaseDistributedCountManager = new RedisBaseDistributedCountManager(ServiceReferenceHolder.getInstance().getRedisPool());
        context.getBundleContext().registerService(DistributedCounterManager.class, redisBaseDistributedCountManager, null);
        ServiceReferenceHolder.getInstance().setRedisPool(getJedisPool(redisConfig));
    }
    // Create caches for the super tenant
    ServerConfiguration.getInstance().overrideConfigurationProperty("Cache.ForceLocalCache", "true");
    CacheProvider.createGatewayKeyCache();
    CacheProvider.createResourceCache();
    CacheProvider.createGatewayTokenCache();
    CacheProvider.createInvalidTokenCache();
    CacheProvider.createGatewayBasicAuthResourceCache();
    CacheProvider.createGatewayUsernameCache();
    CacheProvider.createInvalidUsernameCache();
    CacheProvider.createGatewayApiKeyCache();
    CacheProvider.createGatewayApiKeyDataCache();
    CacheProvider.createInvalidGatewayApiKeyCache();
    CacheProvider.createParsedSignJWTCache();
    CacheProvider.createGatewayInternalKeyCache();
    CacheProvider.createGatewayInternalKeyDataCache();
    CacheProvider.createInvalidInternalKeyCache();
}
Also used : ServerStartupObserver(org.wso2.carbon.core.ServerStartupObserver) APIMgtGatewayJWTGeneratorImpl(org.wso2.carbon.apimgt.common.gateway.jwtgenerator.APIMgtGatewayJWTGeneratorImpl) RedisBaseDistributedCountManager(org.wso2.carbon.apimgt.gateway.RedisBaseDistributedCountManager) APIMgtGatewayUrlSafeJWTGeneratorImpl(org.wso2.carbon.apimgt.common.gateway.jwtgenerator.APIMgtGatewayUrlSafeJWTGeneratorImpl) GatewayStartupListener(org.wso2.carbon.apimgt.gateway.listeners.GatewayStartupListener) Axis2ConfigurationContextObserver(org.wso2.carbon.utils.Axis2ConfigurationContextObserver) ServerStartupListener(org.wso2.carbon.apimgt.gateway.listeners.ServerStartupListener) BundleContext(org.osgi.framework.BundleContext) RevokedJWTMapCleaner(org.wso2.carbon.apimgt.gateway.jwt.RevokedJWTMapCleaner) RedisConfig(org.wso2.carbon.apimgt.impl.dto.RedisConfig) Activate(org.osgi.service.component.annotations.Activate)

Aggregations

BundleContext (org.osgi.framework.BundleContext)1 Activate (org.osgi.service.component.annotations.Activate)1 APIMgtGatewayJWTGeneratorImpl (org.wso2.carbon.apimgt.common.gateway.jwtgenerator.APIMgtGatewayJWTGeneratorImpl)1 APIMgtGatewayUrlSafeJWTGeneratorImpl (org.wso2.carbon.apimgt.common.gateway.jwtgenerator.APIMgtGatewayUrlSafeJWTGeneratorImpl)1 RedisBaseDistributedCountManager (org.wso2.carbon.apimgt.gateway.RedisBaseDistributedCountManager)1 RevokedJWTMapCleaner (org.wso2.carbon.apimgt.gateway.jwt.RevokedJWTMapCleaner)1 GatewayStartupListener (org.wso2.carbon.apimgt.gateway.listeners.GatewayStartupListener)1 ServerStartupListener (org.wso2.carbon.apimgt.gateway.listeners.ServerStartupListener)1 RedisConfig (org.wso2.carbon.apimgt.impl.dto.RedisConfig)1 ServerStartupObserver (org.wso2.carbon.core.ServerStartupObserver)1 Axis2ConfigurationContextObserver (org.wso2.carbon.utils.Axis2ConfigurationContextObserver)1