All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.mizhousoft.boot.sms.service.impl.SmsTemplateContainerImpl Maven / Gradle / Ivy

There is a newer version: 2.0.2
Show newest version
package com.mizhousoft.boot.sms.service.impl;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.mizhousoft.cloudsdk.sms.CloudSmsTemplate;
import com.mizhousoft.cloudsdk.sms.SmsTemplateContainer;

/**
 * 短信模板容器
 *
 * @version
 */
@Service
public class SmsTemplateContainerImpl implements SmsTemplateContainer
{
	private static final Logger LOG = LoggerFactory.getLogger(SmsTemplateContainerImpl.class);

	// 
	private Map templateMap = new ConcurrentHashMap<>(10);

	/**
	 * {@inheritDoc}
	 */
	@Override
	public CloudSmsTemplate getByTemplateCode(String templateCode)
	{
		return templateMap.get(templateCode);
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public void register(CloudSmsTemplate template)
	{
		templateMap.put(template.getTemplateCode(), template);

		LOG.info("Register sms template to container, body is {}.", template.toString());
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public CloudSmsTemplate deregister(String templateCode)
	{
		CloudSmsTemplate template = templateMap.remove(templateCode);

		LOG.info("Register sms template to container, body is {}.", template);

		return template;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy