shuber      2004/08/20 20:11:41 CEST

  Modified files:
    core/src/java/org/jahia/services/cache Cache.java 
                                           JMSHubConsumer.java 
  Log:
  Hopefully this help interlock problems.
  
  Revision  Changes    Path
  1.7       +8 -4      jahia/core/src/java/org/jahia/services/cache/Cache.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/cache/Cache.java.diff?r1=1.6&r2=1.7&f=h
  1.7       +13 -13    jahia/core/src/java/org/jahia/services/cache/JMSHubConsumer.java
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/jahia/core/src/java/org/jahia/services/cache/JMSHubConsumer.java.diff?r1=1.6&r2=1.7&f=h
  
  
  
  Index: Cache.java
  ===================================================================
  RCS file: /cvs/jahia/core/src/java/org/jahia/services/cache/Cache.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Cache.java        20 Aug 2004 17:17:10 -0000      1.6
  +++ Cache.java        20 Aug 2004 18:11:41 -0000      1.7
  @@ -275,7 +275,7 @@
        * Set it to false it you want to update the cache ONLY locally, for example
        * when implementing a cache listener method.
        */
  -    public synchronized void putCacheEntry (Object entryKey, CacheEntry entry, 
boolean propagate) {
  +    public void putCacheEntry (Object entryKey, CacheEntry entry, boolean 
propagate) {
   
           internalPut(entryKey, entry);
   
  @@ -286,7 +286,7 @@
           }
       }
   
  -    private boolean internalPut (Object entryKey, CacheEntry entry) {
  +    private synchronized boolean internalPut (Object entryKey, CacheEntry entry) {
           if ((entryKey == null) || (entry == null)) {
               logger.debug ("null cache entry key or entry object, cannot cache such 
an object!");
               return false;
  @@ -358,7 +358,7 @@
        *
        * @param entryKey  the cache entry key, <code>null</code> is not allowed
        */
  -    public synchronized void remove (Object entryKey) {
  +    public void remove (Object entryKey) {
           internalRemove (entryKey);
   
           // Create the removal message if needed
  @@ -415,14 +415,16 @@
       /** <p>Flushs all the cache entries. When <code>sendToListeners</code> is
        * <code>true</code>, the event is send to the cache's listeners.</p>
        */
  -    public synchronized void flush(boolean propagate) {
  +    public void flush(boolean propagate) {
   
  +        synchronized (this) {
           // clears the cache
           cache.clear();
   
           // reset the cache statistics
           successHitCount = 0;
           totalHitCount = 0;
  +        }
   
           logger.debug("Flushed all entries from cache [" + name + "]");
   
  @@ -605,7 +607,9 @@
               return;
   
           // remove the object from the cache
  +        synchronized (this) {
           cache.remove (entryKey);
  +        }
           logger.debug ("Removed the entry [" + entryKey.toString () +
                         "] from cache [" + name + "]!");
       }
  
  
  
  Index: JMSHubConsumer.java
  ===================================================================
  RCS file: /cvs/jahia/core/src/java/org/jahia/services/cache/JMSHubConsumer.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JMSHubConsumer.java       13 Aug 2004 17:36:28 -0000      1.6
  +++ JMSHubConsumer.java       20 Aug 2004 18:11:41 -0000      1.7
  @@ -68,14 +68,12 @@
       /** references to the caches. */
       private Hashtable caches;
   
  +    private String hubClientID;
  +    private CacheFactory cacheFactory;
  +
       /** the consumer connection to the server. */
       private TopicSubscriber topicSubscriber;
   
  -    /** the reference to the <code>JMSHub</code>. */
  -    private JMSHub jmsHub;
  -
  -
  -
       /** Default constructor, creates a new <code>JMSHubConsumer</code> instance.*/
       public JMSHubConsumer () {
           // instanciate the caches hashtable
  @@ -103,18 +101,19 @@
                       "Cannot initialize the JMS Message Consumer with a null JMSHub 
instance!");
           }
   
  -        // keep track of the hub reference
  -        jmsHub = hub;
  +        cacheFactory = hub.getCacheFactory();
   
           // Initialize the subscription to the related topic
           try {
  +            hubClientID = hub.getTopicConnection().getClientID();
  +
               // get the subscriber instance from the session
  -            topicSubscriber = jmsHub.getTopicSession().createSubscriber (
  -                    jmsHub.getTopic(), null, false);
  +            topicSubscriber = hub.getTopicSession().createSubscriber (
  +                    hub.getTopic(), null, false);
               if (topicSubscriber != null) {
                   topicSubscriber.setMessageListener (this);
                   logger.debug ("JMS Hub successfully set as a listenenr on topic ["+
  -                        jmsHub.getTopic().toString() +"]");
  +                        hub.getTopic().toString() +"]");
   
               } else {
                   throw new JahiaInitializationException(
  @@ -153,7 +152,7 @@
               // check if the received message was not been sent by this client
               String clientID = msg.getString (JMSCacheMessage.CLIENT_KEY);
               if (clientID != null) {
  -                if (clientID.equals (jmsHub.getTopicConnection().getClientID())) {
  +                if (clientID.equals (hubClientID)) {
                       logger.debug("ignoring message, cyclic message!");
                        return;
                   }
  @@ -273,7 +272,7 @@
               logger.debug("Cache ["+ cacheName +"] is not registered in the JMS Hub. 
Try to register it");
   
               // Retrieve the cache from the Cache Factory
  -            cache = jmsHub.getCacheFactory().getCache (cacheName);
  +            cache = cacheFactory.getCache (cacheName);
               if (cache != null) {
                   caches.put (cache.getName(), cache);
   
  @@ -320,7 +319,8 @@
           } finally {
               // let's kill definitively the beast
               topicSubscriber = null;
  -            jmsHub = null;
  +            cacheFactory = null;
  +            hubClientID = null;
           }
       }
   }
  \ No newline at end of file
  

Reply via email to