@@ -0,0 +1,1808 @@
+package com.s4game.server.bus.sync;%0A%0Aimport javax.annotation.Resource;%0A%0Aimport org.aspectj.lang.ProceedingJoinPoint;%0Aimport org.aspectj.lang.annotation.AfterThrowing;%0Aimport org.aspectj.lang.annotation.Around;%0Aimport org.aspectj.lang.annotation.Aspect;%0Aimport org.aspectj.lang.annotation.Pointcut;%0Aimport org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0Aimport org.springframework.stereotype.Component;%0A%0Aimport com.s4game.core.message.Message;%0Aimport com.s4game.core.sync.Lock;%0Aimport com.s4game.core.sync.LockManager;%0Aimport com.s4game.server.bus.init.command.InitCommands;%0Aimport com.s4game.server.bus.share.constants.BusShareConstant;%0Aimport com.s4game.server.bus.share.service.IRoleStateService;%0A%0A/**%0A * @Author zeusgooogle@gmail.com%0A * @sine 2015%E5%B9%B49%E6%9C%8812%E6%97%A5 %E4%B8%8A%E5%8D%8810:36:25%0A * %0A */%0A@Component%0A@Aspect%0Apublic class BusSyncAspect %7B%0A%0A%09private Logger LOG = LoggerFactory.getLogger(getClass());%0A%0A%09@Resource%0A%09private LockManager lockManager;%0A%0A%09@Resource%0A%09private IRoleStateService roleStateService;%0A%0A%09public void pointcut() %7B%0A%0A%09%7D%0A%0A%09@Around(value = %22pointcut()%22)%0A%09public void run(ProceedingJoinPoint joinpoint) throws Throwable %7B%0A%09%09LOG.info(joinpoint.toShortString());%0A%0A%09%09Message message = (Message) joinpoint.getArgs()%5B0%5D;%0A%09%09String command = message.getCommand();%0A%09%09String roleId = message.getRoleId();%0A%0A%09%09Lock lock = this.lockManager.getLock(BusShareConstant.COMPONENT_NAME, roleId);%0A%0A%09%09synchronized (lock) %7B%0A%09%09%09%0A%09%09%09if (this.roleStateService.isOnline(roleId) %7C%7C InitCommands.ROLE_IN.equals(command)) %7B%0A%09%09%09%09joinpoint.proceed();%0A%09%09%09%09return;%0A%09%09%09%7D%0A%09%09%09%0A%09%09%09LOG.error(%22role: %7B%7D bus not online. message: %7B%7D%22, roleId, message.toString());%0A%09%09%7D%0A%09%7D%0A%0A%09@AfterThrowing(value = %22pointcut()%22, throwing = %22e%22)%0A    public void exception(Exception e) %7B%0A        LOG.error(%22execute bus sync aspect error: %7B%7D%22, e.getMessage(), e);%0A    %7D%0A%0A%7D%0A

add bug sync lock