org.nlab.smtp.pool.SmtpConnectionPool Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of smtp-connection-pool Show documentation
Show all versions of smtp-connection-pool Show documentation
SMTP Connection Pool which uses JavaMail and Apache Common Pool
package org.nlab.smtp.pool;
import org.apache.commons.pool2.impl.AbandonedConfig;
import org.apache.commons.pool2.impl.GenericObjectPool;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import org.nlab.smtp.transport.ClosableSmtpConnection;
import org.nlab.smtp.transport.SmtpConnectionFactory;
/**
* Created by nlabrot on 30/04/15.
*/
public class SmtpConnectionPool extends GenericObjectPool {
public SmtpConnectionPool(SmtpConnectionFactory factory) {
super(factory);
}
public SmtpConnectionPool(SmtpConnectionFactory factory, GenericObjectPoolConfig config) {
super(factory, config);
}
public SmtpConnectionPool(SmtpConnectionFactory factory, GenericObjectPoolConfig config, AbandonedConfig abandonedConfig) {
super(factory, config, abandonedConfig);
}
@Override
public ClosableSmtpConnection borrowObject() throws Exception {
ClosableSmtpConnection object = super.borrowObject();
if (object instanceof ObjectPoolAware) {
((ObjectPoolAware) object).setObjectPool(this);
}
return object;
}
@Override
public ClosableSmtpConnection borrowObject(long borrowMaxWaitMillis) throws Exception {
ClosableSmtpConnection object = super.borrowObject(borrowMaxWaitMillis);
if (object instanceof ObjectPoolAware) {
((ObjectPoolAware) object).setObjectPool(this);
}
return object;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy