public static void setHandler(Record r, Handler handler) { r.set(Handler.class, Handler.class, handler); }
public static Handler getHandler(Record r) { return r.get(Handler.class, Handler.class); }
@Override public void setConnectionHost(Connection connection, String host, int port) { Record r = connection.attachments(); // cannot set the address on an incoming connection if (r.get(AcceptorImpl.CONNECTION_ACCEPTOR_KEY, Acceptor.class) == null) { Address addr = new Address(); addr.setHost(host); if (port == 0) { port = 5672; } addr.setPort(Integer.toString(port)); r.set(CONNECTION_PEER_ADDRESS_KEY, Address.class, addr); } else { throw new IllegalStateException("Cannot set the host address on an incoming Connection"); } }
public static void setHandler(Record r, Handler handler) { r.set(Handler.class, Handler.class, handler); }
public static Handler getHandler(Record r) { return r.get(Handler.class, Handler.class); }
public static void setHandler(Record r, Handler handler) { r.set(Handler.class, Handler.class, handler); }
public static Handler getHandler(Record r) { return r.get(Handler.class, Handler.class); }
/** * Gets the principal representing a connection's client. * * @param con The connection to get the principal for. * @param principal The principal representing the authenticated client. * @throws NullPointerException if any of the parameters is {@code null}. */ public static void setClientPrincipal(final ProtonConnection con, final HonoUser principal) { Objects.requireNonNull(principal); final Record attachments = Objects.requireNonNull(con).attachments(); attachments.set(KEY_CLIENT_PRINCIPAL, HonoUser.class, principal); }
/** * Gets the principal representing an authenticated peer. * * @param record The attachments to retrieve the principal from. * @return The principal representing the authenticated client or {@link Constants#PRINCIPAL_ANONYMOUS} * if the client has not been authenticated or record is {@code null}. */ public static HonoUser getClientPrincipal(final Record record) { if (record != null) { final HonoUser client = record.get(KEY_CLIENT_PRINCIPAL, HonoUser.class); return client != null ? client : PRINCIPAL_ANONYMOUS; } else { return PRINCIPAL_ANONYMOUS; } }
public void set(E e, T value) { e.attachments().set(this, klass, value); } }
/** * Gets the principal representing an authenticated peer. * * @param record The attachments to retrieve the principal from. * @return The principal representing the authenticated client or {@link Constants#PRINCIPAL_ANONYMOUS} * if the client has not been authenticated or record is {@code null}. */ public static HonoUser getClientPrincipal(final Record record) { if (record != null) { final HonoUser client = record.get(KEY_CLIENT_PRINCIPAL, HonoUser.class); return client != null ? client : PRINCIPAL_ANONYMOUS; } else { return PRINCIPAL_ANONYMOUS; } }
/** * Sets the (surrogate) identifier of an AMQP connection. * <p> * The identifier will be added to the connection's <em>attachments</em> under key * {@link #KEY_CONNECTION_ID}. * * @param connection The connection to set id for. * @param id The identifier to set. * @throws NullPointerException if any of the parameters is {@code null}. */ public static void setConnectionId(final ProtonConnection connection, final String id) { Objects.requireNonNull(connection).attachments().set(Constants.KEY_CONNECTION_ID, String.class, Objects.requireNonNull(id)); }
/** * Gets the (surrogate) identifier of the AMQP connection that a link is part of. * * @param link The link to determine the connection id for. * @return The identifier retrieved from the link's <em>attachment</em> using key {@link #KEY_CONNECTION_ID} * or {@code null} if the attachments do not contain a value for that a key. */ public static String getConnectionId(final ProtonLink<?> link) { return link.attachments().get(KEY_CONNECTION_ID, String.class); }
/** * Gets the principal representing a connection's client. * * @param con The connection to get the principal for. * @param principal The principal representing the authenticated client. * @throws NullPointerException if any of the parameters is {@code null}. */ public static void setClientPrincipal(final ProtonConnection con, final HonoUser principal) { Objects.requireNonNull(principal); final Record attachments = Objects.requireNonNull(con).attachments(); attachments.set(KEY_CLIENT_PRINCIPAL, HonoUser.class, principal); }
@SuppressWarnings("unchecked") private static Handler<Void> getConnectionLossHandler(final ProtonConnection con) { return con.attachments().get("connectionLossHandler", Handler.class); }
/** * Sets the (surrogate) identifier of an AMQP connection. * <p> * The identifier will be added to the connection's <em>attachments</em> under key * {@link #KEY_CONNECTION_ID}. * * @param connection The connection to set id for. * @param id The identifier to set. * @throws NullPointerException if any of the parameters is {@code null}. */ public static void setConnectionId(final ProtonConnection connection, final String id) { Objects.requireNonNull(connection).attachments().set(Constants.KEY_CONNECTION_ID, String.class, Objects.requireNonNull(id)); }
/** * Gets the (surrogate) identifier of an AMQP connection. * * @param connection The connection to determine the connection id for. * @return The identifier retrieved from the connection's <em>attachments</em> using key {@link #KEY_CONNECTION_ID} * or {@code null} if the attachments do not contain a value for that a key. */ public static String getConnectionId(final ProtonConnection connection) { return connection.attachments().get(KEY_CONNECTION_ID, String.class); }
public static void setHandler(Extendable ext, Handler handler) { ext.attachments().set(Handler.class, Handler.class, handler); }
public T get(E e) { return e.attachments().get(this, klass); }