net.engio.mbassy.listener.Handler类的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(4.4k)|赞(0)|评价(0)|浏览(258)

本文整理了Java中net.engio.mbassy.listener.Handler类的一些代码示例,展示了Handler类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Handler类的具体详情如下:
包路径:net.engio.mbassy.listener.Handler
类名称:Handler

Handler介绍

暂无

代码示例

代码示例来源:origin: bennidi/mbassador

@Override
  @Handler
  public void onMessage(Object msg) {
    // nop
  }
};

代码示例来源:origin: net.engio/mbassador

properties.put(HandlerMethod, handler);
if(handlerConfig.condition().length() > 0){
  if (!ElFilter.isELAvailable()) {
    throw new IllegalStateException("A handler uses an EL filter but no EL implementation is available.");
properties.put(Condition, cleanEL(handlerConfig.condition()));
properties.put(Priority, handlerConfig.priority());
properties.put(Invocation, handlerConfig.invocation());
properties.put(InvocationMode, handlerConfig.delivery());
properties.put(Enveloped, enveloped != null);
properties.put(AcceptSubtypes, !handlerConfig.rejectSubtypes());
properties.put(Listener, listenerConfig);
properties.put(IsSynchronized, ReflectionUtils.getAnnotation( handler, Synchronized.class) != null);

代码示例来源:origin: net.engio/mbassador

public MessageListener getMessageListener(Class target) {
  MessageListener listenerMetadata = new MessageListener(target);
  // get all handlers (this will include all (inherited) methods directly annotated using @Handler)
  Method[] allHandlers = ReflectionUtils.getMethods(AllMessageHandlers, target);
  final int length = allHandlers.length;
  Method handler;
  for (int i = 0; i < length; i++) {
    handler = allHandlers[i];
    // retain only those that are at the bottom of their respective class hierarchy (deepest overriding method)
    if (!ReflectionUtils.containsOverridingMethod(allHandlers, handler)) {
      // for each handler there will be no overriding method that specifies @Handler annotation
      // but an overriding method does inherit the listener configuration of the overridden method
      Handler handlerConfig = ReflectionUtils.getAnnotation(handler, Handler.class);
      Enveloped enveloped = ReflectionUtils.getAnnotation( handler, Enveloped.class );
      if (!handlerConfig.enabled() || !isValidMessageHandler(handler)) {
        continue; // disabled or invalid listeners are ignored
      }
      Method overriddenHandler = ReflectionUtils.getOverridingMethod(handler, target);
      // if a handler is overridden it inherits the configuration of its parent method
      Map<String, Object> handlerProperties = MessageHandler.Properties.Create(overriddenHandler == null ? handler : overriddenHandler,
                                           handlerConfig,
                                           enveloped,
                                           getFilter(handler, handlerConfig),
                                           listenerMetadata);
      MessageHandler handlerMetadata = new MessageHandler(handlerProperties);
      listenerMetadata.addHandler(handlerMetadata);
    }
  }
  return listenerMetadata;
}

代码示例来源:origin: bennidi/mbassador

@Handler
public void handleString(String s) {
  listener1Called = true;
}

代码示例来源:origin: bennidi/mbassador

@Handler(rejectSubtypes = true)
public void handleObject(Object o) {
}

代码示例来源:origin: bennidi/mbassador

@Handler(rejectSubtypes = true)
public void handleAny(Object o) {
}

代码示例来源:origin: bennidi/mbassador

@Handler
  void handle(String str);
}

代码示例来源:origin: bennidi/mbassador

@Handler
public void handleAny(Object o) {
}

代码示例来源:origin: bennidi/mbassador

@Handler(enabled = false)
public void handleString(String s) {
}

代码示例来源:origin: bennidi/mbassador

@Handler
public void handleString(String s) {
}

代码示例来源:origin: bennidi/mbassador

@Handler
  public void handleDead(DeadMessage dead){
    DeadEventCounter.incrementAndGet();
  }
}

代码示例来源:origin: bennidi/mbassador

@Handler
public void handleSync(Integer message){
  receivedSync.add(message);
}

代码示例来源:origin: bennidi/mbassador

@Handler(delivery = Invoke.Asynchronously)
public void handleASync(Integer message){
  receivedAsync.add(message);
}

代码示例来源:origin: bennidi/mbassador

@Handler()
public void handle(Object message) {
  throw new RuntimeException("This is an expected exception");
}

代码示例来源:origin: bennidi/mbassador

@Handler(priority = Integer.MAX_VALUE)
public void handle(Object message){
  handledMessages.add(message);
}

代码示例来源:origin: bennidi/mbassador

@Handler
public void handleSync(Integer message){
  receivedSync.add(message);
}

代码示例来源:origin: bennidi/mbassador

@Handler
public void handle(DeadMessage message){
  deadMessages.incrementAndGet();
}

代码示例来源:origin: bennidi/mbassador

@Handler
  public void handleAndThrowException(String s) throws Exception {
    msgHandlerCounter.incrementAndGet();
    throw new Exception("error in msg handler on call no. " + msgHandlerCounter.get());
  }
});

代码示例来源:origin: bennidi/mbassador

@Handler(rejectSubtypes = true)
  public void handle(MultipartMessage message){
    super.handle(message);
  }
}

代码示例来源:origin: bennidi/mbassador

@Handler
@RejectFiltered
public void handleFilteredEvent(FilteredMessage filtered){
  FilteredEventCounter.incrementAndGet();
}

相关文章

Handler类方法