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

com.iohao.game.bolt.broker.client.external.ext.ExternalBizRegions Maven / Gradle / Ivy

There is a newer version: 17.1.61
Show newest version
/*
 * ioGame
 * Copyright (C) 2021 - 2023  渔民小镇 ([email protected][email protected]) . All Rights Reserved.
 * # iohao.com . 渔民小镇
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
package com.iohao.game.bolt.broker.client.external.ext;

import com.iohao.game.bolt.broker.client.external.ext.impl.AttachmentExternalBizRegion;
import com.iohao.game.bolt.broker.client.external.ext.impl.ExistUserExternalBizRegion;
import com.iohao.game.bolt.broker.client.external.ext.impl.ForcedOfflineExternalBizRegion;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.FieldDefaults;
import org.jctools.maps.NonBlockingHashMap;

import java.util.Map;

/**
 * 对外服扩展的业务域集合
 *
 * @author 渔民小镇
 * @date 2022-07-27
 */
@Getter
@Setter
@FieldDefaults(level = AccessLevel.PRIVATE)
public class ExternalBizRegions {

    /**
     * 
     *     key : 业务码
     *     value : 对应的业务处理器
     * 
*/ Map regionMap = new NonBlockingHashMap<>(); public void add(ExternalBizRegion externalBizRegion) { int bizCode = externalBizRegion.getBizCode(); if (this.regionMap.containsKey(bizCode)) { throw new RuntimeException("重复添加已经存在的业务码:" + bizCode); } this.regionMap.put(bizCode, externalBizRegion); } public ExternalBizRegion getExternalRegion(int bizCode) { return this.regionMap.get(bizCode); } private ExternalBizRegions() { // 框架默认提供的业务类 this.add(new ExistUserExternalBizRegion()); this.add(new ForcedOfflineExternalBizRegion()); this.add(new AttachmentExternalBizRegion()); } public static ExternalBizRegions me() { return Holder.ME; } /** 通过 JVM 的类加载机制, 保证只加载一次 (singleton) */ private static class Holder { static final ExternalBizRegions ME = new ExternalBizRegions(); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy