Search in sources :

Example 1 with CacheInvalidationConfiguration

use of org.wso2.carbon.apimgt.impl.CacheInvalidationConfiguration 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 2 with CacheInvalidationConfiguration

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

the class APIManagerConfiguration method setGlobalCacheInvalidationConfiguration.

private void setGlobalCacheInvalidationConfiguration(OMElement element) {
    CacheInvalidationConfiguration cacheInvalidationConfiguration = new CacheInvalidationConfiguration();
    OMElement enabledElement = element.getFirstChildWithName(new QName(APIConstants.GlobalCacheInvalidation.ENABLED));
    if (enabledElement != null) {
        cacheInvalidationConfiguration.setEnabled(Boolean.parseBoolean(enabledElement.getText()));
    }
    OMElement domainElement = element.getFirstChildWithName(new QName(APIConstants.GlobalCacheInvalidation.Domain));
    if (domainElement != null) {
        cacheInvalidationConfiguration.setDomain(domainElement.getText());
    }
    OMElement streamNameElement = element.getFirstChildWithName(new QName(APIConstants.GlobalCacheInvalidation.Stream));
    if (streamNameElement != null) {
        cacheInvalidationConfiguration.setStream(streamNameElement.getText());
    }
    OMElement usernameElement = element.getFirstChildWithName(new QName(APIConstants.GlobalCacheInvalidation.USERNAME));
    if (usernameElement != null) {
        cacheInvalidationConfiguration.setUsername(APIUtil.replaceSystemProperty(usernameElement.getText()));
    }
    String password;
    OMElement passwordElement = element.getFirstChildWithName(new QName(APIConstants.GlobalCacheInvalidation.PASSWORD));
    if (passwordElement != null) {
        password = MiscellaneousUtil.resolve(passwordElement, secretResolver);
        cacheInvalidationConfiguration.setPassword(APIUtil.replaceSystemProperty(password));
    }
    OMElement receiverUrlGroupElement = element.getFirstChildWithName(new QName(APIConstants.GlobalCacheInvalidation.REVEIVER_URL_GROUP));
    if (receiverUrlGroupElement != null) {
        cacheInvalidationConfiguration.setReceiverUrlGroup(APIUtil.replaceSystemProperty(receiverUrlGroupElement.getText()));
    }
    OMElement authUrlGroupElement = element.getFirstChildWithName(new QName(APIConstants.GlobalCacheInvalidation.AUTH_URL_GROUP));
    if (authUrlGroupElement != null) {
        cacheInvalidationConfiguration.setAuthUrlGroup(APIUtil.replaceSystemProperty(authUrlGroupElement.getText()));
    }
    OMElement receiverConnectionDetailsElement = element.getFirstChildWithName(new QName(APIConstants.GlobalCacheInvalidation.ReceiverConnectionDetails));
    if (receiverConnectionDetailsElement != null) {
        Iterator receiverConnectionDetailsElements = receiverConnectionDetailsElement.getChildElements();
        Properties properties = new Properties();
        while (receiverConnectionDetailsElements.hasNext()) {
            OMElement omElement = (OMElement) receiverConnectionDetailsElements.next();
            String value = MiscellaneousUtil.resolve(omElement, secretResolver);
            properties.put(omElement.getLocalName(), APIUtil.replaceSystemProperty(value));
        }
        cacheInvalidationConfiguration.setJmsConnectionParameters(properties);
    }
    OMElement topicNameElement = element.getFirstChildWithName(new QName(APIConstants.GlobalCacheInvalidation.TOPIC_NAME));
    if (topicNameElement != null) {
        cacheInvalidationConfiguration.setCacheInValidationTopic(topicNameElement.getText());
    }
    OMElement excludedCachesElement = element.getFirstChildWithName(new QName(APIConstants.GlobalCacheInvalidation.EXCLUDED_CACHES));
    if (excludedCachesElement != null) {
        Iterator excludedCaches = excludedCachesElement.getChildElements();
        while (excludedCaches.hasNext()) {
            cacheInvalidationConfiguration.addExcludedCaches(((OMElement) excludedCaches.next()).getText());
        }
    }
    this.cacheInvalidationConfiguration = cacheInvalidationConfiguration;
}
Also used : QName(javax.xml.namespace.QName) Iterator(java.util.Iterator) OMElement(org.apache.axiom.om.OMElement) GatewayArtifactSynchronizerProperties(org.wso2.carbon.apimgt.impl.dto.GatewayArtifactSynchronizerProperties) WorkflowProperties(org.wso2.carbon.apimgt.impl.dto.WorkflowProperties) Properties(java.util.Properties) ThrottleProperties(org.wso2.carbon.apimgt.impl.dto.ThrottleProperties)

Aggregations

Iterator (java.util.Iterator)1 Properties (java.util.Properties)1 CacheInvalidationRequestSender (javax.cache.CacheInvalidationRequestSender)1 CacheEntryListener (javax.cache.event.CacheEntryListener)1 QName (javax.xml.namespace.QName)1 OMElement (org.apache.axiom.om.OMElement)1 BundleContext (org.osgi.framework.BundleContext)1 Activate (org.osgi.service.component.annotations.Activate)1 APIMgtCacheInvalidationRequestSender (org.wso2.carbon.apimgt.cache.invalidation.APIMgtCacheInvalidationRequestSender)1 APIMgtServerStartupListener (org.wso2.carbon.apimgt.cache.invalidation.APIMgtServerStartupListener)1 CacheInvalidationConfiguration (org.wso2.carbon.apimgt.impl.CacheInvalidationConfiguration)1 GatewayArtifactSynchronizerProperties (org.wso2.carbon.apimgt.impl.dto.GatewayArtifactSynchronizerProperties)1 ThrottleProperties (org.wso2.carbon.apimgt.impl.dto.ThrottleProperties)1 WorkflowProperties (org.wso2.carbon.apimgt.impl.dto.WorkflowProperties)1 JMSListenerShutDownService (org.wso2.carbon.apimgt.impl.jms.listener.JMSListenerShutDownService)1 ServerShutdownHandler (org.wso2.carbon.core.ServerShutdownHandler)1 ServerStartupObserver (org.wso2.carbon.core.ServerStartupObserver)1