@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { String methodName = method.getName(); if ("set".equals(methodName) && args[1] != null) { args[1] = serializer.serialize(args[1]); } // Object retValue = ReflectionUtil.invoke(ehcacheService, methodName, args); if ("get".equals(methodName) && retValue != null) { retValue = serializer.deserialize((byte[]) retValue); } return retValue; }
@Override public void messageReceived(ChannelHandlerContext ctx, MessageEvent e) throws Exception { if (e.getMessage() == null) { return; } else if (e.getMessage() instanceof byte[]) { byte[] bytes = (byte[]) e.getMessage(); Object msg; if (bytes.length == 0) { msg = Heartbeat.getSingleton(); } else { try { msg = serializer.deserialize(bytes); } catch (Exception ex) { throw ex; } } UpstreamMessageEvent event = new UpstreamMessageEvent(e.getChannel(), msg, e.getRemoteAddress()); super.messageReceived(ctx, event); } else { super.messageReceived(ctx, e); } }