@Override public Configuration visit(AstPropertyNode propertyNode, State state) { String propertyName = propertyNode.getPropertyName(); Object value = propertyNode.resolve(); if (value instanceof AutoCloseable) { state.configuration.getResources().add((AutoCloseable) value); } if (LOGGER.isDebugEnabled()) { Object formatValue = (value instanceof byte[]) ? AstLiteralBytesValue.toString((byte[]) value) : value; LOGGER.debug(format("Setting value for ${%s} to %s", propertyName, formatValue)); } return state.configuration; }
@Override protected Object decodeBuffer(ChannelBuffer buffer) throws Exception { final int resolvedLength; // TODO: Remove when JUEL sync bug is fixed https://github.com/k3po/k3po/issues/147 synchronized (environment) { resolvedLength = (Integer) length.getValue(environment); } if (buffer.readableBytes() < resolvedLength) { return null; } if (captureName == null) { buffer.readSlice(resolvedLength); } else { byte[] bytes = new byte[resolvedLength]; buffer.readBytes(bytes, 0, resolvedLength); // TODO: Remove when JUEL sync bug is fixed https://github.com/k3po/k3po/issues/147 synchronized (environment) { environment.getELResolver().setValue(environment, null, captureName, bytes); } if (LOGGER.isDebugEnabled()) { LOGGER.debug(format("Setting value for ${%s} to %s", captureName, AstLiteralBytesValue.toString(bytes))); } } return buffer; }
@Override protected Object decodeBuffer(ChannelBuffer buffer) throws Exception { if (buffer.readableBytes() < length) { return null; } if (captureName == null) { buffer.readSlice(length); } else { T value = readBuffer(buffer); // TODO: Remove when JUEL sync bug is fixed https://github.com/k3po/k3po/issues/147 synchronized (environment) { environment.getELResolver().setValue(environment, null, captureName, value); } if (LOGGER.isDebugEnabled()) { Object formatValue = (value instanceof byte[]) ? AstLiteralBytesValue.toString((byte[]) value) : value; LOGGER.debug(format("Setting value for ${%s} to %s", captureName, formatValue)); } } return buffer; }
@Override protected Object decodeBufferLast(ChannelBuffer buffer) throws Exception { if (buffer.readableBytes() < length) { throw new ScriptProgressException(getRegionInfo(), String.format("Expected %d bytes, found %d", length, buffer.readableBytes())); } if (captureName == null) { buffer.readSlice(length); } else { T value = readBuffer(buffer); // TODO: Remove when JUEL sync bug is fixed https://github.com/k3po/k3po/issues/147 synchronized (environment) { environment.getELResolver().setValue(environment, null, captureName, value); } if (LOGGER.isDebugEnabled()) { Object formatValue = (value instanceof byte[]) ? AstLiteralBytesValue.toString((byte[]) value) : value; LOGGER.debug(format("Setting value for ${%s} to %s", captureName, formatValue)); } } return buffer; }