net.dopan.fastdfs.client.TrackerServerFactory Maven / Gradle / Ivy
package net.dopan.fastdfs.client;
import net.dopan.fastdfs.client.core.TrackerClient;
import net.dopan.fastdfs.client.core.TrackerServer;
import org.apache.commons.pool2.BasePooledObjectFactory;
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
/**
* TrackerServer 工厂类,创建对象池需要 BasePooledObjectFactory 对象或子类
* 2018/8/3 15:35
* @author: 刘宽
*/
public class TrackerServerFactory extends BasePooledObjectFactory {
@Override
public TrackerServer create() throws Exception {
// TrackerClient
TrackerClient trackerClient = new TrackerClient();
// TrackerServer
TrackerServer trackerServer = trackerClient.getConnection();
return trackerServer;
}
@Override
public PooledObject wrap(TrackerServer trackerServer) {
return new DefaultPooledObject(trackerServer);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy