use of org.osgi.service.component.annotations.Activate 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();
}
use of org.osgi.service.component.annotations.Activate in project carbon-apimgt by wso2.
the class CacheInvalidationServiceComponent method activate.
@Activate
protected void activate(ComponentContext context) {
CacheInvalidationConfiguration cacheInvalidationConfiguration;
BundleContext bundleContext = context.getBundleContext();
if (DataHolder.getInstance().getAPIManagerConfigurationService() != null) {
cacheInvalidationConfiguration = DataHolder.getInstance().getAPIManagerConfigurationService().getAPIManagerConfiguration().getCacheInvalidationConfiguration();
if (cacheInvalidationConfiguration.isEnabled()) {
APIMgtCacheInvalidationRequestSender apiMgtCacheInvalidationRequestSender = new APIMgtCacheInvalidationRequestSender(cacheInvalidationConfiguration);
cacheInvalidationRequestSenderServiceRegistration = bundleContext.registerService(CacheInvalidationRequestSender.class, apiMgtCacheInvalidationRequestSender, null);
cacheInvalidationRequestSenderServiceRegistration = bundleContext.registerService(CacheEntryListener.class, apiMgtCacheInvalidationRequestSender, null);
APIMgtServerStartupListener apimgtCacheInvalidationServerStartupListener = new APIMgtServerStartupListener();
cacheInvalidationRequestSenderServiceRegistration = bundleContext.registerService(ServerStartupObserver.class, apimgtCacheInvalidationServerStartupListener, null);
cacheInvalidationRequestSenderServiceRegistration = bundleContext.registerService(ServerShutdownHandler.class, apimgtCacheInvalidationServerStartupListener, null);
cacheInvalidationRequestSenderServiceRegistration = bundleContext.registerService(JMSListenerShutDownService.class, apimgtCacheInvalidationServerStartupListener, null);
}
}
}
use of org.osgi.service.component.annotations.Activate in project carbon-apimgt by wso2.
the class APIMKeyMgtClientComponent method activate.
@Activate
protected void activate(ComponentContext context) {
try {
ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem(getClientRepoLocation(), getAxis2ClientXmlLocation());
ServiceReferenceHolder.getInstance().setAxis2ConfigurationContext(ctx);
} catch (AxisFault axisFault) {
log.error("Failed to initialize APIMKeyMgtClientComponent", axisFault);
}
}
use of org.osgi.service.component.annotations.Activate in project carbon-apimgt by wso2.
the class ThrottlePolicyDeployerComponent method activate.
@Activate
protected void activate(ComponentContext context) {
log.debug("Activating component...");
APIManagerConfiguration configuration = ServiceReferenceHolder.getInstance().getAPIMConfiguration();
if (configuration == null) {
log.warn("API Manager Configuration not properly set.");
return;
}
ThrottleProperties throttleProperties = configuration.getThrottleProperties();
if (throttleProperties.isEnablePolicyDeployment()) {
ThrottlePolicyStartupListener throttlePolicyStartupListener = new ThrottlePolicyStartupListener();
registration = context.getBundleContext().registerService(ServerStartupObserver.class, throttlePolicyStartupListener, null);
registration = context.getBundleContext().registerService(ServerShutdownHandler.class, throttlePolicyStartupListener, null);
registration = context.getBundleContext().registerService(JMSListenerShutDownService.class, throttlePolicyStartupListener, null);
}
}
use of org.osgi.service.component.annotations.Activate in project carbon-apimgt by wso2.
the class ServiceComponent method activate.
@Activate
protected void activate(ComponentContext componentContext) {
componentContext.getBundleContext().registerService(EventPublisherFactory.class.getName(), new EventHubEventPublisherFactory(), null);
log.info("Eventing Hub ServiceComponent is activated");
}
Aggregations