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  
  * $Id: MemoryPersistenceStrategy.java 19191 2010-08-25 21:05:23Z tcarlson $
 3  
  * --------------------------------------------------------------------------------------
 4  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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 org.mule.util.UUID;
 14  
 
 15  
 import java.io.IOException;
 16  
 import java.util.ArrayList;
 17  
 import java.util.Collections;
 18  
 import java.util.HashMap;
 19  
 import java.util.List;
 20  
 import java.util.Map;
 21  
 
 22  
 
 23  0
 public class MemoryPersistenceStrategy implements QueuePersistenceStrategy
 24  
 {
 25  0
     private Map map = Collections.synchronizedMap(new HashMap());
 26  
 
 27  
     protected Object getId(Object obj)
 28  
     {
 29  0
         return UUID.getUUID();
 30  
     }
 31  
 
 32  
     public Object store(String queue, Object obj) throws IOException
 33  
     {
 34  0
         if (obj == null)
 35  
         {
 36  0
             throw new IllegalArgumentException("Cannot store null object.");
 37  
         }
 38  0
         Object id = getId(obj);
 39  0
         map.put(id, obj);
 40  0
         return id;
 41  
     }
 42  
 
 43  
     public Object load(String queue, Object id) throws IOException
 44  
     {
 45  0
         return map.get(id);
 46  
     }
 47  
 
 48  
     public void remove(String queue, Object id) throws IOException
 49  
     {
 50  0
         map.remove(id);
 51  0
     }
 52  
 
 53  
     public List restore() throws IOException
 54  
     {
 55  0
         return new ArrayList();
 56  
     }
 57  
 
 58  
     public void open() throws IOException
 59  
     {
 60  
         // nothing to do
 61  0
     }
 62  
 
 63  
     public void close() throws IOException
 64  
     {
 65  
         // nothing to do
 66  0
     }
 67  
 
 68  
     public boolean isTransient()
 69  
     {
 70  0
         return true;
 71  
     }
 72  
 }