1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.mail.internal.thread

File AbstractMailQueueManager.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
5
5
1
71
31
5
1
1
5
1

Classes

Class Line # Actions
AbstractMailQueueManager 32 5 0% 5 0
1.0100%
 

Contributing tests

This file is covered by 10 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.mail.internal.thread;
21   
22    import java.util.Queue;
23    import java.util.concurrent.ConcurrentLinkedQueue;
24   
25    /**
26    * Handles all operations on the Mail Queues.
27    *
28    * @version $Id: 2b089c145c3ceb4b1d420d42e140314142143375 $
29    * @since 6.4
30    * @param <T> the type of the Mail Queue Item managed by the Queue Manager
31    */
 
32    public abstract class AbstractMailQueueManager<T extends MailQueueItem> implements MailQueueManager<T>
33    {
34    /**
35    * The Mail queue that the mail sender thread will use to send mails. We use a separate thread to allow sending
36    * mail asynchronously.
37    */
38    private Queue<T> mailQueue = new ConcurrentLinkedQueue<>();
39   
40    /**
41    * @return the mail queue containing all pending mails to be sent
42    */
 
43  12698 toggle private Queue<T> getMailQueue()
44    {
45  12698 return this.mailQueue;
46    }
47   
 
48  65 toggle @Override
49    public void addToQueue(T mailQueueItem)
50    {
51  65 getMailQueue().add(mailQueueItem);
52    }
53   
 
54  12503 toggle @Override
55    public boolean hasMessage()
56    {
57  12503 return !getMailQueue().isEmpty();
58    }
59   
 
60  65 toggle @Override
61    public T peekMessage()
62    {
63  65 return getMailQueue().peek();
64    }
65   
 
66  65 toggle @Override
67    public boolean removeMessageFromQueue(T mailQueueItem)
68    {
69  65 return getMailQueue().remove(mailQueueItem);
70    }
71    }