Code example for ConcurrentMap

Methods: putIfAbsentremove

0
  public void register(final String service, ChatHandler handler)
  { 
    final DruidNode node = makeDruidNode(service);
    log.info("Registering Eventhandler[%s]", service);
 
    if (handlers.putIfAbsent(service, handler) != null) {
      throw new ISE("handler already registered for service[%s]", service);
    } 
 
    try { 
      serviceAnnouncer.announce(node);
    } 
    catch (Exception e) {
      log.warn(e, "Failed to register service[%s]", service);
      handlers.remove(service, handler);
    } 
  } 
 
  @Override 
  public void unregister(final String service)