Coverage Report - org.mule.util.queue.MemoryPersistenceStrategy
 
Classes in this File Line Coverage Branch Coverage Complexity
MemoryPersistenceStrategy
0%
0/15
0%
0/2
1.25
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.util.queue;
 8  
 
 9  
 import org.mule.util.UUID;
 10  
 
 11  
 import java.io.IOException;
 12  
 import java.util.ArrayList;
 13  
 import java.util.Collections;
 14  
 import java.util.HashMap;
 15  
 import java.util.List;
 16  
 import java.util.Map;
 17  
 
 18  
 
 19  0
 public class MemoryPersistenceStrategy implements QueuePersistenceStrategy
 20  
 {
 21  0
     private Map map = Collections.synchronizedMap(new HashMap());
 22  
 
 23  
     protected Object getId(Object obj)
 24  
     {
 25  0
         return UUID.getUUID();
 26  
     }
 27  
 
 28  
     public Object store(String queue, Object obj) throws IOException
 29  
     {
 30  0
         if (obj == null)
 31  
         {
 32  0
             throw new IllegalArgumentException("Cannot store null object.");
 33  
         }
 34  0
         Object id = getId(obj);
 35  0
         map.put(id, obj);
 36  0
         return id;
 37  
     }
 38  
 
 39  
     public Object load(String queue, Object id) throws IOException
 40  
     {
 41  0
         return map.get(id);
 42  
     }
 43  
 
 44  
     public void remove(String queue, Object id) throws IOException
 45  
     {
 46  0
         map.remove(id);
 47  0
     }
 48  
 
 49  
     public List restore() throws IOException
 50  
     {
 51  0
         return new ArrayList();
 52  
     }
 53  
 
 54  
     public void open() throws IOException
 55  
     {
 56  
         // nothing to do
 57  0
     }
 58  
 
 59  
     public void close() throws IOException
 60  
     {
 61  
         // nothing to do
 62  0
     }
 63  
 
 64  
     public boolean isTransient()
 65  
     {
 66  0
         return true;
 67  
     }
 68  
 }