From 697def4b7ec82544999513c27c13cbea2c19f0fb Mon Sep 17 00:00:00 2001 From: daneshk Date: Sun, 26 Apr 2015 22:10:12 +0530 Subject: [PATCH 1/4] Fixed the issue REGISTRY-2501 --- .../service/ContentBasedSearchService.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/components/registry/org.wso2.carbon.registry.indexing/src/main/java/org/wso2/carbon/registry/indexing/service/ContentBasedSearchService.java b/components/registry/org.wso2.carbon.registry.indexing/src/main/java/org/wso2/carbon/registry/indexing/service/ContentBasedSearchService.java index a98ff8f3b..5844ff1e1 100755 --- a/components/registry/org.wso2.carbon.registry.indexing/src/main/java/org/wso2/carbon/registry/indexing/service/ContentBasedSearchService.java +++ b/components/registry/org.wso2.carbon.registry.indexing/src/main/java/org/wso2/carbon/registry/indexing/service/ContentBasedSearchService.java @@ -27,6 +27,7 @@ import org.wso2.carbon.registry.common.ResourceData; import org.wso2.carbon.registry.common.services.RegistryAbstractAdmin; import org.wso2.carbon.registry.common.utils.CommonUtil; +import org.wso2.carbon.registry.common.utils.UserUtil; import org.wso2.carbon.registry.core.ActionConstants; import org.wso2.carbon.registry.core.Collection; import org.wso2.carbon.registry.core.RegistryConstants; @@ -322,6 +323,21 @@ private ResourceData loadResourceByPath(UserRegistry registry, String path) thro resourceData.setCreatedOn(createdDateTime); CommonUtil.populateAverageStars(resourceData); + String user = child.getProperty("registry.user"); + + if (registry.getUserName().equals(user)) { + resourceData.setPutAllowed(true); + resourceData.setDeleteAllowed(true); + resourceData.setGetAllowed(true); + } else { + resourceData.setPutAllowed( + UserUtil.isPutAllowed(registry.getUserName(), path, registry)); + resourceData.setDeleteAllowed( + UserUtil.isDeleteAllowed(registry.getUserName(), path, registry)); + resourceData.setGetAllowed( + UserUtil.isGetAllowed(registry.getUserName(), path, registry)); + } + child.discard(); return resourceData; From 9e3a71d9a2093fa805d2e5035fd41517d3526945 Mon Sep 17 00:00:00 2001 From: daneshk Date: Wed, 29 Apr 2015 18:12:58 +0530 Subject: [PATCH 2/4] move global cache invalidation to carbon-registry --- .../pom.xml | 76 ++++++ .../connection/BaseConnection.java | 14 ++ .../CacheInvalidationException.java | 11 + .../InvalidationConnectionFactory.java | 38 +++ .../invalidator/connection/JMSConnection.java | 159 +++++++++++++ .../impl/CacheInvalidationPublisher.java | 123 ++++++++++ .../impl/CacheInvalidationSubscriber.java | 160 +++++++++++++ .../impl/ConfigurationManager.java | 177 ++++++++++++++ .../impl/GlobalCacheInvalidationEvent.java | 69 ++++++ .../internal/CacheInvalidationDataHolder.java | 44 ++++ .../CacheInvalidationServiceComponent.java | 78 +++++++ .../src/main/resources/cache.properties | 21 ++ components/registry/pom.xml | 1 + .../caching-invalidator/feature.properties | 217 ++++++++++++++++++ .../pom.xml | 74 ++++++ .../pom.xml | 100 ++++++++ .../src/main/resources/conf/cache.properties | 22 ++ features/caching-invalidator/pom.xml | 39 ++++ pom.xml | 20 +- 19 files changed, 1442 insertions(+), 1 deletion(-) create mode 100644 components/registry/org.wso2.carbon.registry.caching.invalidator/pom.xml create mode 100644 components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/BaseConnection.java create mode 100644 components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/CacheInvalidationException.java create mode 100644 components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/InvalidationConnectionFactory.java create mode 100644 components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/JMSConnection.java create mode 100644 components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/CacheInvalidationPublisher.java create mode 100644 components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/CacheInvalidationSubscriber.java create mode 100644 components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/ConfigurationManager.java create mode 100644 components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/GlobalCacheInvalidationEvent.java create mode 100644 components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/internal/CacheInvalidationDataHolder.java create mode 100644 components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/internal/CacheInvalidationServiceComponent.java create mode 100644 components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/resources/cache.properties create mode 100644 features/caching-invalidator/feature.properties create mode 100644 features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.feature/pom.xml create mode 100644 features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.server.feature/pom.xml create mode 100644 features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.server.feature/src/main/resources/conf/cache.properties create mode 100644 features/caching-invalidator/pom.xml diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/pom.xml b/components/registry/org.wso2.carbon.registry.caching.invalidator/pom.xml new file mode 100644 index 000000000..2ce7ed1c5 --- /dev/null +++ b/components/registry/org.wso2.carbon.registry.caching.invalidator/pom.xml @@ -0,0 +1,76 @@ + + + + + org.wso2.carbon.registry + registry + 4.3.3-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.registry.caching.invalidator + bundle + WSO2 Carbon - Caching Invalidator + OSGi Bundle for the Cache invalidation for Carbon + http://wso2.org + + + + org.wso2.carbon + org.wso2.carbon.core + + + org.wso2.carbon + org.wso2.carbon.utils + + + org.wso2.carbon + javax.cache.wso2 + + + org.wso2.carbon + org.wso2.carbon.logging + + + org.apache.geronimo.specs.wso2 + geronimo-jms_1.1_spec + + + + + + + org.apache.felix + maven-scr-plugin + + + org.apache.felix + maven-bundle-plugin + + true + + + WSO2 Inc + org.wso2.carbon.registry.caching.invalidator + + org.wso2.carbon.registry.caching.invalidator.connection.*, + org.wso2.carbon.registry.caching.invalidator.impl.*, + !org.wso2.carbon.registry.caching.invalidator.internal.* + + + org.wso2.carbon.registry.caching.invalidator.internal + + + !org.wso2.carbon.registry.caching.invalidator.connection.*, + !org.wso2.carbon.registry.caching.invalidator.impl.*, + javax.jms.* + + * + + + + + + + diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/BaseConnection.java b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/BaseConnection.java new file mode 100644 index 000000000..e5ad7e9c1 --- /dev/null +++ b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/BaseConnection.java @@ -0,0 +1,14 @@ +package org.wso2.carbon.registry.caching.invalidator.connection; + +import java.util.Properties; + +public interface BaseConnection { + + public void createConnection(Properties config); + + public void closeConnection(); + + public void publish(Object message); + + public void subscribe(); +} diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/CacheInvalidationException.java b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/CacheInvalidationException.java new file mode 100644 index 000000000..b7f56d957 --- /dev/null +++ b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/CacheInvalidationException.java @@ -0,0 +1,11 @@ +package org.wso2.carbon.registry.caching.invalidator.connection; + +public class CacheInvalidationException extends Exception { + public CacheInvalidationException(String message, Throwable cause) { + super(message,cause); + } + + public CacheInvalidationException(String message) { + super(message); + } +} diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/InvalidationConnectionFactory.java b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/InvalidationConnectionFactory.java new file mode 100644 index 000000000..9591096eb --- /dev/null +++ b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/InvalidationConnectionFactory.java @@ -0,0 +1,38 @@ +package org.wso2.carbon.registry.caching.invalidator.connection; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.registry.caching.invalidator.impl.ConfigurationManager; +import org.wso2.carbon.registry.caching.invalidator.internal.CacheInvalidationDataHolder; + +import java.util.Properties; + +public class InvalidationConnectionFactory { + private static final Log log = LogFactory.getLog(InvalidationConnectionFactory.class); + + public static void createMessageBrokerConnection() throws CacheInvalidationException { + Properties properties = ConfigurationManager.getCacheConfiguration(); + if (properties.containsKey("class.CacheInvalidationClass")) { + BaseConnection connection = (BaseConnection) getObject(properties.getProperty("class.CacheInvalidationClass")); + if (connection != null) { + connection.createConnection(properties); + CacheInvalidationDataHolder.setConnection(connection); + } else { + log.warn("Error while initializing message, Global cache invalidation will not work"); + } + } + } + + private static Object getObject(String className) throws CacheInvalidationException { + try { + Class factoryClass = Class.forName(className); + return factoryClass.newInstance(); + } catch (ClassNotFoundException e) { + throw new CacheInvalidationException("Class " + className + " not found ", e); + } catch (IllegalAccessException e) { + throw new CacheInvalidationException("Class not be accessed ", e); + } catch (InstantiationException e) { + throw new CacheInvalidationException("Class not be instantiated ", e); + } + } +} diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/JMSConnection.java b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/JMSConnection.java new file mode 100644 index 000000000..357f8be04 --- /dev/null +++ b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/JMSConnection.java @@ -0,0 +1,159 @@ +package org.wso2.carbon.registry.caching.invalidator.connection; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.registry.caching.invalidator.impl.ConfigurationManager; +import org.wso2.carbon.registry.caching.invalidator.impl.GlobalCacheInvalidationEvent; +import org.wso2.carbon.registry.caching.invalidator.internal.CacheInvalidationDataHolder; +import org.wso2.carbon.context.PrivilegedCarbonContext; + +import javax.cache.CacheManager; +import javax.cache.Caching; +import javax.jms.BytesMessage; +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.Message; +import javax.jms.MessageConsumer; +import javax.jms.MessageListener; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TopicSession; +import javax.naming.InitialContext; +import javax.naming.NamingException; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.util.Properties; + +public class JMSConnection implements BaseConnection, MessageListener{ + + // Setup the pub/sub connection, session + // Send the msg (byte stream) + private static Connection connection = null; + + private static Destination destination = null; + + private static final Log log = LogFactory.getLog(JMSConnection.class); + @Override + public void createConnection(Properties config) { + try { + InitialContext jndi = new InitialContext(config); + ConnectionFactory connectionFactory = (ConnectionFactory) jndi.lookup("ConnectionFactory"); + destination = (Destination)jndi.lookup("CacheInvalidationTopic"); + + connection = connectionFactory.createConnection(config.getProperty("securityPrincipal"), + config.getProperty("securityCredentials")); + connection.start(); + } catch (NamingException | JMSException e) { + log.error("Global cache invalidation: Error message broker initialization", e); + } + } + + @Override + public void closeConnection() { + if (connection != null) { + try { + connection.close(); + } catch (JMSException e) { + log.error("Global cache invalidation: Error in closing connection", e); + } + } + } + + + @Override + public void publish(Object message) { + Session pubSession = null; + try { + if (connection != null) { + pubSession = connection.createSession(false, TopicSession.AUTO_ACKNOWLEDGE); + MessageProducer publisher = pubSession.createProducer(destination); + BytesMessage bytesMessage = pubSession.createBytesMessage(); + bytesMessage.writeBytes((byte[]) message); + publisher.send(bytesMessage); + } + } catch (JMSException e) { + log.error("Global cache invalidation: Error in publishing the message", e); + } finally { + if (pubSession != null) { + try { + pubSession.close(); + } catch (JMSException e) { + log.error("Global cache invalidation: Error in publishing the message", e); } + } + } + } + + @Override + public void subscribe() { + try { + Session subSession = connection.createSession(false, TopicSession.AUTO_ACKNOWLEDGE); + MessageConsumer messageConsumer = subSession.createConsumer(destination); + messageConsumer.setMessageListener(this); + connection.start(); + log.info("Global cache invalidation is online"); + } catch (JMSException e) { + log.error("Global cache invalidation: Error in subscribing to topic", e); + } + } + + @Override + public void onMessage(Message message) { + BytesMessage bytesMessage = (BytesMessage) message; + byte[] data; + try { + data = new byte[(int) bytesMessage.getBodyLength()]; + for (int i = 0; i < (int) bytesMessage.getBodyLength(); i++) { + data[i] = bytesMessage.readByte(); + } + log.debug("Cache invalidation message received: " + new String(data)); + } catch (JMSException jmsException) { + log.error("Error while reading the received message", jmsException); + return; + } + + boolean isCoordinator = false; + if (CacheInvalidationDataHolder.getConfigContext() != null) { + isCoordinator = CacheInvalidationDataHolder.getConfigContext().getAxisConfiguration() + .getClusteringAgent().isCoordinator(); + } + if (isCoordinator) { + PrivilegedCarbonContext.startTenantFlow(); + try { + log.debug("Global cache invalidation: deserializing data to object"); + GlobalCacheInvalidationEvent event = (GlobalCacheInvalidationEvent) deserialize(data); + log.debug("Global cache invalidation: deserializing complete"); + if (!ConfigurationManager.getSentMsgBuffer().contains(event.getUuid().trim())) { // Ignore own messages + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(event.getTenantId(), true); + CacheManager cacheManager = Caching.getCacheManagerFactory().getCacheManager(event.getCacheManagerName()); + if (cacheManager != null) { + if (cacheManager.getCache(event.getCacheName()) != null) { + cacheManager.getCache(event.getCacheName()).remove(event.getCacheKey()); + log.debug("Global cache invalidated: " + event.getCacheKey()); + } else { + log.error("Global cache invalidation: error cache is null"); + } + } else { + log.error("Global cache invalidation: error cache manager is null"); + } + } else { + // To resolve future performance issues + ConfigurationManager.getSentMsgBuffer().remove(event.getUuid().trim()); + log.debug("Global cache invalidation: own message ignored"); + } + } catch (Exception e) { + log.error("Global cache invalidation: error local cache update", e); + } finally { + PrivilegedCarbonContext.endTenantFlow(); + } + } + } + + private Object deserialize(byte[] bytes) throws IOException, ClassNotFoundException { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes); + ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream); + return objectInputStream.readObject(); + } +} diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/CacheInvalidationPublisher.java b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/CacheInvalidationPublisher.java new file mode 100644 index 000000000..0b1e541d5 --- /dev/null +++ b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/CacheInvalidationPublisher.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wso2.carbon.registry.caching.invalidator.impl; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.caching.impl.CacheInvalidator; +import org.wso2.carbon.registry.caching.invalidator.connection.CacheInvalidationException; +import org.wso2.carbon.registry.caching.invalidator.connection.InvalidationConnectionFactory; +import org.wso2.carbon.registry.caching.invalidator.internal.CacheInvalidationDataHolder; +import org.wso2.carbon.registry.core.utils.UUIDGenerator; + +import javax.jms.BytesMessage; +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TopicSession; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectOutputStream; +import java.io.Serializable; + +/** + * Global cache invalidation publisher implements org.wso2.carbon.caching.impl.CacheInvalidator interface + */ +public class CacheInvalidationPublisher implements CacheInvalidator { + private static final Log log = LogFactory.getLog(CacheInvalidationPublisher.class); + + @Override + public void invalidateCache(int tenantId, String cacheManagerName, String cacheName, Serializable cacheKey) { + log.debug("Global cache invalidation: initializing the connection"); + if (CacheInvalidationDataHolder.getConnection() == null) { + ConfigurationManager.init(); + } + //Converting data to json string + GlobalCacheInvalidationEvent event = new GlobalCacheInvalidationEvent(); + event.setTenantId(tenantId); + event.setCacheManagerName(cacheManagerName); + event.setCacheName(cacheName); + event.setCacheKey(cacheKey); + String uuid = UUIDGenerator.generateUUID(); + event.setUuid(uuid); + byte data[]; + try { + log.debug("Global cache invalidation: converting serializable object to byte stream."); + data = serialize(event); + log.debug("Global cache invalidation: converting data to byte stream complete."); + } catch (IOException e) { + log.error("Global cache invalidation: Error while converting data to byte stream", e); + return; + } + + if (CacheInvalidationDataHolder.getConnection() != null) { + CacheInvalidationDataHolder.getConnection().publish(data); + } else { + try { + InvalidationConnectionFactory.createMessageBrokerConnection(); + CacheInvalidationDataHolder.getConnection().publish(data); + } catch (CacheInvalidationException e) { + log.error("Error while publishing data, connection couldn't establish", e); + } + } + // Setup the pub/sub connection, session + // Send the msg (byte stream) +/* Connection connection = null; + try { + Properties props = new Properties(); + props.put(Context.INITIAL_CONTEXT_FACTORY, ConfigurationManager.getInitialContextFactory()); + props.put(Context.PROVIDER_URL, ConfigurationManager.getProviderUrl()); + props.put(Context.SECURITY_PRINCIPAL, ConfigurationManager.getSecurityPrincipal()); + props.put(Context.SECURITY_CREDENTIALS, ConfigurationManager.getSecurityCredentials()); + props.put("topic.MyTopic", ConfigurationManager.getTopicName()); + InitialContext jndi = new InitialContext(props); + ConnectionFactory connectionFactory = (ConnectionFactory) jndi.lookup("ConnectionFactory"); + Destination destination = (Destination)jndi.lookup("MyTopic"); + + connection = connectionFactory.createConnection(ConfigurationManager.getSecurityPrincipal(), + ConfigurationManager.getSecurityCredentials()); + connection.start(); + Session pubSession = connection.createSession(false, TopicSession.AUTO_ACKNOWLEDGE); + MessageProducer publisher = pubSession.createProducer(destination); + BytesMessage bytesMessage = pubSession.createBytesMessage(); + bytesMessage.writeBytes(data); + publisher.send(bytesMessage); + + } catch (JMSException e) { + log.error("Global cache invalidation: Error message broker initialization", e); + } catch (NamingException e) { + log.error("Global cache invalidation: Error message broker initialization", e); + } finally { + if (connection != null) { + try { + connection.close(); + } catch (Exception e) { + log.error("Global cache invalidation: error close publish connection", e); + } + } + }*/ + } + + private byte[] serialize(Object obj) throws IOException { + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream); + objectOutputStream.writeObject(obj); + return byteArrayOutputStream.toByteArray(); + } +} diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/CacheInvalidationSubscriber.java b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/CacheInvalidationSubscriber.java new file mode 100644 index 000000000..f9f9c6f9b --- /dev/null +++ b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/CacheInvalidationSubscriber.java @@ -0,0 +1,160 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wso2.carbon.registry.caching.invalidator.impl; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.core.clustering.api.CoordinatedActivity; +import org.wso2.carbon.registry.caching.invalidator.connection.CacheInvalidationException; +import org.wso2.carbon.registry.caching.invalidator.connection.InvalidationConnectionFactory; +import org.wso2.carbon.registry.caching.invalidator.internal.CacheInvalidationDataHolder; + +/** + * Global cache invalidation subscriber implements org.wso2.carbon.core.clustering.api.CoordinatedActivity interface + */ +public class CacheInvalidationSubscriber implements CoordinatedActivity { + private static final Log log = LogFactory.getLog(CacheInvalidationSubscriber.class); + + public CacheInvalidationSubscriber() { + if (CacheInvalidationDataHolder.getConfigContext() != null && + CacheInvalidationDataHolder.getConfigContext().getAxisConfiguration().getClusteringAgent() != null) { + boolean isCoordinator = CacheInvalidationDataHolder.getConfigContext().getAxisConfiguration() + .getClusteringAgent().isCoordinator(); + if (isCoordinator && !ConfigurationManager.isSubscribed()) { + if (CacheInvalidationDataHolder.getConnection() != null) { + CacheInvalidationDataHolder.getConnection().subscribe(); + } else { + try { + InvalidationConnectionFactory.createMessageBrokerConnection(); + CacheInvalidationDataHolder.getConnection().subscribe(); + } catch (CacheInvalidationException e) { + log.error("Error while subscribing to the queue, connection couldn't establish", e); + return; + } + } + ConfigurationManager.setSubscribed(true); + } + } + } + + @Override + public void execute() { + if(ConfigurationManager.init() && CacheInvalidationDataHolder.getConfigContext() != null) { + boolean isCoordinator = CacheInvalidationDataHolder.getConfigContext().getAxisConfiguration() + .getClusteringAgent().isCoordinator(); + if (isCoordinator && !ConfigurationManager.isSubscribed()) { + if (CacheInvalidationDataHolder.getConnection() != null) { + CacheInvalidationDataHolder.getConnection().subscribe(); + } else { + try { + InvalidationConnectionFactory.createMessageBrokerConnection(); + CacheInvalidationDataHolder.getConnection().subscribe(); + } catch (CacheInvalidationException e) { + log.error("Error while subscribing to the queue, connection couldn't establish", e); + return; + } + } + ConfigurationManager.setSubscribed(true); + } + if (!isCoordinator && ConfigurationManager.isSubscribed()) { + ConfigurationManager.setSubscribed(false); + } + } + } + +/* private void subscribe() { + log.debug("Global cache invalidation: initializing the subscription"); + try { + Properties props = new Properties(); + props.put(Context.INITIAL_CONTEXT_FACTORY, ConfigurationManager.getInitialContextFactory()); + props.put(Context.PROVIDER_URL, ConfigurationManager.getProviderUrl()); + props.put(Context.SECURITY_PRINCIPAL, ConfigurationManager.getSecurityPrincipal()); + props.put(Context.SECURITY_CREDENTIALS, ConfigurationManager.getSecurityCredentials()); + props.put("topic.MyTopic", ConfigurationManager.getTopicName()); + InitialContext jndi = new InitialContext(props); + ConnectionFactory connectionFactory = (ConnectionFactory) jndi.lookup("ConnectionFactory"); + Destination destination = (Destination)jndi.lookup("MyTopic"); + Connection connection = connectionFactory.createConnection(ConfigurationManager.getSecurityPrincipal(), ConfigurationManager.getSecurityCredentials()); + Session subSession = connection.createSession(false, TopicSession.AUTO_ACKNOWLEDGE); + + MessageConsumer messageConsumer = subSession.createConsumer(destination); + messageConsumer.setMessageListener(this); + connection.start(); + log.info("Global cache invalidation is online"); + } catch (JMSException e) { + log.error("Global cache invalidation: Error message broker initialization", e); + } catch (NamingException e) { + log.error("Global cache invalidation: Error message broker initialization", e); + } + }*/ + +/* private Object deserialize(byte[] bytes) throws Exception { + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes); + ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream); + return objectInputStream.readObject(); + }*/ + +/* @Override + public void onMessage(Message message) { + BytesMessage bytesMessage = (BytesMessage)message; + byte[] data; + try { + data = new byte[(int)bytesMessage.getBodyLength()]; + for (int i = 0; i < (int) bytesMessage.getBodyLength(); i++) { + data[i] = bytesMessage.readByte(); + } + log.debug("Cache invalidation message received: " + new String(data)); + } catch (JMSException jmsException) { + log.error("Error while reading the received message" , jmsException); + return; + } + + boolean isCoordinator = false; + if(CacheInvalidationDataHolder.getConfigContext() != null) { + isCoordinator = CacheInvalidationDataHolder.getConfigContext().getAxisConfiguration() + .getClusteringAgent().isCoordinator(); + } + if(isCoordinator) { + PrivilegedCarbonContext.startTenantFlow(); + try { + log.debug("Global cache invalidation: deserializing data to object"); + GlobalCacheInvalidationEvent event = (GlobalCacheInvalidationEvent) deserialize(data); + log.debug("Global cache invalidation: deserializing complete"); + if (!ConfigurationManager.getSentMsgBuffer().contains(event.getUuid().trim())) { // Ignore own messages + PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(event.getTenantId(), true); + CacheManager cacheManager = Caching.getCacheManagerFactory().getCacheManager(event.getCacheManagerName()); + if (cacheManager != null) { + if (cacheManager.getCache(event.getCacheName()) != null) { + cacheManager.getCache(event.getCacheName()).remove(event.getCacheKey()); + log.debug("Global cache invalidated: " + event.getCacheKey()); + } else { + log.error("Global cache invalidation: error cache is null"); + } + } else { + log.error("Global cache invalidation: error cache manager is null"); + } + } else { + // To resolve future performance issues + ConfigurationManager.getSentMsgBuffer().remove(event.getUuid().trim()); + log.debug("Global cache invalidation: own message ignored"); + } + } catch (Exception e) { + log.error("Global cache invalidation: error local cache update", e); + } finally { + PrivilegedCarbonContext.endTenantFlow(); + } + } + }*/ +} diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/ConfigurationManager.java b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/ConfigurationManager.java new file mode 100644 index 000000000..1e0733630 --- /dev/null +++ b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/ConfigurationManager.java @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wso2.carbon.registry.caching.invalidator.impl; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.wso2.carbon.utils.CarbonUtils; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +/** + * Global cache invalidation configuration manager which extract configuration parameters from cache.xml + */ +public class ConfigurationManager { + private static final Log log = LogFactory.getLog(ConfigurationManager.class); + +/* private static String initialContextFactory = null; + private static String providerUrl = null; + private static String topicName = null; + private static String securityPrincipal = null; + private static String securityCredentials = null;*/ + + private static boolean subscribed = false; + + private static boolean enabled = false; + + private static Properties cacheConfiguration = new Properties(); + + private static List sentMsgBuffer; + + public static boolean init(){ + String configFilePath = CarbonUtils.getCarbonHome() + File.separator + "repository" + + File.separator + "conf" + File.separator + "cache.properties"; + FileInputStream fileInputStream = null; + try{ + fileInputStream = new FileInputStream(configFilePath); + cacheConfiguration.load(fileInputStream); + + if(cacheConfiguration.containsKey("enabled")) { + enabled = Boolean.parseBoolean(cacheConfiguration.getProperty("enabled")); + } + +/* StAXOMBuilder stAXOMBuilder = new StAXOMBuilder(new FileInputStream(configFilePath)); + OMElement documentElement = stAXOMBuilder.getDocumentElement(); + Iterator iterator; + + iterator = documentElement.getChildrenWithName(new QName("initialContextFactory")); + + if(iterator.hasNext()){ + OMElement cache = (OMElement) iterator.next(); + initialContextFactory = cache.getText(); + } + + iterator = documentElement.getChildrenWithName(new QName("providerUrl")); + + if(iterator.hasNext()){ + OMElement cache = (OMElement) iterator.next(); + providerUrl = cache.getText(); + } + + iterator = documentElement.getChildrenWithName(new QName("cacheInvalidateTopic")); + + if(iterator.hasNext()){ + OMElement cache = (OMElement) iterator.next(); + topicName = cache.getText(); + } + + iterator = documentElement.getChildrenWithName(new QName("securityPrincipal")); + + if(iterator.hasNext()){ + OMElement cache = (OMElement) iterator.next(); + securityPrincipal = cache.getText(); + } + + if (securityPrincipal == null || securityPrincipal.equals("")) { + securityPrincipal = "guest"; //default + } + + iterator = documentElement.getChildrenWithName(new QName("securityCredentials")); + + if (iterator.hasNext()) { + OMElement cache = (OMElement) iterator.next(); + securityCredentials = cache.getText(); + } + + if (securityCredentials == null || securityCredentials.equals("")) { + securityCredentials = "guest"; //default + } + + propertyExists = providerUrl != null && !providerUrl.equals(""); + propertyExists &= topicName != null && !topicName.equals("");*/ + + if(!enabled){ + log.info("Global cache invalidation is offline according to cache.properties configurations"); + } + + } catch (IOException ioException) { + log.error("Global cache invalidation : Error while reading cache.properties file", ioException); + } finally { + if (fileInputStream != null) { + try { + fileInputStream.close(); + } catch (IOException ioException) { + log.error("Global cache invalidation : Error while reading cache.properties file", ioException); + } + } + } + return enabled; + } + +/* public static String getTopicName() { + return topicName; + } + + public static String getProviderUrl() { + return providerUrl; + }*/ + + + public static List getSentMsgBuffer() { + if(sentMsgBuffer == null){ + sentMsgBuffer = new ArrayList(); + } + return sentMsgBuffer; + } + +/* public static String getInitialContextFactory() { + return initialContextFactory; + } + + public static String getSecurityPrincipal() { + return securityPrincipal; + } + + public static String getSecurityCredentials() { + return securityCredentials; + }*/ + + public static Properties getCacheConfiguration() { + return cacheConfiguration; + } + + public static boolean isSubscribed() { + return subscribed; + } + + public static void setSubscribed(boolean subscribed) { + ConfigurationManager.subscribed = subscribed; + } + + public static void setEnabled(boolean enabled) { + ConfigurationManager.enabled = enabled; + } + + public static boolean isEnabled() { + return enabled; + } +} diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/GlobalCacheInvalidationEvent.java b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/GlobalCacheInvalidationEvent.java new file mode 100644 index 000000000..365b4b431 --- /dev/null +++ b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/GlobalCacheInvalidationEvent.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wso2.carbon.registry.caching.invalidator.impl; + +import java.io.Serializable; + +/** + * Global cache invalidation event serializable object which used to send the data to message broker + */ +public class GlobalCacheInvalidationEvent implements Serializable { + private int tenantId; + private String cacheManagerName; + private String cacheName; + private Serializable cacheKey; + private String uuid; + + public int getTenantId() { + return tenantId; + } + + public void setTenantId(int tenantId) { + this.tenantId = tenantId; + } + + public String getCacheManagerName() { + return cacheManagerName; + } + + public void setCacheManagerName(String cacheManagerName) { + this.cacheManagerName = cacheManagerName; + } + + public String getCacheName() { + return cacheName; + } + + public void setCacheName(String cacheName) { + this.cacheName = cacheName; + } + + public Serializable getCacheKey() { + return cacheKey; + } + + public void setCacheKey(Serializable cacheKey) { + this.cacheKey = cacheKey; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(String uuid) { + this.uuid = uuid; + } +} diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/internal/CacheInvalidationDataHolder.java b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/internal/CacheInvalidationDataHolder.java new file mode 100644 index 000000000..bdcc8ad31 --- /dev/null +++ b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/internal/CacheInvalidationDataHolder.java @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wso2.carbon.registry.caching.invalidator.internal; + +import org.apache.axis2.context.ConfigurationContext; +import org.wso2.carbon.registry.caching.invalidator.connection.BaseConnection; +import org.wso2.carbon.utils.CarbonUtils; + +/** + * Cache Invalidation data holder + */ +public class CacheInvalidationDataHolder { + private static ConfigurationContext configContext; + private static BaseConnection connection; + + public static void setConfigContext(ConfigurationContext configContext) { + CacheInvalidationDataHolder.configContext = configContext; + } + + public static ConfigurationContext getConfigContext() { + return configContext; + } + + public static void setConnection(BaseConnection connection) { + CacheInvalidationDataHolder.connection = connection; + } + + public static BaseConnection getConnection() { + return connection; + } +} diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/internal/CacheInvalidationServiceComponent.java b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/internal/CacheInvalidationServiceComponent.java new file mode 100644 index 000000000..549575a5d --- /dev/null +++ b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/internal/CacheInvalidationServiceComponent.java @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wso2.carbon.registry.caching.invalidator.internal; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.osgi.framework.ServiceRegistration; +import org.osgi.service.component.ComponentContext; +import org.wso2.carbon.caching.impl.CacheInvalidator; +import org.wso2.carbon.registry.caching.invalidator.connection.InvalidationConnectionFactory; +import org.wso2.carbon.registry.caching.invalidator.impl.CacheInvalidationPublisher; +import org.wso2.carbon.registry.caching.invalidator.impl.CacheInvalidationSubscriber; +import org.wso2.carbon.registry.caching.invalidator.impl.ConfigurationManager; +import org.wso2.carbon.core.clustering.api.CoordinatedActivity; +import org.wso2.carbon.utils.ConfigurationContextService; + +/** + * @scr.component name="CacheInvalidationServiceComponent" immediate="true" + * @scr.reference name="configuration.context.service" + * interface="org.wso2.carbon.utils.ConfigurationContextService" cardinality="1..1" + * policy="dynamic" bind="setConfigurationContextService" unbind="unsetConfigurationContextService" + */ + +public class CacheInvalidationServiceComponent { + private static Log log = LogFactory.getLog(CacheInvalidationServiceComponent.class); + ServiceRegistration serviceRegistration; + CacheInvalidationSubscriber subscriber; + CacheInvalidationPublisher publisher; + + protected void activate(ComponentContext ctxt) { + log.info("Initializing the CacheInvalidationServiceComponent..."); + try { + if(ConfigurationManager.init()) { + InvalidationConnectionFactory.createMessageBrokerConnection(); + subscriber = new CacheInvalidationSubscriber(); + publisher = new CacheInvalidationPublisher(); + serviceRegistration = ctxt.getBundleContext().registerService(CacheInvalidator.class, publisher, null); + serviceRegistration = ctxt.getBundleContext().registerService(CoordinatedActivity.class, subscriber, null); + } + } catch (Exception e) { + String msg = "Failed to initialize the CacheInvalidationServiceComponent."; + log.error(msg, e); + } + } + + protected void deactivate(ComponentContext ctxt) { + log.info("Stopping the CacheInvalidationServiceComponent"); + try{ + if(serviceRegistration != null) { + serviceRegistration.unregister(); + } + }catch (Exception e){ + String msg = "Failed to Stop the CacheInvalidationServiceComponent."; + log.error(msg, e); + } + } + + protected void setConfigurationContextService(ConfigurationContextService contextService) { + CacheInvalidationDataHolder.setConfigContext(contextService.getServerConfigContext()); + } + + protected void unsetConfigurationContextService(ConfigurationContextService contextService) { + CacheInvalidationDataHolder.setConfigContext(null); + } +} diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/resources/cache.properties b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/resources/cache.properties new file mode 100644 index 000000000..e3153422e --- /dev/null +++ b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/resources/cache.properties @@ -0,0 +1,21 @@ + +class.CacheInvalidationClass=org.wso2.carbon.registry.caching.invalidator.connection.JMSConnection +initialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory +providerUrl=tcp://localhost:61616 +securityPrincipal=guest +securityCredentials=guest +cacheInvalidateTopic=GlobalCacheInvalidation \ No newline at end of file diff --git a/components/registry/pom.xml b/components/registry/pom.xml index 0756683e3..a181bdcab 100644 --- a/components/registry/pom.xml +++ b/components/registry/pom.xml @@ -70,6 +70,7 @@ org.wso2.carbon.registry.cmis org.wso2.carbon.registry.metadata org.wso2.carbon.registry.deployment.synchronizer + org.wso2.carbon.registry.caching.invalidator diff --git a/features/caching-invalidator/feature.properties b/features/caching-invalidator/feature.properties new file mode 100644 index 000000000..915939022 --- /dev/null +++ b/features/caching-invalidator/feature.properties @@ -0,0 +1,217 @@ +################################################################################ +# Copyright 2009 WSO2, Inc. (http://wso2.com) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +################################################################################ + +providerName=WSO2 Inc. + +########################## license properties ################################## +licenseURL=http://www.apache.org/licenses/LICENSE-2.0 + +license=\ + Apache License\n\ + Version 2.0, January 2004\n\ + http://www.apache.org/licenses/\n\ +\n\ + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\ +\n\ + 1. Definitions.\n\ +\n\ + "License" shall mean the terms and conditions for use, reproduction,\n\ + and distribution as defined by Sections 1 through 9 of this document.\n\ +\n\ + "Licensor" shall mean the copyright owner or entity authorized by\n\ + the copyright owner that is granting the License.\n\ +\n\ + "Legal Entity" shall mean the union of the acting entity and all\n\ + other entities that control, are controlled by, or are under common\n\ + control with that entity. For the purposes of this definition,\n\ + "control" means (i) the power, direct or indirect, to cause the\n\ + direction or management of such entity, whether by contract or\n\ + otherwise, or (ii) ownership of fifty percent (50%) or more of the\n\ + outstanding shares, or (iii) beneficial ownership of such entity.\n\ +\n\ + "You" (or "Your") shall mean an individual or Legal Entity\n\ + exercising permissions granted by this License.\n\ +\n\ + "Source" form shall mean the preferred form for making modifications,\n\ + including but not limited to software source code, documentation\n\ + source, and configuration files.\n\ +\n\ + "Object" form shall mean any form resulting from mechanical\n\ + transformation or translation of a Source form, including but\n\ + not limited to compiled object code, generated documentation,\n\ + and conversions to other media types.\n\ +\n\ + "Work" shall mean the work of authorship, whether in Source or\n\ + Object form, made available under the License, as indicated by a\n\ + copyright notice that is included in or attached to the work\n\ + (an example is provided in the Appendix below).\n\ +\n\ + "Derivative Works" shall mean any work, whether in Source or Object\n\ + form, that is based on (or derived from) the Work and for which the\n\ + editorial revisions, annotations, elaborations, or other modifications\n\ + represent, as a whole, an original work of authorship. For the purposes\n\ + of this License, Derivative Works shall not include works that remain\n\ + separable from, or merely link (or bind by name) to the interfaces of,\n\ + the Work and Derivative Works thereof.\n\ +\n\ + "Contribution" shall mean any work of authorship, including\n\ + the original version of the Work and any modifications or additions\n\ + to that Work or Derivative Works thereof, that is intentionally\n\ + submitted to Licensor for inclusion in the Work by the copyright owner\n\ + or by an individual or Legal Entity authorized to submit on behalf of\n\ + the copyright owner. For the purposes of this definition, "submitted"\n\ + means any form of electronic, verbal, or written communication sent\n\ + to the Licensor or its representatives, including but not limited to\n\ + communication on electronic mailing lists, source code control systems,\n\ + and issue tracking systems that are managed by, or on behalf of, the\n\ + Licensor for the purpose of discussing and improving the Work, but\n\ + excluding communication that is conspicuously marked or otherwise\n\ + designated in writing by the copyright owner as "Not a Contribution."\n\ +\n\ + "Contributor" shall mean Licensor and any individual or Legal Entity\n\ + on behalf of whom a Contribution has been received by Licensor and\n\ + subsequently incorporated within the Work.\n\ +\n\ + 2. Grant of Copyright License. Subject to the terms and conditions of\n\ + this License, each Contributor hereby grants to You a perpetual,\n\ + worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n\ + copyright license to reproduce, prepare Derivative Works of,\n\ + publicly display, publicly perform, sublicense, and distribute the\n\ + Work and such Derivative Works in Source or Object form.\n\ +\n\ + 3. Grant of Patent License. Subject to the terms and conditions of\n\ + this License, each Contributor hereby grants to You a perpetual,\n\ + worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n\ + (except as stated in this section) patent license to make, have made,\n\ + use, offer to sell, sell, import, and otherwise transfer the Work,\n\ + where such license applies only to those patent claims licensable\n\ + by such Contributor that are necessarily infringed by their\n\ + Contribution(s) alone or by combination of their Contribution(s)\n\ + with the Work to which such Contribution(s) was submitted. If You\n\ + institute patent litigation against any entity (including a\n\ + cross-claim or counterclaim in a lawsuit) alleging that the Work\n\ + or a Contribution incorporated within the Work constitutes direct\n\ + or contributory patent infringement, then any patent licenses\n\ + granted to You under this License for that Work shall terminate\n\ + as of the date such litigation is filed.\n\ +\n\ + 4. Redistribution. You may reproduce and distribute copies of the\n\ + Work or Derivative Works thereof in any medium, with or without\n\ + modifications, and in Source or Object form, provided that You\n\ + meet the following conditions:\n\ +\n\ + (a) You must give any other recipients of the Work or\n\ + Derivative Works a copy of this License; and\n\ +\n\ + (b) You must cause any modified files to carry prominent notices\n\ + stating that You changed the files; and\n\ +\n\ + (c) You must retain, in the Source form of any Derivative Works\n\ + that You distribute, all copyright, patent, trademark, and\n\ + attribution notices from the Source form of the Work,\n\ + excluding those notices that do not pertain to any part of\n\ + the Derivative Works; and\n\ +\n\ + (d) If the Work includes a "NOTICE" text file as part of its\n\ + distribution, then any Derivative Works that You distribute must\n\ + include a readable copy of the attribution notices contained\n\ + within such NOTICE file, excluding those notices that do not\n\ + pertain to any part of the Derivative Works, in at least one\n\ + of the following places: within a NOTICE text file distributed\n\ + as part of the Derivative Works; within the Source form or\n\ + documentation, if provided along with the Derivative Works; or,\n\ + within a display generated by the Derivative Works, if and\n\ + wherever such third-party notices normally appear. The contents\n\ + of the NOTICE file are for informational purposes only and\n\ + do not modify the License. You may add Your own attribution\n\ + notices within Derivative Works that You distribute, alongside\n\ + or as an addendum to the NOTICE text from the Work, provided\n\ + that such additional attribution notices cannot be construed\n\ + as modifying the License.\n\ +\n\ + You may add Your own copyright statement to Your modifications and\n\ + may provide additional or different license terms and conditions\n\ + for use, reproduction, or distribution of Your modifications, or\n\ + for any such Derivative Works as a whole, provided Your use,\n\ + reproduction, and distribution of the Work otherwise complies with\n\ + the conditions stated in this License.\n\ +\n\ + 5. Submission of Contributions. Unless You explicitly state otherwise,\n\ + any Contribution intentionally submitted for inclusion in the Work\n\ + by You to the Licensor shall be under the terms and conditions of\n\ + this License, without any additional terms or conditions.\n\ + Notwithstanding the above, nothing herein shall supersede or modify\n\ + the terms of any separate license agreement you may have executed\n\ + with Licensor regarding such Contributions.\n\ +\n\ + 6. Trademarks. This License does not grant permission to use the trade\n\ + names, trademarks, service marks, or product names of the Licensor,\n\ + except as required for reasonable and customary use in describing the\n\ + origin of the Work and reproducing the content of the NOTICE file.\n\ +\n\ + 7. Disclaimer of Warranty. Unless required by applicable law or\n\ + agreed to in writing, Licensor provides the Work (and each\n\ + Contributor provides its Contributions) on an "AS IS" BASIS,\n\ + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n\ + implied, including, without limitation, any warranties or conditions\n\ + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n\ + PARTICULAR PURPOSE. You are solely responsible for determining the\n\ + appropriateness of using or redistributing the Work and assume any\n\ + risks associated with Your exercise of permissions under this License.\n\ +\n\ + 8. Limitation of Liability. In no event and under no legal theory,\n\ + whether in tort (including negligence), contract, or otherwise,\n\ + unless required by applicable law (such as deliberate and grossly\n\ + negligent acts) or agreed to in writing, shall any Contributor be\n\ + liable to You for damages, including any direct, indirect, special,\n\ + incidental, or consequential damages of any character arising as a\n\ + result of this License or out of the use or inability to use the\n\ + Work (including but not limited to damages for loss of goodwill,\n\ + work stoppage, computer failure or malfunction, or any and all\n\ + other commercial damages or losses), even if such Contributor\n\ + has been advised of the possibility of such damages.\n\ +\n\ + 9. Accepting Warranty or Additional Liability. While redistributing\n\ + the Work or Derivative Works thereof, You may choose to offer,\n\ + and charge a fee for, acceptance of support, warranty, indemnity,\n\ + or other liability obligations and/or rights consistent with this\n\ + License. However, in accepting such obligations, You may act only\n\ + on Your own behalf and on Your sole responsibility, not on behalf\n\ + of any other Contributor, and only if You agree to indemnify,\n\ + defend, and hold each Contributor harmless for any liability\n\ + incurred by, or claims asserted against, such Contributor by reason\n\ + of your accepting any such warranty or additional liability.\n\ +\n\ + END OF TERMS AND CONDITIONS\n + +######################### copyright properties ################################# +copyrightURL=TODO + +copyright=\ +Copyright 2014 WSO2, Inc. (http://wso2.com)\n\ +\n\ +Licensed under the Apache License, Version 2.0 (the "License");\n\ +you may not use this file except in compliance with the License.\n\ +You may obtain a copy of the License at\n\ +\n\ +http://www.apache.org/licenses/LICENSE-2.0\n\ +\n\ +Unless required by applicable law or agreed to in writing, software\n\ +distributed under the License is distributed on an "AS IS" BASIS,\n\ +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\ +See the License for the specific language governing permissions and\n\ +limitations under the License.\n + diff --git a/features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.feature/pom.xml b/features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.feature/pom.xml new file mode 100644 index 000000000..393ba7b07 --- /dev/null +++ b/features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.feature/pom.xml @@ -0,0 +1,74 @@ + + + + + + + org.wso2.carbon.registry + caching-invalidator-feature + 4.3.3-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.registry.caching.invalidator.feature + pom + WSO2 Carbon - Global Caching Invalidator Feature + http://wso2.org + This feature contains the bundles required for Global Cache invalidation for Carbon + + + + org.wso2.carbon.registry + org.wso2.carbon.registry.caching.invalidator.server.feature + zip + ${carbon.registry.version} + + + + + + + org.wso2.maven + carbon-p2-plugin + ${carbon.p2.plugin.version} + + + p2-feature-generation + package + + p2-feature-gen + + + org.wso2.carbon.registry.caching.invalidator.server + ../feature.properties + + + org.eclipse.equinox.p2.type.group:true + + + + org.wso2.carbon.registry:org.wso2.carbon.registry.caching.invalidator.server.feature + + + + + + + + + diff --git a/features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.server.feature/pom.xml b/features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.server.feature/pom.xml new file mode 100644 index 000000000..0cfaaac5c --- /dev/null +++ b/features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.server.feature/pom.xml @@ -0,0 +1,100 @@ + + + + + + + org.wso2.carbon.registry + caching-invalidator-feature + 4.3.3-SNAPSHOT + ../pom.xml + + + 4.0.0 + org.wso2.carbon.registry.caching.invalidator.server.feature + pom + WSO2 Carbon - Global Caching Invalidator Server Feature + http://wso2.org + This feature contains the core bundles required for Global Cache invalidation for Carbon + + + + org.wso2.carbon.registry + org.wso2.carbon.registry.caching.invalidator + + + + + + + maven-resources-plugin + + + copy-resources + generate-resources + + copy-resources + + + src/main/resources + + + resources + + conf/cache.properties + p2.inf + + + + + + + + + org.wso2.maven + carbon-p2-plugin + ${carbon.p2.plugin.version} + + + p2-feature-generation + package + + p2-feature-gen + + + org.wso2.carbon.registry.caching.invalidator.server + ../feature.properties + + + org.wso2.carbon.p2.category.type:server + org.eclipse.equinox.p2.type.group:false + + + + org.wso2.carbon.registry:org.wso2.carbon.registry.caching.invalidator + + + org.apache.geronimo.specs.wso2:geronimo-jms_1.1_spec + + + + + + + + + diff --git a/features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.server.feature/src/main/resources/conf/cache.properties b/features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.server.feature/src/main/resources/conf/cache.properties new file mode 100644 index 000000000..d3e3c671a --- /dev/null +++ b/features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.server.feature/src/main/resources/conf/cache.properties @@ -0,0 +1,22 @@ + +enabled=true +class.CacheInvalidationClass=org.wso2.carbon.registry.caching.invalidator.connection.JMSConnection +initialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory +providerUrl=tcp://localhost:61616 +securityPrincipal=guest +securityCredentials=guest +cacheInvalidateTopic=GlobalCacheInvalidation \ No newline at end of file diff --git a/features/caching-invalidator/pom.xml b/features/caching-invalidator/pom.xml new file mode 100644 index 000000000..29b939fa8 --- /dev/null +++ b/features/caching-invalidator/pom.xml @@ -0,0 +1,39 @@ + + + + + + + org.wso2.carbon.registry + carbon-registry + 4.3.3-SNAPSHOT + ../../pom.xml + + + 4.0.0 + caching-invalidator-feature + pom + WSO2 Carbon - Global cache invalidation feature module + http://wso2.org + + + org.wso2.carbon.registry.caching.invalidator.server.feature + org.wso2.carbon.registry.caching.invalidator.feature + + + + diff --git a/pom.xml b/pom.xml index 0c861fe4f..41e06ec1d 100644 --- a/pom.xml +++ b/pom.xml @@ -39,6 +39,7 @@ features/jcr features/uddi features/deployment-synchronizer + features/caching-invalidator @@ -354,6 +355,11 @@ + + org.wso2.carbon + javax.cache.wso2 + ${carbon.kernel.version} + org.wso2.carbon.commons org.wso2.carbon.user.mgt @@ -761,6 +767,11 @@ org.wso2.carbon.registry.deployment.synchronizer ${carbon.registry.version} + + org.wso2.carbon.registry + org.wso2.carbon.registry.caching.invalidator + ${carbon.registry.version} + @@ -1246,7 +1257,11 @@ oauth2-client ${amber.version} - + + org.apache.geronimo.specs.wso2 + geronimo-jms_1.1_spec + ${orbit.version.geronimo-jms_1.1_spec} + junit @@ -1431,6 +1446,9 @@ 4.3.5 [4.3.0, 4.4.0) + + 1.1.0.wso2v1 + 4.3.3-SNAPSHOT 1.0.1 From 4fe7940ce74783bf04eab45b2d06a3caa235705b Mon Sep 17 00:00:00 2001 From: daneshk Date: Wed, 29 Apr 2015 23:35:27 +0530 Subject: [PATCH 3/4] add the fix for global cache invalidation --- .../pom.xml | 17 ++-- .../connection/BaseConnection.java | 14 --- .../CacheInvalidationException.java | 15 ++++ .../connection/InvalidNotification.java | 29 +++++++ .../InvalidationConnectionFactory.java | 17 +++- ...MSConnection.java => JMSNotification.java} | 30 ++++++- .../impl/CacheInvalidationPublisher.java | 44 ---------- .../impl/CacheInvalidationSubscriber.java | 87 +------------------ .../impl/ConfigurationManager.java | 83 +----------------- .../impl/GlobalCacheInvalidationEvent.java | 2 +- .../internal/CacheInvalidationDataHolder.java | 11 ++- .../CacheInvalidationServiceComponent.java | 8 +- .../src/main/resources/cache.properties | 2 +- .../pom.xml | 2 +- .../pom.xml | 10 ++- .../src/main/resources/conf/cache.properties | 2 +- features/caching-invalidator/pom.xml | 2 +- 17 files changed, 115 insertions(+), 260 deletions(-) delete mode 100644 components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/BaseConnection.java create mode 100644 components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/InvalidNotification.java rename components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/{JMSConnection.java => JMSNotification.java} (81%) diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/pom.xml b/components/registry/org.wso2.carbon.registry.caching.invalidator/pom.xml index 2ce7ed1c5..13b2e8dc5 100644 --- a/components/registry/org.wso2.carbon.registry.caching.invalidator/pom.xml +++ b/components/registry/org.wso2.carbon.registry.caching.invalidator/pom.xml @@ -4,7 +4,7 @@ org.wso2.carbon.registry registry - 4.3.3-SNAPSHOT + 4.4.2-SNAPSHOT ../pom.xml @@ -47,23 +47,16 @@ org.apache.felix maven-bundle-plugin - true - WSO2 Inc - org.wso2.carbon.registry.caching.invalidator + ${project.artifactId} + ${project.artifactId} - org.wso2.carbon.registry.caching.invalidator.connection.*, - org.wso2.carbon.registry.caching.invalidator.impl.*, - !org.wso2.carbon.registry.caching.invalidator.internal.* + org.wso2.carbon.registry.caching.invalidator.* - - org.wso2.carbon.registry.caching.invalidator.internal - - !org.wso2.carbon.registry.caching.invalidator.connection.*, - !org.wso2.carbon.registry.caching.invalidator.impl.*, + !org.wso2.carbon.registry.caching.invalidator.*, javax.jms.* * diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/BaseConnection.java b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/BaseConnection.java deleted file mode 100644 index e5ad7e9c1..000000000 --- a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/BaseConnection.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.wso2.carbon.registry.caching.invalidator.connection; - -import java.util.Properties; - -public interface BaseConnection { - - public void createConnection(Properties config); - - public void closeConnection(); - - public void publish(Object message); - - public void subscribe(); -} diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/CacheInvalidationException.java b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/CacheInvalidationException.java index b7f56d957..2aa87294c 100644 --- a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/CacheInvalidationException.java +++ b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/CacheInvalidationException.java @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.wso2.carbon.registry.caching.invalidator.connection; public class CacheInvalidationException extends Exception { diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/InvalidNotification.java b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/InvalidNotification.java new file mode 100644 index 000000000..d82aed058 --- /dev/null +++ b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/InvalidNotification.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.wso2.carbon.registry.caching.invalidator.connection; + +import java.util.Properties; + +public interface InvalidNotification { + + public void createConnection(Properties config); + + public void closeConnection(); + + public void publish(Object message); + + public void subscribe(); +} diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/InvalidationConnectionFactory.java b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/InvalidationConnectionFactory.java index 9591096eb..2b4620e74 100644 --- a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/InvalidationConnectionFactory.java +++ b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/InvalidationConnectionFactory.java @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.wso2.carbon.registry.caching.invalidator.connection; import org.apache.commons.logging.Log; @@ -13,7 +28,7 @@ public class InvalidationConnectionFactory { public static void createMessageBrokerConnection() throws CacheInvalidationException { Properties properties = ConfigurationManager.getCacheConfiguration(); if (properties.containsKey("class.CacheInvalidationClass")) { - BaseConnection connection = (BaseConnection) getObject(properties.getProperty("class.CacheInvalidationClass")); + InvalidNotification connection = (InvalidNotification) getObject(properties.getProperty("class.CacheInvalidationClass")); if (connection != null) { connection.createConnection(properties); CacheInvalidationDataHolder.setConnection(connection); diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/JMSConnection.java b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/JMSNotification.java similarity index 81% rename from components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/JMSConnection.java rename to components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/JMSNotification.java index 357f8be04..551f53b5d 100644 --- a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/JMSConnection.java +++ b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/connection/JMSNotification.java @@ -1,3 +1,18 @@ +/* + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.wso2.carbon.registry.caching.invalidator.connection; import org.apache.commons.logging.Log; @@ -20,6 +35,7 @@ import javax.jms.MessageProducer; import javax.jms.Session; import javax.jms.TopicSession; +import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import java.io.ByteArrayInputStream; @@ -27,7 +43,7 @@ import java.io.ObjectInputStream; import java.util.Properties; -public class JMSConnection implements BaseConnection, MessageListener{ +public class JMSNotification implements InvalidNotification, MessageListener{ // Setup the pub/sub connection, session // Send the msg (byte stream) @@ -35,13 +51,19 @@ public class JMSConnection implements BaseConnection, MessageListener{ private static Destination destination = null; - private static final Log log = LogFactory.getLog(JMSConnection.class); + private static final Log log = LogFactory.getLog(JMSNotification.class); @Override public void createConnection(Properties config) { try { - InitialContext jndi = new InitialContext(config); + Properties props = new Properties(); + props.put(Context.INITIAL_CONTEXT_FACTORY, config.getProperty("initialContextFactory")); + props.put(Context.PROVIDER_URL, config.getProperty("providerUrl")); + props.put(Context.SECURITY_PRINCIPAL, config.getProperty("securityPrincipal")); + props.put(Context.SECURITY_CREDENTIALS, config.getProperty("securityCredentials")); + props.put("topic.cacheInvalidateTopic", config.getProperty("cacheInvalidateTopic")); + InitialContext jndi = new InitialContext(props); ConnectionFactory connectionFactory = (ConnectionFactory) jndi.lookup("ConnectionFactory"); - destination = (Destination)jndi.lookup("CacheInvalidationTopic"); + destination = (Destination)jndi.lookup("cacheInvalidateTopic"); connection = connectionFactory.createConnection(config.getProperty("securityPrincipal"), config.getProperty("securityCredentials")); diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/CacheInvalidationPublisher.java b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/CacheInvalidationPublisher.java index 0b1e541d5..519c00acb 100644 --- a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/CacheInvalidationPublisher.java +++ b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/CacheInvalidationPublisher.java @@ -23,14 +23,6 @@ import org.wso2.carbon.registry.caching.invalidator.internal.CacheInvalidationDataHolder; import org.wso2.carbon.registry.core.utils.UUIDGenerator; -import javax.jms.BytesMessage; -import javax.jms.Connection; -import javax.jms.ConnectionFactory; -import javax.jms.Destination; -import javax.jms.JMSException; -import javax.jms.MessageProducer; -import javax.jms.Session; -import javax.jms.TopicSession; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.ObjectOutputStream; @@ -76,42 +68,6 @@ public void invalidateCache(int tenantId, String cacheManagerName, String cacheN log.error("Error while publishing data, connection couldn't establish", e); } } - // Setup the pub/sub connection, session - // Send the msg (byte stream) -/* Connection connection = null; - try { - Properties props = new Properties(); - props.put(Context.INITIAL_CONTEXT_FACTORY, ConfigurationManager.getInitialContextFactory()); - props.put(Context.PROVIDER_URL, ConfigurationManager.getProviderUrl()); - props.put(Context.SECURITY_PRINCIPAL, ConfigurationManager.getSecurityPrincipal()); - props.put(Context.SECURITY_CREDENTIALS, ConfigurationManager.getSecurityCredentials()); - props.put("topic.MyTopic", ConfigurationManager.getTopicName()); - InitialContext jndi = new InitialContext(props); - ConnectionFactory connectionFactory = (ConnectionFactory) jndi.lookup("ConnectionFactory"); - Destination destination = (Destination)jndi.lookup("MyTopic"); - - connection = connectionFactory.createConnection(ConfigurationManager.getSecurityPrincipal(), - ConfigurationManager.getSecurityCredentials()); - connection.start(); - Session pubSession = connection.createSession(false, TopicSession.AUTO_ACKNOWLEDGE); - MessageProducer publisher = pubSession.createProducer(destination); - BytesMessage bytesMessage = pubSession.createBytesMessage(); - bytesMessage.writeBytes(data); - publisher.send(bytesMessage); - - } catch (JMSException e) { - log.error("Global cache invalidation: Error message broker initialization", e); - } catch (NamingException e) { - log.error("Global cache invalidation: Error message broker initialization", e); - } finally { - if (connection != null) { - try { - connection.close(); - } catch (Exception e) { - log.error("Global cache invalidation: error close publish connection", e); - } - } - }*/ } private byte[] serialize(Object obj) throws IOException { diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/CacheInvalidationSubscriber.java b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/CacheInvalidationSubscriber.java index f9f9c6f9b..58883ff2e 100644 --- a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/CacheInvalidationSubscriber.java +++ b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/CacheInvalidationSubscriber.java @@ -35,16 +35,16 @@ public CacheInvalidationSubscriber() { if (isCoordinator && !ConfigurationManager.isSubscribed()) { if (CacheInvalidationDataHolder.getConnection() != null) { CacheInvalidationDataHolder.getConnection().subscribe(); + ConfigurationManager.setSubscribed(true); } else { try { InvalidationConnectionFactory.createMessageBrokerConnection(); CacheInvalidationDataHolder.getConnection().subscribe(); + ConfigurationManager.setSubscribed(true); } catch (CacheInvalidationException e) { log.error("Error while subscribing to the queue, connection couldn't establish", e); - return; } } - ConfigurationManager.setSubscribed(true); } } } @@ -74,87 +74,4 @@ public void execute() { } } -/* private void subscribe() { - log.debug("Global cache invalidation: initializing the subscription"); - try { - Properties props = new Properties(); - props.put(Context.INITIAL_CONTEXT_FACTORY, ConfigurationManager.getInitialContextFactory()); - props.put(Context.PROVIDER_URL, ConfigurationManager.getProviderUrl()); - props.put(Context.SECURITY_PRINCIPAL, ConfigurationManager.getSecurityPrincipal()); - props.put(Context.SECURITY_CREDENTIALS, ConfigurationManager.getSecurityCredentials()); - props.put("topic.MyTopic", ConfigurationManager.getTopicName()); - InitialContext jndi = new InitialContext(props); - ConnectionFactory connectionFactory = (ConnectionFactory) jndi.lookup("ConnectionFactory"); - Destination destination = (Destination)jndi.lookup("MyTopic"); - Connection connection = connectionFactory.createConnection(ConfigurationManager.getSecurityPrincipal(), ConfigurationManager.getSecurityCredentials()); - Session subSession = connection.createSession(false, TopicSession.AUTO_ACKNOWLEDGE); - - MessageConsumer messageConsumer = subSession.createConsumer(destination); - messageConsumer.setMessageListener(this); - connection.start(); - log.info("Global cache invalidation is online"); - } catch (JMSException e) { - log.error("Global cache invalidation: Error message broker initialization", e); - } catch (NamingException e) { - log.error("Global cache invalidation: Error message broker initialization", e); - } - }*/ - -/* private Object deserialize(byte[] bytes) throws Exception { - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes); - ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream); - return objectInputStream.readObject(); - }*/ - -/* @Override - public void onMessage(Message message) { - BytesMessage bytesMessage = (BytesMessage)message; - byte[] data; - try { - data = new byte[(int)bytesMessage.getBodyLength()]; - for (int i = 0; i < (int) bytesMessage.getBodyLength(); i++) { - data[i] = bytesMessage.readByte(); - } - log.debug("Cache invalidation message received: " + new String(data)); - } catch (JMSException jmsException) { - log.error("Error while reading the received message" , jmsException); - return; - } - - boolean isCoordinator = false; - if(CacheInvalidationDataHolder.getConfigContext() != null) { - isCoordinator = CacheInvalidationDataHolder.getConfigContext().getAxisConfiguration() - .getClusteringAgent().isCoordinator(); - } - if(isCoordinator) { - PrivilegedCarbonContext.startTenantFlow(); - try { - log.debug("Global cache invalidation: deserializing data to object"); - GlobalCacheInvalidationEvent event = (GlobalCacheInvalidationEvent) deserialize(data); - log.debug("Global cache invalidation: deserializing complete"); - if (!ConfigurationManager.getSentMsgBuffer().contains(event.getUuid().trim())) { // Ignore own messages - PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(event.getTenantId(), true); - CacheManager cacheManager = Caching.getCacheManagerFactory().getCacheManager(event.getCacheManagerName()); - if (cacheManager != null) { - if (cacheManager.getCache(event.getCacheName()) != null) { - cacheManager.getCache(event.getCacheName()).remove(event.getCacheKey()); - log.debug("Global cache invalidated: " + event.getCacheKey()); - } else { - log.error("Global cache invalidation: error cache is null"); - } - } else { - log.error("Global cache invalidation: error cache manager is null"); - } - } else { - // To resolve future performance issues - ConfigurationManager.getSentMsgBuffer().remove(event.getUuid().trim()); - log.debug("Global cache invalidation: own message ignored"); - } - } catch (Exception e) { - log.error("Global cache invalidation: error local cache update", e); - } finally { - PrivilegedCarbonContext.endTenantFlow(); - } - } - }*/ } diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/ConfigurationManager.java b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/ConfigurationManager.java index 1e0733630..e8d676250 100644 --- a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/ConfigurationManager.java +++ b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/ConfigurationManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,12 +33,6 @@ public class ConfigurationManager { private static final Log log = LogFactory.getLog(ConfigurationManager.class); -/* private static String initialContextFactory = null; - private static String providerUrl = null; - private static String topicName = null; - private static String securityPrincipal = null; - private static String securityCredentials = null;*/ - private static boolean subscribed = false; private static boolean enabled = false; @@ -59,56 +53,6 @@ public static boolean init(){ enabled = Boolean.parseBoolean(cacheConfiguration.getProperty("enabled")); } -/* StAXOMBuilder stAXOMBuilder = new StAXOMBuilder(new FileInputStream(configFilePath)); - OMElement documentElement = stAXOMBuilder.getDocumentElement(); - Iterator iterator; - - iterator = documentElement.getChildrenWithName(new QName("initialContextFactory")); - - if(iterator.hasNext()){ - OMElement cache = (OMElement) iterator.next(); - initialContextFactory = cache.getText(); - } - - iterator = documentElement.getChildrenWithName(new QName("providerUrl")); - - if(iterator.hasNext()){ - OMElement cache = (OMElement) iterator.next(); - providerUrl = cache.getText(); - } - - iterator = documentElement.getChildrenWithName(new QName("cacheInvalidateTopic")); - - if(iterator.hasNext()){ - OMElement cache = (OMElement) iterator.next(); - topicName = cache.getText(); - } - - iterator = documentElement.getChildrenWithName(new QName("securityPrincipal")); - - if(iterator.hasNext()){ - OMElement cache = (OMElement) iterator.next(); - securityPrincipal = cache.getText(); - } - - if (securityPrincipal == null || securityPrincipal.equals("")) { - securityPrincipal = "guest"; //default - } - - iterator = documentElement.getChildrenWithName(new QName("securityCredentials")); - - if (iterator.hasNext()) { - OMElement cache = (OMElement) iterator.next(); - securityCredentials = cache.getText(); - } - - if (securityCredentials == null || securityCredentials.equals("")) { - securityCredentials = "guest"; //default - } - - propertyExists = providerUrl != null && !providerUrl.equals(""); - propertyExists &= topicName != null && !topicName.equals("");*/ - if(!enabled){ log.info("Global cache invalidation is offline according to cache.properties configurations"); } @@ -127,15 +71,6 @@ public static boolean init(){ return enabled; } -/* public static String getTopicName() { - return topicName; - } - - public static String getProviderUrl() { - return providerUrl; - }*/ - - public static List getSentMsgBuffer() { if(sentMsgBuffer == null){ sentMsgBuffer = new ArrayList(); @@ -143,18 +78,6 @@ public static List getSentMsgBuffer() { return sentMsgBuffer; } -/* public static String getInitialContextFactory() { - return initialContextFactory; - } - - public static String getSecurityPrincipal() { - return securityPrincipal; - } - - public static String getSecurityCredentials() { - return securityCredentials; - }*/ - public static Properties getCacheConfiguration() { return cacheConfiguration; } @@ -167,10 +90,6 @@ public static void setSubscribed(boolean subscribed) { ConfigurationManager.subscribed = subscribed; } - public static void setEnabled(boolean enabled) { - ConfigurationManager.enabled = enabled; - } - public static boolean isEnabled() { return enabled; } diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/GlobalCacheInvalidationEvent.java b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/GlobalCacheInvalidationEvent.java index 365b4b431..53bc55c66 100644 --- a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/GlobalCacheInvalidationEvent.java +++ b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/impl/GlobalCacheInvalidationEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/internal/CacheInvalidationDataHolder.java b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/internal/CacheInvalidationDataHolder.java index bdcc8ad31..050724823 100644 --- a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/internal/CacheInvalidationDataHolder.java +++ b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/internal/CacheInvalidationDataHolder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. + * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,15 +16,14 @@ package org.wso2.carbon.registry.caching.invalidator.internal; import org.apache.axis2.context.ConfigurationContext; -import org.wso2.carbon.registry.caching.invalidator.connection.BaseConnection; -import org.wso2.carbon.utils.CarbonUtils; +import org.wso2.carbon.registry.caching.invalidator.connection.InvalidNotification; /** * Cache Invalidation data holder */ public class CacheInvalidationDataHolder { private static ConfigurationContext configContext; - private static BaseConnection connection; + private static InvalidNotification connection; public static void setConfigContext(ConfigurationContext configContext) { CacheInvalidationDataHolder.configContext = configContext; @@ -34,11 +33,11 @@ public static ConfigurationContext getConfigContext() { return configContext; } - public static void setConnection(BaseConnection connection) { + public static void setConnection(InvalidNotification connection) { CacheInvalidationDataHolder.connection = connection; } - public static BaseConnection getConnection() { + public static InvalidNotification getConnection() { return connection; } } diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/internal/CacheInvalidationServiceComponent.java b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/internal/CacheInvalidationServiceComponent.java index 549575a5d..b373017f2 100644 --- a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/internal/CacheInvalidationServiceComponent.java +++ b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/internal/CacheInvalidationServiceComponent.java @@ -41,7 +41,7 @@ public class CacheInvalidationServiceComponent { CacheInvalidationPublisher publisher; protected void activate(ComponentContext ctxt) { - log.info("Initializing the CacheInvalidationServiceComponent..."); + log.debug("Cache Invalidation Service activation started"); try { if(ConfigurationManager.init()) { InvalidationConnectionFactory.createMessageBrokerConnection(); @@ -51,19 +51,19 @@ protected void activate(ComponentContext ctxt) { serviceRegistration = ctxt.getBundleContext().registerService(CoordinatedActivity.class, subscriber, null); } } catch (Exception e) { - String msg = "Failed to initialize the CacheInvalidationServiceComponent."; + String msg = "Failed to initialize the Cache Invalidation Service"; log.error(msg, e); } } protected void deactivate(ComponentContext ctxt) { - log.info("Stopping the CacheInvalidationServiceComponent"); + log.info("Cache Invalidation Service stopped"); try{ if(serviceRegistration != null) { serviceRegistration.unregister(); } }catch (Exception e){ - String msg = "Failed to Stop the CacheInvalidationServiceComponent."; + String msg = "Failed to Stop the Cache Invalidation Service"; log.error(msg, e); } } diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/resources/cache.properties b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/resources/cache.properties index e3153422e..6121bb992 100644 --- a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/resources/cache.properties +++ b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/resources/cache.properties @@ -13,7 +13,7 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> -class.CacheInvalidationClass=org.wso2.carbon.registry.caching.invalidator.connection.JMSConnection +class.CacheInvalidationClass=org.wso2.carbon.registry.caching.invalidator.connection.JMSNotification initialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory providerUrl=tcp://localhost:61616 securityPrincipal=guest diff --git a/features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.feature/pom.xml b/features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.feature/pom.xml index 393ba7b07..23e12377e 100644 --- a/features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.feature/pom.xml +++ b/features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.feature/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.registry caching-invalidator-feature - 4.3.3-SNAPSHOT + 4.4.2-SNAPSHOT ../pom.xml diff --git a/features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.server.feature/pom.xml b/features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.server.feature/pom.xml index 0cfaaac5c..a248134a0 100644 --- a/features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.server.feature/pom.xml +++ b/features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.server.feature/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.registry caching-invalidator-feature - 4.3.3-SNAPSHOT + 4.4.2-SNAPSHOT ../pom.xml @@ -36,6 +36,10 @@ org.wso2.carbon.registry org.wso2.carbon.registry.caching.invalidator + + org.apache.geronimo.specs.wso2 + geronimo-jms_1.1_spec + @@ -70,14 +74,14 @@ ${carbon.p2.plugin.version} - p2-feature-generation + 4-p2-feature-generation package p2-feature-gen org.wso2.carbon.registry.caching.invalidator.server - ../feature.properties + ../../etc/feature.properties org.wso2.carbon.p2.category.type:server diff --git a/features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.server.feature/src/main/resources/conf/cache.properties b/features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.server.feature/src/main/resources/conf/cache.properties index d3e3c671a..13c7bf754 100644 --- a/features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.server.feature/src/main/resources/conf/cache.properties +++ b/features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.server.feature/src/main/resources/conf/cache.properties @@ -14,7 +14,7 @@ ~ limitations under the License. --> enabled=true -class.CacheInvalidationClass=org.wso2.carbon.registry.caching.invalidator.connection.JMSConnection +class.CacheInvalidationClass=org.wso2.carbon.registry.caching.invalidator.connection.JMSNotification initialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory providerUrl=tcp://localhost:61616 securityPrincipal=guest diff --git a/features/caching-invalidator/pom.xml b/features/caching-invalidator/pom.xml index 29b939fa8..af0413307 100644 --- a/features/caching-invalidator/pom.xml +++ b/features/caching-invalidator/pom.xml @@ -20,7 +20,7 @@ org.wso2.carbon.registry carbon-registry - 4.3.3-SNAPSHOT + 4.4.2-SNAPSHOT ../../pom.xml From 23156ff1d7398b4d5a9ee975500320074e01af03 Mon Sep 17 00:00:00 2001 From: daneshk Date: Wed, 29 Apr 2015 23:59:23 +0530 Subject: [PATCH 4/4] Set the global cache invalidation disabled by default --- .../CacheInvalidationServiceComponent.java | 2 +- .../src/main/resources/cache.properties | 1 + .../caching-invalidator/feature.properties | 217 ------------------ .../src/main/resources/conf/cache.properties | 2 +- 4 files changed, 3 insertions(+), 219 deletions(-) delete mode 100644 features/caching-invalidator/feature.properties diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/internal/CacheInvalidationServiceComponent.java b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/internal/CacheInvalidationServiceComponent.java index b373017f2..65f9bc7c8 100644 --- a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/internal/CacheInvalidationServiceComponent.java +++ b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/java/org/wso2/carbon/registry/caching/invalidator/internal/CacheInvalidationServiceComponent.java @@ -57,7 +57,7 @@ protected void activate(ComponentContext ctxt) { } protected void deactivate(ComponentContext ctxt) { - log.info("Cache Invalidation Service stopped"); + log.debug("Cache Invalidation Service stopped"); try{ if(serviceRegistration != null) { serviceRegistration.unregister(); diff --git a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/resources/cache.properties b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/resources/cache.properties index 6121bb992..10359da14 100644 --- a/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/resources/cache.properties +++ b/components/registry/org.wso2.carbon.registry.caching.invalidator/src/main/resources/cache.properties @@ -13,6 +13,7 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> +enabled=false class.CacheInvalidationClass=org.wso2.carbon.registry.caching.invalidator.connection.JMSNotification initialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory providerUrl=tcp://localhost:61616 diff --git a/features/caching-invalidator/feature.properties b/features/caching-invalidator/feature.properties deleted file mode 100644 index 915939022..000000000 --- a/features/caching-invalidator/feature.properties +++ /dev/null @@ -1,217 +0,0 @@ -################################################################################ -# Copyright 2009 WSO2, Inc. (http://wso2.com) -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -################################################################################ - -providerName=WSO2 Inc. - -########################## license properties ################################## -licenseURL=http://www.apache.org/licenses/LICENSE-2.0 - -license=\ - Apache License\n\ - Version 2.0, January 2004\n\ - http://www.apache.org/licenses/\n\ -\n\ - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\ -\n\ - 1. Definitions.\n\ -\n\ - "License" shall mean the terms and conditions for use, reproduction,\n\ - and distribution as defined by Sections 1 through 9 of this document.\n\ -\n\ - "Licensor" shall mean the copyright owner or entity authorized by\n\ - the copyright owner that is granting the License.\n\ -\n\ - "Legal Entity" shall mean the union of the acting entity and all\n\ - other entities that control, are controlled by, or are under common\n\ - control with that entity. For the purposes of this definition,\n\ - "control" means (i) the power, direct or indirect, to cause the\n\ - direction or management of such entity, whether by contract or\n\ - otherwise, or (ii) ownership of fifty percent (50%) or more of the\n\ - outstanding shares, or (iii) beneficial ownership of such entity.\n\ -\n\ - "You" (or "Your") shall mean an individual or Legal Entity\n\ - exercising permissions granted by this License.\n\ -\n\ - "Source" form shall mean the preferred form for making modifications,\n\ - including but not limited to software source code, documentation\n\ - source, and configuration files.\n\ -\n\ - "Object" form shall mean any form resulting from mechanical\n\ - transformation or translation of a Source form, including but\n\ - not limited to compiled object code, generated documentation,\n\ - and conversions to other media types.\n\ -\n\ - "Work" shall mean the work of authorship, whether in Source or\n\ - Object form, made available under the License, as indicated by a\n\ - copyright notice that is included in or attached to the work\n\ - (an example is provided in the Appendix below).\n\ -\n\ - "Derivative Works" shall mean any work, whether in Source or Object\n\ - form, that is based on (or derived from) the Work and for which the\n\ - editorial revisions, annotations, elaborations, or other modifications\n\ - represent, as a whole, an original work of authorship. For the purposes\n\ - of this License, Derivative Works shall not include works that remain\n\ - separable from, or merely link (or bind by name) to the interfaces of,\n\ - the Work and Derivative Works thereof.\n\ -\n\ - "Contribution" shall mean any work of authorship, including\n\ - the original version of the Work and any modifications or additions\n\ - to that Work or Derivative Works thereof, that is intentionally\n\ - submitted to Licensor for inclusion in the Work by the copyright owner\n\ - or by an individual or Legal Entity authorized to submit on behalf of\n\ - the copyright owner. For the purposes of this definition, "submitted"\n\ - means any form of electronic, verbal, or written communication sent\n\ - to the Licensor or its representatives, including but not limited to\n\ - communication on electronic mailing lists, source code control systems,\n\ - and issue tracking systems that are managed by, or on behalf of, the\n\ - Licensor for the purpose of discussing and improving the Work, but\n\ - excluding communication that is conspicuously marked or otherwise\n\ - designated in writing by the copyright owner as "Not a Contribution."\n\ -\n\ - "Contributor" shall mean Licensor and any individual or Legal Entity\n\ - on behalf of whom a Contribution has been received by Licensor and\n\ - subsequently incorporated within the Work.\n\ -\n\ - 2. Grant of Copyright License. Subject to the terms and conditions of\n\ - this License, each Contributor hereby grants to You a perpetual,\n\ - worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n\ - copyright license to reproduce, prepare Derivative Works of,\n\ - publicly display, publicly perform, sublicense, and distribute the\n\ - Work and such Derivative Works in Source or Object form.\n\ -\n\ - 3. Grant of Patent License. Subject to the terms and conditions of\n\ - this License, each Contributor hereby grants to You a perpetual,\n\ - worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n\ - (except as stated in this section) patent license to make, have made,\n\ - use, offer to sell, sell, import, and otherwise transfer the Work,\n\ - where such license applies only to those patent claims licensable\n\ - by such Contributor that are necessarily infringed by their\n\ - Contribution(s) alone or by combination of their Contribution(s)\n\ - with the Work to which such Contribution(s) was submitted. If You\n\ - institute patent litigation against any entity (including a\n\ - cross-claim or counterclaim in a lawsuit) alleging that the Work\n\ - or a Contribution incorporated within the Work constitutes direct\n\ - or contributory patent infringement, then any patent licenses\n\ - granted to You under this License for that Work shall terminate\n\ - as of the date such litigation is filed.\n\ -\n\ - 4. Redistribution. You may reproduce and distribute copies of the\n\ - Work or Derivative Works thereof in any medium, with or without\n\ - modifications, and in Source or Object form, provided that You\n\ - meet the following conditions:\n\ -\n\ - (a) You must give any other recipients of the Work or\n\ - Derivative Works a copy of this License; and\n\ -\n\ - (b) You must cause any modified files to carry prominent notices\n\ - stating that You changed the files; and\n\ -\n\ - (c) You must retain, in the Source form of any Derivative Works\n\ - that You distribute, all copyright, patent, trademark, and\n\ - attribution notices from the Source form of the Work,\n\ - excluding those notices that do not pertain to any part of\n\ - the Derivative Works; and\n\ -\n\ - (d) If the Work includes a "NOTICE" text file as part of its\n\ - distribution, then any Derivative Works that You distribute must\n\ - include a readable copy of the attribution notices contained\n\ - within such NOTICE file, excluding those notices that do not\n\ - pertain to any part of the Derivative Works, in at least one\n\ - of the following places: within a NOTICE text file distributed\n\ - as part of the Derivative Works; within the Source form or\n\ - documentation, if provided along with the Derivative Works; or,\n\ - within a display generated by the Derivative Works, if and\n\ - wherever such third-party notices normally appear. The contents\n\ - of the NOTICE file are for informational purposes only and\n\ - do not modify the License. You may add Your own attribution\n\ - notices within Derivative Works that You distribute, alongside\n\ - or as an addendum to the NOTICE text from the Work, provided\n\ - that such additional attribution notices cannot be construed\n\ - as modifying the License.\n\ -\n\ - You may add Your own copyright statement to Your modifications and\n\ - may provide additional or different license terms and conditions\n\ - for use, reproduction, or distribution of Your modifications, or\n\ - for any such Derivative Works as a whole, provided Your use,\n\ - reproduction, and distribution of the Work otherwise complies with\n\ - the conditions stated in this License.\n\ -\n\ - 5. Submission of Contributions. Unless You explicitly state otherwise,\n\ - any Contribution intentionally submitted for inclusion in the Work\n\ - by You to the Licensor shall be under the terms and conditions of\n\ - this License, without any additional terms or conditions.\n\ - Notwithstanding the above, nothing herein shall supersede or modify\n\ - the terms of any separate license agreement you may have executed\n\ - with Licensor regarding such Contributions.\n\ -\n\ - 6. Trademarks. This License does not grant permission to use the trade\n\ - names, trademarks, service marks, or product names of the Licensor,\n\ - except as required for reasonable and customary use in describing the\n\ - origin of the Work and reproducing the content of the NOTICE file.\n\ -\n\ - 7. Disclaimer of Warranty. Unless required by applicable law or\n\ - agreed to in writing, Licensor provides the Work (and each\n\ - Contributor provides its Contributions) on an "AS IS" BASIS,\n\ - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n\ - implied, including, without limitation, any warranties or conditions\n\ - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n\ - PARTICULAR PURPOSE. You are solely responsible for determining the\n\ - appropriateness of using or redistributing the Work and assume any\n\ - risks associated with Your exercise of permissions under this License.\n\ -\n\ - 8. Limitation of Liability. In no event and under no legal theory,\n\ - whether in tort (including negligence), contract, or otherwise,\n\ - unless required by applicable law (such as deliberate and grossly\n\ - negligent acts) or agreed to in writing, shall any Contributor be\n\ - liable to You for damages, including any direct, indirect, special,\n\ - incidental, or consequential damages of any character arising as a\n\ - result of this License or out of the use or inability to use the\n\ - Work (including but not limited to damages for loss of goodwill,\n\ - work stoppage, computer failure or malfunction, or any and all\n\ - other commercial damages or losses), even if such Contributor\n\ - has been advised of the possibility of such damages.\n\ -\n\ - 9. Accepting Warranty or Additional Liability. While redistributing\n\ - the Work or Derivative Works thereof, You may choose to offer,\n\ - and charge a fee for, acceptance of support, warranty, indemnity,\n\ - or other liability obligations and/or rights consistent with this\n\ - License. However, in accepting such obligations, You may act only\n\ - on Your own behalf and on Your sole responsibility, not on behalf\n\ - of any other Contributor, and only if You agree to indemnify,\n\ - defend, and hold each Contributor harmless for any liability\n\ - incurred by, or claims asserted against, such Contributor by reason\n\ - of your accepting any such warranty or additional liability.\n\ -\n\ - END OF TERMS AND CONDITIONS\n - -######################### copyright properties ################################# -copyrightURL=TODO - -copyright=\ -Copyright 2014 WSO2, Inc. (http://wso2.com)\n\ -\n\ -Licensed under the Apache License, Version 2.0 (the "License");\n\ -you may not use this file except in compliance with the License.\n\ -You may obtain a copy of the License at\n\ -\n\ -http://www.apache.org/licenses/LICENSE-2.0\n\ -\n\ -Unless required by applicable law or agreed to in writing, software\n\ -distributed under the License is distributed on an "AS IS" BASIS,\n\ -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n\ -See the License for the specific language governing permissions and\n\ -limitations under the License.\n - diff --git a/features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.server.feature/src/main/resources/conf/cache.properties b/features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.server.feature/src/main/resources/conf/cache.properties index 13c7bf754..10359da14 100644 --- a/features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.server.feature/src/main/resources/conf/cache.properties +++ b/features/caching-invalidator/org.wso2.carbon.registry.caching.invalidator.server.feature/src/main/resources/conf/cache.properties @@ -13,7 +13,7 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> -enabled=true +enabled=false class.CacheInvalidationClass=org.wso2.carbon.registry.caching.invalidator.connection.JMSNotification initialContextFactory=org.apache.activemq.jndi.ActiveMQInitialContextFactory providerUrl=tcp://localhost:61616