org.apache.james.core
Class MimeMessageInputStreamSource

java.lang.Object
  extended by org.apache.james.core.MimeMessageSource
      extended by org.apache.james.core.MimeMessageInputStreamSource
All Implemented Interfaces:
org.apache.avalon.framework.activity.Disposable

public class MimeMessageInputStreamSource
extends MimeMessageSource
implements org.apache.avalon.framework.activity.Disposable

Takes an input stream and creates a repeatable input stream source for a MimeMessageWrapper. It does this by completely reading the input stream and saving that to a temporary file that should delete on exit, or when this object is GC'd.

See Also:
MimeMessageWrapper

Constructor Summary
MimeMessageInputStreamSource(java.lang.String key, java.io.InputStream in)
          Construct a new MimeMessageInputStreamSource from an InputStream that contains the bytes of a MimeMessage.
 
Method Summary
 void dispose()
           
 java.io.InputStream getInputStream()
          Get an input stream to retrieve the data stored in the temporary file
 long getMessageSize()
          Get the size of the temp file
 java.lang.String getSourceId()
          Returns the unique identifier of this input stream source
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MimeMessageInputStreamSource

public MimeMessageInputStreamSource(java.lang.String key,
                                    java.io.InputStream in)
                             throws javax.mail.MessagingException
Construct a new MimeMessageInputStreamSource from an InputStream that contains the bytes of a MimeMessage.

Parameters:
key - the prefix for the name of the temp file
in - the stream containing the MimeMessage
Throws:
javax.mail.MessagingException - if an error occurs while trying to store the stream
Method Detail

getSourceId

public java.lang.String getSourceId()
Returns the unique identifier of this input stream source

Specified by:
getSourceId in class MimeMessageSource
Returns:
the unique identifier for this MimeMessageInputStreamSource

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Get an input stream to retrieve the data stored in the temporary file

Specified by:
getInputStream in class MimeMessageSource
Returns:
a BufferedInputStream containing the data
Throws:
java.io.IOException - if an error occurs while generating the InputStream

getMessageSize

public long getMessageSize()
                    throws java.io.IOException
Get the size of the temp file

Overrides:
getMessageSize in class MimeMessageSource
Returns:
the size of the temp file
Throws:
java.io.IOException - if an error is encoutered while computing the size of the message

dispose

public void dispose()
Specified by:
dispose in interface org.apache.avalon.framework.activity.Disposable
See Also:
Disposable.dispose()


Copyright ? 2002-2009 The Apache Software Foundation. All Rights Reserved.