org.semanticdesktop.aperture.crawler.mail.base
Class MessageDataObjectBase

java.lang.Object
  extended by org.semanticdesktop.aperture.accessor.base.DataObjectBase
      extended by org.semanticdesktop.aperture.crawler.mail.base.MessageDataObjectBase
All Implemented Interfaces:
DataObject, MessageDataObject

public class MessageDataObjectBase
extends DataObjectBase
implements MessageDataObject

A trivial default implementation of a MessageDataObject.

This implementation needs an ExecutorService in order to work properly. Here's an explanation why is it so:.

  1. The requirement was to get a stream of bytes EXACTLY as they appear in an .eml file, with ALL headers and such
  2. there is no way to get the raw bytes of the message with all headers
    - getRawInputStream returns the raw input stream of the CONTENT
    - getContentStream obviously returns the CONTENT input stream, converted to 'intended' byte values according to the "Content-Transfer-Encoding" header if such header is present
    - tried subclassing the MimeMessage to fool java into giving me access to the protected byte[] content field, but java won't do it
  3. I don't want to copy the message content for each MessageDataObject because it the memory consumption will skyrocket
  4. The only method that returns the desired data is writeTo, but it accepts an OutputStream, while I need to return an InputStream, that's why I need to use PipedInputStream and PipedOutputStream, the writeTo method has to be invoked by a separate thread, so that the client can read from the returned input stream
  5. I don't want to create a separate thread for each new MessageDataObjectBase instance, because performance will suck, therefore a shared thread pool with pre-created threads is a much better idea


Constructor Summary
MessageDataObjectBase(URI id, DataSource dataSource, RDFContainer metadata, javax.mail.internet.MimeMessage message)
          Constructor accepting a message.
 
Method Summary
 javax.mail.internet.MimeMessage getMimeMessage()
          Gets an instance of the MimeMessage encapsulated by this DataObject.
 void setMimeMessage(javax.mail.internet.MimeMessage message)
          Sets the MimeMessage that is to be encapsulated by this DataObject.
 
Methods inherited from class org.semanticdesktop.aperture.accessor.base.DataObjectBase
dispose, finalize, getDataSource, getID, getMetadata, getWrappedDataObject, isDisposed, setDataSource, setID, setMetadata, setWrappedDataObject
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.semanticdesktop.aperture.accessor.DataObject
dispose, getDataSource, getID, getMetadata
 

Constructor Detail

MessageDataObjectBase

public MessageDataObjectBase(URI id,
                             DataSource dataSource,
                             RDFContainer metadata,
                             javax.mail.internet.MimeMessage message)
Constructor accepting a message. It will use an exclusive single-thread executor service. Therefore when you create a MessageDataObjectBase instance with this constructor and then call getContent() on it a new thread will be created. It may incur a significant performance overhead. Wherever feasible, please set up a shared executor service and use the other constructor instead.

Parameters:
id - URI of the data object (obligatory)
dataSource - the data source where this data object came from (optional)
metadata - the metadata for this data object (optional)
message - the MimeMessage
Method Detail

setMimeMessage

public void setMimeMessage(javax.mail.internet.MimeMessage message)
Description copied from interface: MessageDataObject
Sets the MimeMessage that is to be encapsulated by this DataObject.

Specified by:
setMimeMessage in interface MessageDataObject
Parameters:
message - the MimeMessage to set

getMimeMessage

public javax.mail.internet.MimeMessage getMimeMessage()
Description copied from interface: MessageDataObject
Gets an instance of the MimeMessage encapsulated by this DataObject.

Specified by:
getMimeMessage in interface MessageDataObject
Returns:
an instance of the MimeMessage encapsulated by this MessageDataObject


Copyright © 2010 Aperture Development Team. All Rights Reserved.