WindChat/windchat-business/src/main/java/com/windchat/im/business/service/ApiServiceFactory.java

68 lines
2.2 KiB
Java
Raw Normal View History

2019-07-29 23:42:16 +08:00
/**
* Copyright 2018-2028 Akaxin Group
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
2019-11-27 23:33:33 +08:00
package com.windchat.im.business.service;
2019-07-29 23:42:16 +08:00
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
2019-11-27 23:36:54 +08:00
import com.windchat.common.constant.RequestAction;
import com.windchat.im.business.impl.IRequestService;
import com.windchat.im.business.impl.tai.ApiDeviceService;
import com.windchat.im.business.impl.tai.ApiFileService;
import com.windchat.im.business.impl.tai.ApiFriendService;
import com.windchat.im.business.impl.tai.ApiGroupService;
import com.windchat.im.business.impl.tai.ApiPluginService;
import com.windchat.im.business.impl.tai.ApiSecretChatService;
import com.windchat.im.business.impl.tai.ApiSiteService;
import com.windchat.im.business.impl.tai.ApiUserService;
2019-07-29 23:42:16 +08:00
/**
* API业务请求分发工厂
*
* @author Sam{@link an.guoyue254@gmail.com}
* @since 2017.10.24 18:25:31
*/
public class ApiServiceFactory {
private static final Logger logger = LoggerFactory.getLogger(ApiServiceFactory.class);
public static IRequestService getService(String serviceName) {
RequestAction nameEnum = RequestAction.getAction(serviceName);
switch (nameEnum) {
case SITE:
return new ApiSiteService();
case API_USER:
return new ApiUserService();
case API_FRIEND:
return new ApiFriendService();
case API_GROUP:
return new ApiGroupService();
case API_SECRETCHAT:
return new ApiSecretChatService();
case API_FILE:
return new ApiFileService();
case API_DEVICE:
return new ApiDeviceService();
case API_PLUGIN:
return new ApiPluginService();
default:
logger.error("api business service error.service={}", nameEnum.getName());
break;
}
return null;
}
}