Search in sources :

Example 76 with Activate

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();
}
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)

Example 77 with Activate

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);
        }
    }
}
Also used : ServerStartupObserver(org.wso2.carbon.core.ServerStartupObserver) CacheEntryListener(javax.cache.event.CacheEntryListener) JMSListenerShutDownService(org.wso2.carbon.apimgt.impl.jms.listener.JMSListenerShutDownService) CacheInvalidationConfiguration(org.wso2.carbon.apimgt.impl.CacheInvalidationConfiguration) ServerShutdownHandler(org.wso2.carbon.core.ServerShutdownHandler) APIMgtCacheInvalidationRequestSender(org.wso2.carbon.apimgt.cache.invalidation.APIMgtCacheInvalidationRequestSender) APIMgtCacheInvalidationRequestSender(org.wso2.carbon.apimgt.cache.invalidation.APIMgtCacheInvalidationRequestSender) CacheInvalidationRequestSender(javax.cache.CacheInvalidationRequestSender) APIMgtServerStartupListener(org.wso2.carbon.apimgt.cache.invalidation.APIMgtServerStartupListener) BundleContext(org.osgi.framework.BundleContext) Activate(org.osgi.service.component.annotations.Activate)

Example 78 with Activate

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);
    }
}
Also used : AxisFault(org.apache.axis2.AxisFault) ConfigurationContext(org.apache.axis2.context.ConfigurationContext) Activate(org.osgi.service.component.annotations.Activate)

Example 79 with Activate

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);
    }
}
Also used : ServerStartupObserver(org.wso2.carbon.core.ServerStartupObserver) APIManagerConfiguration(org.wso2.carbon.apimgt.impl.APIManagerConfiguration) JMSListenerShutDownService(org.wso2.carbon.apimgt.impl.jms.listener.JMSListenerShutDownService) ThrottlePolicyStartupListener(org.wso2.carbon.apimgt.throttle.policy.deployer.utils.ThrottlePolicyStartupListener) ServerShutdownHandler(org.wso2.carbon.core.ServerShutdownHandler) ThrottleProperties(org.wso2.carbon.apimgt.impl.dto.ThrottleProperties) Activate(org.osgi.service.component.annotations.Activate)

Example 80 with Activate

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");
}
Also used : EventHubEventPublisherFactory(org.wso2.carbon.apimgt.eventing.hub.EventHubEventPublisherFactory) EventPublisherFactory(org.wso2.carbon.apimgt.eventing.EventPublisherFactory) EventHubEventPublisherFactory(org.wso2.carbon.apimgt.eventing.hub.EventHubEventPublisherFactory) Activate(org.osgi.service.component.annotations.Activate)

Aggregations

Activate (org.osgi.service.component.annotations.Activate)100 BundleContext (org.osgi.framework.BundleContext)13 File (java.io.File)8 OsgiWhiteboard (org.apache.jackrabbit.oak.osgi.OsgiWhiteboard)7 IOException (java.io.IOException)6 Hashtable (java.util.Hashtable)6 ResourceResolver (org.apache.sling.api.resource.ResourceResolver)5 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)4 ArrayList (java.util.ArrayList)4 Properties (java.util.Properties)3 ServiceReference (org.osgi.framework.ServiceReference)3 PromiseFactory (org.osgi.util.promise.PromiseFactory)3 ServerStartupObserver (org.wso2.carbon.core.ServerStartupObserver)3 JsonObject (com.google.gson.JsonObject)2 Date (java.util.Date)2 Dictionary (java.util.Dictionary)2 ObjectName (javax.management.ObjectName)2 Whiteboard (org.apache.jackrabbit.oak.spi.whiteboard.Whiteboard)2 WhiteboardExecutor (org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardExecutor)2 LoginException (org.apache.sling.api.resource.LoginException)2