Example #1
0
 private final Logger getLogger() {
   if (logger == null) {
     YuepLoggerFactory factory =
         CoreContext.getInstance()
             .local()
             .getService("yuepLoggerFactory", YuepLoggerFactory.class);
     logger = factory.getLogger("TimeService");
   }
   return logger;
 }
Example #2
0
 /**
  * 发消息
  *
  * @param name 消息名
  * @param msg 消息体
  */
 public void publish(String name, Serializable msg) {
   ArrayList<MessageReceiver> curReceivers = null;
   synchronized (map) {
     ArrayList<MessageReceiver> receivers = map.get(name);
     if (null == receivers) return;
     curReceivers = new ArrayList<MessageReceiver>();
     for (int i = 0; i < receivers.size(); i++) {
       curReceivers.add(receivers.get(i));
     }
   }
   for (int i = 0; i < curReceivers.size(); i++) {
     curReceivers.get(i).receive(CoreContext.getInstance().local(), name, msg);
   }
 }
Example #3
0
  public void init() {
    sessionService =
        CoreContext.getInstance().local().getService("sessionService", SessionService.class);

    // 如果session timeout了,则需要将cache的loginedUserSessions也清除掉
    SmCoreContext.subscribeLocalMessage(
        SessionMessage.NAME,
        new MessageReceiver() {
          @Override
          public void receive(CommunicateObject co, String name, Serializable msg) {
            if (msg instanceof SessionMessage) {
              SessionMessage sessionMsg = (SessionMessage) msg;
              Session session = sessionMsg.getSession();
              if (session == null) return;
              if (SessionState.Linkdown == session.getSessionState()) {
                logoutSession(session);
              }
            }
          }
        });

    // 初始化数据,创建默认账号
    initDefaultUserData();
  }
Example #4
0
 @Override
 public void execute() {
   CoreContext.getInstance()
       .publish(MSG_TIMENOTIFY, new BaseMessage(MSG_TIMENOTIFY, "Time Notify Message"));
 }