Coverage Report - org.mule.util.queue.CachingPersistenceStrategy
 
Classes in this File Line Coverage Branch Coverage Complexity
CachingPersistenceStrategy
0%
0/18
N/A
1
 
 1  
 /*
 2  
  * $Id: CachingPersistenceStrategy.java 7976 2007-08-21 14:26:13Z dirk.olmes $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
 5  
  *
 6  
  * The software in this package is published under the terms of the CPAL v1.0
 7  
  * license, a copy of which has been included with this distribution in the
 8  
  * LICENSE.txt file.
 9  
  */
 10  
 
 11  
 package org.mule.util.queue;
 12  
 
 13  
 import java.io.IOException;
 14  
 import java.util.Collections;
 15  
 import java.util.List;
 16  
 import java.util.Map;
 17  
 
 18  
 import org.apache.commons.collections.map.ReferenceMap;
 19  
 
 20  
 public class CachingPersistenceStrategy implements QueuePersistenceStrategy
 21  
 {
 22  
 
 23  
     private QueuePersistenceStrategy ps;
 24  
     private Map objects;
 25  
 
 26  
     public CachingPersistenceStrategy(QueuePersistenceStrategy ps)
 27  0
     {
 28  0
         this.ps = ps;
 29  0
         this.objects = Collections.synchronizedMap(new ReferenceMap());
 30  0
     }
 31  
 
 32  
     public void open() throws IOException
 33  
     {
 34  0
         ps.open();
 35  0
     }
 36  
 
 37  
     public void close() throws IOException
 38  
     {
 39  0
         objects.clear();
 40  0
         ps.close();
 41  0
     }
 42  
 
 43  
     public Object load(String queue, Object id) throws IOException
 44  
     {
 45  
         // XXX: is this something wanted as a check?
 46  
         // Object obj = objects.get(id);
 47  0
         return ps.load(queue, id);
 48  
     }
 49  
 
 50  
     public void remove(String queue, Object id) throws IOException
 51  
     {
 52  0
         objects.remove(id);
 53  0
         ps.remove(queue, id);
 54  0
     }
 55  
 
 56  
     public List restore() throws IOException
 57  
     {
 58  0
         return ps.restore();
 59  
     }
 60  
 
 61  
     public Object store(String queue, Object obj) throws IOException
 62  
     {
 63  0
         Object id = ps.store(queue, obj);
 64  0
         objects.put(id, obj);
 65  0
         return id;
 66  
     }
 67  
 
 68  
     public boolean isTransient()
 69  
     {
 70  0
         return ps.isTransient();
 71  
     }
 72  
 }