KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > dream > message > manager > NonExtensibleMessageManagerDebugPoolImpl


1 /**
2  * Dream
3  * Copyright (C) 2003-2004 INRIA Rhone-Alpes
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library 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 library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact: dream@objectweb.org
20  *
21  * Initial developer(s): Matthieu Leclercq
22  * Contributor(s):
23  */

24
25 package org.objectweb.dream.message.manager;
26
27 import java.util.HashSet JavaDoc;
28 import java.util.Set JavaDoc;
29
30 import org.objectweb.dream.message.Message;
31 import org.objectweb.dream.message.MessageType;
32 import org.objectweb.util.monolog.api.BasicLevel;
33
34 /**
35  * Extension of {@link NonExtensibleMessageManagerPoolImpl}that checks on every
36  * message deletion that the deleted message is not already deleted. This can be
37  * used for debug purpose.
38  */

39 public class NonExtensibleMessageManagerDebugPoolImpl
40     extends
41       NonExtensibleMessageManagerPoolImpl
42 {
43
44   Set JavaDoc deletedMessages = new HashSet JavaDoc();
45
46   /**
47    * @see NonExtensibleMessageManagerPoolImpl#deleteMessage(Message)
48    */

49   public synchronized void deleteMessage(Message message)
50   {
51     if (deletedMessages.contains(message))
52     {
53       logger.log(BasicLevel.ERROR, "Deleting message already deleted",
54           new Exception JavaDoc());
55       return;
56     }
57     super.deleteMessage(message);
58   }
59
60   /**
61    * @see org.objectweb.dream.message.manager.NonExtensibleMessageManagerPoolImpl#createMessage(org.objectweb.dream.message.MessageType)
62    */

63   public synchronized Message createMessage(MessageType type)
64       throws UnknownChunkTypeError
65   {
66     Message message = super.createMessage(type);
67     deletedMessages.remove(message);
68     return message;
69   }
70 }
Popular Tags