com.zx.sms.connect.manager.CMPPEndpointManager Maven / Gradle / Ivy
package com.zx.sms.connect.manager;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import com.zx.sms.connect.manager.cmpp.CMPPEndpointEntity;
import com.zx.sms.connect.manager.cmpp.CMPPServerChildEndpointEntity;
import com.zx.sms.connect.manager.cmpp.CMPPServerEndpointEntity;
import com.zx.sms.connect.manager.smpp.SMPPServerChildEndpointEntity;
public enum CMPPEndpointManager implements EndpointManagerInterface {
INS;
private EndpointManager manager = EndpointManager.INS;
private ConcurrentHashMap> groupMap = new ConcurrentHashMap>();
@Override
public void openEndpoint(EndpointEntity entity) {
manager.openEndpoint(entity);
}
@Override
public void close(EndpointEntity entity) {
manager.close(entity);
}
@Override
public void openAll() throws Exception {
manager.openAll();
}
public void addEndpointEntity(EndpointEntity entity) {
manager.addEndpointEntity(entity);
// 端口按group分组,方便按省份转发处理
if (entity instanceof CMPPEndpointEntity) {
CMPPEndpointEntity cmppentity = (CMPPEndpointEntity) entity;
List list = groupMap.get(cmppentity.getGroupName());
if (list == null) {
list = new ArrayList();
List old = groupMap.putIfAbsent(cmppentity.getGroupName(), list);
list = old == null ? list : old;
}
list.add(cmppentity);
}
}
@Override
public Set allEndPointEntity() {
return manager.allEndPointEntity();
}
public List getEndPointEntityByGroup(String group) {
return groupMap.get(group);
}
@Override
public EndpointConnector getEndpointConnector(EndpointEntity entity) {
return manager.getEndpointConnector(entity);
}
public EndpointConnector getEndpointConnector(String entityId) {
return manager.getEndpointConnector(entityId);
}
@Override
public void remove(String id) {
manager.remove(id);
}
@Override
public EndpointEntity getEndpointEntity(String id) {
return manager.getEndpointEntity(id);
}
public void addAllEndpointEntity(List entities) {
if (entities == null || entities.size() == 0)
return;
for (EndpointEntity entity : entities) {
if (entity.isValid())
addEndpointEntity(entity);
}
}
public void close() {
manager.close();
}
@Override
public void startConnectionCheckTask() {
manager.startConnectionCheckTask();
}
@Override
public void stopConnectionCheckTask() {
manager.stopConnectionCheckTask();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy