/** * Encodes this TransportConfiguration into a buffer. * * <p>Note that this is only used internally ActiveMQ Artemis. * * @param buffer the buffer to encode into */ public void encode(final ActiveMQBuffer buffer) { buffer.writeString(name); buffer.writeString(factoryClassName); buffer.writeInt(params == null ? 0 : params.size()); if (params != null) { encodeMap(buffer, params); } if (extraProps != null) { encodeMap(buffer, extraProps); } }
private void encodeMap(final ActiveMQBuffer buffer, final Map<String, Object> map) { for (Map.Entry<String, Object> entry : map.entrySet()) { buffer.writeString(entry.getKey()); Object val = entry.getValue(); if (val instanceof Boolean) { buffer.writeByte(TransportConfiguration.TYPE_BOOLEAN); buffer.writeBoolean((Boolean) val); } else if (val instanceof Integer) { buffer.writeByte(TransportConfiguration.TYPE_INT); buffer.writeInt((Integer) val); } else if (val instanceof Long) { buffer.writeByte(TransportConfiguration.TYPE_LONG); buffer.writeLong((Long) val); } else if (val instanceof String) { buffer.writeByte(TransportConfiguration.TYPE_STRING); buffer.writeString((String) val); } else { throw ActiveMQClientMessageBundle.BUNDLE.invalidEncodeType(val); } } }