FileDocCategorySizeDatePackage
MimeMessageCopyOnWriteProxy.javaAPI DocApache James 2.3.122191Fri Jan 12 12:56:24 GMT 2007org.apache.james.core

MimeMessageCopyOnWriteProxy

public class MimeMessageCopyOnWriteProxy extends MimeMessage implements org.apache.avalon.framework.activity.Disposable
This object wraps a "possibly shared" MimeMessage tracking copies and automatically cloning it (if shared) when a write operation is invoked.

Fields Summary
protected MessageReferenceTracker
refCount
Constructors Summary
public MimeMessageCopyOnWriteProxy(MimeMessage original)

param
original MimeMessageWrapper
throws
MessagingException

        this(original, false);
    
public MimeMessageCopyOnWriteProxy(MimeMessageSource original)

param
original MimeMessageSource
throws
MessagingException

        this(new MimeMessageWrapper(original), true);
    
private MimeMessageCopyOnWriteProxy(MimeMessage original, boolean writeable)
Private constructor providing an external reference counter.

param
original
param
refCount
throws
MessagingException

        super(Session.getDefaultInstance(System.getProperties(), null));

        if (original instanceof MimeMessageCopyOnWriteProxy) {
            refCount = ((MimeMessageCopyOnWriteProxy) original).refCount;
        } else {
            refCount = new MessageReferenceTracker(original);
        }
        
        if (!writeable) {
            refCount.incrementReferenceCount();
        }
    
Methods Summary
public voidaddFrom(javax.mail.Address[] addresses)

see
javax.mail.Message#addFrom(javax.mail.Address[])

        getWrappedMessageForWriting().addFrom(addresses);
    
public voidaddHeader(java.lang.String name, java.lang.String value)

see
javax.mail.Part#addHeader(java.lang.String, java.lang.String)

        getWrappedMessageForWriting().addHeader(name, value);
    
public voidaddHeaderLine(java.lang.String line)

see
javax.mail.internet.MimePart#addHeaderLine(java.lang.String)

        getWrappedMessageForWriting().addHeaderLine(line);
    
public voidaddRecipient(RecipientType arg0, javax.mail.Address arg1)

see
javax.mail.Message#addRecipient(javax.mail.Message.RecipientType, javax.mail.Address)

        getWrappedMessageForWriting().addRecipient(arg0, arg1);
    
public voidaddRecipients(javax.mail.Message$RecipientType type, javax.mail.Address[] addresses)

see
javax.mail.Message#addRecipients(javax.mail.Message.RecipientType, javax.mail.Address[])

        getWrappedMessageForWriting().addRecipients(type, addresses);
    
public voidaddRecipients(javax.mail.Message$RecipientType type, java.lang.String addresses)

see
javax.mail.internet.MimeMessage#addRecipients(javax.mail.Message.RecipientType, java.lang.String)

        getWrappedMessageForWriting().addRecipients(type, addresses);
    
public synchronized voiddispose()

see
org.apache.avalon.framework.activity.Disposable#dispose()

        if (refCount != null) {
            refCount.decrementReferenceCount();
            refCount = null;
        }
    
public booleanequals(java.lang.Object arg0)

see
java.lang.Object#equals(java.lang.Object)

        return getWrappedMessage().equals(arg0);
    
protected voidfinalize()

see
java.lang.Object#finalize()

        dispose();
        super.finalize();
    
public java.util.EnumerationgetAllHeaderLines()

see
javax.mail.internet.MimePart#getAllHeaderLines()

        return getWrappedMessage().getAllHeaderLines();
    
public java.util.EnumerationgetAllHeaders()

see
javax.mail.Part#getAllHeaders()

        return getWrappedMessage().getAllHeaders();
    
public javax.mail.Address[]getAllRecipients()

see
javax.mail.Message#getAllRecipients()

        return getWrappedMessage().getAllRecipients();
    
public java.lang.ObjectgetContent()

see
javax.mail.Part#getContent()

        return getWrappedMessage().getContent();
    
public java.lang.StringgetContentID()

see
javax.mail.internet.MimePart#getContentID()

        return getWrappedMessage().getContentID();
    
public java.lang.String[]getContentLanguage()

see
javax.mail.internet.MimePart#getContentLanguage()

        return getWrappedMessage().getContentLanguage();
    
public java.lang.StringgetContentMD5()

see
javax.mail.internet.MimePart#getContentMD5()

        return getWrappedMessage().getContentMD5();
    
public java.lang.StringgetContentType()

see
javax.mail.Part#getContentType()

        return getWrappedMessage().getContentType();
    
public javax.activation.DataHandlergetDataHandler()

see
javax.mail.Part#getDataHandler()

        return getWrappedMessage().getDataHandler();
    
public java.lang.StringgetDescription()

see
javax.mail.Part#getDescription()

        return getWrappedMessage().getDescription();
    
public java.lang.StringgetDisposition()

see
javax.mail.Part#getDisposition()

        return getWrappedMessage().getDisposition();
    
public java.lang.StringgetEncoding()

see
javax.mail.internet.MimePart#getEncoding()

        return getWrappedMessage().getEncoding();
    
public java.lang.StringgetFileName()

see
javax.mail.Part#getFileName()

        return getWrappedMessage().getFileName();
    
public javax.mail.FlagsgetFlags()

see
javax.mail.Message#getFlags()

        return getWrappedMessage().getFlags();
    
public javax.mail.FoldergetFolder()

see
javax.mail.Message#getFolder()

        return getWrappedMessage().getFolder();
    
public javax.mail.Address[]getFrom()

see
javax.mail.Message#getFrom()

        return getWrappedMessage().getFrom();
    
public java.lang.String[]getHeader(java.lang.String name)

see
javax.mail.Part#getHeader(java.lang.String)

        return getWrappedMessage().getHeader(name);
    
public java.lang.StringgetHeader(java.lang.String name, java.lang.String delimiter)

see
javax.mail.internet.MimePart#getHeader(java.lang.String, java.lang.String)

        return getWrappedMessage().getHeader(name, delimiter);
    
public java.io.InputStreamgetInputStream()

see
javax.mail.Part#getInputStream()

        return getWrappedMessage().getInputStream();
    
public intgetLineCount()

see
javax.mail.Part#getLineCount()

        return getWrappedMessage().getLineCount();
    
public java.util.EnumerationgetMatchingHeaderLines(java.lang.String[] names)

see
javax.mail.internet.MimePart#getMatchingHeaderLines(java.lang.String[])

        return getWrappedMessage().getMatchingHeaderLines(names);
    
public java.util.EnumerationgetMatchingHeaders(java.lang.String[] names)

see
javax.mail.Part#getMatchingHeaders(java.lang.String[])

        return getWrappedMessage().getMatchingHeaders(names);
    
public java.lang.StringgetMessageID()

see
javax.mail.internet.MimeMessage#getMessageID()

        return getWrappedMessage().getMessageID();
    
public intgetMessageNumber()

see
javax.mail.Message#getMessageNumber()

        return getWrappedMessage().getMessageNumber();
    
public longgetMessageSize()

return
the message size
throws
MessagingException

        return MimeMessageUtil.getMessageSize(getWrappedMessage());
    
public java.util.EnumerationgetNonMatchingHeaderLines(java.lang.String[] names)

see
javax.mail.internet.MimePart#getNonMatchingHeaderLines(java.lang.String[])

        return getWrappedMessage().getNonMatchingHeaderLines(names);
    
public java.util.EnumerationgetNonMatchingHeaders(java.lang.String[] names)

see
javax.mail.Part#getNonMatchingHeaders(java.lang.String[])

        return getWrappedMessage().getNonMatchingHeaders(names);
    
public java.io.InputStreamgetRawInputStream()

see
javax.mail.internet.MimeMessage#getRawInputStream()

        return getWrappedMessage().getRawInputStream();
    
public java.util.DategetReceivedDate()

see
javax.mail.Message#getReceivedDate()

        return getWrappedMessage().getReceivedDate();
    
public javax.mail.Address[]getRecipients(javax.mail.Message$RecipientType type)

see
javax.mail.Message#getRecipients(javax.mail.Message.RecipientType)

        return getWrappedMessage().getRecipients(type);
    
public javax.mail.Address[]getReplyTo()

see
javax.mail.Message#getReplyTo()

        return getWrappedMessage().getReplyTo();
    
public javax.mail.AddressgetSender()

see
javax.mail.internet.MimeMessage#getSender()

        return getWrappedMessage().getSender();
    
public java.util.DategetSentDate()

see
javax.mail.Message#getSentDate()

        return getWrappedMessage().getSentDate();
    
public intgetSize()

see
javax.mail.Part#getSize()

        return getWrappedMessage().getSize();
    
public java.lang.StringgetSubject()

see
javax.mail.Message#getSubject()

        return getWrappedMessage().getSubject();
    
public javax.mail.internet.MimeMessagegetWrappedMessage()

return

        return refCount.getWrapped();
    
protected javax.mail.internet.MimeMessagegetWrappedMessageForWriting()
Check the number of references over the MimeMessage and clone it if needed before returning the reference

throws
MessagingException exception

        synchronized (refCount) {
            if (refCount.getReferenceCount() > 1) {
                refCount.decrementReferenceCount();
                refCount = new MessageReferenceTracker(new MimeMessageWrapper(refCount.getWrapped()));
            }
        }
        return refCount.getWrapped();
    
public inthashCode()

see
java.lang.Object#hashCode()

        return getWrappedMessage().hashCode();
    
public booleanisExpunged()

see
javax.mail.Message#isExpunged()

        return getWrappedMessage().isExpunged();
    
public booleanisMimeType(java.lang.String mimeType)

see
javax.mail.Part#isMimeType(java.lang.String)

        return getWrappedMessage().isMimeType(mimeType);
    
public booleanisSet(javax.mail.Flags.Flag flag)

see
javax.mail.Message#isSet(javax.mail.Flags.Flag)

        return getWrappedMessage().isSet(flag);
    
public booleanmatch(javax.mail.search.SearchTerm arg0)

see
javax.mail.Message#match(javax.mail.search.SearchTerm)

        return getWrappedMessage().match(arg0);
    
public voidremoveHeader(java.lang.String name)

see
javax.mail.Part#removeHeader(java.lang.String)

        getWrappedMessageForWriting().removeHeader(name);
    
public javax.mail.Messagereply(boolean replyToAll)
This does not need a writable message

see
javax.mail.Message#reply(boolean)

        return getWrappedMessage().reply(replyToAll);
    
public voidsaveChanges()

see
javax.mail.Message#saveChanges()

        getWrappedMessageForWriting().saveChanges();
    
public voidsetContent(java.lang.Object o, java.lang.String type)

see
javax.mail.Part#setContent(java.lang.Object, java.lang.String)

        getWrappedMessageForWriting().setContent(o, type);
    
public voidsetContent(javax.mail.Multipart mp)

see
javax.mail.Part#setContent(javax.mail.Multipart)

        getWrappedMessageForWriting().setContent(mp);
    
public voidsetContentID(java.lang.String cid)

see
javax.mail.internet.MimeMessage#setContentID(java.lang.String)

        getWrappedMessageForWriting().setContentID(cid);
    
public voidsetContentLanguage(java.lang.String[] languages)

see
javax.mail.internet.MimePart#setContentLanguage(java.lang.String[])

        getWrappedMessageForWriting().setContentLanguage(languages);
    
public voidsetContentMD5(java.lang.String md5)

see
javax.mail.internet.MimePart#setContentMD5(java.lang.String)

        getWrappedMessageForWriting().setContentMD5(md5);
    
public voidsetDataHandler(javax.activation.DataHandler dh)

see
javax.mail.Part#setDataHandler(javax.activation.DataHandler)

        getWrappedMessageForWriting().setDataHandler(dh);
    
public voidsetDescription(java.lang.String description)

see
javax.mail.Part#setDescription(java.lang.String)

        getWrappedMessageForWriting().setDescription(description);
    
public voidsetDescription(java.lang.String description, java.lang.String charset)

see
javax.mail.internet.MimeMessage#setDescription(java.lang.String, java.lang.String)

        getWrappedMessageForWriting().setDescription(description, charset);
    
public voidsetDisposition(java.lang.String disposition)

see
javax.mail.Part#setDisposition(java.lang.String)

        getWrappedMessageForWriting().setDisposition(disposition);
    
public voidsetFileName(java.lang.String filename)

see
javax.mail.Part#setFileName(java.lang.String)

        getWrappedMessageForWriting().setFileName(filename);
    
public voidsetFlag(javax.mail.Flags.Flag arg0, boolean arg1)

see
javax.mail.Message#setFlag(javax.mail.Flags.Flag, boolean)

        getWrappedMessageForWriting().setFlag(arg0, arg1);
    
public voidsetFlags(javax.mail.Flags flag, boolean set)

see
javax.mail.Message#setFlags(javax.mail.Flags, boolean)

        getWrappedMessageForWriting().setFlags(flag, set);
    
public voidsetFrom(javax.mail.Address address)

see
javax.mail.Message#setFrom(javax.mail.Address)

        getWrappedMessageForWriting().setFrom(address);
    
public voidsetFrom()

see
javax.mail.Message#setFrom()

        getWrappedMessageForWriting().setFrom();
    
public voidsetHeader(java.lang.String name, java.lang.String value)

see
javax.mail.Part#setHeader(java.lang.String, java.lang.String)

        getWrappedMessageForWriting().setHeader(name, value);
    
public voidsetRecipients(javax.mail.Message$RecipientType type, javax.mail.Address[] addresses)

see
javax.mail.Message#setRecipients(javax.mail.Message.RecipientType, javax.mail.Address[])

        getWrappedMessageForWriting().setRecipients(type, addresses);
    
public voidsetRecipients(javax.mail.Message$RecipientType type, java.lang.String addresses)

see
javax.mail.internet.MimeMessage#setRecipients(javax.mail.Message.RecipientType, java.lang.String)

        getWrappedMessageForWriting().setRecipients(type, addresses);
    
public voidsetReplyTo(javax.mail.Address[] addresses)

see
javax.mail.Message#setReplyTo(javax.mail.Address[])

        getWrappedMessageForWriting().setReplyTo(addresses);
    
public voidsetSender(javax.mail.Address arg0)

see
javax.mail.internet.MimeMessage#setSender(javax.mail.Address)

        getWrappedMessageForWriting().setSender(arg0);
    
public voidsetSentDate(java.util.Date d)

see
javax.mail.Message#setSentDate(java.util.Date)

        getWrappedMessageForWriting().setSentDate(d);
    
public voidsetSubject(java.lang.String subject)

see
javax.mail.Message#setSubject(java.lang.String)

        getWrappedMessageForWriting().setSubject(subject);
    
public voidsetSubject(java.lang.String subject, java.lang.String charset)

see
javax.mail.internet.MimeMessage#setSubject(java.lang.String, java.lang.String)

        getWrappedMessageForWriting().setSubject(subject, charset);
    
public voidsetText(java.lang.String text)

see
javax.mail.Part#setText(java.lang.String)

        getWrappedMessageForWriting().setText(text);
    
public voidsetText(java.lang.String text, java.lang.String charset)

see
javax.mail.internet.MimePart#setText(java.lang.String, java.lang.String)

        getWrappedMessageForWriting().setText(text, charset);
    
public java.lang.StringtoString()

see
java.lang.Object#toString()

        return getWrappedMessage().toString();
    
public voidwriteTo(java.io.OutputStream os)
Rewritten for optimization purposes

        getWrappedMessage().writeTo(os);
    
public voidwriteTo(java.io.OutputStream os, java.lang.String[] ignoreList)
Rewritten for optimization purposes

        getWrappedMessage().writeTo(os, ignoreList);