com.calfater.mailcarbon.impl.manager.message
Class MessageManager

java.lang.Object
  extended by com.calfater.mailcarbon.impl.manager.message.MessageManager
All Implemented Interfaces:
IMessageManager

public class MessageManager
extends java.lang.Object
implements IMessageManager

The Class MessageManager.

Author:
sebastien borie

Constructor Summary
MessageManager(int maxAttempts)
          Constructor.
 
Method Summary
 boolean canProcess(javax.mail.Message message)
          Ask the MessageManager to lock the resource if the message can be processed.
 void clear()
          Clear the list of already copied messages
 void done(javax.mail.Message message)
          Tells the MessageManager that the message is successfully copied and remove thread lock.
 void failed(javax.mail.Message message)
          Tells the MessageManager that an error occurred while copying the message and free the message's thread lock.
 boolean failedTooManyTimes(javax.mail.Message message)
          Ask the MessageManager if a message failled too many times to copy.
 int getFailledCount(javax.mail.Message message)
          Get the number of failed attempts.
 int getMaxAttempts()
          Gets the max attempts.
 java.util.List<java.lang.String> getMessages()
          Gets the messages.
 void setMessages(java.util.List<java.lang.String> messageList)
          Sets the messages.
protected  java.lang.String uniqueId(javax.mail.Message message)
          Generate a unique message id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MessageManager

public MessageManager(int maxAttempts)
Constructor.

Parameters:
maxAttempts - number of attempts before to consider a message as invalid.
Method Detail

canProcess

public boolean canProcess(javax.mail.Message message)
Description copied from interface: IMessageManager
Ask the MessageManager to lock the resource if the message can be processed. A message can be processed if it has not been already copied, no thread use it, it doesn't failed to copy too many times.

Specified by:
canProcess in interface IMessageManager
Parameters:
message - the message
Returns:
if the message can be processed (and is locked)

done

public void done(javax.mail.Message message)
Description copied from interface: IMessageManager
Tells the MessageManager that the message is successfully copied and remove thread lock.

Specified by:
done in interface IMessageManager
Parameters:
message - A copied message.

failed

public void failed(javax.mail.Message message)
Description copied from interface: IMessageManager
Tells the MessageManager that an error occurred while copying the message and free the message's thread lock.

Specified by:
failed in interface IMessageManager
Parameters:
message - the message

failedTooManyTimes

public boolean failedTooManyTimes(javax.mail.Message message)
Description copied from interface: IMessageManager
Ask the MessageManager if a message failled too many times to copy.

Specified by:
failedTooManyTimes in interface IMessageManager
Parameters:
message - the message
Returns:
if the message filled too many time to copy.

getMessages

public final java.util.List<java.lang.String> getMessages()
Description copied from interface: IMessageManager
Gets the messages.

Specified by:
getMessages in interface IMessageManager
Returns:
the list of successfully copied messages

setMessages

public final void setMessages(java.util.List<java.lang.String> messageList)
Description copied from interface: IMessageManager
Sets the messages.

Specified by:
setMessages in interface IMessageManager
Parameters:
messageList - the list of successfully copied messages

getMaxAttempts

public int getMaxAttempts()
Description copied from interface: IMessageManager
Gets the max attempts.

Specified by:
getMaxAttempts in interface IMessageManager
Returns:
the max attempts before a message is marked as skiped

clear

public void clear()
Description copied from interface: IMessageManager
Clear the list of already copied messages

Specified by:
clear in interface IMessageManager

getFailledCount

public int getFailledCount(javax.mail.Message message)
Get the number of failed attempts. O if any. 0 means both that the message have already been copied without error or the message has never been copied.

Parameters:
message - the message
Returns:
fail's message count

uniqueId

protected java.lang.String uniqueId(javax.mail.Message message)
Generate a unique message id.

Parameters:
message -
Returns:
id


Copyright © 2010. All Rights Reserved.