org.apache.james.core
Class MimeMessageInputStreamSource

java.lang.Object
  |
  +--org.apache.james.core.MimeMessageSource
        |
        +--org.apache.james.core.MimeMessageInputStreamSource
All Implemented Interfaces:
Disposable

public class MimeMessageInputStreamSource
extends MimeMessageSource
implements 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.

Author:
Serge Knystautas
See Also:
MimeMessageWrapper

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

Constructor Detail

MimeMessageInputStreamSource

public MimeMessageInputStreamSource(String key,
                                    InputStream in)
                             throws 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:
MessagingException - if an error occurs while trying to store the stream
Method Detail

getSourceId

public 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 InputStream getInputStream()
                           throws 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:
IOException - if an error occurs while generating the InputStream

getMessageSize

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

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

dispose

public void dispose()
Specified by:
dispose in interface Disposable
See Also:
Disposable.dispose()

finalize

public void finalize()

Finalizer that closes and deletes the temp file. Very bad.

We're leaving this in temporarily, while also establishing a more formal mechanism for cleanup through use of the dispose() method.

Overrides:
finalize in class Object


"Copyright © 1999-2002 Apache Jakarta Project. All Rights Reserved."