Java 类javax.mail.util.SharedByteArrayInputStream 实例源码

项目:alfresco-repository    文件:ImapModelMessage.java   
@Override
protected InputStream getContentStream() throws MessagingException
{
    try
    {
        if (this.contentStream == null)
        {
            if (content != null)
            {
                return new SharedByteArrayInputStream(content);
            }
            else
            {
                throw new MessagingException("No content");
            }
        }
        return this.contentStream;
    }
    catch (Exception e)
    {
        throw new MessagingException(e.getMessage(),e);
    }
}
项目:community-edition-old    文件:ImapModelMessage.java   
@Override
protected InputStream getContentStream() throws MessagingException
{
    try
    {
        if (this.contentStream == null)
        {
            if (content != null)
            {
                return new SharedByteArrayInputStream(content);
            }
            else
            {
                throw new MessagingException("No content");
            }
        }
        return this.contentStream;
    }
    catch (Exception e)
    {
        throw new MessagingException(e.getMessage(),e);
    }
}
项目:MailsterSMTP    文件:SharedStreamUtils.java   
/**
 * Provides a private unstuffed {@link InputStream} for each invocation unless
 * <code>useCopy</code> is false in which case the <code>data</code> stream
 * is unstuffed and returned. Unstuffing is made by encapsulating the stream within
 * special streams.
 * 
 * @see org.mailster.smtp.util.CharTerminatedInputStream
 * @see org.mailster.smtp.util.DotUnstuffingInputStream
 */
public static InputStream getPrivateInputStream(boolean useCopy, InputStream data)
{
    InputStream in = data;

    if (useCopy)
    {
        if (data instanceof SharedByteArrayInputStream)
            in = ((SharedByteArrayInputStream) data).newStream(0, -1);
        else
        if (data instanceof SharedTmpFileInputStream)
            in = ((SharedTmpFileInputStream) data).newStream(0, -1);
        else
            throw new IllegalArgumentException("Unexpected data stream type : "
                    +data.getClass().getName());
    }

    in = new CharTerminatedInputStream(in, SMTP_TERMINATOR);
    in = new DotUnstuffingInputStream(in);

    return in;
}
项目:arquillian-extension-mail-master    文件:DefaultMailTestUtil.java   
/**
 * Clones the <code>Message</code>. This is a workaround as documented here: http://www.oracle.com/technetwork/java/javamail/faq/index.html#imapserverbug.
 * The internal Greenmail server is not supporting newer versions of the mail protocol.
 * @param session
 * @param n
 * @return
 * @throws MessagingException
 * @throws IOException
 */
private MimeMessage copy(final Session session, final Message n) throws MessagingException, IOException {
    final MimeMessage msg = (MimeMessage)n;
    final ByteArrayOutputStream bos = new ByteArrayOutputStream();
    msg.writeTo(bos);
    bos.close();
    final SharedByteArrayInputStream bis = new SharedByteArrayInputStream(bos.toByteArray());
    final MimeMessage cmsg = new MimeMessage(session, bis);
    bis.close();
    return cmsg;
}
项目:James    文件:AbstractMailRepositoryTest.java   
protected void setUp() throws Exception {
    super.setUp();
    mailRepository = getMailRepository();
    MimeMessageInputStreamSource mmis = null;
    try {
        mmis = new MimeMessageInputStreamSource("test", new SharedByteArrayInputStream((content + sep + body).getBytes()));
    } catch (MessagingException e) {
    }
    mimeMessage = new MimeMessageCopyOnWriteProxy(mmis);
    Collection<MailAddress> recipients = new ArrayList<MailAddress>();
    recipients.add(new MailAddress("rec1", "domain.com"));
    recipients.add(new MailAddress("rec2", "domain.com"));
    mail = new MailImpl("mail1", new MailAddress("sender", "domain.com"), recipients, mimeMessage);
    mail.setAttribute("testAttribute", "testValue");
}
项目:James    文件:MimeMessageWrapperTest.java   
protected MimeMessage getMessageFromSources(String sources) throws Exception {
    MimeMessageInputStreamSource mmis = null;
    try {
        mmis = new MimeMessageInputStreamSource("test", new SharedByteArrayInputStream(sources.getBytes()));
    } catch (MessagingException e) {
    }
    return new TestableMimeMessageWrapper(mmis);
}
项目:James    文件:MimeMessageCopyOnWriteProxyTest.java   
protected MimeMessage getMessageFromSources(String sources) throws Exception {
    MimeMessageInputStreamSource mmis = null;
    try {
        mmis = new MimeMessageInputStreamSource("test", new SharedByteArrayInputStream(sources.getBytes()));
    } catch (MessagingException e) {
    }
    return new MimeMessageCopyOnWriteProxy(mmis);
    // return new MimeMessage(Session.getDefaultInstance(new
    // Properties()),new ByteArrayInputStream(sources.getBytes()));
}
项目:MailsterSMTP    文件:SMTPDecoderContext.java   
/** */
protected InputStream getNewInputStream() throws IOException
{       
    if (this.thresholdReached)
        return new SharedTmpFileInputStream(this.outFile);
    else
        return new SharedByteArrayInputStream(asArray(this.buf));
}
项目:James    文件:MimeMessageObjectMessageSource.java   
public MimeMessageObjectMessageSource(ObjectMessage message) throws JMSException {
    this.message = message;
    this.id = message.getJMSMessageID();
    this.content = (byte[]) message.getObject();
    in = new SharedByteArrayInputStream(content);
}
项目:James    文件:MimeMessageFromSharedStreamTest.java   
protected MimeMessage getMessageFromSources(String sources) throws Exception {
    return new MimeMessage(Session.getDefaultInstance(new Properties()), new SharedByteArrayInputStream(sources.getBytes()));
}