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