Package org.infinispan.server.websocket

Examples of org.infinispan.server.websocket.CacheListener


  @Override
   public void handleOp(JSONObject opPayload, Cache<Object, Object> cache, ChannelHandlerContext ctx) throws JSONException {
    String opCode = (String) opPayload.get(OpHandler.OP_CODE);
    String key = (String) opPayload.opt(OpHandler.KEY);
    String[] onEvents = (String[]) opPayload.opt("onEvents");
    CacheListener listener = listeners.get(cache);
   
    if(key == null) {
      // If key not specified... notify on all...
      key = "*";
    }
   
    if(listener == null) {
      synchronized (this) {
        listener = listeners.get(cache);
        if(listener == null) {
          listener = new CacheListener();
          listeners.put(cache, listener)
          cache.addListener(listener);
        }
      }
    }
   
    String[] keyTokens = key.split(",");   
    for(String keyToken : keyTokens) {
      ChannelNotifyParams notifyParams = new ChannelNotifyParams(ctx.getChannel(), keyToken, onEvents);   
     
      if(opCode.equals("notify")) {
        listener.addChannel(notifyParams);
        // And push the value to the channel (if it's not wildcard)...
        if(!keyToken.equals("*")) {
          ChannelUtils.pushCacheValue(keyToken, cache, ctx);
        }
      } else if(opCode.equals("unnotify")) {
        listener.removeChannel(notifyParams);
      }
    }   
  }
View Full Code Here


  @Override
   public void handleOp(JsonObject opPayload, Cache<Object, Object> cache, ChannelHandlerContext ctx) {
    String opCode = (String) opPayload.get(OpHandler.OP_CODE);
    String key = (String) opPayload.get(OpHandler.KEY);
    String[] onEvents = (String[]) opPayload.get("onEvents");
    CacheListener listener = listeners.get(cache);
   
    if(key == null) {
      // If key not specified... notify on all...
      key = "*";
    }
   
    if(listener == null) {
      synchronized (this) {
        listener = listeners.get(cache);
        if(listener == null) {
          listener = new CacheListener();
          listeners.put(cache, listener)
          cache.addListener(listener);
        }
      }
    }
   
    String[] keyTokens = key.split(",");   
    for(String keyToken : keyTokens) {
      ChannelNotifyParams notifyParams = new ChannelNotifyParams(ctx.channel(), keyToken, onEvents);
     
      if(opCode.equals("notify")) {
        listener.addChannel(notifyParams);
        // And push the value to the channel (if it's not wildcard)...
        if(!keyToken.equals("*")) {
          ChannelUtils.pushCacheValue(keyToken, cache, ctx);
        }
      } else if(opCode.equals("unnotify")) {
        listener.removeChannel(notifyParams);
      }
    }   
  }
View Full Code Here

  @Override
   public void handleOp(JSONObject opPayload, Cache<Object, Object> cache, ChannelHandlerContext ctx) throws JSONException {
    String opCode = (String) opPayload.get(OpHandler.OP_CODE);
    String key = (String) opPayload.opt(OpHandler.KEY);
    String[] onEvents = (String[]) opPayload.opt("onEvents");
    CacheListener listener = listeners.get(cache);
   
    if(key == null) {
      // If key not specified... notify on all...
      key = "*";
    }
   
    if(listener == null) {
      synchronized (this) {
        listener = listeners.get(cache);
        if(listener == null) {
          listener = new CacheListener();
          listeners.put(cache, listener)
          cache.addListener(listener);
        }
      }
    }
   
    String[] keyTokens = key.split(",");   
    for(String keyToken : keyTokens) {
      ChannelNotifyParams notifyParams = new ChannelNotifyParams(ctx.channel(), keyToken, onEvents);
     
      if(opCode.equals("notify")) {
        listener.addChannel(notifyParams);
        // And push the value to the channel (if it's not wildcard)...
        if(!keyToken.equals("*")) {
          ChannelUtils.pushCacheValue(keyToken, cache, ctx);
        }
      } else if(opCode.equals("unnotify")) {
        listener.removeChannel(notifyParams);
      }
    }   
  }
View Full Code Here

  public void handleOp(JSONObject opPayload, Cache<Object, Object> cache, ChannelHandlerContext ctx) throws JSONException {
    String opCode = (String) opPayload.get(OpHandler.OP_CODE);
    String key = (String) opPayload.opt(OpHandler.KEY);
    String[] onEvents = (String[]) opPayload.opt("onEvents");
    CacheListener listener = listeners.get(cache);
   
    if(key == null) {
      // If key not specified... notify on all...
      key = "*";
    }
   
    if(listener == null) {
      synchronized (this) {
        listener = listeners.get(cache);
        if(listener == null) {
          listener = new CacheListener();
          listeners.put(cache, listener)
          cache.addListener(listener);
        }
      }
    }
   
    String[] keyTokens = key.split(",");   
    for(String keyToken : keyTokens) {
      ChannelNotifyParams notifyParams = new ChannelNotifyParams(ctx.getChannel(), keyToken, onEvents);   
     
      if(opCode.equals("notify")) {
        listener.addChannel(notifyParams);
        // And push the value to the channel (if it's not wildcard)...
        if(!keyToken.equals("*")) {
          ChannelUtils.pushCacheValue(keyToken, cache, ctx);
        }
      } else if(opCode.equals("unnotify")) {
        listener.removeChannel(notifyParams);
      }
    }   
  }
View Full Code Here

  @Override
   public void handleOp(JSONObject opPayload, Cache<Object, Object> cache, ChannelHandlerContext ctx) throws JSONException {
    String opCode = (String) opPayload.get(OpHandler.OP_CODE);
    String key = (String) opPayload.opt(OpHandler.KEY);
    String[] onEvents = (String[]) opPayload.opt("onEvents");
    CacheListener listener = listeners.get(cache);
   
    if(key == null) {
      // If key not specified... notify on all...
      key = "*";
    }
   
    if(listener == null) {
      synchronized (this) {
        listener = listeners.get(cache);
        if(listener == null) {
          listener = new CacheListener();
          listeners.put(cache, listener)
          cache.addListener(listener);
        }
      }
    }
   
    String[] keyTokens = key.split(",");   
    for(String keyToken : keyTokens) {
      ChannelNotifyParams notifyParams = new ChannelNotifyParams(ctx.getChannel(), keyToken, onEvents);   
     
      if(opCode.equals("notify")) {
        listener.addChannel(notifyParams);
        // And push the value to the channel (if it's not wildcard)...
        if(!keyToken.equals("*")) {
          ChannelUtils.pushCacheValue(keyToken, cache, ctx);
        }
      } else if(opCode.equals("unnotify")) {
        listener.removeChannel(notifyParams);
      }
    }   
  }
View Full Code Here

TOP

Related Classes of org.infinispan.server.websocket.CacheListener

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.